Advertisement Jump to content
Sign in to follow this  

Physx Cook TriangleMesh always get unexpected result

This topic is 1181 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The problem is this:
I have a rendering vertex set which will get a right result for rendering. But when i try to use Physx to Cook those vertices into a PxTriangleMesh it will always get unexpected result.
I wonder if is those vertices are too tough for Physx to cook into a right result.
I have tried many way to solve it including merging duplicated vertices but little improvement got.

This is the Cooking Paramters i set:
PxCookingParams params(scale);
params.meshWeldTolerance = 0.00001f;
params.meshPreprocessParams = PxMeshPreprocessingFlags(PxMeshPreprocessingFlag::eWELD_VERTICES | PxMeshPreprocessingFlag::eREMOVE_UNREFERENCED_VERTICES | PxMeshPreprocessingFlag::eREMOVE_DUPLICATED_TRIANGLES);

Is this is a commond problem or i just forgot something to set?
How to solve this problem?

Share this post

Link to post
Share on other sites

It is not clear wheather you use indicies on the mesh, if not, you will have to properly explain raw verticies interpretation, as I believe there are more possible (triangle array, triangle strip etc.)

Share this post

Link to post
Share on other sites

Here what I use to cook a triangle mesh collider :

// Set the triangle mesh desc.
physx::PxTriangleMeshDesc MeshDesc;
MeshDesc.points.count     = MeshVertices.GetSize();
MeshDesc.points.stride    = sizeof( physx::PxVec3 );      = &MeshVertices[ 0 ];
MeshDesc.triangles.count  = MeshIndices.GetSize() / 3;
MeshDesc.triangles.stride = 3 * sizeof( physx::PxU32 );   = &MeshIndices[ 0 ];

// Cook the triangle mesh.
physx::PxDefaultMemoryOutputStream WriteBuffer;
if( CEngine::GetPhysicsSystem().GetCooking()->cookTriangleMesh( MeshDesc, WriteBuffer ) == false )
  CEngine::GetLogger().LogError( "cookTriangleMesh failed" );
Edited by Alundra

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!