28#define USE_LOCAL_STACK 1
45 m_compoundShapeRevision0 = compoundShape0->getUpdateRevision();
48 m_compoundShapeRevision1 = compoundShape1->getUpdateRevision();
54 m_childCollisionAlgorithmCache->~btHashedSimplePairCache();
61 btSimplePairArray& pairs = m_childCollisionAlgorithmCache->getOverlappingPairArray();
62 for (
i = 0;
i < pairs.
size();
i++)
75 int numChildren = pairs.
size();
77 for (
i = 0;
i < numChildren;
i++)
86 m_childCollisionAlgorithmCache->removeAllPairs();
116 BT_PROFILE(
"btCompoundCompoundLeafCallback::Process");
131 const btCollisionShape* childShape0 = compoundShape0->getChildShape(childIndex0);
132 const btCollisionShape* childShape1 = compoundShape1->getChildShape(childIndex1);
136 const btTransform& childTrans0 = compoundShape0->getChildTransform(childIndex0);
137 btTransform newChildWorldTrans0 = orgTrans0 * childTrans0;
140 const btTransform& childTrans1 = compoundShape1->getChildTransform(childIndex1);
141 btTransform newChildWorldTrans1 = orgTrans1 * childTrans1;
144 btVector3 aabbMin0, aabbMax0, aabbMin1, aabbMax1;
145 childShape0->getAabb(newChildWorldTrans0, aabbMin0, aabbMax0);
146 childShape1->getAabb(newChildWorldTrans1, aabbMin1, aabbMax1);
150 aabbMin0 -= thresholdVec;
151 aabbMax0 += thresholdVec;
165 bool removePair =
false;
167 if (
m_resultOut->m_closestPointDistanceThreshold > 0)
198 m_resultOut->setShapeIdentifiersA(-1, childIndex0);
199 m_resultOut->setShapeIdentifiersB(-1, childIndex1);
220 newmin -=
btVector3(distanceThreshold, distanceThreshold, distanceThreshold);
221 newmax +=
btVector3(distanceThreshold, distanceThreshold, distanceThreshold);
236#ifdef USE_LOCAL_STACK
248 if (depth > treshold)
251 treshold = stkStack.
size() - 4;
295 const btDbvt* tree0 = compoundShape0->getDynamicAabbTree();
296 const btDbvt* tree1 = compoundShape1->getDynamicAabbTree();
297 if (!tree0 || !tree1)
303 if ((compoundShape0->getUpdateRevision() != m_compoundShapeRevision0) || (compoundShape1->getUpdateRevision() != m_compoundShapeRevision1))
307 m_compoundShapeRevision0 = compoundShape0->getUpdateRevision();
308 m_compoundShapeRevision1 = compoundShape1->getUpdateRevision();
317#ifdef USE_LOCAL_STACK
319 manifoldArray.initializeFromBuffer(&localManifolds, 0, 4);
321 btSimplePairArray& pairs = m_childCollisionAlgorithmCache->getOverlappingPairArray();
322 for (
i = 0;
i < pairs.
size();
i++)
328 for (
int m = 0; m < manifoldArray.size(); m++)
337 manifoldArray.resize(0);
352 btAssert(m_removePairs.size() == 0);
355 btSimplePairArray& pairs = m_childCollisionAlgorithmCache->getOverlappingPairArray();
360 btVector3 aabbMin0, aabbMax0, aabbMin1, aabbMax1;
362 for (
i = 0;
i < pairs.
size();
i++)
372 childShape0 = compoundShape0->getChildShape(pairs[
i].m_indexA);
373 const btTransform& childTrans0 = compoundShape0->getChildTransform(pairs[
i].m_indexA);
375 childShape0->getAabb(newChildWorldTrans0, aabbMin0, aabbMax0);
378 aabbMin0 -= thresholdVec;
379 aabbMax0 += thresholdVec;
384 childShape1 = compoundShape1->getChildShape(pairs[
i].m_indexB);
385 const btTransform& childTrans1 = compoundShape1->getChildTransform(pairs[
i].m_indexB);
387 childShape1->getAabb(newChildWorldTrans1, aabbMin1, aabbMax1);
390 aabbMin1 -= thresholdVec;
391 aabbMax1 += thresholdVec;
397 m_removePairs.push_back(
btSimplePair(pairs[
i].m_indexA, pairs[
i].m_indexB));
401 for (
int i = 0;
i < m_removePairs.size();
i++)
403 m_childCollisionAlgorithmCache->removeOverlappingPair(m_removePairs[
i].m_indexA, m_removePairs[
i].m_indexB);
405 m_removePairs.clear();
SIMD_FORCE_INLINE bool TestAabbAgainstAabb2(const btVector3 &aabbMin1, const btVector3 &aabbMax1, const btVector3 &aabbMin2, const btVector3 &aabbMax2)
conservative test for overlap between two aabbs
SIMD_FORCE_INLINE void btTransformAabb(const btVector3 &halfExtents, btScalar margin, const btTransform &t, btVector3 &aabbMinOut, btVector3 &aabbMaxOut)
#define btAlignedFree(ptr)
#define btAlignedAlloc(size, alignment)
btAlignedObjectArray< btPersistentManifold * > btManifoldArray
btCollisionShape
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
bool(* btShapePairCallback)(const btCollisionShape *pShape0, const btCollisionShape *pShape1)
btShapePairCallback gCompoundCompoundChildShapePairCallback
static DBVT_INLINE bool MyIntersect(const btDbvtAabbMm &a, const btDbvtAabbMm &b, const btTransform &xform, btScalar distanceThreshold)
static void MycollideTT(const btDbvtNode *root0, const btDbvtNode *root1, const btTransform &xform, btCompoundCompoundLeafCallback *callback, btScalar distanceThreshold)
btCompoundShape(bool enableDynamicAabbTree=true, const int initialChildCapacity=0)
int getNumChildShapes() const
btDispatcher * m_dispatcher
DBVT_INLINE bool Intersect(const btDbvtAabbMm &a, const btDbvtAabbMm &b)
@ BT_CLOSEST_POINT_ALGORITHMS
@ BT_CONTACT_POINT_ALGORITHMS
btAlignedObjectArray< btSimplePair > btSimplePairArray
SIMD_FORCE_INLINE int getNumContacts() const
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
#define ATTRIBUTE_ALIGNED16(a)
btVector3
btVector3 can be used to represent 3D points and vectors. It has an un-used w component to suit 16-by...
SIMD_FORCE_INLINE int size() const
return the number of elements in the array
SIMD_FORCE_INLINE void resize(int newsize, const T &fillData=T())
void initializeFromBuffer(void *buffer, int size, int capacity)
btDispatcher * m_dispatcher
virtual void getAllContactManifolds(btManifoldArray &manifoldArray)=0
virtual void processCollision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)=0
virtual ~btCollisionAlgorithm()
virtual void processCollision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
class btPersistentManifold * m_sharedManifold
void removeChildAlgorithms()
btCompoundCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, bool isSwapped)
virtual void processCollision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
btScalar calculateTimeOfImpact(btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
btCompoundCompoundCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, bool isSwapped)
virtual ~btCompoundCompoundCollisionAlgorithm()
virtual void getAllContactManifolds(btManifoldArray &manifoldArray)
btSimplePairArray & getOverlappingPairArray()
btManifoldResult is a helper class to manage contact results.
void setPersistentManifold(btPersistentManifold *manifoldPtr)
btScalar m_closestPointDistanceThreshold
SIMD_FORCE_INLINE void refreshContactPoints()
SIMD_FORCE_INLINE const btCollisionShape * getCollisionShape() const
SIMD_FORCE_INLINE const btTransform & getWorldTransform() const
btPersistentManifold * m_sharedManifold
void Process(const btDbvtNode *leaf0, const btDbvtNode *leaf1)
btDispatcher * m_dispatcher
const btCollisionObjectWrapper * m_compound0ColObjWrap
btCompoundCompoundLeafCallback(const btCollisionObjectWrapper *compound1ObjWrap, const btCollisionObjectWrapper *compound0ObjWrap, btDispatcher *dispatcher, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut, btHashedSimplePairCache *childAlgorithmsCache, btPersistentManifold *sharedManifold)
const btCollisionObjectWrapper * m_compound1ColObjWrap
class btHashedSimplePairCache * m_childCollisionAlgorithmCache
const btDispatcherInfo & m_dispatchInfo
btManifoldResult * m_resultOut
static btDbvtAabbMm FromMM(const btVector3 &mi, const btVector3 &mx)
DBVT_INLINE bool isinternal() const