Skip to content

Joints as entities #561

@ThierryBerger

Description

@ThierryBerger

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:

  • how to choose which body has the joint data ?
  • we cannot create 2 joints on a same entity, and have to leverage hierarchy to represent multiple impulse joints.
  • API to query joint data is difficult to make ergonomic (see rapier 0.20 feature: RevoluteJoint::angle + more detailed joints enum #530), because data is split between:
    • body1: Entity or other component RigidbodyHandle
    • body2: parent within the component ImpulseJoint.

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions