A:
Add an unsigned subObjectElementIndex_
to RayQueryResult that defaults to M_MAX_UNSIGNED
. Update Ray::HitDistance
to be able to output the index in the index buffer of the first triangle vertex (the index of the index, not the index of the vertex). Make relevant changes to Geometry
to bubble that up and use it in StaticModel::ProcessRayQuery
, recording the index whenever the distance checks pass.
Then fix all the places that are unhappy about adding the extra parameter to Ray::HitDistance, fix scripting bindings, etc.
The rest of RayQueryResult already contains what you need to get in order to get the vertex and index data as well as vertex data description for pulling out the vertex attributes you care about for your whatever-it-means-here-triangle.
B:
Roll a bespoke / copy-pasta of Ray::HitDistance to use after first successful cast to cast again and capture out more data.
C:
Tweak Ray::HitDistance to accept an output-count and thus treat the input pointers as the start of an array, where the first element is the hit position, and the next N are the element data that was used for the triangle of the hit. Then somehow bubble that mess of information back up and hope you don’t end up ever having more types of triangles you need to get.