Browse Source

MeshShapeUserDataTest: Fixed crash when pointing the camera at the moving box

Jorrit Rouwe 9 months ago
parent
commit
8f24d90522
1 changed files with 8 additions and 7 deletions
  1. 8 7
      Samples/Tests/Shapes/MeshShapeUserDataTest.cpp

+ 8 - 7
Samples/Tests/Shapes/MeshShapeUserDataTest.cpp

@@ -82,13 +82,14 @@ void MeshShapeUserDataTest::PrePhysicsUpdate(const PreUpdateParams &inParams)
 		// Get the leaf shape (mesh shape in this case)
 		SubShapeID remainder;
 		const Shape *shape = lock.GetBody().GetShape()->GetLeafShape(hit.mSubShapeID2, remainder);
-		JPH_ASSERT(shape->GetType() == EShapeType::Mesh);
-
-		// Get user data from the triangle that was hit
-		uint32 user_data = static_cast<const MeshShape *>(shape)->GetTriangleUserData(remainder);
+		if (shape->GetType() == EShapeType::Mesh)
+		{
+			// Get user data from the triangle that was hit
+			uint32 user_data = static_cast<const MeshShape *>(shape)->GetTriangleUserData(remainder);
 
-		// Draw it on screen
-		RVec3 hit_pos = ray.GetPointOnRay(hit.mFraction);
-		mDebugRenderer->DrawText3D(hit_pos, StringFormat("UserData: %d", user_data).c_str());
+			// Draw it on screen
+			RVec3 hit_pos = ray.GetPointOnRay(hit.mFraction);
+			mDebugRenderer->DrawText3D(hit_pos, StringFormat("UserData: %d", user_data).c_str());
+		}
 	}
 }