stride
stride copied to clipboard
Character component with complex collider throws exception and crashes program
- Starting with the Stride "Terrain" sample.
- Added a vehicle model fbx file.
- Used Add Physics asset / convex hull to create collider
- Used this collider with a rigid body, works fine.
- Tried to use this collider with a character component, and it crashes the program.
- Made a much simpler multi box collider for the vehicle (one rectangle and four cylinders).
- This simpler collider also crashes the program when used with a character component.
Stack trace from crash attached
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.
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?