Revolute Joint limits bug

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):

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;


Thoughts?
I think it's like that to allow you to set limits of more than one rotation, for example the steering wheel on a car usually turns 3-4 times from lock to lock.
Hmm, I see. So what is the proper workaround in my case then? It would seem like its fairly common case for you to have objects where rotations +-360 degrees are equivalent. How do you create a revolute joint between these object where the rotations can be quite a different number but actually the same?
You could do the angle normalize you mentioned, after getting the current angle from the joint. eg.
Code:
while ( angle < -Degrees(180.f) ) angle += Degrees(360.f);
while ( angle >  Degrees(180.f) ) angle -= Degrees(360.f);
Thanks, that's what I ended up doing. I guess I was hoping there was a more approved way of doing it that didn't require a local edit.

Original thread: https://box2d.org/forum/viewtopic.php?t=8268