jrouwe / JoltPhysics

A multi core friendly rigid body physics and collision detection library. Written in C++. Suitable for games and VR applications. Used by Horizon Forbidden West.
MIT License
6.42k stars 414 forks source link

Crash in SkeletonMapperTest sample #1045

Closed KyleN97 closed 4 months ago

KyleN97 commented 5 months ago

I'm trying to see how constrains could be used within a mapped skeleton, however when trying to override the constraint type within RagdollLoader::sLoad() it causes a crash straight away.

Within the void SkeletonMapperTest::Initialize() function i changed:

 // Load ragdoll
mRagdollSettings = RagdollLoader::sLoad("Assets/Human.tof", EMotionType::Dynamic);  

to

// Load ragdoll
mRagdollSettings = RagdollLoader::sLoad("Assets/Human.tof", EMotionType::Dynamic, EConstraintOverride::TypeFixed);

Then loading into the test it will crash, the cause seems to be somewhere relevant to mRagdoll->DriveToPoseUsingMotors(mRagdollPose);

jrouwe commented 4 months ago

The DriveToPoseUsingMotors function currently assumes that your ragdoll consists only of SwingTwistConstraint's. It does a hard cast to this constraint type, but since your constraint is a FixedConstraint that will crash. FixedConstraints don't have motors (they're not supposed to move), so this cannot work.

jrouwe commented 4 months ago

I changed the crash into an assert in #1047

KyleN97 commented 4 months ago

Thanks for the clarification!