2
0
Эх сурвалжийг харах

(Tapered)CapsuleShape::GetSurfaceNormal returned NaNs in case a surface position on the central axis was provided (#227)

Jorrit Rouwe 2 жил өмнө
parent
commit
d8f9d59cba

+ 1 - 1
Jolt/Physics/Collision/Shape/CapsuleShape.cpp

@@ -252,7 +252,7 @@ Vec3 CapsuleShape::GetSurfaceNormal(const SubShapeID &inSubShapeID, Vec3Arg inLo
 	else if (inLocalSurfacePosition.GetY() < -mHalfHeightOfCylinder)
 		return (inLocalSurfacePosition - Vec3(0, -mHalfHeightOfCylinder, 0)).Normalized();
 	else
-		return Vec3(inLocalSurfacePosition.GetX(), 0, inLocalSurfacePosition.GetZ()).Normalized();
+		return Vec3(inLocalSurfacePosition.GetX(), 0, inLocalSurfacePosition.GetZ()).NormalizedOr(Vec3::sAxisX());
 }
 
 AABox CapsuleShape::GetLocalBounds() const

+ 1 - 1
Jolt/Physics/Collision/Shape/TaperedCapsuleShape.cpp

@@ -267,7 +267,7 @@ Vec3 TaperedCapsuleShape::GetSurfaceNormal(const SubShapeID &inSubShapeID, Vec3A
 	else
 	{
 		// Get perpendicular vector to the surface in the xz plane
-		Vec3 perpendicular = Vec3(inLocalSurfacePosition.GetX(), 0, inLocalSurfacePosition.GetZ()).Normalized();
+		Vec3 perpendicular = Vec3(inLocalSurfacePosition.GetX(), 0, inLocalSurfacePosition.GetZ()).NormalizedOr(Vec3::sAxisX());
 
 		// We know that the perpendicular has length 1 and that it needs a y component where tan(alpha) = y / 1 in order to align it to the surface
 		perpendicular.SetY(mTanAlpha);