BulletMultiThreaded (SPU/multi-core): added compound shape support and concave-convex (swapped case). Thanks to Marten Svanfeldt

This commit is contained in:
ejcoumans
2007-08-02 20:16:58 +00:00
parent 8a1d556e93
commit 5279f9e129
6 changed files with 1040 additions and 779 deletions

View File

@@ -35,8 +35,15 @@ btCompoundShape::~btCompoundShape()
void btCompoundShape::addChildShape(const btTransform& localTransform,btCollisionShape* shape)
{
m_childTransforms.push_back(localTransform);
m_childShapes.push_back(shape);
//m_childTransforms.push_back(localTransform);
//m_childShapes.push_back(shape);
btCompoundShapeChild child;
child.m_transform = localTransform;
child.m_childShape = shape;
child.m_childShapeType = shape->getShapeType();
child.m_childMargin = shape->getMargin();
m_children.push_back(child);
//extend the local aabbMin/aabbMax
btVector3 localAabbMin,localAabbMax;

View File

@@ -26,12 +26,21 @@ subject to the following restrictions:
class btOptimizedBvh;
ATTRIBUTE_ALIGNED16(struct) btCompoundShapeChild
{
btTransform m_transform;
btCollisionShape* m_childShape;
int m_childShapeType;
btScalar m_childMargin;
};
/// btCompoundShape allows to store multiple other btCollisionShapes
/// This allows for concave collision objects. This is more general then the Static Concave btTriangleMeshShape.
class btCompoundShape : public btCollisionShape
ATTRIBUTE_ALIGNED16(class) btCompoundShape : public btCollisionShape
{
btAlignedObjectArray<btTransform> m_childTransforms;
btAlignedObjectArray<btCollisionShape*> m_childShapes;
//btAlignedObjectArray<btTransform> m_childTransforms;
//btAlignedObjectArray<btCollisionShape*> m_childShapes;
btAlignedObjectArray<btCompoundShapeChild> m_children;
btVector3 m_localAabbMin;
btVector3 m_localAabbMax;
@@ -46,25 +55,31 @@ public:
int getNumChildShapes() const
{
return int (m_childShapes.size());
return int (m_children.size());
}
btCollisionShape* getChildShape(int index)
{
return m_childShapes[index];
return m_children[index].m_childShape;
}
const btCollisionShape* getChildShape(int index) const
{
return m_childShapes[index];
return m_children[index].m_childShape;
}
btTransform& getChildTransform(int index)
btTransform getChildTransform(int index)
{
return m_childTransforms[index];
return m_children[index].m_transform;
}
const btTransform& getChildTransform(int index) const
const btTransform getChildTransform(int index) const
{
return m_childTransforms[index];
return m_children[index].m_transform;
}
btCompoundShapeChild* getChildList()
{
return &m_children[0];
}
///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version