From b422d2d5092efd0e90744cd1f6502bcf5be7d001 Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Tue, 21 Jan 2014 12:00:54 +0100 Subject: [PATCH 1/3] lerp fix --- Code/OysterMath/LinearMath.h | 2 +- Code/OysterMath/OysterMath.h | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Code/OysterMath/LinearMath.h b/Code/OysterMath/LinearMath.h index e7e99c91..5926a635 100644 --- a/Code/OysterMath/LinearMath.h +++ b/Code/OysterMath/LinearMath.h @@ -753,7 +753,7 @@ namespace LinearAlgebra3D ::LinearAlgebra::Vector4 interpolated = ::LinearAlgebra::Nlerp( rotation.v[1], normalizedAxis, t ); if( interpolated.Dot(interpolated) == 0 ) return rotation; // return no change - return SnapAxisYToAxis_Nlerp( rotation, interpolated ); + return SnapAxisYToNormal_UsingNlerp( rotation, interpolated ); } } diff --git a/Code/OysterMath/OysterMath.h b/Code/OysterMath/OysterMath.h index 9ce38deb..3770bf02 100644 --- a/Code/OysterMath/OysterMath.h +++ b/Code/OysterMath/OysterMath.h @@ -46,7 +46,16 @@ namespace Oyster { namespace Math //! Oyster's native math library //! Returns false if there is no explicit solution. bool SuperpositionMatrix( const Float4x4 &in, const Float4x4 &out, Float4x4 &targetMem ); + /******************************************************************** + * Linear Interpolation + * @return start * (1-t) + end * t + ********************************************************************/ using ::LinearAlgebra::Lerp; + + /******************************************************************** + * Normalized Linear Interpolation + * @return nullvector if Lerp( start, end, t ) is nullvector. + ********************************************************************/ using ::LinearAlgebra::Nlerp; } } From 0d39240fc23c4a16ae93a5215567bfddadd853b4 Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Tue, 21 Jan 2014 12:08:31 +0100 Subject: [PATCH 2/3] lerp fix 2 --- Code/OysterMath/LinearMath.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Code/OysterMath/LinearMath.h b/Code/OysterMath/LinearMath.h index 5926a635..d8ef06da 100644 --- a/Code/OysterMath/LinearMath.h +++ b/Code/OysterMath/LinearMath.h @@ -733,7 +733,7 @@ namespace LinearAlgebra3D ScalarType projectedMagnitude = rotation.v[0].Dot( normalizedAxis ); if( projectedMagnitude == 1 ) { // infinite possible solutions -> roadtrip! - ::LinearAlgebra::Vector4 interpolated = ::LinearAlgebra::Nlerp( rotation.v[1], normalizedAxis, t ); + ::LinearAlgebra::Vector4 interpolated = ::LinearAlgebra::Nlerp( rotation.v[1], normalizedAxis, (ScalarType)0.5f ); // interpolated.Dot( interpolated ) == 0 should be impossible at this point projectedMagnitude = rotation.v[0].Dot( interpolated ); @@ -744,7 +744,7 @@ namespace LinearAlgebra3D rotation.v[0] -= projectedMagnitude * normalizedAxis; rotation.v[0].Normalize(); rotation.v[1] = normalizedAxis; - rotation.v[2] = rotation.v[0].Cross( rotation.v[1] ); + rotation.v[2].xyz = rotation.v[0].xyz.Cross( rotation.v[1].xyz ); } template From 65db1bf90d5a784a7f3f7795edd9f2398efeafde Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Tue, 21 Jan 2014 12:11:30 +0100 Subject: [PATCH 3/3] lerp fix 3 --- Code/OysterMath/LinearMath.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Code/OysterMath/LinearMath.h b/Code/OysterMath/LinearMath.h index d8ef06da..d32ea04f 100644 --- a/Code/OysterMath/LinearMath.h +++ b/Code/OysterMath/LinearMath.h @@ -745,6 +745,7 @@ namespace LinearAlgebra3D rotation.v[0].Normalize(); rotation.v[1] = normalizedAxis; rotation.v[2].xyz = rotation.v[0].xyz.Cross( rotation.v[1].xyz ); + return rotation; } template