After cooking, why is the order of mesh faces changed?

Hi everyone,

I have a question about cooking of triangle mesh. I have a .obj file, which includes 24 vertices and 12 faces. I imported the mesh and output all the vertices and faces, as shown below:

10 10 10
-10 10 10
10 -10 10
-10 -10 10
10 10 10
10 -10 10
10 10 -10
10 -10 -10
10 10 10
10 10 -10
-10 10 10
-10 10 -10
-10 -10 -10
-10 10 -10
10 -10 -10
10 10 -10
-10 -10 -10
10 -10 -10
-10 -10 10
10 -10 10
-10 -10 -10
-10 -10 10
-10 10 -10
-10 10 10

0 1 2
3 2 1
4 5 6
7 6 5
8 9 10
11 10 9
12 13 14
15 14 13
16 17 18
19 18 17
20 21 22
23 22 21

After cooking the triangle mesh, I output the vertexBuffer and the indexBuffer, which are shown as below:

10 10 10
-10 10 10
10 -10 10
-10 -10 10
10 10 10
10 -10 10
10 10 -10
10 -10 -10
10 10 10
10 10 -10
-10 10 10
-10 10 -10
-10 -10 -10
-10 10 -10
10 -10 -10
10 10 -10
-10 -10 -10
10 -10 -10
-10 -10 10
10 -10 10
-10 -10 -10
-10 -10 10
-10 10 -10
-10 10 10

15 14 13
12 13 14
16 17 18
19 18 17
7 6 5
23 22 21
0 1 2
20 21 22
8 9 10
11 10 9
3 2 1
4 5 6

The order of the faces are different. For example, the first face was (0, 1, 2), however, after cooking, the first face is (15, 14, 13).

Is it real, or did I do something wrong?

Thanks for your help!

Hi,
yes this is correct behaviour. The SDK does internally resort the vertices during the cooking process. However you can get a remap table that would tell you the vertex remap indices, there is getTrianglesRemap on PxTriangleMesh:
/**
\brief Returns the triangle remapping table.

The triangles are internally sorted according to various criteria. Hence the internal triangle order
does not always match the original (user-defined) order. The remapping table helps finding the old
indices knowing the new ones:

	remapTable[ internalTriangleIndex ] = originalTriangleIndex

\return	the remapping table (or NULL if 'PxCookingParams::suppressTriangleMeshRemapTable' has been used)
@see getNbTriangles() getTriangles() PxCookingParams::suppressTriangleMeshRemapTable
*/
virtual	const PxU32*			getTrianglesRemap()							const	= 0;

Regards,
Ales

Hi Borous,

Thanks for your answer!