Add FaceIndex to RayCastHit

This commit is contained in:
Wojtek Figat
2021-11-05 11:43:46 +01:00
parent 4b735a365b
commit 406102fd25
2 changed files with 8 additions and 1 deletions

View File

@@ -140,6 +140,7 @@ void RayCastHit::Gather(const PxRaycastHit& hit)
Normal = P2C(hit.normal);
Distance = hit.distance;
Collider = hit.shape ? static_cast<PhysicsColliderActor*>(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<PhysicsColliderActor*>(hit.shape->userData) : nullptr;
FaceIndex = hit.faceIndex;
UV = Vector2::Zero;
}

View File

@@ -41,7 +41,12 @@ DECLARE_SCRIPTING_TYPE_NO_SPAWN(RayCastHit);
API_FIELD() Vector3 Point;
/// <summary>
/// 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).
/// </summary>
API_FIELD() uint32 FaceIndex;
/// <summary>
/// The barycentric coordinates of hit triangle. Valid only for triangle mesh and height field.
/// </summary>
API_FIELD() Vector2 UV;