erincatto / box2d

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

More GetReactionForce/Torque Fixes #645

Closed wnbittle closed 3 years ago

wnbittle commented 4 years ago

I noticed a couple of other issues based on the PR to fix #634:

1. b2_revolute_joint.cpp GetReactionTorque has the wrong sign

- return inv_dt * (m_lowerImpulse + m_upperImpulse);
+ return inv_dt * (m_lowerImpulse - m_upperImpulse);

2. b2_prismatic_joint.cpp GetReactionForce has the wrong sign

- return inv_dt * (m_impulse.x * m_perp + (m_motorImpulse + m_lowerImpulse + m_upperImpulse) * m_axis);
+ return inv_dt * (m_impulse.x * m_perp + (m_motorImpulse + m_lowerImpulse - m_upperImpulse) * m_axis);

3. b2_distance_joint.cpp GetReactionForce isn't including the limit impulse

- b2Vec2 F = (inv_dt * m_impulse) * m_u;
+ b2Vec2 F = (inv_dt * m_impulse + m_lowerImpulse - m_upperImpulse) * m_u;
thegrb93 commented 3 years ago

This PR? https://github.com/erincatto/box2d/pull/641

erincatto commented 3 years ago

Fixed in #653