I'm posting to report a crash that can occur in btGImpactShape.h when using large meshes that cause the signed indices to become negative. The solution is to simply use unsigned indicies. See the following diff:
Code: Select all
Index: btGImpactShape.h
===================================================================
--- btGImpactShape.h (revision 5646)
+++ btGImpactShape.h (revision 5647)
@@ -636,25 +636,25 @@
return (int )numverts;
}
- SIMD_FORCE_INLINE void get_indices(int face_index,int &i0,int &i1,int &i2) const
+ SIMD_FORCE_INLINE void get_indices(int face_index,unsigned int &i0,unsigned int &i1,unsigned int &i2) const
{
if(indicestype == PHY_SHORT)
{
- short * s_indices = (short *)(indexbase + face_index*indexstride);
+ unsigned short* s_indices = (unsigned short *)(indexbase + face_index * indexstride);
i0 = s_indices[0];
i1 = s_indices[1];
i2 = s_indices[2];
}
else
{
- int * i_indices = (int *)(indexbase + face_index*indexstride);
+ unsigned int * i_indices = (unsigned int *)(indexbase + face_index*indexstride);
i0 = i_indices[0];
i1 = i_indices[1];
i2 = i_indices[2];
}
}
- SIMD_FORCE_INLINE void get_vertex(int vertex_index, btVector3 & vertex) const
+ SIMD_FORCE_INLINE void get_vertex(unsigned int vertex_index, btVector3 & vertex) const
{
if(type == PHY_DOUBLE)
{
@@ -683,7 +683,7 @@
virtual void get_primitive_triangle(int prim_index,btPrimitiveTriangle & triangle) const
{
- int indices[3];
+ unsigned int indices[3];
get_indices(prim_index,indices[0],indices[1],indices[2]);
get_vertex(indices[0],triangle.m_vertices[0]);
get_vertex(indices[1],triangle.m_vertices[1]);
@@ -693,7 +693,7 @@
SIMD_FORCE_INLINE void get_bullet_triangle(int prim_index,btTriangleShapeEx & triangle) const
{
- int indices[3];
+ unsigned int indices[3];
get_indices(prim_index,indices[0],indices[1],indices[2]);
get_vertex(indices[0],triangle.m_vertices1[0]);
get_vertex(indices[1],triangle.m_vertices1[1]);