From 358cddfd9a159e41fc5a3a7e31e93bd99f39938a Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Mon, 3 Feb 2014 16:20:16 +0100 Subject: [PATCH] SnapAngularAxis fix floating point error there acos param could be slightly higher than 1. Caused it to return undefined. A clamp ought to fix it. --- Code/OysterMath/LinearMath.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/OysterMath/LinearMath.h b/Code/OysterMath/LinearMath.h index ebb1e375..9b21fc02 100644 --- a/Code/OysterMath/LinearMath.h +++ b/Code/OysterMath/LinearMath.h @@ -794,7 +794,7 @@ namespace LinearAlgebra3D { ::LinearAlgebra::Vector4 worldStartNormal( WorldAxisOf(Rotation(startAngularAxis.xyz), localStartNormal.xyz), (ScalarType)0 ); targetMem = ::LinearAlgebra::Vector4( worldStartNormal.xyz.Cross(worldEndNormal.xyz), (ScalarType)0); - targetMem *= (ScalarType)::std::acos( worldStartNormal.Dot(worldEndNormal) ); + targetMem *= (ScalarType)::std::acos( ::Utility::Value::Clamp(worldStartNormal.Dot(worldEndNormal), (ScalarType)0, (ScalarType)1) ); return targetMem += startAngularAxis; }