diff --git a/Source/Engine/Physics/Physics.Queries.cpp b/Source/Engine/Physics/Physics.Queries.cpp index d32a4affc..bb6940db5 100644 --- a/Source/Engine/Physics/Physics.Queries.cpp +++ b/Source/Engine/Physics/Physics.Queries.cpp @@ -140,6 +140,7 @@ void RayCastHit::Gather(const PxRaycastHit& hit) Normal = P2C(hit.normal); Distance = hit.distance; Collider = hit.shape ? static_cast(hit.shape->userData) : nullptr; + FaceIndex = hit.faceIndex; UV.X = hit.u; UV.Y = hit.v; } @@ -150,6 +151,7 @@ void RayCastHit::Gather(const PxSweepHit& hit) Normal = P2C(hit.normal); Distance = hit.distance; Collider = hit.shape ? static_cast(hit.shape->userData) : nullptr; + FaceIndex = hit.faceIndex; UV = Vector2::Zero; } diff --git a/Source/Engine/Physics/Physics.h b/Source/Engine/Physics/Physics.h index 55ff70f31..7fc21c16f 100644 --- a/Source/Engine/Physics/Physics.h +++ b/Source/Engine/Physics/Physics.h @@ -41,7 +41,12 @@ DECLARE_SCRIPTING_TYPE_NO_SPAWN(RayCastHit); API_FIELD() Vector3 Point; /// - /// The barycentric coordinates of hit point, for triangle mesh and height field. + /// The index of the face that was hit. Valid only for convex mesh (polygon index), triangle mesh (triangle index) and height field (triangle index). + /// + API_FIELD() uint32 FaceIndex; + + /// + /// The barycentric coordinates of hit triangle. Valid only for triangle mesh and height field. /// API_FIELD() Vector2 UV;