fix SoftDemo crash, due to changes in OpenGLGuiHelper rendering
fixes Issue #1655
This commit is contained in:
@@ -433,11 +433,15 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli
|
|||||||
if (collisionShape->getShapeType() == SOFTBODY_SHAPE_PROXYTYPE)
|
if (collisionShape->getShapeType() == SOFTBODY_SHAPE_PROXYTYPE)
|
||||||
{
|
{
|
||||||
computeSoftBodyVertices(collisionShape, gfxVertices, indices);
|
computeSoftBodyVertices(collisionShape, gfxVertices, indices);
|
||||||
|
if (gfxVertices.size() && indices.size())
|
||||||
|
{
|
||||||
int shapeId = registerGraphicsShape(&gfxVertices[0].xyzw[0], gfxVertices.size(), &indices[0], indices.size(), B3_GL_TRIANGLES,
|
int shapeId = registerGraphicsShape(&gfxVertices[0].xyzw[0], gfxVertices.size(), &indices[0], indices.size(), B3_GL_TRIANGLES,
|
||||||
m_data->m_checkedTexture);
|
m_data->m_checkedTexture);
|
||||||
|
|
||||||
b3Assert(shapeId >= 0);
|
b3Assert(shapeId >= 0);
|
||||||
collisionShape->setUserIndex(shapeId);
|
collisionShape->setUserIndex(shapeId);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (collisionShape->getShapeType()==MULTI_SPHERE_SHAPE_PROXYTYPE)
|
if (collisionShape->getShapeType()==MULTI_SPHERE_SHAPE_PROXYTYPE)
|
||||||
{
|
{
|
||||||
btMultiSphereShape* ms = (btMultiSphereShape*) collisionShape;
|
btMultiSphereShape* ms = (btMultiSphereShape*) collisionShape;
|
||||||
@@ -1265,6 +1269,11 @@ void OpenGLGuiHelper::autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWor
|
|||||||
btCollisionObject* colObj = sortedObjects[i];
|
btCollisionObject* colObj = sortedObjects[i];
|
||||||
//btRigidBody* body = btRigidBody::upcast(colObj);
|
//btRigidBody* body = btRigidBody::upcast(colObj);
|
||||||
//does this also work for btMultiBody/btMultiBodyLinkCollider?
|
//does this also work for btMultiBody/btMultiBodyLinkCollider?
|
||||||
|
btSoftBody* sb = btSoftBody::upcast(colObj);
|
||||||
|
if (sb)
|
||||||
|
{
|
||||||
|
colObj->getCollisionShape()->setUserPointer(sb);
|
||||||
|
}
|
||||||
createCollisionShapeGraphicsObject(colObj->getCollisionShape());
|
createCollisionShapeGraphicsObject(colObj->getCollisionShape());
|
||||||
int colorIndex = colObj->getBroadphaseHandle()->getUid() & 3;
|
int colorIndex = colObj->getBroadphaseHandle()->getUid() & 3;
|
||||||
|
|
||||||
@@ -1313,6 +1322,8 @@ void OpenGLGuiHelper::computeSoftBodyVertices(btCollisionShape* collisionShape,
|
|||||||
btAlignedObjectArray<GLInstanceVertex>& gfxVertices,
|
btAlignedObjectArray<GLInstanceVertex>& gfxVertices,
|
||||||
btAlignedObjectArray<int>& indices)
|
btAlignedObjectArray<int>& indices)
|
||||||
{
|
{
|
||||||
|
if (collisionShape->getUserPointer()==0)
|
||||||
|
return;
|
||||||
b3Assert(collisionShape->getUserPointer());
|
b3Assert(collisionShape->getUserPointer());
|
||||||
btSoftBody* psb = (btSoftBody*)collisionShape->getUserPointer();
|
btSoftBody* psb = (btSoftBody*)collisionShape->getUserPointer();
|
||||||
gfxVertices.resize(psb->m_faces.size() * 3);
|
gfxVertices.resize(psb->m_faces.size() * 3);
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ public:
|
|||||||
for ( int i=0;i<softWorld->getSoftBodyArray().size();i++)
|
for ( int i=0;i<softWorld->getSoftBodyArray().size();i++)
|
||||||
{
|
{
|
||||||
btSoftBody* psb=(btSoftBody*)softWorld->getSoftBodyArray()[i];
|
btSoftBody* psb=(btSoftBody*)softWorld->getSoftBodyArray()[i];
|
||||||
if (softWorld->getDebugDrawer() && !(softWorld->getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe)))
|
//if (softWorld->getDebugDrawer() && !(softWorld->getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe)))
|
||||||
{
|
{
|
||||||
btSoftBodyHelpers::DrawFrame(psb,softWorld->getDebugDrawer());
|
btSoftBodyHelpers::DrawFrame(psb,softWorld->getDebugDrawer());
|
||||||
btSoftBodyHelpers::Draw(psb,softWorld->getDebugDrawer(),softWorld->getDrawFlags());
|
btSoftBodyHelpers::Draw(psb,softWorld->getDebugDrawer(),softWorld->getDrawFlags());
|
||||||
|
|||||||
Reference in New Issue
Block a user