mirror of https://github.com/axmolengine/axmol.git
clamp sin value to -1, 1
This commit is contained in:
parent
484d763a8d
commit
5d677d49bb
|
@ -402,7 +402,9 @@ void Node::updateRotation3D()
|
|||
//convert quaternion to Euler angle
|
||||
float x = _rotationQuat.x, y = _rotationQuat.y, z = _rotationQuat.z, w = _rotationQuat.w;
|
||||
_rotationX = atan2f(2.f * (w * x + y * z), 1.f - 2.f * (x * x + y * y));
|
||||
_rotationY = asinf(2.f * (w * y - z * x));
|
||||
float sy = 2.f * (w * y - z * x);
|
||||
sy = clampf(sy, -1, 1);
|
||||
_rotationY = asinf(sy);
|
||||
_rotationZ_X = atan2f(2.f * (w * z + x * y), 1.f - 2.f * (y * y + z * z));
|
||||
|
||||
_rotationX = CC_RADIANS_TO_DEGREES(_rotationX);
|
||||
|
|
Loading…
Reference in New Issue