Search Unity

Question Getting the submesh index of a traceinline rayquery intersection?

Discussion in 'General Graphics' started by Pjbomb2, Mar 9, 2023.

  1. Pjbomb2

    Pjbomb2

    Joined:
    Jan 29, 2021
    Posts:
    39
    So I have an issue
    Say I have a mesh with 4 submeshes
    And I intersect that mesh with traceinline to get a rayquery
    And I use RayQuery.CommittedPrimitiveIndex() to get the index of the triangle
    Problem is this index starts at 0 for each submesh, meaning you need to provide an offset yourself if your trying to index into an array of triangles
    This is fine, except theres no way I can find to get an index that corosponds to the submesh index, meaning theres no way to differentiate between which submesh your intersecting
    Please tell me I am missing something?
    I am already doing a similar thing to differentiate between different meshes(make a list of offsets, and index into that list via RayQuery.CommittedInstanceID()), but there doesnt seem to be a way to differentiate between which submesh you intersect?
     
  2. Pjbomb2

    Pjbomb2

    Joined:
    Jan 29, 2021
    Posts:
    39
    Ok fixed it finally after struggling all night
    Turns out that you can use CommittedGeometryIndex to get the submesh index
     
    Sluggy likes this.