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/BroadphaseCollision/btDbvtBroadphase.cpp

    r2907 r2908  
    101101                        btDbvtProxy*    pb=(btDbvtProxy*)nb->data;
    102102#if DBVT_BP_SORTPAIRS
    103                         if(pa->m_uniqueId>pb->m_uniqueId)
    104                                 btSwap(pa,pb);
     103                        if(pa>pb) btSwap(pa,pb);
    105104#endif
    106105                        pbp->m_paircache->addOverlappingPair(pa,pb);
     
    134133        m_updates_done          =       0;
    135134        m_updates_ratio         =       0;
    136         m_paircache                     =       paircache? paircache    : new(btAlignedAlloc(sizeof(btHashedOverlappingPairCache),16)) btHashedOverlappingPairCache();
     135        m_paircache                     =       paircache?
     136paircache       :
     137        new(btAlignedAlloc(sizeof(btHashedOverlappingPairCache),16)) btHashedOverlappingPairCache();
    137138        m_gid                           =       0;
    138139        m_pid                           =       0;
     
    210211}
    211212
    212 struct  BroadphaseRayTester : btDbvt::ICollide
    213 {
    214         btBroadphaseRayCallback& m_rayCallback;
    215         BroadphaseRayTester(btBroadphaseRayCallback& orgCallback)
    216                 :m_rayCallback(orgCallback)
    217         {
    218         }
    219         void                                    Process(const btDbvtNode* leaf)
    220         {
    221                 btDbvtProxy*    proxy=(btDbvtProxy*)leaf->data;
    222                 m_rayCallback.process(proxy);
    223         }
    224 };     
    225 
    226213void    btDbvtBroadphase::rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback,const btVector3& aabbMin,const btVector3& aabbMax)
    227214{
     215
     216        struct  BroadphaseRayTester : btDbvt::ICollide
     217        {
     218                btBroadphaseRayCallback& m_rayCallback;
     219                BroadphaseRayTester(btBroadphaseRayCallback& orgCallback)
     220                        :m_rayCallback(orgCallback)
     221                {
     222                }
     223                void                                    Process(const btDbvtNode* leaf)
     224                {
     225                        btDbvtProxy*    proxy=(btDbvtProxy*)leaf->data;
     226                        m_rayCallback.process(proxy);
     227                }
     228        };     
     229
    228230        BroadphaseRayTester callback(rayCallback);
    229231
     
    340342        }
    341343#endif
    342 
    343         performDeferredRemoval(dispatcher);
    344 
    345 }
    346 
    347 void btDbvtBroadphase::performDeferredRemoval(btDispatcher* dispatcher)
    348 {
    349 
    350         if (m_paircache->hasDeferredRemoval())
    351         {
    352 
    353                 btBroadphasePairArray&  overlappingPairArray = m_paircache->getOverlappingPairArray();
    354 
    355                 //perform a sort, to find duplicates and to sort 'invalid' pairs to the end
    356                 overlappingPairArray.quickSort(btBroadphasePairSortPredicate());
    357 
    358                 int invalidPair = 0;
    359 
    360                
    361                 int i;
    362 
    363                 btBroadphasePair previousPair;
    364                 previousPair.m_pProxy0 = 0;
    365                 previousPair.m_pProxy1 = 0;
    366                 previousPair.m_algorithm = 0;
    367                
    368                
    369                 for (i=0;i<overlappingPairArray.size();i++)
    370                 {
    371                
    372                         btBroadphasePair& pair = overlappingPairArray[i];
    373 
    374                         bool isDuplicate = (pair == previousPair);
    375 
    376                         previousPair = pair;
    377 
    378                         bool needsRemoval = false;
    379 
    380                         if (!isDuplicate)
    381                         {
    382                                 //important to perform AABB check that is consistent with the broadphase
    383                                 btDbvtProxy*            pa=(btDbvtProxy*)pair.m_pProxy0;
    384                                 btDbvtProxy*            pb=(btDbvtProxy*)pair.m_pProxy1;
    385                                 bool hasOverlap = Intersect(pa->leaf->volume,pb->leaf->volume);
    386 
    387                                 if (hasOverlap)
    388                                 {
    389                                         needsRemoval = false;
    390                                 } else
    391                                 {
    392                                         needsRemoval = true;
    393                                 }
    394                         } else
    395                         {
    396                                 //remove duplicate
    397                                 needsRemoval = true;
    398                                 //should have no algorithm
    399                                 btAssert(!pair.m_algorithm);
    400                         }
    401                        
    402                         if (needsRemoval)
    403                         {
    404                                 m_paircache->cleanOverlappingPair(pair,dispatcher);
    405 
    406                                 pair.m_pProxy0 = 0;
    407                                 pair.m_pProxy1 = 0;
    408                                 invalidPair++;
    409                         }
    410                        
    411                 }
    412 
    413                 //perform a sort, to sort 'invalid' pairs to the end
    414                 overlappingPairArray.quickSort(btBroadphasePairSortPredicate());
    415                 overlappingPairArray.resize(overlappingPairArray.size() - invalidPair);
    416         }
    417344}
    418345
     
    420347void                                                    btDbvtBroadphase::collide(btDispatcher* dispatcher)
    421348{
    422         /*printf("---------------------------------------------------------\n");
    423         printf("m_sets[0].m_leaves=%d\n",m_sets[0].m_leaves);
    424         printf("m_sets[1].m_leaves=%d\n",m_sets[1].m_leaves);
    425         printf("numPairs = %d\n",getOverlappingPairCache()->getNumOverlappingPairs());
    426         {
    427                 int i;
    428                 for (i=0;i<getOverlappingPairCache()->getNumOverlappingPairs();i++)
    429                 {
    430                         printf("pair[%d]=(%d,%d),",i,getOverlappingPairCache()->getOverlappingPairArray()[i].m_pProxy0->getUid(),
    431                                 getOverlappingPairCache()->getOverlappingPairArray()[i].m_pProxy1->getUid());
    432                 }
    433                 printf("\n");
    434         }
    435 */
    436 
    437 
    438 
    439349        SPC(m_profiling.m_total);
    440350        /* optimize                             */
     
    492402                if(pairs.size()>0)
    493403                {
    494 
    495                         int                     ni=btMin(pairs.size(),btMax<int>(m_newpairs,(pairs.size()*m_cupdates)/100));
     404                        const int       ci=pairs.size();
     405                        int                     ni=btMin(ci,btMax<int>(m_newpairs,(ci*m_cupdates)/100));
    496406                        for(int i=0;i<ni;++i)
    497407                        {
    498                                 btBroadphasePair&       p=pairs[(m_cid+i)%pairs.size()];
     408                                btBroadphasePair&       p=pairs[(m_cid+i)%ci];
    499409                                btDbvtProxy*            pa=(btDbvtProxy*)p.m_pProxy0;
    500410                                btDbvtProxy*            pb=(btDbvtProxy*)p.m_pProxy1;
     
    502412                                {
    503413#if DBVT_BP_SORTPAIRS
    504                                         if(pa->m_uniqueId>pb->m_uniqueId)
    505                                                 btSwap(pa,pb);
     414                                        if(pa>pb) btSwap(pa,pb);
    506415#endif
    507416                                        m_paircache->removeOverlappingPair(pa,pb,dispatcher);
     
    558467        aabbMin=bounds.Mins();
    559468        aabbMax=bounds.Maxs();
    560 }
    561 
    562 void btDbvtBroadphase::resetPool(btDispatcher* dispatcher)
    563 {
    564        
    565         int totalObjects = m_sets[0].m_leaves + m_sets[1].m_leaves;
    566         if (!totalObjects)
    567         {
    568                 //reset internal dynamic tree data structures
    569                 m_sets[0].clear();
    570                 m_sets[1].clear();
    571                
    572                 m_deferedcollide        =       false;
    573                 m_needcleanup           =       true;
    574                 m_prediction            =       1/(btScalar)2;
    575                 m_stageCurrent          =       0;
    576                 m_fixedleft                     =       0;
    577                 m_fupdates                      =       1;
    578                 m_dupdates                      =       0;
    579                 m_cupdates                      =       10;
    580                 m_newpairs                      =       1;
    581                 m_updates_call          =       0;
    582                 m_updates_done          =       0;
    583                 m_updates_ratio         =       0;
    584                
    585                 m_gid                           =       0;
    586                 m_pid                           =       0;
    587                 m_cid                           =       0;
    588                 for(int i=0;i<=STAGECOUNT;++i)
    589                 {
    590                         m_stageRoots[i]=0;
    591                 }
    592         }
    593469}
    594470
     
    725601#undef  SPC
    726602#endif
    727 
Note: See TracChangeset for help on using the changeset viewer.