stride icon indicating copy to clipboard operation
stride copied to clipboard

Character component with complex collider throws exception and crashes program

Open gbriggs-trmb opened this issue 2 years ago • 2 comments

  1. Starting with the Stride "Terrain" sample.
  2. Added a vehicle model fbx file.
  3. Used Add Physics asset / convex hull to create collider
  4. Used this collider with a rigid body, works fine.
  5. Tried to use this collider with a character component, and it crashes the program.
  6. Made a much simpler multi box collider for the vehicle (one rectangle and four cylinders).
  7. This simpler collider also crashes the program when used with a character component.

Stack trace from crash attached

strideCharacterWithComplexColliderCrash.txt

gbriggs-trmb avatar Nov 04 '21 22:11 gbriggs-trmb

Cast to ConvexShape on this line causing the crash https://github.com/stride3d/stride/blob/master/sources/engine/Stride.Physics/Elements/CharacterComponent.cs#L283 Here's the constructor being called on that line: https://github.com/stride3d/BulletSharpPInvoke/blob/master/BulletSharp/Dynamics/KinematicCharacterController.cs#L557

I think I remember bullet's internals not actually supporting compound shapes, that constructor definitely doesn't though. Must be verified by whoever ends up taking this over.

Eideren avatar Jan 03 '22 17:01 Eideren

KinematicCharacterController requires a ConvexShape and even though the InternalShape on the CollisionShape is the base class, the actual type presented is a derived type. It is not possible to cast them between each other like we're attempting to do on https://github.com/stride3d/stride/blob/master/sources/engine/Stride.Physics/Elements/CharacterComponent.cs#L283. Bullet's sweep test also requires it to be convex internally.

We don't want to lose the reference of the internal shape so we can't just map a convex shape. Do we just alert the user more gracefully? What's the best way for them to know in advance?

AmbulantRex avatar Jun 23 '22 14:06 AmbulantRex