Merge branch 'master' of https://github.com/erwincoumans/bullet3
This commit is contained in:
@@ -187,6 +187,7 @@ struct BulletMJCFImporterInternalData
|
|||||||
|
|
||||||
//those collision shapes are deleted by caller (todo: make sure this happens!)
|
//those collision shapes are deleted by caller (todo: make sure this happens!)
|
||||||
btAlignedObjectArray<btCollisionShape*> m_allocatedCollisionShapes;
|
btAlignedObjectArray<btCollisionShape*> m_allocatedCollisionShapes;
|
||||||
|
mutable btAlignedObjectArray<btTriangleMesh*> m_allocatedMeshInterfaces;
|
||||||
|
|
||||||
BulletMJCFImporterInternalData()
|
BulletMJCFImporterInternalData()
|
||||||
:m_activeModel(-1),
|
:m_activeModel(-1),
|
||||||
@@ -1855,6 +1856,8 @@ class btCompoundShape* BulletMJCFImporter::convertLinkCollisionShapes( int linkI
|
|||||||
{
|
{
|
||||||
|
|
||||||
btTriangleMesh* meshInterface = new btTriangleMesh();
|
btTriangleMesh* meshInterface = new btTriangleMesh();
|
||||||
|
m_data->m_allocatedMeshInterfaces.push_back(meshInterface);
|
||||||
|
|
||||||
for (int i=0;i<glmesh->m_numIndices/3;i++)
|
for (int i=0;i<glmesh->m_numIndices/3;i++)
|
||||||
{
|
{
|
||||||
float* v0 = glmesh->m_vertices->at(glmesh->m_indices->at(i*3)).xyzw;
|
float* v0 = glmesh->m_vertices->at(glmesh->m_indices->at(i*3)).xyzw;
|
||||||
@@ -1926,6 +1929,15 @@ class btCollisionShape* BulletMJCFImporter::getAllocatedCollisionShape(int index
|
|||||||
return m_data->m_allocatedCollisionShapes[index];
|
return m_data->m_allocatedCollisionShapes[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int BulletMJCFImporter::getNumAllocatedMeshInterfaces() const
|
||||||
|
{
|
||||||
|
return m_data->m_allocatedMeshInterfaces.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
btStridingMeshInterface* BulletMJCFImporter::getAllocatedMeshInterface(int index)
|
||||||
|
{
|
||||||
|
return m_data->m_allocatedMeshInterfaces[index];
|
||||||
|
}
|
||||||
|
|
||||||
int BulletMJCFImporter::getNumModels() const
|
int BulletMJCFImporter::getNumModels() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -78,6 +78,9 @@ public:
|
|||||||
virtual int getNumModels() const;
|
virtual int getNumModels() const;
|
||||||
virtual void activateModel(int modelIndex);
|
virtual void activateModel(int modelIndex);
|
||||||
|
|
||||||
|
virtual int getNumAllocatedMeshInterfaces() const;
|
||||||
|
virtual btStridingMeshInterface* getAllocatedMeshInterface(int index);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ ATTRIBUTE_ALIGNED16(struct) BulletURDFInternalData
|
|||||||
int m_bodyId;
|
int m_bodyId;
|
||||||
btHashMap<btHashInt,UrdfMaterialColor> m_linkColors;
|
btHashMap<btHashInt,UrdfMaterialColor> m_linkColors;
|
||||||
btAlignedObjectArray<btCollisionShape*> m_allocatedCollisionShapes;
|
btAlignedObjectArray<btCollisionShape*> m_allocatedCollisionShapes;
|
||||||
|
mutable btAlignedObjectArray<btTriangleMesh*> m_allocatedMeshInterfaces;
|
||||||
|
|
||||||
LinkVisualShapesConverter* m_customVisualShapesConverter;
|
LinkVisualShapesConverter* m_customVisualShapesConverter;
|
||||||
|
|
||||||
@@ -572,7 +573,7 @@ bool findExistingMeshFile(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
btCollisionShape* convertURDFToCollisionShape(const UrdfCollision* collision, const char* urdfPathPrefix)
|
btCollisionShape* BulletURDFImporter::convertURDFToCollisionShape(const UrdfCollision* collision, const char* urdfPathPrefix) const
|
||||||
{
|
{
|
||||||
BT_PROFILE("convertURDFToCollisionShape");
|
BT_PROFILE("convertURDFToCollisionShape");
|
||||||
|
|
||||||
@@ -775,6 +776,7 @@ upAxisMat.setIdentity();
|
|||||||
{
|
{
|
||||||
BT_PROFILE("convert trimesh");
|
BT_PROFILE("convert trimesh");
|
||||||
btTriangleMesh* meshInterface = new btTriangleMesh();
|
btTriangleMesh* meshInterface = new btTriangleMesh();
|
||||||
|
m_data->m_allocatedMeshInterfaces.push_back(meshInterface);
|
||||||
{
|
{
|
||||||
BT_PROFILE("convert vertices");
|
BT_PROFILE("convert vertices");
|
||||||
|
|
||||||
@@ -1229,6 +1231,19 @@ btCollisionShape* BulletURDFImporter::getAllocatedCollisionShape(int index)
|
|||||||
return m_data->m_allocatedCollisionShapes[index];
|
return m_data->m_allocatedCollisionShapes[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int BulletURDFImporter::getNumAllocatedMeshInterfaces() const
|
||||||
|
{
|
||||||
|
return m_data->m_allocatedMeshInterfaces.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
btStridingMeshInterface* BulletURDFImporter::getAllocatedMeshInterface(int index)
|
||||||
|
{
|
||||||
|
return m_data->m_allocatedMeshInterfaces[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class btCompoundShape* BulletURDFImporter::convertLinkCollisionShapes(int linkIndex, const char* pathPrefix, const btTransform& localInertiaFrame) const
|
class btCompoundShape* BulletURDFImporter::convertLinkCollisionShapes(int linkIndex, const char* pathPrefix, const btTransform& localInertiaFrame) const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ public:
|
|||||||
|
|
||||||
virtual void convertLinkVisualShapes2(int linkIndex, int urdfIndex, const char* pathPrefix, const btTransform& inertialFrame, class btCollisionObject* colObj, int bodyUniqueId) const;
|
virtual void convertLinkVisualShapes2(int linkIndex, int urdfIndex, const char* pathPrefix, const btTransform& inertialFrame, class btCollisionObject* colObj, int bodyUniqueId) const;
|
||||||
|
|
||||||
|
class btCollisionShape* convertURDFToCollisionShape(const struct UrdfCollision* collision, const char* urdfPathPrefix) const;
|
||||||
|
|
||||||
///todo(erwincoumans) refactor this convertLinkCollisionShapes/memory allocation
|
///todo(erwincoumans) refactor this convertLinkCollisionShapes/memory allocation
|
||||||
|
|
||||||
virtual class btCompoundShape* convertLinkCollisionShapes(int linkIndex, const char* pathPrefix, const btTransform& localInertiaFrame) const;
|
virtual class btCompoundShape* convertLinkCollisionShapes(int linkIndex, const char* pathPrefix, const btTransform& localInertiaFrame) const;
|
||||||
@@ -69,7 +71,9 @@ public:
|
|||||||
virtual int getNumAllocatedCollisionShapes() const;
|
virtual int getNumAllocatedCollisionShapes() const;
|
||||||
virtual class btCollisionShape* getAllocatedCollisionShape(int index);
|
virtual class btCollisionShape* getAllocatedCollisionShape(int index);
|
||||||
|
|
||||||
|
virtual int getNumAllocatedMeshInterfaces() const;
|
||||||
|
virtual class btStridingMeshInterface* getAllocatedMeshInterface(int index);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ public:
|
|||||||
virtual class btCollisionShape* getAllocatedCollisionShape(int /*index*/ ) {return 0;}
|
virtual class btCollisionShape* getAllocatedCollisionShape(int /*index*/ ) {return 0;}
|
||||||
virtual int getNumModels() const {return 0;}
|
virtual int getNumModels() const {return 0;}
|
||||||
virtual void activateModel(int /*modelIndex*/) { }
|
virtual void activateModel(int /*modelIndex*/) { }
|
||||||
|
virtual int getNumAllocatedMeshInterfaces() const { return 0;}
|
||||||
|
virtual class btStridingMeshInterface* getAllocatedMeshInterface(int index) {return 0;}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1191,6 +1191,7 @@ struct PhysicsServerCommandProcessorInternalData
|
|||||||
btAlignedObjectArray<std::string*> m_strings;
|
btAlignedObjectArray<std::string*> m_strings;
|
||||||
|
|
||||||
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
|
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
|
||||||
|
btAlignedObjectArray<btStridingMeshInterface*> m_meshInterfaces;
|
||||||
|
|
||||||
MyOverlapFilterCallback* m_broadphaseCollisionFilterCallback;
|
MyOverlapFilterCallback* m_broadphaseCollisionFilterCallback;
|
||||||
btHashedOverlappingPairCache* m_pairCache;
|
btHashedOverlappingPairCache* m_pairCache;
|
||||||
@@ -2027,6 +2028,11 @@ void PhysicsServerCommandProcessor::deleteDynamicsWorld()
|
|||||||
btCollisionShape* shape = m_data->m_collisionShapes[j];
|
btCollisionShape* shape = m_data->m_collisionShapes[j];
|
||||||
delete shape;
|
delete shape;
|
||||||
}
|
}
|
||||||
|
for (int j=0;j<m_data->m_meshInterfaces.size();j++)
|
||||||
|
{
|
||||||
|
delete m_data->m_meshInterfaces[j];
|
||||||
|
}
|
||||||
|
m_data->m_meshInterfaces.clear();
|
||||||
m_data->m_collisionShapes.clear();
|
m_data->m_collisionShapes.clear();
|
||||||
|
|
||||||
delete m_data->m_dynamicsWorld;
|
delete m_data->m_dynamicsWorld;
|
||||||
@@ -2232,7 +2238,12 @@ bool PhysicsServerCommandProcessor::processImportedObjects(const char* fileName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i=0;i<u2b.getNumAllocatedMeshInterfaces();i++)
|
||||||
|
{
|
||||||
|
m_data->m_meshInterfaces.push_back(u2b.getAllocatedMeshInterface(i));
|
||||||
|
}
|
||||||
|
|
||||||
for (int i=0;i<u2b.getNumAllocatedCollisionShapes();i++)
|
for (int i=0;i<u2b.getNumAllocatedCollisionShapes();i++)
|
||||||
{
|
{
|
||||||
btCollisionShape* shape =u2b.getAllocatedCollisionShape(i);
|
btCollisionShape* shape =u2b.getAllocatedCollisionShape(i);
|
||||||
@@ -2278,7 +2289,6 @@ bool PhysicsServerCommandProcessor::loadMjcf(const char* fileName, char* bufferS
|
|||||||
bool loadOk = u2b.loadMJCF(fileName, &logger, useFixedBase);
|
bool loadOk = u2b.loadMJCF(fileName, &logger, useFixedBase);
|
||||||
if (loadOk)
|
if (loadOk)
|
||||||
{
|
{
|
||||||
|
|
||||||
processImportedObjects(fileName,bufferServerToClient,bufferSizeInBytes,useMultiBody,flags, u2b);
|
processImportedObjects(fileName,bufferServerToClient,bufferSizeInBytes,useMultiBody,flags, u2b);
|
||||||
}
|
}
|
||||||
return loadOk;
|
return loadOk;
|
||||||
@@ -3787,6 +3797,7 @@ bool PhysicsServerCommandProcessor::processCommand(const struct SharedMemoryComm
|
|||||||
|
|
||||||
BT_PROFILE("convert trimesh");
|
BT_PROFILE("convert trimesh");
|
||||||
btTriangleMesh* meshInterface = new btTriangleMesh();
|
btTriangleMesh* meshInterface = new btTriangleMesh();
|
||||||
|
this->m_data->m_meshInterfaces.push_back(meshInterface);
|
||||||
{
|
{
|
||||||
BT_PROFILE("convert vertices");
|
BT_PROFILE("convert vertices");
|
||||||
|
|
||||||
@@ -3801,6 +3812,7 @@ bool PhysicsServerCommandProcessor::processCommand(const struct SharedMemoryComm
|
|||||||
{
|
{
|
||||||
BT_PROFILE("create btBvhTriangleMeshShape");
|
BT_PROFILE("create btBvhTriangleMeshShape");
|
||||||
btBvhTriangleMeshShape* trimesh = new btBvhTriangleMeshShape(meshInterface,true,true);
|
btBvhTriangleMeshShape* trimesh = new btBvhTriangleMeshShape(meshInterface,true,true);
|
||||||
|
m_data->m_collisionShapes.push_back(trimesh);
|
||||||
//trimesh->setLocalScaling(collision->m_geometry.m_meshScale);
|
//trimesh->setLocalScaling(collision->m_geometry.m_meshScale);
|
||||||
shape = trimesh;
|
shape = trimesh;
|
||||||
if (compound)
|
if (compound)
|
||||||
@@ -3808,6 +3820,7 @@ bool PhysicsServerCommandProcessor::processCommand(const struct SharedMemoryComm
|
|||||||
compound->addChildShape(childTransform,shape);
|
compound->addChildShape(childTransform,shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
delete glmesh;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user