forked from bartvdbraak/blender
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)
This commit is contained in:
parent
cc2e3980f8
commit
f8ef887880
@ -1240,7 +1240,7 @@ void DefaultMotionState::getWorldOrientation(float& quatIma0,float& quatIma1,flo
|
|||||||
|
|
||||||
void DefaultMotionState::setWorldPosition(float posX,float posY,float posZ)
|
void DefaultMotionState::setWorldPosition(float posX,float posY,float posZ)
|
||||||
{
|
{
|
||||||
btPoint3 pos(posX,posY,posZ);
|
btVector3 pos(posX,posY,posZ);
|
||||||
m_worldTransform.setOrigin( pos );
|
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++)
|
for (int i=0;i<poly->VertexCount();i++)
|
||||||
{
|
{
|
||||||
const float* vtx = poly->GetVertex(i)->getXYZ();
|
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)
|
//avoid duplicates (could better directly use vertex offsets, rather than a vertex compare)
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (int j=0;j<m_vertexArray.size();j++)
|
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();
|
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();
|
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();
|
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(vertex0);
|
||||||
m_vertexArray.push_back(vertex1);
|
m_vertexArray.push_back(vertex1);
|
||||||
@ -1365,13 +1365,13 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope,bo
|
|||||||
if (poly->VertexCount() == 4)
|
if (poly->VertexCount() == 4)
|
||||||
{
|
{
|
||||||
const float* vtx = poly->GetVertex(3)->getXYZ();
|
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();
|
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();
|
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(vertex0);
|
||||||
m_vertexArray.push_back(vertex1);
|
m_vertexArray.push_back(vertex1);
|
||||||
@ -1442,7 +1442,7 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PHY_SHAPE_POLYTOPE:
|
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;
|
break;
|
||||||
|
|
||||||
case PHY_SHAPE_MESH:
|
case PHY_SHAPE_MESH:
|
||||||
@ -1459,10 +1459,11 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape()
|
|||||||
|
|
||||||
|
|
||||||
// m_vertexArray is necessarily a multiple of 3
|
// 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);
|
btGImpactMeshShape* gimpactShape = new btGImpactMeshShape(collisionMeshData);
|
||||||
|
|
||||||
collisionShape = gimpactShape;
|
collisionShape = gimpactShape;
|
||||||
@ -1476,9 +1477,9 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape()
|
|||||||
collisionMeshData->m_weldingThreshold = m_weldingThreshold;
|
collisionMeshData->m_weldingThreshold = m_weldingThreshold;
|
||||||
|
|
||||||
// m_vertexArray is necessarily a multiple of 3
|
// 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
|
// this shape will be shared and not deleted until shapeInfo is deleted
|
||||||
m_unscaledShape = new btBvhTriangleMeshShape( collisionMeshData, true );
|
m_unscaledShape = new btBvhTriangleMeshShape( collisionMeshData, true );
|
||||||
|
@ -161,7 +161,7 @@ public:
|
|||||||
btTransform m_childTrans;
|
btTransform m_childTrans;
|
||||||
btVector3 m_childScale;
|
btVector3 m_childScale;
|
||||||
void* m_userData;
|
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.
|
// triangle array for concave mesh shape.
|
||||||
// In this case a triangle is made of 3 consecutive points
|
// In this case a triangle is made of 3 consecutive points
|
||||||
std::vector<int> m_polygonIndexArray; // Contains the array of polygon index in the
|
std::vector<int> m_polygonIndexArray; // Contains the array of polygon index in the
|
||||||
|
@ -414,7 +414,7 @@ void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl)
|
|||||||
const btTransform& t = ctrl->GetCollisionObject()->getWorldTransform();
|
const btTransform& t = ctrl->GetCollisionObject()->getWorldTransform();
|
||||||
|
|
||||||
|
|
||||||
btPoint3 minAabb,maxAabb;
|
btVector3 minAabb,maxAabb;
|
||||||
|
|
||||||
shapeinterface->getAabb(t,minAabb,maxAabb);
|
shapeinterface->getAabb(t,minAabb,maxAabb);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user