Create a new pointer in btCollisionShape instead of just using userPtr.

This commit is contained in:
Jan Matas
2018-02-08 13:49:36 +00:00
parent 82214eb99f
commit d2d987a5ed
3 changed files with 16 additions and 3 deletions

View File

@@ -1291,8 +1291,8 @@ void OpenGLGuiHelper::computeSoftBodyVertices(btCollisionShape* collisionShape,
btAlignedObjectArray<GLInstanceVertex>& gfxVertices,
btAlignedObjectArray<int>& 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

View File

@@ -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);

View File

@@ -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;