diff options
author | Erwin Coumans <blender@erwincoumans.com> | 2009-03-02 20:43:35 +0300 |
---|---|---|
committer | Erwin Coumans <blender@erwincoumans.com> | 2009-03-02 20:43:35 +0300 |
commit | f8ef887880ac217cc831b2ab9677e1f9e825537b (patch) | |
tree | 4d0f726e598d7d7c3c3f8919ae805d0b967aa544 | |
parent | cc2e3980f8469d1dec876f7bbff7ab31bffa553a (diff) |
minor update to be compatible with Bullet 2.74 physics:
btPoint3 has been deprecated, it was already a typedef to btVector3
replace std::vector by btAlignedObjectArray when storing Bullet objects, because MSVC STL implementation has some bugs, preventing to contain aligned objects
(btVector3 is 16-byte aligned, to allow SIMD)
3 files changed, 16 insertions, 15 deletions
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index d09ad58fe3b..fc76af15301 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -1240,7 +1240,7 @@ void DefaultMotionState::getWorldOrientation(float& quatIma0,float& quatIma1,flo void DefaultMotionState::setWorldPosition(float posX,float posY,float posZ) { - btPoint3 pos(posX,posY,posZ); + btVector3 pos(posX,posY,posZ); m_worldTransform.setOrigin( pos ); } @@ -1328,7 +1328,7 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope,bo for (int i=0;i<poly->VertexCount();i++) { const float* vtx = poly->GetVertex(i)->getXYZ(); - btPoint3 point(vtx[0],vtx[1],vtx[2]); + btVector3 point(vtx[0],vtx[1],vtx[2]); //avoid duplicates (could better directly use vertex offsets, rather than a vertex compare) bool found = false; for (int j=0;j<m_vertexArray.size();j++) @@ -1348,13 +1348,13 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope,bo { { const float* vtx = poly->GetVertex(2)->getXYZ(); - btPoint3 vertex0(vtx[0],vtx[1],vtx[2]); + btVector3 vertex0(vtx[0],vtx[1],vtx[2]); vtx = poly->GetVertex(1)->getXYZ(); - btPoint3 vertex1(vtx[0],vtx[1],vtx[2]); + btVector3 vertex1(vtx[0],vtx[1],vtx[2]); vtx = poly->GetVertex(0)->getXYZ(); - btPoint3 vertex2(vtx[0],vtx[1],vtx[2]); + btVector3 vertex2(vtx[0],vtx[1],vtx[2]); m_vertexArray.push_back(vertex0); m_vertexArray.push_back(vertex1); @@ -1365,13 +1365,13 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope,bo if (poly->VertexCount() == 4) { const float* vtx = poly->GetVertex(3)->getXYZ(); - btPoint3 vertex0(vtx[0],vtx[1],vtx[2]); + btVector3 vertex0(vtx[0],vtx[1],vtx[2]); vtx = poly->GetVertex(2)->getXYZ(); - btPoint3 vertex1(vtx[0],vtx[1],vtx[2]); + btVector3 vertex1(vtx[0],vtx[1],vtx[2]); vtx = poly->GetVertex(0)->getXYZ(); - btPoint3 vertex2(vtx[0],vtx[1],vtx[2]); + btVector3 vertex2(vtx[0],vtx[1],vtx[2]); m_vertexArray.push_back(vertex0); m_vertexArray.push_back(vertex1); @@ -1442,7 +1442,7 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape() break; case PHY_SHAPE_POLYTOPE: - collisionShape = new btConvexHullShape(&m_vertexArray.begin()->getX(), m_vertexArray.size()); + collisionShape = new btConvexHullShape(&m_vertexArray[0].getX(), m_vertexArray.size()); break; case PHY_SHAPE_MESH: @@ -1459,10 +1459,11 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape() // m_vertexArray is necessarily a multiple of 3 - for (std::vector<btPoint3>::iterator it=m_vertexArray.begin(); it != m_vertexArray.end(); ) + for (int i=0;i<m_vertexArray.size(); i+=3 ) { - collisionMeshData->addTriangle(*it++,*it++,*it++); + collisionMeshData->addTriangle(m_vertexArray[i+2],m_vertexArray[i+1],m_vertexArray[i]); } + btGImpactMeshShape* gimpactShape = new btGImpactMeshShape(collisionMeshData); collisionShape = gimpactShape; @@ -1476,9 +1477,9 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape() collisionMeshData->m_weldingThreshold = m_weldingThreshold; // m_vertexArray is necessarily a multiple of 3 - for (std::vector<btPoint3>::iterator it=m_vertexArray.begin(); it != m_vertexArray.end(); ) + for (int i=0;i<m_vertexArray.size(); i+=3 ) { - collisionMeshData->addTriangle(*it++,*it++,*it++); + collisionMeshData->addTriangle(m_vertexArray[i+2],m_vertexArray[i+1],m_vertexArray[i]); } // this shape will be shared and not deleted until shapeInfo is deleted m_unscaledShape = new btBvhTriangleMeshShape( collisionMeshData, true ); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index c771aa2624b..deb3c0880e9 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -161,7 +161,7 @@ public: btTransform m_childTrans; btVector3 m_childScale; void* m_userData; - std::vector<btPoint3> m_vertexArray; // Contains both vertex array for polytope shape and + btAlignedObjectArray<btVector3> m_vertexArray; // Contains both vertex array for polytope shape and // triangle array for concave mesh shape. // In this case a triangle is made of 3 consecutive points std::vector<int> m_polygonIndexArray; // Contains the array of polygon index in the diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index eb01385bc01..63ad427852e 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -414,7 +414,7 @@ void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl) const btTransform& t = ctrl->GetCollisionObject()->getWorldTransform(); - btPoint3 minAabb,maxAabb; + btVector3 minAabb,maxAabb; shapeinterface->getAabb(t,minAabb,maxAabb); |