Closed Draiget closed 2 years ago
Thanks, I think I know the cause.
Can't believe I didn't catch this. I am adding to m_Events[ uThreadId ].emplace_back( std::forward< T >( val )... );
here, and the pInternalData
is set to a local member of that.
When the vector grows, pInternalData
becomes invalidated as the JoltPhysicsCollisionEvent
gets reallocated.
A custom copy + move constructor needs to be implemented into the JoltPhysicsCollisionEvent
class to re-point m_Event.pInternalData
to the right &m_Data
of the newly copied class.
(I won't have time to implement this tonight, so feel free to try it out yourself + PR and get the free GitHub points, otherwise I will fix it tomorrow).
Actually, I'll do it now... I lied.
That is fastest issue response I've seen, heh, thank you!
Btw, I had an another issue with ->
https://github.com/Joshua-Ashton/VPhysics-Jolt/blob/347e78d122973dc5135bd5c16c734f4ef39e01a6/vphysics_jolt/vjolt_environment.cpp#L916
There are some STL/SDL (not remember) checks that asserting on assignment of m_CachedObjects[ i ]
to smth, I did a small replacement locally to m_CachedObjects.insert(m_CachedObjects.begin() + i, reinterpret_cast<IPhysicsObject*>(pBody->GetUserData()));
and it works like a charm.
Can you try https://github.com/Joshua-Ashton/VPhysics-Jolt/pull/52 and see if that fixes it for you?
Sure, let me try.
There are some STL/SDL (not remember) checks that asserting on assignment of m_CachedObjects[ i ] to smth, I did a small replacement locally to m_CachedObjects.insert(m_CachedObjects.begin() + i, reinterpret_cast<IPhysicsObject*>(pBody->GetUserData())); and it works like a charm.
Just looked, it should be resize and not reserve haha. I'll do a PR for that too.
Thanks for the clear issue, some ez wins before bed :-)
Hehe, no problem, I can confirm that https://github.com/Joshua-Ashton/VPhysics-Jolt/pull/52 fixes my issue, no crash so far.
Not sure it supposed to be working with Garry's Mod, but in case if anyone know how this could be fixed, I'll post some details of my issue here.
So I just created one cube and used stacker against it, once boxes fall and collide - crash is happened, I dive a bit deep into the problem and found that crash is caused by
PhysCollisionScreenShake
(game\server\physics.cpp) atpEvent->pInternalData->GetContactPoint( vecPos );
.As you can see in the debugger,UDP: Nvm, this is an VTable ptr, the data is seems to be at least non-nullptr:pInternalData
of the event is an invalid pointer:The call-stack is the following:
Crashes in
PhysCollisionScreenShake
:at 57241A20
(*(void (__thiscall **)(_DWORD, float *))(**(_DWORD **)(a4 + 28) + 4))(*(_DWORD *)(a4 + 28), vecPos);
which is probablypEvent->pInternalData->GetContactPoint( vecPos );
, so it's trying to callGetContactPoint
againstnullptr
.Any ideas?
P.S. Manual windows build of VPhysics-Jolt@
347e78d
using SSDK-2013@0d8dcee
, VS2022 (target for module isx32-Debug
).