Hello!

I recently started using bullet and I find it very useful, thanks for your hard work!

However, I've been struggling the last days trying to simulate some kind of servo motor. After lots of tests involving different constraints with different parameters, I decided to settle with a locked btGeneric6DofConstraint by changing the locked range every time the motor needs to move. This worked fairly well, but when the motor went over PI or under -PI, it turned along the longest arc path to reach the new locking position.

Luckly the btRotationalLimitMotor code was very easy to understand, and I made the following changes to btRotationalLimitMotor::testLimitValue (added lines preceded with ++):

**Code:**

if (test_value < m_loLimit)

{

m_currentLimit = 1;//low limit violation

m_currentLimitError = test_value - m_loLimit;

++ if(m_currentLimitError>SIMD_PI) m_currentLimitError-=SIMD_2_PI;

++ else if(m_currentLimitError<-SIMD_PI) m_currentLimitError+=SIMD_2_PI;

return 1;

}

else if (test_value> m_hiLimit)

{

m_currentLimit = 2;//High limit violation

m_currentLimitError = test_value - m_hiLimit;

++ if(m_currentLimitError>SIMD_PI) m_currentLimitError-=SIMD_2_PI;

++ else if(m_currentLimitError<-SIMD_PI) m_currentLimitError+=SIMD_2_PI;

return 2;

};

It works as I want, however, I'm wondering if I've broken some other expected behavior by manipulating the limit error this way.

Does somebody knows what could go wrong with change?

Thanks in advance.