buzer2020 / Amnesia64

64-bit Windows port of Amnesia:TDD
GNU General Public License v3.0
19 stars 11 forks source link

Amnesia porting questions, Newton bugs.. #1

Closed brynet closed 3 years ago

brynet commented 3 years ago

Hello @buzer2020 ! :-)

I discovered your fork last night, it was interesting to me as it appears to be the first attempt to have sorted out the lack of source code for dependencies and patched in a slightly newer version of Newton. I'm also attempting to get Amnesia running on an unsupported platform, so I needed to compile everything from source. Removing FBX, even if temporarily, also helped a ton.

I've actually managed to cobble things together using the CMake project files, and compiling both Newton 2.32 and Angelscript with your patches, it works well enough to load into the main menu and create a profile, but crashes when creating a new game inside Newton with a SIGBUS. I've spent a couple hours staring at backtraces and C++ code, but unfortunately I can't make any progress...

Thread 1 received signal SIGBUS, Bus error.
0x0000000000cbdc62 in dgWorld::Collide (this=0x20cbe6080, collisionA=
    0x29681f500, matrixA=..., collisionB=0x24ab36d40, matrixB=..., 
    points=0x261f6e000, normals=0x2ad205000, penetration=0x297974000, 
    maxSize=32, threadIndex=0)
    at ../../source/physics/dgNarrowPhaseCollision.cpp:2144
2144            collideBodyA.m_matrix = matrixA;
(gdb) bt
#0  0x0000000000cbdc62 in dgWorld::Collide (this=0x20cbe6080, 
    collisionA=0x29681f500, matrixA=..., collisionB=0x24ab36d40, matrixB=..., 
    points=0x261f6e000, normals=0x2ad205000, penetration=0x297974000, 
    maxSize=32, threadIndex=0)
    at ../../source/physics/dgNarrowPhaseCollision.cpp:2144
#1  0x0000000000c35811 in NewtonCollisionCollide (newtonWorld=0x20cbe6080, 
    maxSize=32, collisionA=0x29681f500, matrixA=0x7f7ffffe5d98, 
    collisionB=0x24ab36d40, matrixB=0x7f7ffffe5d58, contacts=0x261f6e000, 
    normals=0x2ad205000, penetration=0x297974000, threadIndex=0)
    at ../../source/newton/Newton.cpp:4095
#2  0x0000000000bc4273 in hpl::cPhysicsWorldNewton::CheckShapeCollision (
    this=0x2f29de000, apShapeA=0x257eee000, a_mtxA=..., apShapeB=0x249f0a400, 
    a_mtxB=..., aCollideData=..., alMaxPoints=32, 
    abCorrectNormalDirection=true)
    at /home/tmpbuild/AmnesiaTheDarkDescent/HPL2/core/sources/impl/PhysicsWorldNewton.cpp:649
#3  0x0000000000a0f1c4 in hpl::iPhysicsWorld::CheckShapeWorldCollision (
    this=0x2f29de000, apPushVector=0x7f7ffffe6398, apShape=0x257eee000, 
    a_mtxTransform=..., apSkipBody=0x283da6800, abSkipStatic=false, 
    abIsCharacter=true, apCallback=0x0, abCollideCharacter=true, 
    alMinPushStrength=0, alCollideFlags=4294967295, abDebug=false)
    at /home/tmpbuild/AmnesiaTheDarkDescent/HPL2/core/sources/physics/PhysicsWorld.cpp:481
#4  0x00000000009f08b3 in hpl::iCharacterBody::CheckCollision (
    this=0x20f007000, apPushBackVector=0x7f7ffffe6398, avPos=..., 
    apCallback=0x0, alShapeIdx=0)
    at /home/tmpbuild/AmnesiaTheDarkDescent/HPL2/core/sources/physics/CharacterBody.cpp:2272
#5  0x00000000009ed61d in hpl::iCharacterBody::CheckMoveCollision (
    this=0x20f007000, avPosAdd=..., afTimeStep=0.00100000005)
    at /home/tmpbuild/AmnesiaTheDarkDescent/HPL2/core/sources/physics/CharacterBody.cpp:1567
#6  0x00000000009ecaf9 in hpl::iCharacterBody::Update (this=0x20f007000, 
    afTimeStep=0.00100000005)
    at /home/tmpbuild/AmnesiaTheDarkDescent/HPL2/core/sources/physics/CharacterB
ody.cpp:994
#7  0x0000000000701d1f in cLuxPlayer::CreateCharacterBody (this=0x251c08800, 
    apPhysicsWorld=0x2f29de000) at LuxPlayer.cpp:1458
#8  0x000000000070136a in cLuxPlayer::CreateWorldEntities (this=0x251c08800, 
    apMap=0x2537f2c00) at LuxPlayer.cpp:524
#9  0x000000000052134e in iLuxUpdateable::LuxRunMessage (this=0x251c08800, 
    aMessage=eLuxUpdateableMessage_CreateWorldEntities, apData=0x2537f2c00)
    at LuxTypes.h:599
#10 0x000000000051f055 in cLuxBase::RunModuleMessage (this=0x27352a000, 
    aMessage=eLuxUpdateableMessage_CreateWorldEntities, apData=0x2537f2c00)
    at LuxBase.cpp:543
#11 0x00000000006e49df in cLuxMapHandler::SetCurrentMap (this=0x2e92dc000, 
    apMap=0x2537f2c00, abRunScript=true, abFirstTime=true, asPlayerPos=...)
    at LuxMapHandler.cpp:456
#12 0x0000000000516175 in cLuxBase::StartGame (this=0x27352a000, asFile=..., 
    asFolder=..., asStartPos=...) at LuxBase.cpp:617
#13 0x000000000066c0f9 in cLuxMainMenu::OnMenuExit (this=0x2dd305800)
    at LuxMainMenu.cpp:680
#14 0x000000000066de7b in cLuxMainMenu::UpdateBase (this=0x2dd305800,
    afTimeStep=0.0166666657) at LuxMainMenu.cpp:784
#15 0x000000000066dcf7 in cLuxMainMenu::Update (this=0x2dd305800, 
    afTimeStep=0.0166666657) at LuxMainMenu.cpp:445
#16 0x0000000000704dad in hpl::iUpdateable::RunMessage (this=0x2dd305800, 
    aMessage=hpl::eUpdateableMessage_Update, afX=0.0166666657)
    at /home/tmpbuild/AmnesiaTheDarkDescent/HPL2/core/include/engine/Updateable.h:81
#17 0x0000000000866f82 in hpl::cUpdater::RunMessage (this=0x2aca56c00, 
    aMessage=hpl::eUpdateableMessage_Update, afX=0.0166666657)
    at /home/tmpbuild/AmnesiaTheDarkDescent/HPL2/core/sources/engine/Updater.cpp:125
#18 0x000000000085a421 in hpl::cEngine::Run (this=0x2cbab7e00)
    at /home/tmpbuild/AmnesiaTheDarkDescent/HPL2/core/sources/engine/Engine.cpp:455
#19 0x000000000051ef62 in cLuxBase::Run (this=0x27352a000) at LuxBase.cpp:527
#20 0x0000000000845c8b in hplMain (asCommandline=...) at Main.cpp:50
#21 0x0000000000b4a7f5 in main (argc=1, argv=0x7f7ffffe71a8)
    at /home/tmpbuild/AmnesiaTheDarkDescent/HPL2/core/sources/impl/LowLevelSystemSDL.cpp:116
(gdb) print matrixA
$1 = (const dgMatrix &) @0x7f7ffffe5d98: {
  m_front = {<dgTemplateVector<float>> = {m_x = 1, m_y = 0, m_z = 0, 
      m_w = 0}, <No data fields>}, m_up = {<dgTemplateVector<float>> = {
      m_x = 0, m_y = 1, m_z = 0, m_w = 0}, <No data fields>}, 
  m_right = {<dgTemplateVector<float>> = {m_x = 0, m_y = 0, m_z = 1, 
      m_w = 0}, <No data fields>}, m_posit = {<dgTemplateVector<float>> = {
      m_x = 8.5, m_y = 6.0999999, m_z = 9.25, m_w = 1}, <No data fields>}}
(gdb) print matrixB
$2 = (const dgMatrix &) @0x7f7ffffe5d58: {
  m_front = {<dgTemplateVector<float>> = {m_x = 1, m_y = 0, m_z = 0, 
      m_w = 0}, <No data fields>}, m_up = {<dgTemplateVector<float>> = {
      m_x = 0, m_y = 1, m_z = 0, m_w = 0}, <No data fields>}, 
  m_right = {<dgTemplateVector<float>> = {m_x = 0, m_y = 0, m_z = 1, 
      m_w = 0}, <No data fields>}, m_posit = {<dgTemplateVector<float>> = {
      m_x = 0, m_y = 0, m_z = 0, m_w = 1}, <No data fields>}}
(gdb) info all-registers
rax            0x7f7ffffe5d98   140187732434328
rbx            0x0      0
rcx            0x20cbe6000      8803737600
rdx            0x0      0
rsi            0x0      0
rdi            0x7f7ffffe58c0   140187732433088
rbp            0x7f7ffffe5b60   0x7f7ffffe5b60
rsp            0x7f7ffffe2ce0   0x7f7ffffe2ce0
r8             0x7f7ffffe7f5f   140187732442975
r9             0x261f6e000      10233503744
r10            0x20     32
r11            0x166b4930906fce58       1615465364272959064
r12            0x2ad205000      11494510592
r13            0x297974000      11133206528
r14            0x2ad205000      11494510592
r15            0x261f6e000      10233503744
rip            0xcbdc62 0xcbdc62 <dgWorld::Collide(dgCollision*, dgMatrix const&, dgCollision*, dgMatrix const&, dgTriplex*, dgTriplex*, float*, int, int)+322>
eflags         0x10246  [ PF ZF IF RF ]
cs             0x2b     43
ss             0x23     35
ds             0x23     35
es             0x23     35
fs             0x23     35
gs             0x23     35
st0            0        (raw 0x00000000000000000000)
st1            0        (raw 0x00000000000000000000)
st2            0        (raw 0x00000000000000000000)
st3            0        (raw 0x00000000000000000000)
st4            0        (raw 0x00000000000000000000)
st5            0        (raw 0x00000000000000000000)
st6            1        (raw 0x3fff8000000000000000)
st7            8        (raw 0x40028000000000000000)
fctrl          0x37f    895
fstat          0x20     32
ftag           0xffff   65535
fiseg          0x0      0
fioff          0x0      0
foseg          0x0      0
fooff          0x0      0
fop            0x0      0
xmm0           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, 
  v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, 
  uint128 = 0x00000000000000000000000000000000}
xmm1           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, 
  v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, 
  uint128 = 0x00000000000000000000000000000000}
xmm2           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, 
  v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0},
  uint128 = 0x00000000000000000000000000000000}
xmm3           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, 
  v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, 
  uint128 = 0x00000000000000000000000000000000}
xmm4           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, 
  v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, 
  uint128 = 0x00000000000000000000000000000000}
xmm5           {v4_float = {0x1, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, 
  v16_int8 = {0x0, 0x0, 0x80, 0x3f, 0x0 <repeats 12 times>}, v8_int16 = {0x0, 
    0x3f80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x3f800000, 0x0, 0x0, 
    0x0}, v2_int64 = {0x3f800000, 0x0}, 
  uint128 = 0x0000000000000000000000003f800000}
xmm6           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, 
  v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, 
  uint128 = 0x00000000000000000000000000000000}
xmm7           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0},
  v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, 
  uint128 = 0x00000000000000000000000000000000}
xmm8           {v4_float = {0x1, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, 
  v16_int8 = {0x0, 0x0, 0x80, 0x3f, 0x0 <repeats 12 times>}, v8_int16 = {0x0, 
    0x3f80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x3f800000, 0x0, 0x0, 
    0x0}, v2_int64 = {0x3f800000, 0x0}, 
  uint128 = 0x0000000000000000000000003f800000}
xmm9           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, 
  v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, 
  uint128 = 0x00000000000000000000000000000000}
xmm10          {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, 
  v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, 
  uint128 = 0x00000000000000000000000000000000}
xmm11          {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, 
  v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, 
  uint128 = 0x00000000000000000000000000000000}
xmm12          {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, 
  v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, 
  uint128 = 0x00000000000000000000000000000000}
xmm13          {v4_float = {0x1, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, 
  v16_int8 = {0x0, 0x0, 0x80, 0x3f, 0x0 <repeats 12 times>}, v8_int16 = {0x0, 
    0x3f80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x3f800000, 0x0, 0x0, 
    0x0}, v2_int64 = {0x3f800000, 0x0}, 
  uint128 = 0x0000000000000000000000003f800000}
xmm14          {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, 
  v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, 
  uint128 = 0x00000000000000000000000000000000}
xmm15          {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, 
  v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, 
  uint128 = 0x00000000000000000000000000000000}
mxcsr          0x1fb7   [ IE DE ZE UE PE IM DM ZM OM UM PM ]

if I comment out the assignments, like so:

//collideBodyA.m_matrix = matrixA;
...
//collideBodyB.m_matrix = matrixB;

It no longer crashes, but then I think the character model collides with the floor and keeps falling through the world, dying over and over again.. but that's just a guess.

I know you're working on 64-bit Windows, but I thought I'd let you know your work so far as been helpful getting me this far.

menu

buzer2020 commented 3 years ago

Hi @brynet, sorry I didn't notice your message until today. Did you manage to fix it? If not, I have a guess that maybe on your platform the types dgMatrix (Newton's matrix) and hpl::cMatrixf (the engine's matrix) aren't actually compatible. It's better to make sure they have the same size (64 bytes) and alignment properties.

brynet commented 3 years ago

Another developer @namtsui managed to get it to work, we collaborated and are merging our efforts, thank-you. I still have not worked out why I ran into this with how I was building before, I suspect it may have been due to compiler I used, but I appreciate your suggestion on where I should look.

https://twitter.com/canadianbryan/status/1314551619766419459