+ provide access to 'root' collision shape, in case the original collision shape is temporarily replaced by a child collision shape.
+ added MultiMaterialDemo showing how to use the new btTriangleIndexVertexMaterialArray. Thanks to Alex Silverman for this contribution!
This commit is contained in:
@@ -19,6 +19,7 @@ subject to the following restrictions:
|
||||
btCollisionObject::btCollisionObject()
|
||||
: m_broadphaseHandle(0),
|
||||
m_collisionShape(0),
|
||||
m_rootCollisionShape(0),
|
||||
m_collisionFlags(btCollisionObject::CF_STATIC_OBJECT),
|
||||
m_islandTag1(-1),
|
||||
m_companionId(-1),
|
||||
|
||||
@@ -51,6 +51,11 @@ protected:
|
||||
btVector3 m_interpolationAngularVelocity;
|
||||
btBroadphaseProxy* m_broadphaseHandle;
|
||||
btCollisionShape* m_collisionShape;
|
||||
|
||||
///m_rootCollisionShape is temporarily used to store the original collision shape
|
||||
///The m_collisionShape might be temporarily replaced by a child collision shape during collision detection purposes
|
||||
///If it is NULL, the m_collisionShape is not temporarily replaced.
|
||||
btCollisionShape* m_rootCollisionShape;
|
||||
|
||||
int m_collisionFlags;
|
||||
|
||||
@@ -141,6 +146,7 @@ public:
|
||||
void setCollisionShape(btCollisionShape* collisionShape)
|
||||
{
|
||||
m_collisionShape = collisionShape;
|
||||
m_rootCollisionShape = collisionShape;
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE const btCollisionShape* getCollisionShape() const
|
||||
@@ -153,8 +159,22 @@ public:
|
||||
return m_collisionShape;
|
||||
}
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE const btCollisionShape* getRootCollisionShape() const
|
||||
{
|
||||
return m_rootCollisionShape;
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE btCollisionShape* getRootCollisionShape()
|
||||
{
|
||||
return m_rootCollisionShape;
|
||||
}
|
||||
|
||||
///Avoid using this internal API call
|
||||
///internalSetTemporaryCollisionShape is used to temporary replace the actual collision shape by a child collision shape.
|
||||
void internalSetTemporaryCollisionShape(btCollisionShape* collisionShape)
|
||||
{
|
||||
m_collisionShape = collisionShape;
|
||||
}
|
||||
|
||||
int getActivationState() const { return m_activationState1;}
|
||||
|
||||
|
||||
@@ -34,10 +34,9 @@ m_isSwapped(isSwapped)
|
||||
for (i=0;i<numChildren;i++)
|
||||
{
|
||||
btCollisionShape* childShape = compoundShape->getChildShape(i);
|
||||
btCollisionShape* orgShape = colObj->getCollisionShape();
|
||||
colObj->setCollisionShape( childShape );
|
||||
colObj->internalSetTemporaryCollisionShape( childShape );
|
||||
m_childCollisionAlgorithms[i] = ci.m_dispatcher1->findAlgorithm(colObj,otherObj);
|
||||
colObj->setCollisionShape( orgShape );
|
||||
colObj->setCollisionShape( colObj->getRootCollisionShape());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,14 +116,9 @@ void btConvexTriangleCallback::processTriangle(btVector3* triangle,int partId, i
|
||||
{
|
||||
btTriangleShape tm(triangle[0],triangle[1],triangle[2]);
|
||||
tm.setMargin(m_collisionMarginTriangle);
|
||||
btCollisionShape* tmpShape = ob->getCollisionShape();
|
||||
|
||||
//copy over user pointers to temporary shape
|
||||
tm.setUserPointer(tmpShape->getUserPointer());
|
||||
|
||||
ob->setCollisionShape( &tm );
|
||||
ob->internalSetTemporaryCollisionShape( &tm );
|
||||
|
||||
|
||||
btCollisionAlgorithm* colAlgo = ci.m_dispatcher1->findAlgorithm(m_convexBody,m_triBody,m_manifoldPtr);
|
||||
///this should use the btDispatcher, so the actual registered algorithm is used
|
||||
// btConvexConvexAlgorithm cvxcvxalgo(m_manifoldPtr,ci,m_convexBody,m_triBody);
|
||||
@@ -134,11 +129,9 @@ void btConvexTriangleCallback::processTriangle(btVector3* triangle,int partId, i
|
||||
colAlgo->processCollision(m_convexBody,m_triBody,*m_dispatchInfoPtr,m_resultOut);
|
||||
colAlgo->~btCollisionAlgorithm();
|
||||
ci.m_dispatcher1->freeCollisionAlgorithm(colAlgo);
|
||||
ob->setCollisionShape( tmpShape );
|
||||
|
||||
ob->setCollisionShape( ob->getRootCollisionShape());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user