I’m doing some work with the PhysX types and I see on the method getVerticesForModification() in PxTriangleMesh.h that if I want a 1 to 1 index mapping with the original mesh (before cooking) then I need to set the cooking flags eWELD_VERTICES = 0, eDISABLE_CLEAN_MESH = 1. I’ve been reworking some of the procedural Mesh component to allow me to update specific triangles on the fly and I’m making it so It updates their complex collision as well. I believe this is the only thing standing in the way before my work I’ve done so far should work.
I see in the PhysLevel.cpp
PCookingParams.meshPreprocessParams = PxMeshPreprocessingFlags(PxMeshPreprocessingFlag::eWELD_VERTICES | PxMeshPreprocessingFlag::eREMOVE_UNREFERENCED_VERTICES | PxMeshPreprocessingFlag::eREMOVE_DUPLICATED_TRIANGLES);
Which looks like where I should be changing the flags but how do I access this variable PCookingParams?
I tried setting the flags manually in the PhysLevel.cpp which is where I thought it was stored.
PCookingParams.meshPreprocessParams = PxMeshPreprocessingFlags(0 | 0 | 0 | 1 | 0 | 1);
The first bit is supposed to be eWELD_VERTICES, the next is eREMOVE_UNREFERENCED_VERTICES, then eREMOVE_DUPLICATED_TRIANGLES, and also eDISABLE_CLEAN_MESH which is supposed to stop the welding of verts when clean mesh is off. Yet I still see that my verts are being welded. Which throws off the vertex index.
I was setting the flags incorrectly. Lack of know how. I didn’t know that you don’t specify each bit in the flag only the enum that you want and the enum will shift itself over. So this worked for me
PCookingParams.meshPreprocessParams = PxMeshPreprocessingFlags(PxMeshPreprocessingFlag::eDISABLE_CLEAN_MESH | PxMeshPreprocessingFlag::eFORCE_32BIT_INDICES);