Jondolf / avian

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

Make disabling joints possible. #519

Closed shanecelis closed 1 week ago

shanecelis commented 1 week ago

Objective

Make disabling joints possible.

Solution

I added DisableJoint and added the Without<DisableJoint> filter on the query.

Naming

In discord Jondolf had used the name JointDisabled; however, I thought the verb form DisableJoint was my preference. But this is not a strong opinion. If there are other past tense components, then I'm happy to have it either way.

Other Considerations

I added derives for copy, clone, reflect, and serialize but these were added to follow suit rather than for a good reason of my own.

Alternatives

One could set the compliance to a large number. But what large number? And why bother computing when one would prefer disabling?


Changelog

Jondolf commented 1 week ago

I think in this case, I'd use JointDisabled. It's a marker indicating the state of the joint, and for that, a descriptive word like Disabled might be better than the present tense verb Disable. Using the present verb here would imply to me that it is actively doing something, like queuing the joint to get disabled, rather than just saying "this joint is disabled".

If we're looking for examples of this in Bevy and other ECSs, Flecs has a Disabled tag, and Bevy will likely add one as well (an earlier PR for it is here).