Any way to tell how much memory is used by a pxTriangleMesh?

Is there a way to tell the exact amount of memory used by a pxTriangleMesh created with createTriangleMesh()?

If not, anyone know a good approximation? Just the size of the vertex array and the index array?


you can take a look at the SnippetTriangleMeshCreate. The mesh size is roughly the size of the cooked mesh data, almost all data are copied from the cooked mesh to the runtime mesh representation.

You mean the PxTriangleMesh class? How do you measure its size? You mean just add up the contents?
Like numVertices * sizeof (PxVec3) + numTriangles * 3 * sizeof(PxU32) + sizeof(pxTriangleMesh) ?

From the snippet:
PxDefaultMemoryOutputStream outBuffer;
gCooking->cookTriangleMesh(meshDesc, outBuffer);

	PxDefaultMemoryInputData stream(outBuffer.getData(), outBuffer.getSize());
	triMesh = gPhysics->createTriangleMesh(stream);

	meshSize = outBuffer.getSize();

The meshSize is the approximation you are looking for.

Hm, I am using the realtime cooking, so it isn’t being written to a stream. I wonder if there’s a way to get the size in that case?