fix for btGeneric6DofConstraint, when the btRotationalLimitMotor goes over PI or under -PI.

See http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=5046&p=27113#p27113
Thanks zlash for the fix/report and Flix for the reminder.
This commit is contained in:
erwin.coumans
2012-02-18 09:21:16 +00:00
parent 15deee7e79
commit 22dc2ca6c3

View File

@@ -130,12 +130,20 @@ int btRotationalLimitMotor::testLimitValue(btScalar test_value)
{
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;
};
@@ -1067,4 +1075,4 @@ void btGeneric6DofConstraint::setAxis(const btVector3& axis1,const btVector3& ax
m_frameInB = m_rbB.getCenterOfMassTransform().inverse() * frameInW;
calculateTransforms();
}
}