Differential D1739 Diff 5899 extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp
Changeset View
Changeset View
Standalone View
Standalone View
extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp
| Show First 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | public: | ||||
| { | { | ||||
| btAssert(index>=0); | btAssert(index>=0); | ||||
| const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(m_compoundColObjWrap->getCollisionShape()); | const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(m_compoundColObjWrap->getCollisionShape()); | ||||
| btAssert(index<compoundShape->getNumChildShapes()); | btAssert(index<compoundShape->getNumChildShapes()); | ||||
| //backup | //backup | ||||
| btTransform orgTrans = m_compoundColObjWrap->getWorldTransform(); | btTransform orgTrans = m_compoundColObjWrap->getWorldTransform(); | ||||
| btTransform orgInterpolationTrans = m_compoundColObjWrap->getWorldTransform(); | |||||
| const btTransform& childTrans = compoundShape->getChildTransform(index); | const btTransform& childTrans = compoundShape->getChildTransform(index); | ||||
| btTransform newChildWorldTrans = orgTrans*childTrans ; | btTransform newChildWorldTrans = orgTrans*childTrans ; | ||||
| //perform an AABB check first | //perform an AABB check first | ||||
| btVector3 aabbMin0,aabbMax0,aabbMin1,aabbMax1; | btVector3 aabbMin0,aabbMax0,aabbMin1,aabbMax1; | ||||
| childShape->getAabb(newChildWorldTrans,aabbMin0,aabbMax0); | childShape->getAabb(newChildWorldTrans,aabbMin0,aabbMax0); | ||||
| m_otherObjWrap->getCollisionShape()->getAabb(m_otherObjWrap->getWorldTransform(),aabbMin1,aabbMax1); | m_otherObjWrap->getCollisionShape()->getAabb(m_otherObjWrap->getWorldTransform(),aabbMin1,aabbMax1); | ||||
| ▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | void btCompoundCollisionAlgorithm::processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) | ||||
| { | { | ||||
| ///clear and update all | ///clear and update all | ||||
| removeChildAlgorithms(); | removeChildAlgorithms(); | ||||
| preallocateChildAlgorithms(body0Wrap,body1Wrap); | preallocateChildAlgorithms(body0Wrap,body1Wrap); | ||||
| m_compoundShapeRevision = compoundShape->getUpdateRevision(); | m_compoundShapeRevision = compoundShape->getUpdateRevision(); | ||||
| } | } | ||||
| if (m_childCollisionAlgorithms.size()==0) | |||||
| return; | |||||
| const btDbvt* tree = compoundShape->getDynamicAabbTree(); | const btDbvt* tree = compoundShape->getDynamicAabbTree(); | ||||
| //use a dynamic aabb tree to cull potential child-overlaps | //use a dynamic aabb tree to cull potential child-overlaps | ||||
| btCompoundLeafCallback callback(colObjWrap,otherObjWrap,m_dispatcher,dispatchInfo,resultOut,&m_childCollisionAlgorithms[0],m_sharedManifold); | btCompoundLeafCallback callback(colObjWrap,otherObjWrap,m_dispatcher,dispatchInfo,resultOut,&m_childCollisionAlgorithms[0],m_sharedManifold); | ||||
| ///we need to refresh all contact manifolds | ///we need to refresh all contact manifolds | ||||
| ///note that we should actually recursively traverse all children, btCompoundShape can nested more then 1 level deep | ///note that we should actually recursively traverse all children, btCompoundShape can nested more then 1 level deep | ||||
| ///so we should add a 'refreshManifolds' in the btCollisionAlgorithm | ///so we should add a 'refreshManifolds' in the btCollisionAlgorithm | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | void btCompoundCollisionAlgorithm::processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) | ||||
| { | { | ||||
| //iterate over all children, perform an AABB check inside ProcessChildShape | //iterate over all children, perform an AABB check inside ProcessChildShape | ||||
| int numChildren = m_childCollisionAlgorithms.size(); | int numChildren = m_childCollisionAlgorithms.size(); | ||||
| int i; | int i; | ||||
| btManifoldArray manifoldArray; | btManifoldArray manifoldArray; | ||||
| const btCollisionShape* childShape = 0; | const btCollisionShape* childShape = 0; | ||||
| btTransform orgTrans; | btTransform orgTrans; | ||||
| btTransform orgInterpolationTrans; | |||||
| btTransform newChildWorldTrans; | btTransform newChildWorldTrans; | ||||
| btVector3 aabbMin0,aabbMax0,aabbMin1,aabbMax1; | btVector3 aabbMin0,aabbMax0,aabbMin1,aabbMax1; | ||||
| for (i=0;i<numChildren;i++) | for (i=0;i<numChildren;i++) | ||||
| { | { | ||||
| if (m_childCollisionAlgorithms[i]) | if (m_childCollisionAlgorithms[i]) | ||||
| { | { | ||||
| childShape = compoundShape->getChildShape(i); | childShape = compoundShape->getChildShape(i); | ||||
| //if not longer overlapping, remove the algorithm | //if not longer overlapping, remove the algorithm | ||||
| orgTrans = colObjWrap->getWorldTransform(); | orgTrans = colObjWrap->getWorldTransform(); | ||||
| orgInterpolationTrans = colObjWrap->getWorldTransform(); | |||||
| const btTransform& childTrans = compoundShape->getChildTransform(i); | const btTransform& childTrans = compoundShape->getChildTransform(i); | ||||
| newChildWorldTrans = orgTrans*childTrans ; | newChildWorldTrans = orgTrans*childTrans ; | ||||
| //perform an AABB check first | //perform an AABB check first | ||||
| childShape->getAabb(newChildWorldTrans,aabbMin0,aabbMax0); | childShape->getAabb(newChildWorldTrans,aabbMin0,aabbMax0); | ||||
| otherObjWrap->getCollisionShape()->getAabb(otherObjWrap->getWorldTransform(),aabbMin1,aabbMax1); | otherObjWrap->getCollisionShape()->getAabb(otherObjWrap->getWorldTransform(),aabbMin1,aabbMax1); | ||||
| if (!TestAabbAgainstAabb2(aabbMin0,aabbMax0,aabbMin1,aabbMax1)) | if (!TestAabbAgainstAabb2(aabbMin0,aabbMax0,aabbMin1,aabbMax1)) | ||||
| ▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines | |||||