From 76c83add3d29dfe7d4ce8397854b09c6f6419106 Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Thu, 19 Dec 2013 11:15:49 +0100 Subject: [PATCH] Added sanity check to SphericalRigidBody::GetNormalAt --- Code/GamePhysics/Implementation/SphericalRigidBody.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Code/GamePhysics/Implementation/SphericalRigidBody.cpp b/Code/GamePhysics/Implementation/SphericalRigidBody.cpp index 9dcfaa32..13a46145 100644 --- a/Code/GamePhysics/Implementation/SphericalRigidBody.cpp +++ b/Code/GamePhysics/Implementation/SphericalRigidBody.cpp @@ -124,7 +124,13 @@ Sphere & SphericalRigidBody::GetBoundingSphere( Sphere &targetMem ) const Float4 & SphericalRigidBody::GetNormalAt( const Float4 &worldPos, Float4 &targetMem ) const { - return targetMem = (worldPos - this->rigid.box.center).GetNormalized(); + targetMem = worldPos - this->rigid.box.center; + Float magnitude = targetMem.GetMagnitude(); + if( magnitude != 0.0f ) + { // sanity check + targetMem.Normalize(); + } + return targetMem; } Float3 & SphericalRigidBody::GetGravityNormal( Float3 &targetMem ) const