Merge pull request #1125 from erwincoumans/master
GLInstancingRenderer: don't crash but assert/return -1 when exceeding vertex capacity
This commit is contained in:
@@ -87,7 +87,16 @@ struct UrdfGeometry
|
|||||||
|
|
||||||
UrdfGeometry()
|
UrdfGeometry()
|
||||||
:m_type(URDF_GEOM_UNKNOWN),
|
:m_type(URDF_GEOM_UNKNOWN),
|
||||||
m_hasFromTo(false),
|
m_sphereRadius(1),
|
||||||
|
m_boxSize(1,1,1),
|
||||||
|
m_capsuleRadius(1),
|
||||||
|
m_capsuleHeight(1),
|
||||||
|
m_hasFromTo(0),
|
||||||
|
m_capsuleFrom(0,1,0),
|
||||||
|
m_capsuleTo(1,0,0),
|
||||||
|
m_planeNormal(0,0,1),
|
||||||
|
m_meshFileType(0),
|
||||||
|
m_meshScale(1,1,1),
|
||||||
m_hasLocalMaterial(false)
|
m_hasLocalMaterial(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -893,17 +893,25 @@ int GLInstancingRenderer::registerShape(const float* vertices, int numvertices,
|
|||||||
gfxObj->m_numVertices = numvertices;
|
gfxObj->m_numVertices = numvertices;
|
||||||
|
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, m_data->m_vbo);
|
|
||||||
int vertexStrideInBytes = 9*sizeof(float);
|
int vertexStrideInBytes = 9*sizeof(float);
|
||||||
int sz = numvertices*vertexStrideInBytes;
|
int sz = numvertices*vertexStrideInBytes;
|
||||||
|
int totalUsed = vertexStrideInBytes*gfxObj->m_vertexArrayOffset+sz;
|
||||||
|
b3Assert(totalUsed<m_data->m_maxShapeCapacityInBytes);
|
||||||
|
if (totalUsed>=m_data->m_maxShapeCapacityInBytes)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, m_data->m_vbo);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
char* dest= (char*)glMapBuffer( GL_ARRAY_BUFFER,GL_WRITE_ONLY);//GL_WRITE_ONLY
|
char* dest= (char*)glMapBuffer( GL_ARRAY_BUFFER,GL_WRITE_ONLY);//GL_WRITE_ONLY
|
||||||
|
|
||||||
|
|
||||||
#ifdef B3_DEBUG
|
#ifdef B3_DEBUG
|
||||||
int totalUsed = vertexStrideInBytes*gfxObj->m_vertexArrayOffset+sz;
|
|
||||||
b3Assert(totalUsed<m_data->m_maxShapeCapacityInBytes);
|
|
||||||
#endif//B3_DEBUG
|
#endif//B3_DEBUG
|
||||||
|
|
||||||
memcpy(dest+vertexStrideInBytes*gfxObj->m_vertexArrayOffset,vertices,sz);
|
memcpy(dest+vertexStrideInBytes*gfxObj->m_vertexArrayOffset,vertices,sz);
|
||||||
|
|||||||
Reference in New Issue
Block a user