Accessing static mesh triangles

Hi everyone, newbie here.

I’m starting to mess with some code which should take samples on a mesh surface but…I can’t figure out a way to get access to the mesh (actor) triangles.
I was able to get the vertices this way


FVector AVertex = MyMesh->RenderData->LODResources[0].PositionVertexBuffer.VertexPosition(0);

but the documentation doesn’t help in doing the same for triangles and all the bits of answers I see around make me think it’s not possible for whatever reason.

Actually, getting a copy of the Adjacency Index Buffer of the LOD as this


TArray<uint32> adj;
MyMesh->RenderData->LODResources[0].AdjacencyIndexBuffer.GetCopy(adj);

seems to give me an expected list of adjacent vertices which is a bit closer to what I need, but how should I interpret it since its length is 12 times the number of triangles?

Long story short: any help in finding a way to get my hands on the mesh triangles (or shooting down my dreams too) would be amazing!

Regarding your question about Vertex Buffer/Triangle relation, you need to access your vertices through the IndexBuffer from an arbitrary FaceIndex (for example, what comes out of FHitResult from line or shape traces) like so:



FIndexArrayView IndexBuffer = MyMesh->RenderData->LODResources[0].IndexBuffer.GetArrayView();
uint32 VertexIndex = IndexBuffer[FaceIndex * 3 + VertexNum];
FVector VertexPos = MyMesh->RenderData->LODResources[0].PositionVertexBuffer.VertexPosition(VertexIndex);

Where FaceIndex and VertexNum are integers for your current triangle and the number of vertex for that triangle respectively.

BTW, I’m bumping this in hopes for someone to enlighten us about the AdjacencyIndexBuffer, which as you said, is 12 times larger than the triangle count. As of now, I understand that entries 0, 1 and 2 contain the indices for Face0’s vertices; 12, 13 and 14 are the vertices for Face1 and so on. But i’m not understanding the data in between. The rest of the indices all seem to correspond to vertices that share position with the ones from the current triangle, but it looks pretty random to me. I could iterate those 12 entries per face vertex, but if there’s actually a logic to that, it would be awesome to know.