dimforge / dimforge/bevy_rapier

Joints as entities

Open
#561 0 comments 0 reactions 0 assignees View on GitHub
A-Integration C-Enhancement D-Medium P-Medium
Dominant language
Rust
Stars
1.6k
Forks
282
PR merge metrics
No merged PRs in 30d

Description

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 https://github.com/dimforge/bevy_rapier/pull/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)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.