From f5d43aaa2e57728f6e2b39e3a2644f8459dc425a Mon Sep 17 00:00:00 2001 From: Benau Date: Tue, 13 Sep 2016 07:43:19 +0800 Subject: [PATCH] Use btAsin in setHPR The following quaternion calculated by shortestArcQuat in rescue animation leads to nan in asinf: 0.710828841, -0.00974362344, -0.703500867, 0.00481829932 -2.0f * (X * Z - Y * W) equals 1.00004351 with above figures With btAsin it will: if (xbtScalar(1)) x=btScalar(1); return asin(x); --- src/utils/vec3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/vec3.cpp b/src/utils/vec3.cpp index d7b5cfdef..d3c2001bd 100644 --- a/src/utils/vec3.cpp +++ b/src/utils/vec3.cpp @@ -30,7 +30,7 @@ void Vec3::setHPR(const btQuaternion& q) float ZSquared = Z * Z; setX(atan2f(2.0f * (Y * Z + X * W), -XSquared - YSquared + ZSquared + WSquared)); - setY(asinf(-2.0f * (X * Z - Y * W))); + setY(btAsin(-2.0f * (X * Z - Y * W))); setZ(atan2f(2.0f * (X * Y + Z * W), XSquared - YSquared - ZSquared + WSquared)); } // setHPR(btQuaternion)