Jondolf / avian

ECS-driven 2D and 3D physics engine for the Bevy game engine.
https://crates.io/crates/avian3d
Apache License 2.0
1.36k stars 108 forks source link

Initial application of external force will make multi collider setup go haywire #296

Open claudijo opened 8 months ago

claudijo commented 8 months ago

When porting some buoyancy mechanics from Rapier to XPBD I encountered an issue with a multi collider/rigid body setup with fixed joints (conceptually a raft with pontoons in each corner).

When applying external force (buoyancy) to the pontoons for the first time, the raft will go into an exaggerated spin.

This exaggerated spin only happens when the pontoons are exposed to an external force for the first time and the raft don't have any angular velocity. Subsequent application of a buoyancy force as the raft re-enters the water, will behave as expected and not cause any exaggerated spin.

I've made a small example project that reproduces the issue. See https://github.com/claudijo/raft/blob/main/src/main.rs

Here is a short clip to demonstrate the issue

https://github.com/Jondolf/bevy_xpbd/assets/540995/10e73e69-815c-4048-90e0-7d73f7e7b69a

claudijo commented 2 months ago

For what it's worth, am happy to report that this works as expected when using the Avian engine, the successor of XPBD.