diff --git a/Code/OysterMath/LinearMath.h b/Code/OysterMath/LinearMath.h index 9ea4bf42..7874cb52 100644 --- a/Code/OysterMath/LinearMath.h +++ b/Code/OysterMath/LinearMath.h @@ -750,12 +750,20 @@ namespace LinearAlgebra3D template ::LinearAlgebra::Vector4 & SnapAngularAxis( ::LinearAlgebra::Vector4 &startAngularAxis, const ::LinearAlgebra::Vector4 &localStartNormal, const ::LinearAlgebra::Vector4 &worldEndNormal, ::LinearAlgebra::Vector4 &targetMem = ::LinearAlgebra::Vector4() ) { - ::LinearAlgebra::Vector4 worldStartNormal( WorldAxisOf(Rotation(startAngularAxis), localStartNormal), (ScalarType)0 ); + ::LinearAlgebra::Vector4 worldStartNormal( WorldAxisOf(Rotation(startAngularAxis.xyz), localStartNormal), (ScalarType)0 ); targetMem = ::LinearAlgebra::Vector4( worldStartNormal.xyz.Cross(worldEndNormal.xyz), (ScalarType)0); targetMem *= (ScalarType)::std::acos( worldStartNormal.Dot(worldEndNormal) ); return targetMem += startAngularAxis; } + template + ::LinearAlgebra::Vector3 & SnapAngularAxis( ::LinearAlgebra::Vector3 &startAngularAxis, const ::LinearAlgebra::Vector3 &localStartNormal, const ::LinearAlgebra::Vector3 &worldEndNormal, ::LinearAlgebra::Vector3 &targetMem = ::LinearAlgebra::Vector3() ) + { + return targetMem = SnapAngularAxis( ::LinearAlgebra::Vector4(startAngularAxis, (ScalarType)0), + ::LinearAlgebra::Vector4(localStartNormal, (ScalarType)0), + ::LinearAlgebra::Vector4(worldEndNormal, (ScalarType)0), ).xyz; + } + template ::LinearAlgebra::Matrix4x4 & SnapAxisYToNormal_UsingNlerp( ::LinearAlgebra::Matrix4x4 &rotation, const ::LinearAlgebra::Vector4 &normalizedAxis ) {