From dfe618bd62c7e238acab05aff7ae3f2cd2257bdc Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Mon, 15 May 2017 07:59:07 -0700 Subject: [PATCH 1/2] initialize UrdfGeometry members --- examples/Importers/ImportURDFDemo/UrdfParser.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/examples/Importers/ImportURDFDemo/UrdfParser.h b/examples/Importers/ImportURDFDemo/UrdfParser.h index 0bb291e58..de96885e5 100644 --- a/examples/Importers/ImportURDFDemo/UrdfParser.h +++ b/examples/Importers/ImportURDFDemo/UrdfParser.h @@ -87,7 +87,16 @@ struct UrdfGeometry UrdfGeometry() :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) { } From a554c250a74878bc3c45a128aaca2aa708f2be9f Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Mon, 15 May 2017 09:02:49 -0700 Subject: [PATCH 2/2] GLInstancingRenderer: don't crash but assert/return -1, if the # vertices exceeds the maximum capacity. --- examples/OpenGLWindow/GLInstancingRenderer.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/examples/OpenGLWindow/GLInstancingRenderer.cpp b/examples/OpenGLWindow/GLInstancingRenderer.cpp index 39a8c8a5b..7d628b11d 100644 --- a/examples/OpenGLWindow/GLInstancingRenderer.cpp +++ b/examples/OpenGLWindow/GLInstancingRenderer.cpp @@ -893,17 +893,25 @@ int GLInstancingRenderer::registerShape(const float* vertices, int numvertices, gfxObj->m_numVertices = numvertices; - glBindBuffer(GL_ARRAY_BUFFER, m_data->m_vbo); + int vertexStrideInBytes = 9*sizeof(float); int sz = numvertices*vertexStrideInBytes; + int totalUsed = vertexStrideInBytes*gfxObj->m_vertexArrayOffset+sz; + b3Assert(totalUsedm_maxShapeCapacityInBytes); + if (totalUsed>=m_data->m_maxShapeCapacityInBytes) + { + return -1; + } + + glBindBuffer(GL_ARRAY_BUFFER, m_data->m_vbo); + #if 0 char* dest= (char*)glMapBuffer( GL_ARRAY_BUFFER,GL_WRITE_ONLY);//GL_WRITE_ONLY #ifdef B3_DEBUG - int totalUsed = vertexStrideInBytes*gfxObj->m_vertexArrayOffset+sz; - b3Assert(totalUsedm_maxShapeCapacityInBytes); + #endif//B3_DEBUG memcpy(dest+vertexStrideInBytes*gfxObj->m_vertexArrayOffset,vertices,sz);