Browse Source

Bugfix: Penetration depth of mesh/heightfield vs soft body vertex had the wrong sign

Jorrit Rouwe 1 year ago
parent
commit
df22a599ef
1 changed files with 1 additions and 1 deletions
  1. 1 1
      Jolt/Physics/Collision/Shape/Shape.cpp

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

@@ -290,7 +290,7 @@ void Shape::sCollideSoftBodyVerticesUsingRayCast(const Shape &inShape, Mat44Arg
 			if (inShape.CastRay(ray.Transformed(inverse_transform), SubShapeIDCreator(), hit))
 			if (inShape.CastRay(ray.Transformed(inverse_transform), SubShapeIDCreator(), hit))
 			{
 			{
 				// Calculate penetration
 				// Calculate penetration
-				float penetration = (hit.mFraction - 0.5f) * movement.Length();
+				float penetration = (0.5f - hit.mFraction) * movement.Length();
 				if (penetration > v.mLargestPenetration)
 				if (penetration > v.mLargestPenetration)
 				{
 				{
 					v.mLargestPenetration = penetration;
 					v.mLargestPenetration = penetration;