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

Started by
2 comments, last by lucky6969b 7 years, 2 months ago

Hello,

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?

 

Thanks

Jack

 


	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);
	
Advertisement

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 );

 

Nice, Man...

thanks a lot

This topic is closed to new replies.

Advertisement