Bläddra i källkod

Fix VehicleCollisionTesters colliding with sensor bodies (#86)

Fixes vehicles being able to drive on water, or collide with triggers etc.
Joshie 3 år sedan
förälder
incheckning
ed508b94bc
1 ändrade filer med 6 tillägg och 0 borttagningar
  1. 6 0
      Jolt/Physics/Vehicle/VehicleCollisionTester.cpp

+ 6 - 0
Jolt/Physics/Vehicle/VehicleCollisionTester.cpp

@@ -42,6 +42,9 @@ bool VehicleCollisionTesterRay::Collide(PhysicsSystem &inPhysicsSystem, uint inW
 				JPH_ASSERT(lock.Succeeded()); // When this runs all bodies are locked so this should not fail
 				JPH_ASSERT(lock.Succeeded()); // When this runs all bodies are locked so this should not fail
 				const Body *body = &lock.GetBody();
 				const Body *body = &lock.GetBody();
 
 
+				if (body->IsSensor())
+					return;
+
 				// Test that we're not hitting a vertical wall
 				// Test that we're not hitting a vertical wall
 				Vec3 contact_pos = mRay.GetPointOnRay(inResult.mFraction);
 				Vec3 contact_pos = mRay.GetPointOnRay(inResult.mFraction);
 				Vec3 normal = body->GetWorldSpaceSurfaceNormal(inResult.mSubShapeID2, contact_pos);
 				Vec3 normal = body->GetWorldSpaceSurfaceNormal(inResult.mSubShapeID2, contact_pos);
@@ -125,6 +128,9 @@ bool VehicleCollisionTesterCastSphere::Collide(PhysicsSystem &inPhysicsSystem, u
 				JPH_ASSERT(lock.Succeeded()); // When this runs all bodies are locked so this should not fail
 				JPH_ASSERT(lock.Succeeded()); // When this runs all bodies are locked so this should not fail
 				const Body *body = &lock.GetBody();
 				const Body *body = &lock.GetBody();
 
 
+				if (body->IsSensor())
+					return;
+
 				// Test that we're not hitting a vertical wall
 				// Test that we're not hitting a vertical wall
 				Vec3 normal = -inResult.mPenetrationAxis.Normalized();
 				Vec3 normal = -inResult.mPenetrationAxis.Normalized();
 				if (normal.Dot(mUpDirection) > mCosMaxSlopeAngle)
 				if (normal.Dot(mUpDirection) > mCosMaxSlopeAngle)