Pārlūkot izejas kodu

Fix VehicleCollisionTesters colliding with sensor bodies (#86)

Fixes vehicles being able to drive on water, or collide with triggers etc.
Joshie 3 gadi atpakaļ
vecāks
revīzija
ed508b94bc
1 mainītis faili ar 6 papildinājumiem un 0 dzēšanām
  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
 				const Body *body = &lock.GetBody();
 
+				if (body->IsSensor())
+					return;
+
 				// Test that we're not hitting a vertical wall
 				Vec3 contact_pos = mRay.GetPointOnRay(inResult.mFraction);
 				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
 				const Body *body = &lock.GetBody();
 
+				if (body->IsSensor())
+					return;
+
 				// Test that we're not hitting a vertical wall
 				Vec3 normal = -inResult.mPenetrationAxis.Normalized();
 				if (normal.Dot(mUpDirection) > mCosMaxSlopeAngle)