Changeset 2908 for code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp
- Timestamp:
- Apr 8, 2009, 12:58:47 AM (16 years ago)
- Location:
- code/branches/questsystem5
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem5
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp
r2907 r2908 20 20 #include "LinearMath/btIDebugDraw.h" 21 21 #include "LinearMath/btAabbUtil2.h" 22 #include "btManifoldResult.h"23 22 24 23 btCompoundCollisionAlgorithm::btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped) … … 30 29 31 30 btCollisionObject* colObj = m_isSwapped? body1 : body0; 32 btAssert (colObj->getCollisionShape()->isCompound()); 31 btCollisionObject* otherObj = m_isSwapped? body0 : body1; 32 assert (colObj->getCollisionShape()->isCompound()); 33 33 34 34 btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape()); 35 m_compoundShapeRevision = compoundShape->getUpdateRevision();36 37 preallocateChildAlgorithms(body0,body1);38 }39 40 void btCompoundCollisionAlgorithm::preallocateChildAlgorithms(btCollisionObject* body0,btCollisionObject* body1)41 {42 btCollisionObject* colObj = m_isSwapped? body1 : body0;43 btCollisionObject* otherObj = m_isSwapped? body0 : body1;44 btAssert (colObj->getCollisionShape()->isCompound());45 46 btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());47 48 35 int numChildren = compoundShape->getNumChildShapes(); 49 36 int i; … … 60 47 btCollisionShape* childShape = compoundShape->getChildShape(i); 61 48 colObj->internalSetTemporaryCollisionShape( childShape ); 62 m_childCollisionAlgorithms[i] = m_dispatcher->findAlgorithm(colObj,otherObj,m_sharedManifold);49 m_childCollisionAlgorithms[i] = ci.m_dispatcher1->findAlgorithm(colObj,otherObj,m_sharedManifold); 63 50 colObj->internalSetTemporaryCollisionShape( tmpShape ); 64 51 } … … 66 53 } 67 54 68 void btCompoundCollisionAlgorithm::removeChildAlgorithms() 55 56 btCompoundCollisionAlgorithm::~btCompoundCollisionAlgorithm() 69 57 { 70 58 int numChildren = m_childCollisionAlgorithms.size(); … … 78 66 } 79 67 } 80 }81 82 btCompoundCollisionAlgorithm::~btCompoundCollisionAlgorithm()83 {84 removeChildAlgorithms();85 68 } 86 69 … … 185 168 btCollisionObject* otherObj = m_isSwapped? body0 : body1; 186 169 187 188 189 btAssert (colObj->getCollisionShape()->isCompound()); 170 assert (colObj->getCollisionShape()->isCompound()); 190 171 btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape()); 191 192 ///btCompoundShape might have changed:193 ////make sure the internal child collision algorithm caches are still valid194 if (compoundShape->getUpdateRevision() != m_compoundShapeRevision)195 {196 ///clear and update all197 removeChildAlgorithms();198 199 preallocateChildAlgorithms(body0,body1);200 }201 202 172 203 173 btDbvt* tree = compoundShape->getDynamicAabbTree(); … … 205 175 btCompoundLeafCallback callback(colObj,otherObj,m_dispatcher,dispatchInfo,resultOut,&m_childCollisionAlgorithms[0],m_sharedManifold); 206 176 207 ///we need to refresh all contact manifolds208 ///note that we should actually recursively traverse all children, btCompoundShape can nested more then 1 level deep209 ///so we should add a 'refreshManifolds' in the btCollisionAlgorithm210 {211 int i;212 btManifoldArray manifoldArray;213 for (i=0;i<m_childCollisionAlgorithms.size();i++)214 {215 if (m_childCollisionAlgorithms[i])216 {217 m_childCollisionAlgorithms[i]->getAllContactManifolds(manifoldArray);218 for (int m=0;m<manifoldArray.size();m++)219 {220 if (manifoldArray[m]->getNumContacts())221 {222 resultOut->setPersistentManifold(manifoldArray[m]);223 resultOut->refreshContactPoints();224 resultOut->setPersistentManifold(0);//??necessary?225 }226 }227 manifoldArray.clear();228 }229 }230 }231 177 232 178 if (tree) … … 297 243 btCollisionObject* otherObj = m_isSwapped? body0 : body1; 298 244 299 btAssert (colObj->getCollisionShape()->isCompound());245 assert (colObj->getCollisionShape()->isCompound()); 300 246 301 247 btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape()); … … 340 286 341 287 342
Note: See TracChangeset
for help on using the changeset viewer.