dimforge / bevy_rapier

Official Rapier plugin for the Bevy game engine.
https://rapier.rs
Apache License 2.0
1.28k stars 260 forks source link

Joints as entities #561

Open Vrixyz opened 4 months ago

Vrixyz commented 4 months ago

The current API for (impulse) joints is not idiomatic to ECS:

A body contains its joint data, and contains a reference to its other body. This leads to the following surprises:

Suggested change

I suggest moving the ImpulseJoint out of the body, to have a separate entity containing all information: joint data + the linked entities.

This way we could model multiple joints per body and have all joint data available in the same fashion.

To be noted this is also the choice of Avian (see https://docs.rs/avian3d/latest/avian3d/dynamics/solver/joints/struct.FixedJoint.html)