erincatto / box2d

Box2D is a 2D physics engine for games
https://box2d.org
MIT License
8.09k stars 1.52k forks source link

Motor joint anchors #662

Closed elemel closed 2 weeks ago

elemel commented 3 years ago

The way that the motor joint works now, it effectively has an anchor in body A that can be moved around by updating the linear offset. The effective anchor in body B is fixed to that body's position.

Have you considered allowing the user to control the motor joint using the anchors instead of a linear offset? This would make the joint symmetric with respect to the bodies. The joint would strive to move the world positions of the anchors to align with each other. I guess that it would become more similar to a weld joint with movable anchors.

For joints in general, how come the anchors are fixed at creation? Would it be possible to allow moving them around, or does this lead to non-physical behaviour? I'm thinking that it would be a cheaper alternative to destroying the joint and recreating it with new anchors.