Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 8, 2009, 12:58:47 AM (16 years ago)
Author:
dafrick
Message:

Reverted to revision 2906 (because I'm too stupid to merge correctly, 2nd try will follow shortly. ;))

Location:
code/branches/questsystem5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/questsystem5

  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp

    r2907 r2908  
    2020#include "LinearMath/btIDebugDraw.h"
    2121#include "LinearMath/btAabbUtil2.h"
    22 #include "btManifoldResult.h"
    2322
    2423btCompoundCollisionAlgorithm::btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped)
     
    3029
    3130        btCollisionObject* colObj = m_isSwapped? body1 : body0;
    32         btAssert (colObj->getCollisionShape()->isCompound());
     31        btCollisionObject* otherObj = m_isSwapped? body0 : body1;
     32        assert (colObj->getCollisionShape()->isCompound());
    3333       
    3434        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 
    4835        int numChildren = compoundShape->getNumChildShapes();
    4936        int i;
     
    6047                        btCollisionShape* childShape = compoundShape->getChildShape(i);
    6148                        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);
    6350                        colObj->internalSetTemporaryCollisionShape( tmpShape );
    6451                }
     
    6653}
    6754
    68 void    btCompoundCollisionAlgorithm::removeChildAlgorithms()
     55
     56btCompoundCollisionAlgorithm::~btCompoundCollisionAlgorithm()
    6957{
    7058        int numChildren = m_childCollisionAlgorithms.size();
     
    7866                }
    7967        }
    80 }
    81 
    82 btCompoundCollisionAlgorithm::~btCompoundCollisionAlgorithm()
    83 {
    84         removeChildAlgorithms();
    8568}
    8669
     
    185168        btCollisionObject* otherObj = m_isSwapped? body0 : body1;
    186169
    187        
    188 
    189         btAssert (colObj->getCollisionShape()->isCompound());
     170        assert (colObj->getCollisionShape()->isCompound());
    190171        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 
    202172
    203173        btDbvt* tree = compoundShape->getDynamicAabbTree();
     
    205175        btCompoundLeafCallback  callback(colObj,otherObj,m_dispatcher,dispatchInfo,resultOut,&m_childCollisionAlgorithms[0],m_sharedManifold);
    206176
    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         }
    231177
    232178        if (tree)
     
    297243        btCollisionObject* otherObj = m_isSwapped? body0 : body1;
    298244
    299         btAssert (colObj->getCollisionShape()->isCompound());
     245        assert (colObj->getCollisionShape()->isCompound());
    300246       
    301247        btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());
     
    340286
    341287
    342 
Note: See TracChangeset for help on using the changeset viewer.