From d2d987a5ed2bb8b3cd6d914b8db790958eeafe88 Mon Sep 17 00:00:00 2001 From: Jan Matas Date: Thu, 8 Feb 2018 13:49:36 +0000 Subject: [PATCH] Create a new pointer in btCollisionShape instead of just using userPtr. --- examples/ExampleBrowser/OpenGLGuiHelper.cpp | 4 ++-- .../SharedMemory/PhysicsServerCommandProcessor.cpp | 2 +- .../CollisionShapes/btCollisionShape.h | 13 +++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/examples/ExampleBrowser/OpenGLGuiHelper.cpp b/examples/ExampleBrowser/OpenGLGuiHelper.cpp index 1c7daff79..388708259 100644 --- a/examples/ExampleBrowser/OpenGLGuiHelper.cpp +++ b/examples/ExampleBrowser/OpenGLGuiHelper.cpp @@ -1291,8 +1291,8 @@ void OpenGLGuiHelper::computeSoftBodyVertices(btCollisionShape* collisionShape, btAlignedObjectArray& gfxVertices, btAlignedObjectArray& indices) { - b3Assert(collisionShape->getUserPointer()); - btSoftBody* psb = (btSoftBody*)collisionShape->getUserPointer(); + b3Assert(collisionShape->getBodyPointer()); + btSoftBody* psb = (btSoftBody*)collisionShape->getBodyPointer(); gfxVertices.resize(psb->m_faces.size() * 3); int i, j, k; for (i = 0; i < psb->m_faces.size(); i++) // Foreach face diff --git a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp index 7995ef1dd..086fdfd05 100644 --- a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp +++ b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp @@ -5862,7 +5862,7 @@ bool PhysicsServerCommandProcessor::processLoadSoftBodyCommand(const struct Shar psb->scale(btVector3(scale,scale,scale)); psb->setTotalMass(mass,true); psb->getCollisionShape()->setMargin(collisionMargin); - psb->getCollisionShape()->setUserPointer(psb); + psb->getCollisionShape()->setBodyPointer(psb); m_data->m_dynamicsWorld->addSoftBody(psb); m_data->m_guiHelper->createCollisionShapeGraphicsObject(psb->getCollisionShape()); m_data->m_guiHelper->autogenerateGraphicsObjects(this->m_data->m_dynamicsWorld); diff --git a/src/BulletCollision/CollisionShapes/btCollisionShape.h b/src/BulletCollision/CollisionShapes/btCollisionShape.h index 6c4916fbd..299dff038 100644 --- a/src/BulletCollision/CollisionShapes/btCollisionShape.h +++ b/src/BulletCollision/CollisionShapes/btCollisionShape.h @@ -30,6 +30,7 @@ protected: int m_shapeType; void* m_userPointer; int m_userIndex; + void* m_bodyPointer; public: @@ -131,6 +132,18 @@ public: { return m_userPointer; } + + /// optional pointer to body the shape represents + void setBodyPointer(void* bodyPointer) + { + m_bodyPointer = bodyPointer; + } + + void* getBodyPointer() const + { + return m_bodyPointer; + } + void setUserIndex(int index) { m_userIndex = index;