Accessing triangle connectivity from MDLMesh

I'm loading an OBJ model into a MDLMesh using MDLAsset. I'm trying to access the raw vertex data, indices, and connectivity for the triangles. So far I've been able to get the vertices from the MDLMesh (using mdlMesh.vertexAttributeData) and the indices (from the MDLSubmeshes). But I haven't been able to figure out how to access connectivity - i.e., how the triangles connect to each other. Is that information stored anywhere in the mesh?

Replies

The vertices and the indices are all that there is. If you want connectivity then you need to make a reverse map -- each vertex gets a list of which triangles it participates in. There is no reason to store this as it is easily calculated in linear time.

Two triangles are "connected" to each other if they share one or more vertices. Trianges (1,2,3) and (3,4,5) are connected at vertex 3. Triangles (1,2,3) and (1,2,5) are connected at side (1,2). Triangles (1,2,3) and (1,3,2) are coincident but face opposite directions.