Merge pull request #353 from cameronwhite/fix-conetwist-nans

Fix a potential division by zero for cone twist constraints.
This commit is contained in:
erwincoumans
2015-04-22 11:44:29 -07:00

View File

@@ -778,8 +778,10 @@ void btConeTwistConstraint::calcAngleInfo2(const btTransform& transA, const btTr
target[2] = x * ivA[2] + y * jvA[2] + z * kvA[2]; target[2] = x * ivA[2] + y * jvA[2] + z * kvA[2];
target.normalize(); target.normalize();
m_swingAxis = -ivB.cross(target); m_swingAxis = -ivB.cross(target);
m_swingCorrection = m_swingAxis.length(); m_swingCorrection = m_swingAxis.length();
m_swingAxis.normalize();
if (!btFuzzyZero(m_swingCorrection))
m_swingAxis.normalize();
} }
} }