Added sanity check to SphericalRigidBody::GetNormalAt

This commit is contained in:
Dander7BD 2013-12-19 11:15:49 +01:00
parent 42418257cb
commit 76c83add3d
1 changed files with 7 additions and 1 deletions

View File

@ -124,7 +124,13 @@ Sphere & SphericalRigidBody::GetBoundingSphere( Sphere &targetMem ) const
Float4 & SphericalRigidBody::GetNormalAt( const Float4 &worldPos, Float4 &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 Float3 & SphericalRigidBody::GetGravityNormal( Float3 &targetMem ) const