Skip to content

Commit

Permalink
MeshShapeUserDataTest: Fixed crash when pointing the camera at the mo…
Browse files Browse the repository at this point in the history
…ving box
  • Loading branch information
jrouwe committed Nov 10, 2024
1 parent 354f149 commit 8f24d90
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Samples/Tests/Shapes/MeshShapeUserDataTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}

0 comments on commit 8f24d90

Please sign in to comment.