Finally applied patch to removeChildShape from btCompoundShape
http://code.google.com/p/bullet/issues/detail?id=51 Thanks to Ola Røer Thorsen for the patch!
This commit is contained in:
@@ -62,9 +62,53 @@ void btCompoundShape::addChildShape(const btTransform& localTransform,btCollisio
|
||||
}
|
||||
}
|
||||
|
||||
void btCompoundShape::removeChildShape(btCollisionShape* shape)
|
||||
{
|
||||
bool done_removing;
|
||||
|
||||
// Find the children containing the shape specified, and remove those children.
|
||||
do
|
||||
{
|
||||
done_removing = true;
|
||||
|
||||
for(int i = 0; i < m_children.size(); i++)
|
||||
{
|
||||
if(m_children[i].m_childShape == shape)
|
||||
{
|
||||
m_children.remove(m_children[i]);
|
||||
done_removing = false; // Do another iteration pass after removing from the vector
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (!done_removing);
|
||||
|
||||
recalculateLocalAabb();
|
||||
}
|
||||
|
||||
|
||||
///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
|
||||
void btCompoundShape::recalculateLocalAabb()
|
||||
{
|
||||
// Recalculate the local aabb
|
||||
// Brute force, it iterates over all the shapes left.
|
||||
m_localAabbMin = btVector3(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||
m_localAabbMax = btVector3(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
|
||||
|
||||
//extend the local aabbMin/aabbMax
|
||||
for (int j = 0; j < m_children.size(); j++)
|
||||
{
|
||||
btVector3 localAabbMin,localAabbMax;
|
||||
m_children[j].m_childShape->getAabb(m_children[j].m_transform, localAabbMin, localAabbMax);
|
||||
for (int i=0;i<3;i++)
|
||||
{
|
||||
if (m_localAabbMin[i] > localAabbMin[i])
|
||||
m_localAabbMin[i] = localAabbMin[i];
|
||||
if (m_localAabbMax[i] < localAabbMax[i])
|
||||
m_localAabbMax[i] = localAabbMax[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
|
||||
void btCompoundShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const
|
||||
{
|
||||
btVector3 localHalfExtents = btScalar(0.5)*(m_localAabbMax-m_localAabbMin);
|
||||
|
||||
@@ -36,7 +36,15 @@ ATTRIBUTE_ALIGNED16(struct) btCompoundShapeChild
|
||||
int m_childShapeType;
|
||||
btScalar m_childMargin;
|
||||
};
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE bool operator==(const btCompoundShapeChild& c1, const btCompoundShapeChild& c2)
|
||||
{
|
||||
return ( c1.m_transform == c2.m_transform &&
|
||||
c1.m_childShape == c2.m_childShape &&
|
||||
c1.m_childShapeType == c2.m_childShapeType &&
|
||||
c1.m_childMargin == c2.m_childMargin );
|
||||
}
|
||||
|
||||
/// btCompoundShape allows to store multiple other btCollisionShapes
|
||||
/// This allows for concave collision objects. This is more general then the Static Concave btTriangleMeshShape.
|
||||
ATTRIBUTE_ALIGNED16(class) btCompoundShape : public btCollisionShape
|
||||
@@ -58,6 +66,12 @@ public:
|
||||
|
||||
void addChildShape(const btTransform& localTransform,btCollisionShape* shape);
|
||||
|
||||
/** Remove all children shapes that contain the specified shape. */
|
||||
virtual void removeChildShape(btCollisionShape* shape);
|
||||
|
||||
|
||||
|
||||
|
||||
int getNumChildShapes() const
|
||||
{
|
||||
return int (m_children.size());
|
||||
@@ -88,8 +102,11 @@ public:
|
||||
}
|
||||
|
||||
///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
|
||||
void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
|
||||
|
||||
virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
|
||||
|
||||
/** Re-calculate the local Aabb. Is called at the end of removeChildShapes.
|
||||
Use this yourself if you modify the children or their transforms. */
|
||||
virtual void recalculateLocalAabb();
|
||||
|
||||
virtual void setLocalScaling(const btVector3& scaling)
|
||||
{
|
||||
|
||||
@@ -406,5 +406,11 @@ class btMatrix3x3 {
|
||||
}
|
||||
*/
|
||||
|
||||
SIMD_FORCE_INLINE bool operator==(const btMatrix3x3& m1, const btMatrix3x3& m2)
|
||||
{
|
||||
return ( m1[0][0] == m2[0][0] && m1[1][0] == m2[1][0] && m1[2][0] == m2[2][0] &&
|
||||
m1[0][1] == m2[0][1] && m1[1][1] == m2[1][1] && m1[2][1] == m2[2][1] &&
|
||||
m1[0][2] == m2[0][2] && m1[1][2] == m2[1][2] && m1[2][2] == m2[2][2] );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -188,8 +188,13 @@ btTransform::operator*(const btTransform& t) const
|
||||
{
|
||||
return btTransform(m_basis * t.m_basis,
|
||||
(*this)(t.m_origin));
|
||||
}
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE bool operator==(const btTransform& t1, const btTransform& t2)
|
||||
{
|
||||
return ( t1.getBasis() == t2.getBasis() &&
|
||||
t1.getOrigin() == t2.getOrigin() );
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -198,3 +203,4 @@ btTransform::operator*(const btTransform& t) const
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user