Changeset 2907 for code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp
- Timestamp:
- Apr 8, 2009, 12:36:08 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
r2662 r2907 20 20 #include "LinearMath/btIDebugDraw.h" 21 21 #include "LinearMath/btAabbUtil2.h" 22 #include "btManifoldResult.h" 22 23 23 24 btCompoundCollisionAlgorithm::btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped) … … 29 30 30 31 btCollisionObject* colObj = m_isSwapped? body1 : body0; 32 btAssert (colObj->getCollisionShape()->isCompound()); 33 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; 31 43 btCollisionObject* otherObj = m_isSwapped? body0 : body1; 32 assert (colObj->getCollisionShape()->isCompound());44 btAssert (colObj->getCollisionShape()->isCompound()); 33 45 34 46 btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape()); 47 35 48 int numChildren = compoundShape->getNumChildShapes(); 36 49 int i; … … 47 60 btCollisionShape* childShape = compoundShape->getChildShape(i); 48 61 colObj->internalSetTemporaryCollisionShape( childShape ); 49 m_childCollisionAlgorithms[i] = ci.m_dispatcher1->findAlgorithm(colObj,otherObj,m_sharedManifold);62 m_childCollisionAlgorithms[i] = m_dispatcher->findAlgorithm(colObj,otherObj,m_sharedManifold); 50 63 colObj->internalSetTemporaryCollisionShape( tmpShape ); 51 64 } … … 53 66 } 54 67 55 56 btCompoundCollisionAlgorithm::~btCompoundCollisionAlgorithm() 68 void btCompoundCollisionAlgorithm::removeChildAlgorithms() 57 69 { 58 70 int numChildren = m_childCollisionAlgorithms.size(); … … 66 78 } 67 79 } 80 } 81 82 btCompoundCollisionAlgorithm::~btCompoundCollisionAlgorithm() 83 { 84 removeChildAlgorithms(); 68 85 } 69 86 … … 168 185 btCollisionObject* otherObj = m_isSwapped? body0 : body1; 169 186 170 assert (colObj->getCollisionShape()->isCompound()); 187 188 189 btAssert (colObj->getCollisionShape()->isCompound()); 171 190 btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape()); 191 192 ///btCompoundShape might have changed: 193 ////make sure the internal child collision algorithm caches are still valid 194 if (compoundShape->getUpdateRevision() != m_compoundShapeRevision) 195 { 196 ///clear and update all 197 removeChildAlgorithms(); 198 199 preallocateChildAlgorithms(body0,body1); 200 } 201 172 202 173 203 btDbvt* tree = compoundShape->getDynamicAabbTree(); … … 175 205 btCompoundLeafCallback callback(colObj,otherObj,m_dispatcher,dispatchInfo,resultOut,&m_childCollisionAlgorithms[0],m_sharedManifold); 176 206 207 ///we need to refresh all contact manifolds 208 ///note that we should actually recursively traverse all children, btCompoundShape can nested more then 1 level deep 209 ///so we should add a 'refreshManifolds' in the btCollisionAlgorithm 210 { 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 } 177 231 178 232 if (tree) … … 243 297 btCollisionObject* otherObj = m_isSwapped? body0 : body1; 244 298 245 assert (colObj->getCollisionShape()->isCompound());299 btAssert (colObj->getCollisionShape()->isCompound()); 246 300 247 301 btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape()); … … 286 340 287 341 342
Note: See TracChangeset
for help on using the changeset viewer.