Hi there, I've been implementing CollisionBodys and Colliders in a game engine, but during testing I struggled to apply transformations to colliders. After calling setLocalToBodyTransform(), I would get the following error:
Assertion failed: mMapEntityToComponentIndex.containsKey(bodyEntity), file C:\(...)\reactphysics3d\include\reactphysics3d/components/RigidBodyComponents.h, line 418
That references this assertion:
// Return true if the body is sleeping
RP3D_FORCE_INLINE bool RigidBodyComponents::getIsSleeping(Entity bodyEntity) const {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
return mIsSleeping[mMapEntityToComponentIndex[bodyEntity]];
}
I found it odd that I was hitting an assertion in a RigidBody method despite not utilising RigidBodys. I believe this is due to some undefined behavior, since static_cast isn't guaranteed to return nullptr if the body isn't a RigidBody, so it then proceeds to try to call some methods it probably shouldn't :D
Hi there, I've been implementing
CollisionBody
s andColliders
in a game engine, but during testing I struggled to apply transformations to colliders. After callingsetLocalToBodyTransform()
, I would get the following error:That references this assertion:
I found it odd that I was hitting an assertion in a
RigidBody
method despite not utilisingRigidBody
s. I believe this is due to some undefined behavior, sincestatic_cast
isn't guaranteed to returnnullptr
if the body isn't aRigidBody
, so it then proceeds to try to call some methods it probably shouldn't :DSwitching to
dynamic_cast
has fixed my issue.