I think there is a bug with the way the revolute joint limits work. Assuming a revolute joint with a +/- 90 degree joint limit (something like this):
b2RevoluteJointDef jointDef;
jointDef.bodyA = bodyA;
jointDef.bodyB = bodyB;
jointDef.collideConnected = false;
jointDef.enableLimit = true;
jointDef.upperAngle = Degrees(90.f);
jointDef.lowerAngle = -Degrees(90.f);
b2Joint *joint = world->CreateJoint(&jointDef);
Now if bodyA has a rotation of 0 degrees and bodyB has a rotation of 360 degrees (6.28 radians) then the joint limit shouldn't do anything. Both bodies have a relative angle of 0 degrees. Unfortunately the revolute joint treats the difference in angle as 360 degrees and flips one of the bodies over. How do I prevent this from happening? My guess is that this line in b2revolutejoint.cpp needs an angle normalize before comparing the two angles:
Thoughts?
Code:
b2RevoluteJointDef jointDef;
jointDef.bodyA = bodyA;
jointDef.bodyB = bodyB;
jointDef.collideConnected = false;
jointDef.enableLimit = true;
jointDef.upperAngle = Degrees(90.f);
jointDef.lowerAngle = -Degrees(90.f);
b2Joint *joint = world->CreateJoint(&jointDef);
Now if bodyA has a rotation of 0 degrees and bodyB has a rotation of 360 degrees (6.28 radians) then the joint limit shouldn't do anything. Both bodies have a relative angle of 0 degrees. Unfortunately the revolute joint treats the difference in angle as 360 degrees and flips one of the bodies over. How do I prevent this from happening? My guess is that this line in b2revolutejoint.cpp needs an angle normalize before comparing the two angles:
Quote:
if (m_enableLimit && fixedRotation == false)
{
float32 jointAngle = aB - aA - m_referenceAngle;
{
float32 jointAngle = aB - aA - m_referenceAngle;
Thoughts?