• Advertisement
Sign in to follow this  

[Bullet] Adding Static Meshes into btBvhTriangleMeshShape that have more than 65535 indices?

Recommended Posts


For the argument of 3*sizeof(int), why I can't load the Mesh Shape in 16bit format for the index.

If I load the mesh with 32bit index and the mesh has less than 65535 indices, it will overflow the vertex buffer.

I have tried to use 3* sizeof(WORD) as index stride and I can't put (WORD*)pIndexData, because bullet won't recognize the prototype,

Any ideas?





	indexVertexArrays =
            new btTriangleIndexVertexArray(pMesh->GetNumFaces(),
            (int*)pIndexData, 3 * sizeof(int), pMesh->GetNumVertices(),
            (btScalar*)pVertexData, dwVertexSize);
	        // For non-moving objects only
        staticShape = new btBvhTriangleMeshShape(indexVertexArrays, true);
Edited by lucky6969b

Share this post

Link to post
Share on other sites

I was able to create indexed triangle vertex arrays with 16-bit index format in Bullet by calling the 0-argument constructor and specifying the stride manually.


            typedef unsigned short IndexFormat;			

            pMesh->m_pTriMesh = new btTriangleIndexVertexArray();

			btIndexedMesh iMesh;
			iMesh.m_numTriangles        = pMesh->m_numFaces;
			iMesh.m_triangleIndexBase   = (const unsigned char *)pMesh->m_pIndices;
			iMesh.m_triangleIndexStride = 3 * sizeof(IndexFormat);
			iMesh.m_numVertices         = pMesh->m_numVertices;
			iMesh.m_vertexBase          = (const unsigned char *)pMesh->m_pVertices;
			iMesh.m_vertexStride        = sizeof(D3DXVECTOR3);
			pMesh->m_pTriMesh->addIndexedMesh( iMesh, PHY_SHORT );


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Advertisement