Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 8, 2009, 12:58:47 AM (15 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:
69 edited

Legend:

Unmodified
Added
Removed
  • code/branches/questsystem5

  • code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btAxisSweep3.cpp

    r2907 r2908  
    2020#include "btAxisSweep3.h"
    2121
     22#include <assert.h>
    2223
    2324btAxisSweep3::btAxisSweep3(const btVector3& worldAabbMin,const btVector3& worldAabbMax, unsigned short int maxHandles, btOverlappingPairCache* pairCache, bool disableRaycastAccelerator)
  • code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btAxisSweep3.h

    r2907 r2908  
    4343public:
    4444       
    45  BT_DECLARE_ALIGNED_ALLOCATOR();
    4645
    4746        class Edge
     
    140139        SIMD_FORCE_INLINE Handle* getHandle(BP_FP_INT_TYPE index) const {return m_pHandles + index;}
    141140
    142         virtual void resetPool(btDispatcher* dispatcher);
     141        void resetPool();
    143142
    144143        void    processAllOverlappingPairs(btOverlapCallback* callback);
     
    222221
    223222        if (checkCardinality)
    224                 btAssert(numEdges == m_numHandles*2+1);
     223                assert(numEdges == m_numHandles*2+1);
    225224}
    226225#endif //DEBUG_BROADPHASE
     
    348347        }
    349348
    350         //btAssert(bounds.HasVolume());
     349        //assert(bounds.HasVolume());
    351350
    352351        // init bounds
     
    454453BP_FP_INT_TYPE btAxisSweep3Internal<BP_FP_INT_TYPE>::allocHandle()
    455454{
    456         btAssert(m_firstFreeHandle);
     455        assert(m_firstFreeHandle);
    457456
    458457        BP_FP_INT_TYPE handle = m_firstFreeHandle;
     
    466465void btAxisSweep3Internal<BP_FP_INT_TYPE>::freeHandle(BP_FP_INT_TYPE handle)
    467466{
    468         btAssert(handle > 0 && handle < m_maxHandles);
     467        assert(handle > 0 && handle < m_maxHandles);
    469468
    470469        getHandle(handle)->SetNextFree(m_firstFreeHandle);
     
    589588
    590589template <typename BP_FP_INT_TYPE>
    591 void btAxisSweep3Internal<BP_FP_INT_TYPE>::resetPool(btDispatcher* dispatcher)
     590void btAxisSweep3Internal<BP_FP_INT_TYPE>::resetPool()
    592591{
    593592        if (m_numHandles == 0)
     
    643642                        if (!isDuplicate)
    644643                        {
    645                                 ///important to use an AABB test that is consistent with the broadphase
    646644                                bool hasOverlap = testAabbOverlap(pair.m_pProxy0,pair.m_pProxy1);
    647645
     
    689687        }
    690688
     689
     690
     691       
     692
    691693}
    692694
     
    729731void btAxisSweep3Internal<BP_FP_INT_TYPE>::updateHandle(BP_FP_INT_TYPE handle, const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher)
    730732{
    731 //      btAssert(bounds.IsFinite());
    732         //btAssert(bounds.HasVolume());
     733//      assert(bounds.IsFinite());
     734        //assert(bounds.HasVolume());
    733735
    734736        Handle* pHandle = getHandle(handle);
  • code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btBroadphaseInterface.h

    r2907 r2908  
    6565        virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const =0;
    6666
    67         ///reset broadphase internal structures, to ensure determinism/reproducability
    68         virtual void resetPool(btDispatcher* dispatcher) {};
    69 
    7067        virtual void    printStats() = 0;
    7168
  • code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h

    r2907 r2908  
    7070
    7171        SOFTBODY_SHAPE_PROXYTYPE,
    72         HFFLUID_SHAPE_PROXYTYPE,
    73         HFFLUID_BUOYANT_CONVEX_SHAPE_PROXYTYPE,
     72
    7473        INVALID_SHAPE_PROXYTYPE,
    7574
     
    189188
    190189                //keep them sorted, so the std::set operations work
    191                 if (proxy0.m_uniqueId < proxy1.m_uniqueId)
     190                if (&proxy0 < &proxy1)
    192191        {
    193192            m_pProxy0 = &proxy0;
     
    230229                bool operator() ( const btBroadphasePair& a, const btBroadphasePair& b )
    231230                {
    232                         const int uidA0 = a.m_pProxy0 ? a.m_pProxy0->m_uniqueId : -1;
    233                         const int uidB0 = b.m_pProxy0 ? b.m_pProxy0->m_uniqueId : -1;
    234                         const int uidA1 = a.m_pProxy1 ? a.m_pProxy1->m_uniqueId : -1;
    235                         const int uidB1 = b.m_pProxy1 ? b.m_pProxy1->m_uniqueId : -1;
    236 
    237                          return uidA0 > uidB0 ||
    238                                 (a.m_pProxy0 == b.m_pProxy0 && uidA1 > uidB1) ||
     231                         return a.m_pProxy0 > b.m_pProxy0 ||
     232                                (a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 > b.m_pProxy1) ||
    239233                                (a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 == b.m_pProxy1 && a.m_algorithm > b.m_algorithm);
    240234                }
  • code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btDbvt.cpp

    r2907 r2908  
    394394}
    395395
    396 #if 0
     396//
    397397static DBVT_INLINE btDbvtNode*  walkup(btDbvtNode* n,int count)
    398398{
     
    400400        return(n);
    401401}
    402 #endif
    403402
    404403//
     
    425424void                    btDbvt::clear()
    426425{
    427         if(m_root)     
    428                 recursedeletenode(this,m_root);
     426        if(m_root)      recursedeletenode(this,m_root);
    429427        btAlignedFree(m_free);
    430428        m_free=0;
    431         m_lkhd          =       -1;
    432         m_stkStack.clear();
    433         m_opath         =       0;
    434        
    435429}
    436430
  • code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btDbvt.h

    r2907 r2908  
    5858
    5959//SSE gives errors on a MSVC 7.1
    60 #ifdef BT_USE_SSE
     60#if (defined (WIN32) && (_MSC_VER) && _MSC_VER >= 1400) && (!defined (BT_USE_DOUBLE_PRECISION))
    6161#define DBVT_SELECT_IMPL                DBVT_IMPL_SSE
    6262#define DBVT_MERGE_IMPL                 DBVT_IMPL_SSE
     
    8383#define DBVT_PREFIX                                     template <typename T>
    8484#define DBVT_IPOLICY                            T& policy
    85 #define DBVT_CHECKTYPE                          static const ICollide&  typechecker=*(T*)1;(void)typechecker;
     85#define DBVT_CHECKTYPE                          static const ICollide&  typechecker=*(T*)0;
    8686#else
    8787#define DBVT_VIRTUAL_DTOR(a)            virtual ~a() {}
     
    147147        DBVT_INLINE friend bool                 Intersect(      const btDbvtAabbMm& a,
    148148                const btDbvtAabbMm& b);
    149        
     149        DBVT_INLINE friend bool                 Intersect(      const btDbvtAabbMm& a,
     150                const btDbvtAabbMm& b,
     151                const btTransform& xform);
    150152        DBVT_INLINE friend bool                 Intersect(      const btDbvtAabbMm& a,
    151153                const btVector3& b);
     
    303305                  const btDbvtNode* root1,
    304306                  DBVT_IPOLICY);
    305 #if 0
     307
    306308        DBVT_PREFIX
    307309                void            collideTT(      const btDbvtNode* root0,
     
    315317                const btTransform& xform1,
    316318                DBVT_IPOLICY);
    317 #endif
    318 
    319319        DBVT_PREFIX
    320320                void            collideTV(      const btDbvtNode* root,
     
    531531}
    532532
    533 
     533//
     534DBVT_INLINE bool                Intersect(      const btDbvtAabbMm& a,
     535                                                                  const btDbvtAabbMm& b,
     536                                                                  const btTransform& xform)
     537{
     538        const btVector3         d0=xform*b.Center()-a.Center();
     539        const btVector3         d1=d0*xform.getBasis();
     540        btScalar                        s0[2]={0,0};
     541        btScalar                        s1[2]={dot(xform.getOrigin(),d0),s1[0]};
     542        a.AddSpan(d0,s0[0],s0[1]);
     543        b.AddSpan(d1,s1[0],s1[1]);
     544        if(s0[0]>(s1[1])) return(false);
     545        if(s0[1]<(s1[0])) return(false);
     546        return(true);
     547}
    534548
    535549//
     
    835849}
    836850
    837 #if 0
     851
    838852//
    839853DBVT_PREFIX
     
    891905                }
    892906}
     907
    893908//
    894909DBVT_PREFIX
     
    902917        collideTT(root0,root1,xform,policy);
    903918}
    904 #endif
    905919
    906920//
  • 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 
  • code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btDbvtBroadphase.h

    r2907 r2908  
    2525
    2626#define DBVT_BP_PROFILE                                 0
    27 //#define DBVT_BP_SORTPAIRS                             1
     27#define DBVT_BP_SORTPAIRS                               1
    2828#define DBVT_BP_PREVENTFALSEUPDATE              0
    2929#define DBVT_BP_ACCURATESLEEPING                0
     
    115115        void                                                    printStats();
    116116        static void                                             benchmark(btBroadphaseInterface*);
    117 
    118 
    119         void    performDeferredRemoval(btDispatcher* dispatcher);
    120 
    121         ///reset broadphase internal structures, to ensure determinism/reproducability
    122         virtual void resetPool(btDispatcher* dispatcher);
    123 
    124117};
    125118
  • code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp

    r2907 r2908  
    483483
    484484}
    485 
    486 void btMultiSapBroadphase::resetPool(btDispatcher* dispatcher)
    487 {
    488         // not yet
    489 }
  • code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h

    r2907 r2908  
    144144        void quicksort (btBroadphasePairArray& a, int lo, int hi);
    145145
    146         ///reset broadphase internal structures, to ensure determinism/reproducability
    147         virtual void resetPool(btDispatcher* dispatcher);
    148 
    149146};
    150147
  • code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp

    r2907 r2908  
    2020#include "btDispatcher.h"
    2121#include "btCollisionAlgorithm.h"
    22 #include "LinearMath/btAabbUtil2.h"
    2322
    2423#include <stdio.h>
     
    137136{
    138137        gFindPairs++;
    139         if(proxy0->m_uniqueId>proxy1->m_uniqueId)
    140                 btSwap(proxy0,proxy1);
     138        if(proxy0>proxy1) btSwap(proxy0,proxy1);
    141139        int proxyId1 = proxy0->getUid();
    142140        int proxyId2 = proxy1->getUid();
     
    214212btBroadphasePair* btHashedOverlappingPairCache::internalAddPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1)
    215213{
    216         if(proxy0->m_uniqueId>proxy1->m_uniqueId)
    217                 btSwap(proxy0,proxy1);
     214        if(proxy0>proxy1) btSwap(proxy0,proxy1);
    218215        int proxyId1 = proxy0->getUid();
    219216        int proxyId2 = proxy1->getUid();
     
    274271{
    275272        gRemovePairs++;
    276         if(proxy0->m_uniqueId>proxy1->m_uniqueId)
    277                 btSwap(proxy0,proxy1);
     273        if(proxy0>proxy1) btSwap(proxy0,proxy1);
    278274        int proxyId1 = proxy0->getUid();
    279275        int proxyId2 = proxy1->getUid();
     
    397393}
    398394
    399 void    btHashedOverlappingPairCache::sortOverlappingPairs(btDispatcher* dispatcher)
    400 {
    401         ///need to keep hashmap in sync with pair address, so rebuild all
    402         btBroadphasePairArray tmpPairs;
    403         int i;
    404         for (i=0;i<m_overlappingPairArray.size();i++)
    405         {
    406                 tmpPairs.push_back(m_overlappingPairArray[i]);
    407         }
    408 
    409         for (i=0;i<tmpPairs.size();i++)
    410         {
    411                 removeOverlappingPair(tmpPairs[i].m_pProxy0,tmpPairs[i].m_pProxy1,dispatcher);
    412         }
    413        
    414         for (i = 0; i < m_next.size(); i++)
    415         {
    416                 m_next[i] = BT_NULL_PAIR;
    417         }
    418 
    419         tmpPairs.quickSort(btBroadphasePairSortPredicate());
    420 
    421         for (i=0;i<tmpPairs.size();i++)
    422         {
    423                 addOverlappingPair(tmpPairs[i].m_pProxy0,tmpPairs[i].m_pProxy1);
    424         }
    425 
    426        
    427 }
    428395
    429396
     
    463430{
    464431        //don't add overlap with own
    465         btAssert(proxy0 != proxy1);
     432        assert(proxy0 != proxy1);
    466433
    467434        if (!needsBroadphaseCollision(proxy0,proxy1))
     
    494461        if (findIndex < m_overlappingPairArray.size())
    495462        {
    496                 //btAssert(it != m_overlappingPairSet.end());
     463                //assert(it != m_overlappingPairSet.end());
    497464                 btBroadphasePair* pair = &m_overlappingPairArray[findIndex];
    498465                return pair;
     
    524491                {
    525492                        cleanOverlappingPair(*pair,dispatcher);
    526                         pair->m_pProxy0 = 0;
    527                         pair->m_pProxy1 = 0;
    528                         m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
     493
     494                        m_overlappingPairArray.swap(i,m_overlappingPairArray.capacity()-1);
    529495                        m_overlappingPairArray.pop_back();
    530496                        gOverlappingPairs--;
     
    626592        processAllOverlappingPairs(&removeCallback,dispatcher);
    627593}
    628 
    629 void    btSortedOverlappingPairCache::sortOverlappingPairs(btDispatcher* dispatcher)
    630 {
    631         //should already be sorted
    632 }
    633 
  • code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h

    r2907 r2908  
    8484
    8585        virtual void    setInternalGhostPairCallback(btOverlappingPairCallback* ghostPairCallback)=0;
    86 
    87         virtual void    sortOverlappingPairs(btDispatcher* dispatcher) = 0;
    88 
    8986
    9087};
     
    263260        }
    264261
    265         virtual void    sortOverlappingPairs(btDispatcher* dispatcher);
    266        
    267 
    268 protected:
     262public:
    269263       
    270264        btAlignedObjectArray<int>       m_hashTable;
     
    376370                }
    377371
    378                 virtual void    sortOverlappingPairs(btDispatcher* dispatcher);
    379                
    380372
    381373};
     
    456448        }
    457449       
    458         virtual void    sortOverlappingPairs(btDispatcher* dispatcher)
    459         {
    460         }
    461450
    462451
  • code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp

    r2907 r2908  
    470470
    471471#ifdef RAYAABB2
     472        btVector3 rayFrom = raySource;
    472473        btVector3 rayDir = (rayTarget-raySource);
    473474        rayDir.normalize ();
     
    558559
    559560#ifdef RAYAABB2
     561        btVector3 rayFrom = raySource;
    560562        btVector3 rayDirection = (rayTarget-raySource);
    561563        rayDirection.normalize ();
     
    816818#include <new>
    817819
    818 #if 0
    819820//PCK: consts
    820821static const unsigned BVH_ALIGNMENT = 16;
     
    822823
    823824static const unsigned BVH_ALIGNMENT_BLOCKS = 2;
    824 #endif
     825
    825826
    826827
     
    11461147
    11471148
    1148 
  • code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp

    r2907 r2908  
    325325}
    326326
    327 void    btSimpleBroadphase::resetPool(btDispatcher* dispatcher)
    328 {
    329         //not yet
    330 }
     327
     328
  • code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btSimpleBroadphase.h

    r2907 r2908  
    109109        }
    110110
    111         ///reset broadphase internal structures, to ensure determinism/reproducability
    112         virtual void resetPool(btDispatcher* dispatcher);
    113 
    114111
    115112        void    validate();
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp

    r2907 r2908  
    5353                {
    5454                        m_doubleDispatch[i][j] = m_collisionConfiguration->getCollisionAlgorithmCreateFunc(i,j);
    55                         btAssert(m_doubleDispatch[i][j]);
     55                        assert(m_doubleDispatch[i][j]);
    5656                }
    5757        }
     
    8080        btCollisionObject* body1 = (btCollisionObject*)b1;
    8181
    82         //test for Bullet 2.74: use a relative contact breaking threshold without clamping against 'gContactBreakingThreshold'
    83         //btScalar contactBreakingThreshold = btMin(gContactBreakingThreshold,btMin(body0->getCollisionShape()->getContactBreakingThreshold(),body1->getCollisionShape()->getContactBreakingThreshold()));
    84         btScalar contactBreakingThreshold = btMin(body0->getCollisionShape()->getContactBreakingThreshold(),body1->getCollisionShape()->getContactBreakingThreshold());
    85 
    86         btScalar contactProcessingThreshold = btMin(body0->getContactProcessingThreshold(),body1->getContactProcessingThreshold());
    87                
     82        btScalar contactBreakingThreshold = btMin(gContactBreakingThreshold,btMin(body0->getCollisionShape()->getContactBreakingThreshold(),body1->getCollisionShape()->getContactBreakingThreshold()));
     83       
    8884        void* mem = 0;
    8985       
     
    9692
    9793        }
    98         btPersistentManifold* manifold = new(mem) btPersistentManifold (body0,body1,0,contactBreakingThreshold,contactProcessingThreshold);
     94        btPersistentManifold* manifold = new(mem) btPersistentManifold (body0,body1,0,contactBreakingThreshold);
    9995        manifold->m_index1a = m_manifoldsPtr.size();
    10096        m_manifoldsPtr.push_back(manifold);
     
    147143        return algo;
    148144}
     145
    149146
    150147
     
    164161bool    btCollisionDispatcher::needsCollision(btCollisionObject* body0,btCollisionObject* body1)
    165162{
    166         btAssert(body0);
    167         btAssert(body1);
     163        assert(body0);
     164        assert(body1);
    168165
    169166        bool needsCollision = true;
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCollisionObject.cpp

    r2907 r2908  
    1818
    1919btCollisionObject::btCollisionObject()
    20         :       m_anisotropicFriction(1.f,1.f,1.f),
    21         m_hasAnisotropicFriction(false),
    22         m_contactProcessingThreshold(1e30f),
    23                 m_broadphaseHandle(0),
     20        :       m_broadphaseHandle(0),
    2421                m_collisionShape(0),
    2522                m_rootCollisionShape(0),
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCollisionObject.h

    r2907 r2908  
    5353        btVector3       m_interpolationLinearVelocity;
    5454        btVector3       m_interpolationAngularVelocity;
    55        
    56         btVector3               m_anisotropicFriction;
    57         bool                            m_hasAnisotropicFriction;
    58         btScalar                m_contactProcessingThreshold;   
    59 
    6055        btBroadphaseProxy*              m_broadphaseHandle;
    6156        btCollisionShape*               m_collisionShape;
     
    120115                CO_COLLISION_OBJECT =1,
    121116                CO_RIGID_BODY,
     117                CO_SOFT_BODY,
    122118                ///CO_GHOST_OBJECT keeps track of all objects overlapping its AABB and that pass its collision filter
    123119                ///It is useful for collision sensors, explosion objects, character controller etc.
    124                 CO_GHOST_OBJECT,
    125                 CO_SOFT_BODY,
    126                 CO_HF_FLUID
     120                CO_GHOST_OBJECT
    127121        };
    128122
     
    133127        }
    134128
    135         const btVector3& getAnisotropicFriction() const
    136         {
    137                 return m_anisotropicFriction;
    138         }
    139         void    setAnisotropicFriction(const btVector3& anisotropicFriction)
    140         {
    141                 m_anisotropicFriction = anisotropicFriction;
    142                 m_hasAnisotropicFriction = (anisotropicFriction[0]!=1.f) || (anisotropicFriction[1]!=1.f) || (anisotropicFriction[2]!=1.f);
    143         }
    144         bool    hasAnisotropicFriction() const
    145         {
    146                 return m_hasAnisotropicFriction;
    147         }
    148 
    149         ///the constraint solver can discard solving contacts, if the distance is above this threshold. 0 by default.
    150         ///Note that using contacts with positive distance can improve stability. It increases, however, the chance of colliding with degerate contacts, such as 'interior' triangle edges
    151         void    setContactProcessingThreshold( btScalar contactProcessingThreshold)
    152         {
    153                 m_contactProcessingThreshold = contactProcessingThreshold;
    154         }
    155         btScalar        getContactProcessingThreshold() const
    156         {
    157                 return m_contactProcessingThreshold;
    158         }
    159129
    160130        SIMD_FORCE_INLINE bool          isStaticObject() const {
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.cpp

    r2907 r2908  
    7070                        getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(bp,m_dispatcher1);
    7171                        getBroadphase()->destroyProxy(bp,m_dispatcher1);
    72                         collisionObject->setBroadphaseHandle(0);
    7372                }
    7473        }
     
    120119
    121120
    122 void    btCollisionWorld::updateSingleAabb(btCollisionObject* colObj)
    123 {
    124         btVector3 minAabb,maxAabb;
    125         colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb);
    126         //need to increase the aabb for contact thresholds
    127         btVector3 contactThreshold(gContactBreakingThreshold,gContactBreakingThreshold,gContactBreakingThreshold);
    128         minAabb -= contactThreshold;
    129         maxAabb += contactThreshold;
    130 
    131         btBroadphaseInterface* bp = (btBroadphaseInterface*)m_broadphasePairCache;
    132 
    133         //moving objects should be moderately sized, probably something wrong if not
    134         if ( colObj->isStaticObject() || ((maxAabb-minAabb).length2() < btScalar(1e12)))
    135         {
    136                 bp->setAabb(colObj->getBroadphaseHandle(),minAabb,maxAabb, m_dispatcher1);
    137         } else
    138         {
    139                 //something went wrong, investigate
    140                 //this assert is unwanted in 3D modelers (danger of loosing work)
    141                 colObj->setActivationState(DISABLE_SIMULATION);
    142 
    143                 static bool reportMe = true;
    144                 if (reportMe && m_debugDrawer)
    145                 {
    146                         reportMe = false;
    147                         m_debugDrawer->reportErrorWarning("Overflow in AABB, object removed from simulation");
    148                         m_debugDrawer->reportErrorWarning("If you can reproduce this, please email bugs@continuousphysics.com\n");
    149                         m_debugDrawer->reportErrorWarning("Please include above information, your Platform, version of OS.\n");
    150                         m_debugDrawer->reportErrorWarning("Thanks.\n");
    151                 }
    152         }
    153 }
    154 
    155121void    btCollisionWorld::updateAabbs()
    156122{
     
    165131                if (colObj->isActive())
    166132                {
    167                         updateSingleAabb(colObj);
    168                 }
    169         }
     133                        btVector3 minAabb,maxAabb;
     134                        colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb);
     135                        //need to increase the aabb for contact thresholds
     136                        btVector3 contactThreshold(gContactBreakingThreshold,gContactBreakingThreshold,gContactBreakingThreshold);
     137                        minAabb -= contactThreshold;
     138                        maxAabb += contactThreshold;
     139
     140                        btBroadphaseInterface* bp = (btBroadphaseInterface*)m_broadphasePairCache;
     141
     142                        //moving objects should be moderately sized, probably something wrong if not
     143                        if ( colObj->isStaticObject() || ((maxAabb-minAabb).length2() < btScalar(1e12)))
     144                        {
     145                                bp->setAabb(colObj->getBroadphaseHandle(),minAabb,maxAabb, m_dispatcher1);
     146                        } else
     147                        {
     148                                //something went wrong, investigate
     149                                //this assert is unwanted in 3D modelers (danger of loosing work)
     150                                colObj->setActivationState(DISABLE_SIMULATION);
     151
     152                                static bool reportMe = true;
     153                                if (reportMe && m_debugDrawer)
     154                                {
     155                                        reportMe = false;
     156                                        m_debugDrawer->reportErrorWarning("Overflow in AABB, object removed from simulation");
     157                                        m_debugDrawer->reportErrorWarning("If you can reproduce this, please email bugs@continuousphysics.com\n");
     158                                        m_debugDrawer->reportErrorWarning("Please include above information, your Platform, version of OS.\n");
     159                                        m_debugDrawer->reportErrorWarning("Thanks.\n");
     160                                }
     161                        }
     162                }
     163        }
     164
    170165}
    171166
     
    299294                                        BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to,
    300295                                                btCollisionWorld::RayResultCallback* resultCallback, btCollisionObject* collisionObject,btTriangleMeshShape*    triangleMesh):
    301                   //@BP Mod
    302                                                 btTriangleRaycastCallback(from,to, resultCallback->m_flags),
     296                                                btTriangleRaycastCallback(from,to),
    303297                                                        m_resultCallback(resultCallback),
    304298                                                        m_collisionObject(collisionObject),
     
    349343                                        BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to,
    350344                                                btCollisionWorld::RayResultCallback* resultCallback, btCollisionObject* collisionObject,btConcaveShape* triangleMesh):
    351                   //@BP Mod
    352                   btTriangleRaycastCallback(from,to, resultCallback->m_flags),
     345                                                btTriangleRaycastCallback(from,to),
    353346                                                        m_resultCallback(resultCallback),
    354347                                                        m_collisionObject(collisionObject),
     
    671664                        //RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject();
    672665                        //btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
    673 #if 0
     666                       
    674667#ifdef RECALCULATE_AABB
    675668                        btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
     
    679672                        const btVector3& collisionObjectAabbMin = collisionObject->getBroadphaseHandle()->m_aabbMin;
    680673                        const btVector3& collisionObjectAabbMax = collisionObject->getBroadphaseHandle()->m_aabbMax;
    681 #endif
    682674#endif
    683675                        //btScalar hitLambda = m_resultCallback.m_closestHitFraction;
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.h

    r2907 r2908  
    5959 *
    6060 */
    61 
    62 
    6361 
    6462 
     
    8280{
    8381
    84 
    8582       
    8683protected:
    8784
    8885        btAlignedObjectArray<btCollisionObject*>        m_collisionObjects;
    89 
    9086       
    9187        btDispatcher*   m_dispatcher1;
     
    9995        btIDebugDraw*   m_debugDrawer;
    10096
    101 
    10297       
    10398public:
     
    138133                return m_dispatcher1;
    139134        }
    140 
    141         void    updateSingleAabb(btCollisionObject* colObj);
    142135
    143136        virtual void    updateAabbs();
     
    161154                int     m_shapePart;
    162155                int     m_triangleIndex;
    163 
    164156               
    165157                //const btCollisionShape*       m_shapeTemp;
     
    194186                short int       m_collisionFilterGroup;
    195187                short int       m_collisionFilterMask;
    196       //@BP Mod - Custom flags, currently used to enable backface culling on tri-meshes, see btRaycastCallback
    197       unsigned int m_flags;
    198188
    199189                virtual ~RayResultCallback()
     
    209199                        m_collisionObject(0),
    210200                        m_collisionFilterGroup(btBroadphaseProxy::DefaultFilter),
    211                         m_collisionFilterMask(btBroadphaseProxy::AllFilter),
    212          //@BP Mod
    213          m_flags(0)
     201                        m_collisionFilterMask(btBroadphaseProxy::AllFilter)
    214202                {
    215203                }
     
    239227                btVector3       m_hitNormalWorld;
    240228                btVector3       m_hitPointWorld;
    241 
    242229                       
    243230                virtual btScalar        addSingleResult(LocalRayResult& rayResult,bool normalInWorldSpace)
     
    245232                        //caller already does the filter on the m_closestHitFraction
    246233                        btAssert(rayResult.m_hitFraction <= m_closestHitFraction);
    247 
    248234                       
    249235                        m_closestHitFraction = rayResult.m_hitFraction;
     
    292278                short int       m_collisionFilterGroup;
    293279                short int       m_collisionFilterMask;
    294 
    295280               
    296281                ConvexResultCallback()
     
    304289                {
    305290                }
    306 
    307291               
    308292                bool    hasHit() const
     
    310294                        return (m_closestHitFraction < btScalar(1.));
    311295                }
    312 
    313296
    314297               
     
    339322                btVector3       m_hitPointWorld;
    340323                btCollisionObject*      m_hitCollisionObject;
    341 
    342324               
    343325                virtual btScalar        addSingleResult(LocalConvexResult& convexResult,bool normalInWorldSpace)
     
    345327//caller already does the filter on the m_closestHitFraction
    346328                        btAssert(convexResult.m_hitFraction <= m_closestHitFraction);
    347 
    348329                                               
    349330                        m_closestHitFraction = convexResult.m_hitFraction;
  • 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 
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h

    r2907 r2908  
    2727#include "LinearMath/btAlignedObjectArray.h"
    2828class btDispatcher;
    29 class btCollisionObject;
    3029
    3130/// btCompoundCollisionAlgorithm  supports collision between CompoundCollisionShapes and other collision shapes
     
    3736        class btPersistentManifold*     m_sharedManifold;
    3837        bool                                    m_ownsManifold;
    39 
    40         int     m_compoundShapeRevision;//to keep track of changes, so that childAlgorithm array can be updated
    4138       
    42         void    removeChildAlgorithms();
    43        
    44         void    preallocateChildAlgorithms(btCollisionObject* body0,btCollisionObject* body1);
    45 
    4639public:
    4740
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp

    r2907 r2908  
    5252btConvexConvexAlgorithm::CreateFunc::CreateFunc(btSimplexSolverInterface*                       simplexSolver, btConvexPenetrationDepthSolver* pdSolver)
    5353{
    54         m_numPerturbationIterations = 0;
    55         m_minimumPointsPerturbationThreshold = 3;
    5654        m_simplexSolver = simplexSolver;
    5755        m_pdSolver = pdSolver;
     
    6260}
    6361
    64 btConvexConvexAlgorithm::btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver,int numPerturbationIterations, int minimumPointsPerturbationThreshold)
     62btConvexConvexAlgorithm::btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver)
    6563: btActivatingCollisionAlgorithm(ci,body0,body1),
    6664m_simplexSolver(simplexSolver),
     
    6866m_ownManifold (false),
    6967m_manifoldPtr(mf),
    70 m_lowLevelOfDetail(false),
     68m_lowLevelOfDetail(false)
    7169#ifdef USE_SEPDISTANCE_UTIL2
    7270,m_sepDistance((static_cast<btConvexShape*>(body0->getCollisionShape()))->getAngularMotionDisc(),
    73                           (static_cast<btConvexShape*>(body1->getCollisionShape()))->getAngularMotionDisc()),
     71                          (static_cast<btConvexShape*>(body1->getCollisionShape()))->getAngularMotionDisc())
    7472#endif
    75 m_numPerturbationIterations(numPerturbationIterations),
    76 m_minimumPointsPerturbationThreshold(minimumPointsPerturbationThreshold)
    7773{
    7874        (void)body0;
     
    9894
    9995
    100 struct btPerturbedContactResult : public btManifoldResult
    101 {
    102         btManifoldResult* m_originalManifoldResult;
    103         btTransform m_transformA;
    104         btTransform m_transformB;
    105         btTransform     m_unPerturbedTransform;
    106         bool    m_perturbA;
    107         btIDebugDraw*   m_debugDrawer;
    108 
    109 
    110         btPerturbedContactResult(btManifoldResult* originalResult,const btTransform& transformA,const btTransform& transformB,const btTransform& unPerturbedTransform,bool perturbA,btIDebugDraw* debugDrawer)
    111                 :m_originalManifoldResult(originalResult),
    112                 m_transformA(transformA),
    113                 m_transformB(transformB),
    114                 m_perturbA(perturbA),
    115                 m_unPerturbedTransform(unPerturbedTransform),
    116                 m_debugDrawer(debugDrawer)
    117         {
    118         }
    119         virtual ~ btPerturbedContactResult()
    120         {
    121         }
    122 
    123         virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar orgDepth)
    124         {
    125                 btVector3 endPt,startPt;
    126                 btScalar newDepth;
    127                 btVector3 newNormal;
    128 
    129                 if (m_perturbA)
    130                 {
    131                         btVector3 endPtOrg = pointInWorld + normalOnBInWorld*orgDepth;
    132                         endPt = (m_unPerturbedTransform*m_transformA.inverse())(endPtOrg);
    133                         newDepth = (endPt -  pointInWorld).dot(normalOnBInWorld);
    134                         startPt = endPt+normalOnBInWorld*newDepth;
    135                 } else
    136                 {
    137                         endPt = pointInWorld + normalOnBInWorld*orgDepth;
    138                         startPt = (m_unPerturbedTransform*m_transformB.inverse())(pointInWorld);
    139                         newDepth = (endPt -  startPt).dot(normalOnBInWorld);
    140                        
    141                 }
    142 
    143 //#define DEBUG_CONTACTS 1
    144 #ifdef DEBUG_CONTACTS
    145                 m_debugDrawer->drawLine(startPt,endPt,btVector3(1,0,0));
    146                 m_debugDrawer->drawSphere(startPt,0.05,btVector3(0,1,0));
    147                 m_debugDrawer->drawSphere(endPt,0.05,btVector3(0,0,1));
    148 #endif //DEBUG_CONTACTS
    149 
    150                
    151                 m_originalManifoldResult->addContactPoint(normalOnBInWorld,startPt,newDepth);
    152         }
    153 
    154 };
    155 
    156 extern btScalar gContactBreakingThreshold;
     96
     97
    15798
    15899//
     
    170111        resultOut->setPersistentManifold(m_manifoldPtr);
    171112
    172         //comment-out next line to test multi-contact generation
    173         //resultOut->getPersistentManifold()->clearManifold();
    174113       
    175114
     
    208147
    209148        gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
     149
    210150        btScalar sepDist = gjkPairDetector.getCachedSeparatingDistance()+dispatchInfo.m_convexConservativeDistanceThreshold;
    211 
    212         //now perturbe directions to get multiple contact points
    213         btVector3 v0,v1;
    214         btVector3 sepNormalWorldSpace = gjkPairDetector.getCachedSeparatingAxis().normalized();
    215         btPlaneSpace1(sepNormalWorldSpace,v0,v1);
    216         //now perform 'm_numPerturbationIterations' collision queries with the perturbated collision objects
    217        
    218         //perform perturbation when more then 'm_minimumPointsPerturbationThreshold' points
    219         if (resultOut->getPersistentManifold()->getNumContacts() < m_minimumPointsPerturbationThreshold)
    220         {
    221                
    222                 int i;
    223 
    224                 bool perturbeA = true;
    225                 const btScalar angleLimit = 0.125f * SIMD_PI;
    226                 btScalar perturbeAngle;
    227                 btScalar radiusA = min0->getAngularMotionDisc();
    228                 btScalar radiusB = min1->getAngularMotionDisc();
    229                 if (radiusA < radiusB)
    230                 {
    231                         perturbeAngle = gContactBreakingThreshold /radiusA;
    232                         perturbeA = true;
    233                 } else
    234                 {
    235                         perturbeAngle = gContactBreakingThreshold / radiusB;
    236                         perturbeA = false;
    237                 }
    238                 if ( perturbeAngle > angleLimit )
    239                                 perturbeAngle = angleLimit;
    240 
    241                 btTransform unPerturbedTransform;
    242                 if (perturbeA)
    243                 {
    244                         unPerturbedTransform = input.m_transformA;
    245                 } else
    246                 {
    247                         unPerturbedTransform = input.m_transformB;
    248                 }
    249                
    250                 for ( i=0;i<m_numPerturbationIterations;i++)
    251                 {
    252                         btQuaternion perturbeRot(v0,perturbeAngle);
    253                         btScalar iterationAngle = i*(SIMD_2_PI/btScalar(m_numPerturbationIterations));
    254                         btQuaternion rotq(sepNormalWorldSpace,iterationAngle);
    255                        
    256                        
    257                         if (perturbeA)
    258                         {
    259                                 input.m_transformA.setBasis(  btMatrix3x3(rotq.inverse()*perturbeRot*rotq)*body0->getWorldTransform().getBasis());
    260                                 input.m_transformB = body1->getWorldTransform();
    261 #ifdef DEBUG_CONTACTS
    262                                 dispatchInfo.m_debugDraw->drawTransform(input.m_transformA,10.0);
    263 #endif //DEBUG_CONTACTS
    264                         } else
    265                         {
    266                                 input.m_transformA = body0->getWorldTransform();
    267                                 input.m_transformB.setBasis( btMatrix3x3(rotq.inverse()*perturbeRot*rotq)*body1->getWorldTransform().getBasis());
    268 #ifdef DEBUG_CONTACTS
    269                                 dispatchInfo.m_debugDraw->drawTransform(input.m_transformB,10.0);
    270 #endif
    271                         }
    272                        
    273                         btPerturbedContactResult perturbedResultOut(resultOut,input.m_transformA,input.m_transformB,unPerturbedTransform,perturbeA,dispatchInfo.m_debugDraw);
    274                         gjkPairDetector.getClosestPoints(input,perturbedResultOut,dispatchInfo.m_debugDraw);
    275                        
    276                        
    277                 }
    278         }
    279 
    280        
    281151
    282152#ifdef USE_SEPDISTANCE_UTIL2
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h

    r2907 r2908  
    3434///#define USE_SEPDISTANCE_UTIL2 1
    3535
    36 ///The convexConvexAlgorithm collision algorithm implements time of impact, convex closest points and penetration depth calculations between two convex objects.
    37 ///Multiple contact points are calculated by perturbing the orientation of the smallest object orthogonal to the separating normal.
    38 ///This idea was described by Gino van den Bergen in this forum topic http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=4&t=288&p=888#p888
     36///ConvexConvexAlgorithm collision algorithm implements time of impact, convex closest points and penetration depth calculations.
    3937class btConvexConvexAlgorithm : public btActivatingCollisionAlgorithm
    4038{
     
    5048        bool                    m_lowLevelOfDetail;
    5149       
    52         int m_numPerturbationIterations;
    53         int m_minimumPointsPerturbationThreshold;
    54 
    55 
    5650        ///cache separating vector to speedup collision detection
    5751       
     
    5953public:
    6054
    61         btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver, int numPerturbationIterations, int minimumPointsPerturbationThreshold);
    62 
     55        btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver);
    6356
    6457        virtual ~btConvexConvexAlgorithm();
     
    8679        struct CreateFunc :public       btCollisionAlgorithmCreateFunc
    8780        {
    88 
    8981                btConvexPenetrationDepthSolver*         m_pdSolver;
    9082                btSimplexSolverInterface*                       m_simplexSolver;
    91                 int m_numPerturbationIterations;
    92                 int m_minimumPointsPerturbationThreshold;
    93 
     83               
    9484                CreateFunc(btSimplexSolverInterface*                    simplexSolver, btConvexPenetrationDepthSolver* pdSolver);
    9585               
     
    9989                {
    10090                        void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvexConvexAlgorithm));
    101                         return new(mem) btConvexConvexAlgorithm(ci.m_manifold,ci,body0,body1,m_simplexSolver,m_pdSolver,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold);
     91                        return new(mem) btConvexConvexAlgorithm(ci.m_manifold,ci,body0,body1,m_simplexSolver,m_pdSolver);
    10292                }
    10393        };
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp

    r2907 r2908  
    55This software is provided 'as-is', without any express or implied warranty.
    66In no event will the authors be held liable for any damages arising from the use of this software.
    7 Permission is granted to anyone to use this software for any purpose,
    8 including commercial applications, and to alter it and redistribute it freely,
     7Permission is granted to anyone to use this software for any purpose, 
     8including commercial applications, and to alter it and redistribute it freely, 
    99subject to the following restrictions:
    1010
     
    2323//#include <stdio.h>
    2424
    25 btConvexPlaneCollisionAlgorithm::btConvexPlaneCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped, int numPerturbationIterations,int minimumPointsPerturbationThreshold)
     25btConvexPlaneCollisionAlgorithm::btConvexPlaneCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped)
    2626: btCollisionAlgorithm(ci),
    2727m_ownManifold(false),
    2828m_manifoldPtr(mf),
    29 m_isSwapped(isSwapped),
    30 m_numPerturbationIterations(numPerturbationIterations),
    31 m_minimumPointsPerturbationThreshold(minimumPointsPerturbationThreshold)
     29m_isSwapped(isSwapped)
    3230{
    3331        btCollisionObject* convexObj = m_isSwapped? col1 : col0;
    3432        btCollisionObject* planeObj = m_isSwapped? col0 : col1;
    35 
     33       
    3634        if (!m_manifoldPtr && m_dispatcher->needsCollision(convexObj,planeObj))
    3735        {
     
    5149}
    5250
    53 void btConvexPlaneCollisionAlgorithm::collideSingleContact (const btQuaternion& perturbeRot, btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
     51
     52
     53void btConvexPlaneCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
    5454{
    55     btCollisionObject* convexObj = m_isSwapped? body1 : body0;
     55        (void)dispatchInfo;
     56        (void)resultOut;
     57        if (!m_manifoldPtr)
     58                return;
     59
     60        btCollisionObject* convexObj = m_isSwapped? body1 : body0;
    5661        btCollisionObject* planeObj = m_isSwapped? body0: body1;
    5762
     
    5964        btStaticPlaneShape* planeShape = (btStaticPlaneShape*) planeObj->getCollisionShape();
    6065
    61     bool hasCollision = false;
     66        bool hasCollision = false;
    6267        const btVector3& planeNormal = planeShape->getPlaneNormal();
    6368        const btScalar& planeConstant = planeShape->getPlaneConstant();
    64        
    65         btTransform convexWorldTransform = convexObj->getWorldTransform();
     69        btTransform planeInConvex;
     70        planeInConvex= convexObj->getWorldTransform().inverse() * planeObj->getWorldTransform();
    6671        btTransform convexInPlaneTrans;
    67         convexInPlaneTrans= planeObj->getWorldTransform().inverse() * convexWorldTransform;
    68         //now perturbe the convex-world transform
    69         convexWorldTransform.getBasis()*=btMatrix3x3(perturbeRot);
    70         btTransform planeInConvex;
    71         planeInConvex= convexWorldTransform.inverse() * planeObj->getWorldTransform();
    72        
     72        convexInPlaneTrans= planeObj->getWorldTransform().inverse() * convexObj->getWorldTransform();
     73
    7374        btVector3 vtx = convexShape->localGetSupportingVertex(planeInConvex.getBasis()*-planeNormal);
    74 
    7575        btVector3 vtxInPlane = convexInPlaneTrans(vtx);
    7676        btScalar distance = (planeNormal.dot(vtxInPlane) - planeConstant);
     
    8888                resultOut->addContactPoint(normalOnSurfaceB,pOnB,distance);
    8989        }
    90 }
    91 
    92 
    93 void btConvexPlaneCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
    94 {
    95         (void)dispatchInfo;
    96         if (!m_manifoldPtr)
    97                 return;
    98 
    99     btCollisionObject* convexObj = m_isSwapped? body1 : body0;
    100         btCollisionObject* planeObj = m_isSwapped? body0: body1;
    101 
    102         btConvexShape* convexShape = (btConvexShape*) convexObj->getCollisionShape();
    103         btStaticPlaneShape* planeShape = (btStaticPlaneShape*) planeObj->getCollisionShape();
    104 
    105     bool hasCollision = false;
    106         const btVector3& planeNormal = planeShape->getPlaneNormal();
    107         const btScalar& planeConstant = planeShape->getPlaneConstant();
    108 
    109         //first perform a collision query with the non-perturbated collision objects
    110         {
    111                 btQuaternion rotq(0,0,0,1);
    112                 collideSingleContact(rotq,body0,body1,dispatchInfo,resultOut);
    113         }
    114 
    115         if (resultOut->getPersistentManifold()->getNumContacts()<m_minimumPointsPerturbationThreshold)
    116         {
    117                 btVector3 v0,v1;
    118                 btPlaneSpace1(planeNormal,v0,v1);
    119                 //now perform 'm_numPerturbationIterations' collision queries with the perturbated collision objects
    120 
    121                 const btScalar angleLimit = 0.125f * SIMD_PI;
    122                 btScalar perturbeAngle;
    123                 btScalar radius = convexShape->getAngularMotionDisc();
    124                 perturbeAngle = gContactBreakingThreshold / radius;
    125                 if ( perturbeAngle > angleLimit )
    126                                 perturbeAngle = angleLimit;
    127 
    128                 btQuaternion perturbeRot(v0,perturbeAngle);
    129                 for (int i=0;i<m_numPerturbationIterations;i++)
    130                 {
    131                         btScalar iterationAngle = i*(SIMD_2_PI/btScalar(m_numPerturbationIterations));
    132                         btQuaternion rotq(planeNormal,iterationAngle);
    133                         collideSingleContact(rotq.inverse()*perturbeRot*rotq,body0,body1,dispatchInfo,resultOut);
    134                 }
    135         }
    136 
    13790        if (m_ownManifold)
    13891        {
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h

    r2907 r2908  
    55This software is provided 'as-is', without any express or implied warranty.
    66In no event will the authors be held liable for any damages arising from the use of this software.
    7 Permission is granted to anyone to use this software for any purpose,
    8 including commercial applications, and to alter it and redistribute it freely,
     7Permission is granted to anyone to use this software for any purpose, 
     8including commercial applications, and to alter it and redistribute it freely, 
    99subject to the following restrictions:
    1010
     
    2929class btConvexPlaneCollisionAlgorithm : public btCollisionAlgorithm
    3030{
    31         bool            m_ownManifold;
     31        bool    m_ownManifold;
    3232        btPersistentManifold*   m_manifoldPtr;
    33         bool            m_isSwapped;
    34         int                     m_numPerturbationIterations;
    35         int                     m_minimumPointsPerturbationThreshold;
    36 
     33        bool    m_isSwapped;
     34       
    3735public:
    3836
    39         btConvexPlaneCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped, int numPerturbationIterations,int minimumPointsPerturbationThreshold);
     37        btConvexPlaneCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped);
    4038
    4139        virtual ~btConvexPlaneCollisionAlgorithm();
    4240
    4341        virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
    44 
    45         void collideSingleContact (const btQuaternion& perturbeRot, btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
    4642
    4743        virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
     
    5753        struct CreateFunc :public       btCollisionAlgorithmCreateFunc
    5854        {
    59                 int     m_numPerturbationIterations;
    60                 int m_minimumPointsPerturbationThreshold;
    61                        
    62                 CreateFunc()
    63                         : m_numPerturbationIterations(3),
    64                         m_minimumPointsPerturbationThreshold(3)
    65                 {
    66                 }
    67                
    6855                virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
    6956                {
     
    7158                        if (!m_swapped)
    7259                        {
    73                                 return new(mem) btConvexPlaneCollisionAlgorithm(0,ci,body0,body1,false,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold);
     60                                return new(mem) btConvexPlaneCollisionAlgorithm(0,ci,body0,body1,false);
    7461                        } else
    7562                        {
    76                                 return new(mem) btConvexPlaneCollisionAlgorithm(0,ci,body0,body1,true,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold);
     63                                return new(mem) btConvexPlaneCollisionAlgorithm(0,ci,body0,body1,true);
    7764                        }
    7865                }
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp

    r2907 r2908  
    289289        return m_emptyCreateFunc;
    290290}
    291 
    292 void btDefaultCollisionConfiguration::setConvexConvexMultipointIterations(int numPerturbationIterations, int minimumPointsPerturbationThreshold)
    293 {
    294         btConvexConvexAlgorithm::CreateFunc* convexConvex = (btConvexConvexAlgorithm::CreateFunc*) m_convexConvexCreateFunc;
    295         convexConvex->m_numPerturbationIterations = numPerturbationIterations;
    296         convexConvex->m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold;
    297 }
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h

    r2907 r2908  
    112112        virtual btCollisionAlgorithmCreateFunc* getCollisionAlgorithmCreateFunc(int proxyType0,int proxyType1);
    113113
    114         ///Use this method to allow to generate multiple contact points between at once, between two objects using the generic convex-convex algorithm.
    115         ///By default, this feature is disabled for best performance.
    116         ///@param numPerturbationIterations controls the number of collision queries. Set it to zero to disable the feature.
    117         ///@param minimumPointsPerturbationThreshold is the minimum number of points in the contact cache, above which the feature is disabled
    118         ///3 is a good value for both params, if you want to enable the feature. This is because the default contact cache contains a maximum of 4 points, and one collision query at the unperturbed orientation is performed first.
    119         ///See Bullet/Demos/CollisionDemo for an example how this feature gathers multiple points.
    120         ///@todo we could add a per-object setting of those parameters, for level-of-detail collision detection.
    121         void    setConvexConvexMultipointIterations(int numPerturbationIterations=3, int minimumPointsPerturbationThreshold = 3);
    122114
    123115};
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btGhostObject.cpp

    r2907 r2908  
    6464btPairCachingGhostObject::~btPairCachingGhostObject()
    6565{
    66         m_hashPairCache->~btHashedOverlappingPairCache();
    6766        btAlignedFree( m_hashPairCache );
    6867}
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btManifoldResult.cpp

    r2907 r2908  
    5656void btManifoldResult::addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)
    5757{
    58         btAssert(m_manifoldPtr);
     58        assert(m_manifoldPtr);
    5959        //order in manifold needs to match
    6060       
     
    9393   newPt.m_index0  = m_index0;
    9494   newPt.m_index1  = m_index1;
    95         //printf("depth=%f\n",depth);
     95       
    9696        ///@todo, check this for any side effects
    9797        if (insertIndex >= 0)
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btManifoldResult.h

    r2907 r2908  
    4646        int m_index0;
    4747        int m_index1;
    48        
    49 
    5048public:
    5149
     
    8078        }
    8179
    82 
    8380        virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth);
    8481
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp

    r2907 r2908  
    2525#include "LinearMath/btQuickprof.h"
    2626
    27 btSimulationIslandManager::btSimulationIslandManager():
    28 m_splitIslands(true)
     27btSimulationIslandManager::btSimulationIslandManager()
    2928{
    3029}
     
    4544       
    4645        {
    47                
     46                btBroadphasePair* pairPtr = colWorld->getPairCache()->getOverlappingPairArrayPtr();
     47
    4848                for (int i=0;i<colWorld->getPairCache()->getNumOverlappingPairs();i++)
    4949                {
    50                         btBroadphasePair* pairPtr = colWorld->getPairCache()->getOverlappingPairArrayPtr();
    5150                        const btBroadphasePair& collisionPair = pairPtr[i];
    5251                        btCollisionObject* colObj0 = (btCollisionObject*)collisionPair.m_pProxy0->m_clientObject;
     
    187186                        }
    188187
    189                         btAssert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
     188                        assert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
    190189                        if (colObj0->getIslandTag() == islandId)
    191190                        {
     
    214213                                }
    215214
    216                                 btAssert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
     215                                assert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
    217216
    218217                                if (colObj0->getIslandTag() == islandId)
     
    235234                                }
    236235
    237                                 btAssert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
     236                                assert((colObj0->getIslandTag() == islandId) || (colObj0->getIslandTag() == -1));
    238237
    239238                                if (colObj0->getIslandTag() == islandId)
     
    253252        int maxNumManifolds = dispatcher->getNumManifolds();
    254253
    255 //#define SPLIT_ISLANDS 1
    256 //#ifdef SPLIT_ISLANDS
    257 
    258        
    259 //#endif //SPLIT_ISLANDS
     254#define SPLIT_ISLANDS 1
     255#ifdef SPLIT_ISLANDS
     256
     257       
     258#endif //SPLIT_ISLANDS
    260259
    261260       
     
    281280                                colObj0->activate();
    282281                        }
    283                         if(m_splitIslands)
    284                         {
    285                                 //filtering for response
    286                                 if (dispatcher->needsResponse(colObj0,colObj1))
    287                                         m_islandmanifold.push_back(manifold);
    288                         }
     282#ifdef SPLIT_ISLANDS
     283        //              //filtering for response
     284                        if (dispatcher->needsResponse(colObj0,colObj1))
     285                                m_islandmanifold.push_back(manifold);
     286#endif //SPLIT_ISLANDS
    289287                }
    290288        }
     
    306304        BT_PROFILE("processIslands");
    307305
    308         if(!m_splitIslands)
    309         {
    310                 btPersistentManifold** manifold = dispatcher->getInternalManifoldPointer();
    311                 int maxNumManifolds = dispatcher->getNumManifolds();
    312                 callback->ProcessIsland(&collisionObjects[0],collisionObjects.size(),manifold,maxNumManifolds, -1);
    313         }
    314         else
    315         {
    316                 // Sort manifolds, based on islands
    317                 // Sort the vector using predicate and std::sort
    318                 //std::sort(islandmanifold.begin(), islandmanifold.end(), btPersistentManifoldSortPredicate);
    319 
    320                 int numManifolds = int (m_islandmanifold.size());
    321 
    322                 //we should do radix sort, it it much faster (O(n) instead of O (n log2(n))
    323                 m_islandmanifold.quickSort(btPersistentManifoldSortPredicate());
    324 
    325                 //now process all active islands (sets of manifolds for now)
    326 
    327                 int startManifoldIndex = 0;
    328                 int endManifoldIndex = 1;
    329 
    330                 //int islandId;
    331 
    332                
    333 
    334         //      printf("Start Islands\n");
    335 
    336                 //traverse the simulation islands, and call the solver, unless all objects are sleeping/deactivated
    337                 for ( startIslandIndex=0;startIslandIndex<numElem;startIslandIndex = endIslandIndex)
    338                 {
    339                         int islandId = getUnionFind().getElement(startIslandIndex).m_id;
    340 
    341 
    342                            bool islandSleeping = false;
    343                        
    344                                         for (endIslandIndex = startIslandIndex;(endIslandIndex<numElem) && (getUnionFind().getElement(endIslandIndex).m_id == islandId);endIslandIndex++)
    345                                         {
    346                                                         int i = getUnionFind().getElement(endIslandIndex).m_sz;
    347                                                         btCollisionObject* colObj0 = collisionObjects[i];
    348                                                         m_islandBodies.push_back(colObj0);
    349                                                         if (!colObj0->isActive())
    350                                                                         islandSleeping = true;
    351                                         }
    352                        
    353 
    354                         //find the accompanying contact manifold for this islandId
    355                         int numIslandManifolds = 0;
    356                         btPersistentManifold** startManifold = 0;
    357 
    358                         if (startManifoldIndex<numManifolds)
    359                         {
    360                                 int curIslandId = getIslandId(m_islandmanifold[startManifoldIndex]);
    361                                 if (curIslandId == islandId)
    362                                 {
    363                                         startManifold = &m_islandmanifold[startManifoldIndex];
    364                                
    365                                         for (endManifoldIndex = startManifoldIndex+1;(endManifoldIndex<numManifolds) && (islandId == getIslandId(m_islandmanifold[endManifoldIndex]));endManifoldIndex++)
    366                                         {
    367 
    368                                         }
    369                                         /// Process the actual simulation, only if not sleeping/deactivated
    370                                         numIslandManifolds = endManifoldIndex-startManifoldIndex;
    371                                 }
    372 
    373                         }
    374 
    375                         if (!islandSleeping)
    376                         {
    377                                 callback->ProcessIsland(&m_islandBodies[0],m_islandBodies.size(),startManifold,numIslandManifolds, islandId);
    378         //                      printf("Island callback of size:%d bodies, %d manifolds\n",islandBodies.size(),numIslandManifolds);
    379                         }
     306#ifndef SPLIT_ISLANDS
     307        btPersistentManifold** manifold = dispatcher->getInternalManifoldPointer();
     308       
     309        callback->ProcessIsland(&collisionObjects[0],collisionObjects.size(),manifold,maxNumManifolds, -1);
     310#else
     311        // Sort manifolds, based on islands
     312        // Sort the vector using predicate and std::sort
     313        //std::sort(islandmanifold.begin(), islandmanifold.end(), btPersistentManifoldSortPredicate);
     314
     315        int numManifolds = int (m_islandmanifold.size());
     316
     317        //we should do radix sort, it it much faster (O(n) instead of O (n log2(n))
     318        m_islandmanifold.quickSort(btPersistentManifoldSortPredicate());
     319
     320        //now process all active islands (sets of manifolds for now)
     321
     322        int startManifoldIndex = 0;
     323        int endManifoldIndex = 1;
     324
     325        //int islandId;
     326
     327       
     328
     329//      printf("Start Islands\n");
     330
     331        //traverse the simulation islands, and call the solver, unless all objects are sleeping/deactivated
     332        for ( startIslandIndex=0;startIslandIndex<numElem;startIslandIndex = endIslandIndex)
     333        {
     334                int islandId = getUnionFind().getElement(startIslandIndex).m_id;
     335
     336
     337               bool islandSleeping = false;
     338               
     339                for (endIslandIndex = startIslandIndex;(endIslandIndex<numElem) && (getUnionFind().getElement(endIslandIndex).m_id == islandId);endIslandIndex++)
     340                {
     341                        int i = getUnionFind().getElement(endIslandIndex).m_sz;
     342                        btCollisionObject* colObj0 = collisionObjects[i];
     343                                                m_islandBodies.push_back(colObj0);
     344                        if (!colObj0->isActive())
     345                                islandSleeping = true;
     346                }
     347               
     348
     349                //find the accompanying contact manifold for this islandId
     350                int numIslandManifolds = 0;
     351                btPersistentManifold** startManifold = 0;
     352
     353                if (startManifoldIndex<numManifolds)
     354                {
     355                        int curIslandId = getIslandId(m_islandmanifold[startManifoldIndex]);
     356                        if (curIslandId == islandId)
     357                        {
     358                                startManifold = &m_islandmanifold[startManifoldIndex];
    380359                       
    381                         if (numIslandManifolds)
    382                         {
    383                                 startManifoldIndex = endManifoldIndex;
    384                         }
    385 
    386                         m_islandBodies.resize(0);
    387                 }
    388         } // else if(!splitIslands)
    389 
    390 }
     360                                for (endManifoldIndex = startManifoldIndex+1;(endManifoldIndex<numManifolds) && (islandId == getIslandId(m_islandmanifold[endManifoldIndex]));endManifoldIndex++)
     361                                {
     362
     363                                }
     364                                /// Process the actual simulation, only if not sleeping/deactivated
     365                                numIslandManifolds = endManifoldIndex-startManifoldIndex;
     366                        }
     367
     368                }
     369
     370                if (!islandSleeping)
     371                {
     372                        callback->ProcessIsland(&m_islandBodies[0],m_islandBodies.size(),startManifold,numIslandManifolds, islandId);
     373//                      printf("Island callback of size:%d bodies, %d manifolds\n",islandBodies.size(),numIslandManifolds);
     374                }
     375               
     376                if (numIslandManifolds)
     377                {
     378                        startManifoldIndex = endManifoldIndex;
     379                }
     380
     381                m_islandBodies.resize(0);
     382        }
     383#endif //SPLIT_ISLANDS
     384
     385
     386}
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.h

    r2907 r2908  
    3636        btAlignedObjectArray<btCollisionObject* >  m_islandBodies;
    3737       
    38         bool m_splitIslands;
    3938       
    4039public:
     
    6766        void buildIslands(btDispatcher* dispatcher,btCollisionWorld* colWorld);
    6867
    69         bool getSplitIslands()
    70         {
    71                 return m_splitIslands;
    72         }
    73         void setSplitIslands(bool doSplitIslands)
    74         {
    75                 m_splitIslands = doSplitIslands;
    76         }
    77 
    7868};
    7969
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp

    r2907 r2908  
    7979
    8080        ///point on A (worldspace)
    81         ///btVector3 pos0 = col0->getWorldTransform().getOrigin() - radius0 * normalOnSurfaceB;
     81        btVector3 pos0 = col0->getWorldTransform().getOrigin() - radius0 * normalOnSurfaceB;
    8282        ///point on B (worldspace)
    8383        btVector3 pos1 = col1->getWorldTransform().getOrigin() + radius1* normalOnSurfaceB;
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btUnionFind.cpp

    r2907 r2908  
    1515
    1616#include "btUnionFind.h"
     17#include <assert.h>
     18
    1719
    1820
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btUnionFind.h

    r2907 r2908  
    9999                int find(int x)
    100100                {
    101                         //btAssert(x < m_N);
    102                         //btAssert(x >= 0);
     101                        //assert(x < m_N);
     102                        //assert(x >= 0);
    103103
    104104                        while (x != m_elements[x].m_id)
     
    111111                #endif //
    112112                                x = m_elements[x].m_id;
    113                                 //btAssert(x < m_N);
    114                                 //btAssert(x >= 0);
     113                                //assert(x < m_N);
     114                                //assert(x >= 0);
    115115
    116116                        }
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btBoxShape.h

    r2907 r2908  
    162162                {
    163163                case 0:
    164                         plane.setValue(btScalar(1.),btScalar(0.),btScalar(0.),-halfExtents.x());
     164                        plane.setValue(btScalar(1.),btScalar(0.),btScalar(0.));
     165                        plane[3] = -halfExtents.x();
    165166                        break;
    166167                case 1:
    167                         plane.setValue(btScalar(-1.),btScalar(0.),btScalar(0.),-halfExtents.x());
     168                        plane.setValue(btScalar(-1.),btScalar(0.),btScalar(0.));
     169                        plane[3] = -halfExtents.x();
    168170                        break;
    169171                case 2:
    170                         plane.setValue(btScalar(0.),btScalar(1.),btScalar(0.),-halfExtents.y());
     172                        plane.setValue(btScalar(0.),btScalar(1.),btScalar(0.));
     173                        plane[3] = -halfExtents.y();
    171174                        break;
    172175                case 3:
    173                         plane.setValue(btScalar(0.),btScalar(-1.),btScalar(0.),-halfExtents.y());
     176                        plane.setValue(btScalar(0.),btScalar(-1.),btScalar(0.));
     177                        plane[3] = -halfExtents.y();
    174178                        break;
    175179                case 4:
    176                         plane.setValue(btScalar(0.),btScalar(0.),btScalar(1.),-halfExtents.z());
     180                        plane.setValue(btScalar(0.),btScalar(0.),btScalar(1.));
     181                        plane[3] = -halfExtents.z();
    177182                        break;
    178183                case 5:
    179                         plane.setValue(btScalar(0.),btScalar(0.),btScalar(-1.),-halfExtents.z());
     184                        plane.setValue(btScalar(0.),btScalar(0.),btScalar(-1.));
     185                        plane[3] = -halfExtents.z();
    180186                        break;
    181187                default:
    182                         btAssert(0);
     188                        assert(0);
    183189                }
    184190        }
     
    307313                        break;
    308314                default:
    309                         btAssert(0);
     315                        assert(0);
    310316                }
    311317        }
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btCollisionShape.cpp

    r2907 r2908  
    1515
    1616#include "BulletCollision/CollisionShapes/btCollisionShape.h"
    17 
    18 
    19 btScalar gContactThresholdFactor=btScalar(0.02);
    2017
    2118
     
    4845btScalar        btCollisionShape::getContactBreakingThreshold() const
    4946{
    50         return getAngularMotionDisc() * gContactThresholdFactor;
     47        ///@todo make this 0.1 configurable
     48        return getAngularMotionDisc() * btScalar(0.1);
    5149}
    5250btScalar        btCollisionShape::getAngularMotionDisc() const
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btCompoundShape.cpp

    r2907 r2908  
    2323m_collisionMargin(btScalar(0.)),
    2424m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.)),
    25 m_dynamicAabbTree(0),
    26 m_updateRevision(1)
     25m_dynamicAabbTree(0)
    2726{
    2827        m_shapeType = COMPOUND_SHAPE_PROXYTYPE;
     
    4847void    btCompoundShape::addChildShape(const btTransform& localTransform,btCollisionShape* shape)
    4948{
    50         m_updateRevision++;
    5149        //m_childTransforms.push_back(localTransform);
    5250        //m_childShapes.push_back(shape);
     
    5755        child.m_childMargin = shape->getMargin();
    5856
    59        
     57        m_children.push_back(child);
     58
    6059        //extend the local aabbMin/aabbMax
    6160        btVector3 localAabbMin,localAabbMax;
     
    7675        {
    7776                const btDbvtVolume      bounds=btDbvtVolume::FromMM(localAabbMin,localAabbMax);
    78                 int index = m_children.size();
     77                int index = m_children.size()-1;
    7978                child.m_node = m_dynamicAabbTree->insert(bounds,(void*)index);
    8079        }
    81 
    82         m_children.push_back(child);
    8380
    8481}
     
    103100void btCompoundShape::removeChildShapeByIndex(int childShapeIndex)
    104101{
    105         m_updateRevision++;
    106102        btAssert(childShapeIndex >=0 && childShapeIndex < m_children.size());
    107103        if (m_dynamicAabbTree)
     
    118114void btCompoundShape::removeChildShape(btCollisionShape* shape)
    119115{
    120         m_updateRevision++;
    121116        // Find the children containing the shape specified, and remove those children.
    122117        //note: there might be multiple children using the same shape!
     
    145140        // Recalculate the local aabb
    146141        // Brute force, it iterates over all the shapes left.
    147 
    148142        m_localAabbMin = btVector3(btScalar(1e30),btScalar(1e30),btScalar(1e30));
    149143        m_localAabbMax = btVector3(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
     
    168162{
    169163        btVector3 localHalfExtents = btScalar(0.5)*(m_localAabbMax-m_localAabbMin);
     164        localHalfExtents += btVector3(getMargin(),getMargin(),getMargin());
    170165        btVector3 localCenter = btScalar(0.5)*(m_localAabbMax+m_localAabbMin);
    171        
    172         //avoid an illegal AABB when there are no children
    173         if (!m_children.size())
    174         {
    175                 localHalfExtents.setValue(0,0,0);
    176                 localCenter.setValue(0,0,0);
    177         }
    178         localHalfExtents += btVector3(getMargin(),getMargin(),getMargin());
    179                
    180166
    181167        btMatrix3x3 abs_b = trans.getBasis().absolute(); 
     
    188174        aabbMin = center-extent;
    189175        aabbMax = center+extent;
    190        
     176
    191177}
    192178
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btCompoundShape.h

    r2907 r2908  
    5959
    6060        btDbvt*                                                 m_dynamicAabbTree;
    61 
    62         ///increment m_updateRevision when adding/removing/replacing child shapes, so that some caches can be updated
    63         int                                                             m_updateRevision;
    6461
    6562public:
     
    156153        void calculatePrincipalAxisTransform(btScalar* masses, btTransform& principal, btVector3& inertia) const;
    157154
    158         int     getUpdateRevision() const
    159         {
    160                 return m_updateRevision;
    161         }
    162155
    163156private:
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btConeShape.cpp

    r2907 r2908  
    6161                break;
    6262        default:
    63                 btAssert(0);
     63                assert(0);
    6464        };
    6565}
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btConvexHullShape.cpp

    r2907 r2908  
    182182bool btConvexHullShape::isInside(const btVector3& ,btScalar ) const
    183183{
    184         btAssert(0);
     184        assert(0);
    185185        return false;
    186186}
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp

    r2907 r2908  
    151151bool btConvexPointCloudShape::isInside(const btVector3& ,btScalar ) const
    152152{
    153         btAssert(0);
     153        assert(0);
    154154        return false;
    155155}
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btConvexShape.cpp

    r2907 r2908  
    155155
    156156                btCapsuleShape* capsuleShape = (btCapsuleShape*)this;
     157                btVector3 halfExtents = capsuleShape->getImplicitShapeDimensions();
    157158                btScalar halfHeight = capsuleShape->getHalfHeight();
    158159                int capsuleUpAxis = capsuleShape->getUpAxis();
     
    301302        {
    302303                btSphereShape* sphereShape = (btSphereShape*)this;
    303                 btScalar radius = sphereShape->getImplicitShapeDimensions().getX();// * convexShape->getLocalScaling().getX();
    304                 btScalar margin = radius + sphereShape->getMarginNonVirtual();
     304                float radius = sphereShape->getImplicitShapeDimensions().getX();// * convexShape->getLocalScaling().getX();
     305                float margin = radius + sphereShape->getMarginNonVirtual();
    305306                const btVector3& center = t.getOrigin();
    306307                btVector3 extent(margin,margin,margin);
     
    314315        {
    315316                btBoxShape* convexShape = (btBoxShape*)this;
    316                 btScalar margin=convexShape->getMarginNonVirtual();
     317                float margin=convexShape->getMarginNonVirtual();
    317318                btVector3 halfExtents = convexShape->getImplicitShapeDimensions();
    318319                halfExtents += btVector3(margin,margin,margin);
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp

    r2907 r2908  
    145145}
    146146
    147 
    148 /// This returns the "raw" (user's initial) height, not the actual height.
    149 /// The actual height needs to be adjusted to be relative to the center
    150 ///   of the heightfield's AABB.
    151 btScalar
    152 btHeightfieldTerrainShape::getRawHeightFieldValue(int x,int y) const
     147btScalar        btHeightfieldTerrainShape::getHeightFieldValue(int x,int y) const
    153148{
    154149        btScalar val = 0.f;
     
    187182
    188183
    189 /// this returns the vertex in bullet-local coordinates
     184
    190185void    btHeightfieldTerrainShape::getVertex(int x,int y,btVector3& vertex) const
    191186{
     187
    192188        btAssert(x>=0);
    193189        btAssert(y>=0);
     
    195191        btAssert(y<m_heightStickLength);
    196192
    197         btScalar        height = getRawHeightFieldValue(x,y);
     193
     194        btScalar        height = getHeightFieldValue(x,y);
    198195
    199196        switch (m_upAxis)
     
    202199                {
    203200                vertex.setValue(
    204                         height - m_localOrigin.getX(),
     201                        height,
    205202                        (-m_width/btScalar(2.0)) + x,
    206203                        (-m_length/btScalar(2.0) ) + y
     
    212209                        vertex.setValue(
    213210                        (-m_width/btScalar(2.0)) + x,
    214                         height - m_localOrigin.getY(),
     211                        height,
    215212                        (-m_length/btScalar(2.0)) + y
    216213                        );
     
    222219                        (-m_width/btScalar(2.0)) + x,
    223220                        (-m_length/btScalar(2.0)) + y,
    224                         height - m_localOrigin.getZ()
     221                        height
    225222                        );
    226223                        break;
     
    234231
    235232        vertex*=m_localScaling;
     233       
    236234}
    237235
     
    241239getQuantized
    242240(
    243 btScalar x
     241float x
    244242)
    245243{
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h

    r2907 r2908  
    3030  center (as determined by width and length and height, with each
    3131  axis multiplied by the localScaling).
    32 
    33   \b NOTE: be careful with coordinates.  If you have a heightfield with a local
    34   min height of -100m, and a max height of +500m, you may be tempted to place it
    35   at the origin (0,0) and expect the heights in world coordinates to be
    36   -100 to +500 meters.
    37   Actually, the heights will be -300 to +300m, because bullet will re-center
    38   the heightfield based on its AABB (which is determined by the min/max
    39   heights).  So keep in mind that once you create a btHeightfieldTerrainShape
    40   object, the heights will be adjusted relative to the center of the AABB.  This
    41   is different to the behavior of many rendering engines, but is useful for
    42   physics engines.
    4332
    4433  Most (but not all) rendering and heightfield libraries assume upAxis = 1
     
    10089        btVector3       m_localScaling;
    10190
    102         virtual btScalar        getRawHeightFieldValue(int x,int y) const;
     91        virtual btScalar        getHeightFieldValue(int x,int y) const;
    10392        void            quantizeWithClamp(int* out, const btVector3& point,int isMax) const;
    10493        void            getVertex(int x,int y,btVector3& vertex) const;
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp

    r2907 r2908  
    2929btVector3 btMinkowskiSumShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
    3030{
    31         btVector3 supVertexA = m_transA(m_shapeA->localGetSupportingVertexWithoutMargin(vec*m_transA.getBasis()));
    32         btVector3 supVertexB = m_transB(m_shapeB->localGetSupportingVertexWithoutMargin(-vec*m_transB.getBasis()));
     31        btVector3 supVertexA = m_transA(m_shapeA->localGetSupportingVertexWithoutMargin(-vec*m_transA.getBasis()));
     32        btVector3 supVertexB = m_transB(m_shapeB->localGetSupportingVertexWithoutMargin(vec*m_transB.getBasis()));
    3333        return  supVertexA - supVertexB;
    3434}
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h

    r2907 r2908  
    3232        BT_DECLARE_ALIGNED_ALLOCATOR();
    3333
    34     btMultimaterialTriangleMeshShape(): btBvhTriangleMeshShape() {m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;}
     34    btMultimaterialTriangleMeshShape(): btBvhTriangleMeshShape() {}
    3535    btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true):
    3636        btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, buildBvh)
    3737        {
    38             m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
    39 
    4038            btVector3 m_triangle[3];
    4139            const unsigned char *vertexbase;
     
    7068        btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, bvhAabbMin, bvhAabbMax, buildBvh)
    7169        {
    72             m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
    73 
    7470            btVector3 m_triangle[3];
    7571            const unsigned char *vertexbase;
     
    112108*/
    113109    }
     110        virtual int     getShapeType() const
     111        {
     112                return MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
     113        }
     114       
    114115        //debugging
    115116        virtual const char*     getName()const {return "MULTIMATERIALTRIANGLEMESH";}
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btSphereShape.h

    r2907 r2908  
    4848        btScalar        getRadius() const { return m_implicitShapeDimensions.getX() * m_localScaling.getX();}
    4949
    50         void    setUnscaledRadius(btScalar      radius)
    51         {
    52                 m_implicitShapeDimensions.setX(radius);
    53                 btConvexInternalShape::setMargin(radius);
    54         }
    55 
    5650        //debugging
    5751        virtual const char*     getName()const {return "SPHERE";}
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp

    r2907 r2908  
    8383}
    8484
    85 
    86 void    btTriangleIndexVertexArray::setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const
     85void    btTriangleIndexVertexArray::setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax )
    8786{
    8887        m_aabbMin = aabbMin;
     
    9796}
    9897
    99 
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h

    r2907 r2908  
    5353        IndexedMeshArray        m_indexedMeshes;
    5454        int m_pad[2];
    55         mutable int m_hasAabb; // using int instead of bool to maintain alignment
    56         mutable btVector3 m_aabbMin;
    57         mutable btVector3 m_aabbMax;
     55        int m_hasAabb; // using int instead of bool to maintain alignment
     56        btVector3 m_aabbMin;
     57        btVector3 m_aabbMax;
    5858
    5959public:
     
    107107
    108108        virtual bool    hasPremadeAabb() const;
    109         virtual void    setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const;
     109        virtual void    setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax );
    110110        virtual void    getPremadeAabb(btVector3* aabbMin, btVector3* aabbMax ) const;
    111111
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp

    r2907 r2908  
    1 
    21/*
    32Bullet Continuous Collision Detection and Physics Library
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleMesh.cpp

    r2907 r2908  
    3636        {
    3737                m_indexedMeshes[0].m_numTriangles = m_32bitIndices.size()/3;
    38                 m_indexedMeshes[0].m_triangleIndexBase = 0;
     38                m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_32bitIndices[0];
    3939                m_indexedMeshes[0].m_indexType = PHY_INTEGER;
    4040                m_indexedMeshes[0].m_triangleIndexStride = 3*sizeof(int);
     
    4242        {
    4343                m_indexedMeshes[0].m_numTriangles = m_16bitIndices.size()/3;
    44                 m_indexedMeshes[0].m_triangleIndexBase = 0;
     44                m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_16bitIndices[0];
    4545                m_indexedMeshes[0].m_indexType = PHY_SHORT;
    4646                m_indexedMeshes[0].m_triangleIndexStride = 3*sizeof(short int);
     
    5050        {
    5151                m_indexedMeshes[0].m_numVertices = m_4componentVertices.size();
    52                 m_indexedMeshes[0].m_vertexBase = 0;
     52                m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_4componentVertices[0];
    5353                m_indexedMeshes[0].m_vertexStride = sizeof(btVector3);
    5454        } else
    5555        {
    5656                m_indexedMeshes[0].m_numVertices = m_3componentVertices.size()/3;
    57                 m_indexedMeshes[0].m_vertexBase = 0;
     57                m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0];
    5858                m_indexedMeshes[0].m_vertexStride = 3*sizeof(btScalar);
    5959        }
     
    112112                        }
    113113        }
    114                 m_3componentVertices.push_back((float)vertex.getX());
    115                 m_3componentVertices.push_back((float)vertex.getY());
    116                 m_3componentVertices.push_back((float)vertex.getZ());
     114                m_3componentVertices.push_back(vertex.getX());
     115                m_3componentVertices.push_back(vertex.getY());
     116                m_3componentVertices.push_back(vertex.getZ());
    117117                m_indexedMeshes[0].m_numVertices++;
    118118                m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0];
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleMeshShape.h

    r2907 r2908  
    4141        virtual btVector3       localGetSupportingVertexWithoutMargin(const btVector3& vec)const
    4242        {
    43                 btAssert(0);
     43                assert(0);
    4444                return localGetSupportingVertex(vec);
    4545        }
  • code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/btGImpactBvh.cpp

    r2907 r2908  
    151151        }
    152152
    153         btAssert(!((splitIndex==startIndex) || (splitIndex == (endIndex))));
     153        bool unbal = (splitIndex==startIndex) || (splitIndex == (endIndex));
     154        btAssert(!unbal);
    154155
    155156        return splitIndex;
  • code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/btGImpactQuantizedBvh.cpp

    r2907 r2908  
    172172        }
    173173
    174         btAssert(!((splitIndex==startIndex) || (splitIndex == (endIndex))));
     174        bool unbal = (splitIndex==startIndex) || (splitIndex == (endIndex));
     175        btAssert(!unbal);
    175176
    176177        return splitIndex;
  • code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/btGImpactShape.h

    r2907 r2908  
    882882class btGImpactMeshShape : public btGImpactShapeInterface
    883883{
    884         btStridingMeshInterface* m_meshInterface;
    885 
    886884protected:
    887885        btAlignedObjectArray<btGImpactMeshShapePart*> m_mesh_parts;
     
    910908        btGImpactMeshShape(btStridingMeshInterface * meshInterface)
    911909        {
    912                 m_meshInterface = meshInterface;
    913910                buildMeshParts(meshInterface);
    914911        }
     
    926923
    927924
    928         btStridingMeshInterface* getMeshInterface()
    929         {
    930                 return m_meshInterface;
    931         }
    932 
    933         const btStridingMeshInterface* getMeshInterface() const
    934         {
    935                 return m_meshInterface;
    936         }
    937925
    938926        int getMeshPartCount() const
     
    10461034
    10471035        //! call when reading child shapes
    1048         virtual void lockChildShapes() const
    1049         {
    1050                 btAssert(0);
    1051         }
    1052 
    1053         virtual void unlockChildShapes() const
     1036        virtual void lockChildShapes()
     1037        {
     1038                btAssert(0);
     1039        }
     1040
     1041        virtual void unlockChildShapes()
    10541042        {
    10551043                btAssert(0);
  • code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/gim_box_set.cpp

    r2907 r2908  
    111111        }
    112112
    113         btAssert(!((splitIndex==startIndex) || (splitIndex == (endIndex))));
     113        bool unbal = (splitIndex==startIndex) || (splitIndex == (endIndex));
     114        btAssert(!unbal);
    114115
    115116        return splitIndex;
     
    180181}
    181182
    182 
  • code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/gim_math.h

    r2907 r2908  
    108108#define GIM_CLAMP(number,minval,maxval) (number<minval?minval:(number>maxval?maxval:number))
    109109
    110 #define GIM_GREATER(x, y)       btFabs(x) > (y)
     110#define GIM_GREATER(x, y)       fabsf(x) > (y)
    111111
    112112///Swap numbers
  • code/branches/questsystem5/src/bullet/BulletCollision/Gimpact/gim_tri_collision.h

    r2907 r2908  
    276276                else
    277277                {
    278                         btScalar sumuv;
     278                        float sumuv;
    279279                        sumuv = u+v;
    280280                        if(sumuv<-G_EPSILON)
  • code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp

    r2907 r2908  
    136136                        //btScalar clippedDist  = dist;
    137137                       
    138                         //don't report time of impact for motion away from the contact normal (or causes minor penetration)
    139                         if ((projectedLinearVelocity+ maxAngularProjectedVelocity)<=SIMD_EPSILON)
    140                                 return false;
    141138                       
    142139                        dLambda = dist / (projectedLinearVelocity+ maxAngularProjectedVelocity);
     
    200197
    201198                }
    202        
     199
     200                //don't report time of impact for motion away from the contact normal (or causes minor penetration)
    203201                if ((projectedLinearVelocity+ maxAngularProjectedVelocity)<=result.m_allowedPenetration)//SIMD_EPSILON)
    204202                        return false;
    205                        
     203
    206204                result.m_fraction = lambda;
    207205                result.m_normal = n;
  • code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp

    r2907 r2908  
    151151                        if ((delta > btScalar(0.0)) && (delta * delta > squaredDistance * input.m_maximumDistanceSquared))
    152152                        {
    153                                 checkSimplex=true;
    154                                 //checkPenetration = false;
     153                                checkPenetration = false;
    155154                                break;
    156155                        }
  • code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h

    r2907 r2908  
    113113                        }
    114114                       
    115                         ///this returns the most recent applied impulse, to satisfy contact constraints by the constraint solver
    116                         btScalar        getAppliedImpulse() const
    117                         {
    118                                 return m_appliedImpulse;
    119                         }
    120 
    121115                       
    122116
  • code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp

    r2907 r2908  
    184184               
    185185        }
    186         if (insertIndex<0)
    187                 insertIndex=0;
    188 
    189186        btAssert(m_pointCache[insertIndex].m_userPersistentData==0);
    190187        m_pointCache[insertIndex] = newPoint;
  • code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h

    r2907 r2908  
    5656
    5757        btScalar        m_contactBreakingThreshold;
    58         btScalar        m_contactProcessingThreshold;
    5958
    6059       
     
    7271        btPersistentManifold();
    7372
    74         btPersistentManifold(void* body0,void* body1,int , btScalar contactBreakingThreshold,btScalar contactProcessingThreshold)
     73        btPersistentManifold(void* body0,void* body1,int , btScalar contactBreakingThreshold)
    7574                : m_body0(body0),m_body1(body1),m_cachedPoints(0),
    76                 m_contactBreakingThreshold(contactBreakingThreshold),
    77                 m_contactProcessingThreshold(contactProcessingThreshold)
     75                m_contactBreakingThreshold(contactBreakingThreshold)
    7876        {
    7977               
     
    114112        ///@todo: get this margin from the current physics / collision environment
    115113        btScalar        getContactBreakingThreshold() const;
    116 
    117         btScalar        getContactProcessingThreshold() const
    118         {
    119                 return m_contactProcessingThreshold;
    120         }
    121114       
    122115        int getCacheEntry(const btManifoldPoint& newPoint) const;
  • code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btRaycastCallback.cpp

    r2907 r2908  
    2424#include "btRaycastCallback.h"
    2525
    26 btTriangleRaycastCallback::btTriangleRaycastCallback(const btVector3& from,const btVector3& to, unsigned int flags)
     26btTriangleRaycastCallback::btTriangleRaycastCallback(const btVector3& from,const btVector3& to)
    2727        :
    2828        m_from(from),
    2929        m_to(to),
    30    //@BP Mod
    31    m_flags(flags),
    3230        m_hitFraction(btScalar(1.))
    3331{
     
    5856                return ; // same sign
    5957        }
    60    //@BP Mod - Backface filtering
    61    if (((m_flags & kF_FilterBackfaces) != 0) && (dist_a > btScalar(0.0)))
    62    {
    63       // Backface, skip check
    64       return;
    65    }
    6658       
    6759        const btScalar proj_length=dist_a-dist_b;
     
    9890                                        if ( (btScalar)(cp2.dot(triangleNormal)) >=edge_tolerance)
    9991                                        {
    100                   //@BP Mod
    101                   // Triangle normal isn't normalized
    102                                       triangleNormal.normalize();
    10392
    104                   //@BP Mod - Allow for unflipped normal when raycasting against backfaces
    105                   if (((m_flags & kF_KeepUnflippedNormal) != 0) || (dist_a <= btScalar(0.0)))
     93                                                if ( dist_a > 0 )
    10694                                                {
    107                                                         m_hitFraction = reportHit(-triangleNormal,distance,partId,triangleIndex);
     95                                                        m_hitFraction = reportHit(triangleNormal,distance,partId,triangleIndex);
    10896                                                }
    10997                                                else
    11098                                                {
    111                      m_hitFraction = reportHit(triangleNormal,distance,partId,triangleIndex);
     99                                                        m_hitFraction = reportHit(-triangleNormal,distance,partId,triangleIndex);
    112100                                                }
    113101                                        }
  • code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h

    r2907 r2908  
    3030        btVector3 m_to;
    3131
    32    //@BP Mod - allow backface filtering and unflipped normals
    33    enum EFlags
    34    {
    35       kF_None                 = 0,
    36       kF_FilterBackfaces      = 1 << 0,
    37       kF_KeepUnflippedNormal  = 1 << 1,   // Prevents returned face normal getting flipped when a ray hits a back-facing triangle
    38 
    39       kF_Terminator        = 0xFFFFFFFF
    40    };
    41    unsigned int m_flags;
    42 
    4332        btScalar        m_hitFraction;
    4433
    45         btTriangleRaycastCallback(const btVector3& from,const btVector3& to, unsigned int flags=0);
     34        btTriangleRaycastCallback(const btVector3& from,const btVector3& to);
    4635       
    4736        virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex);
  • code/branches/questsystem5/src/bullet/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp

    r2907 r2908  
    2626
    2727#include "btVoronoiSimplexSolver.h"
     28#include <assert.h>
     29//#include <stdio.h>
    2830
    2931#define VERTA  0
     
    3638{
    3739       
    38         btAssert(m_numVertices>0);
     40        assert(m_numVertices>0);
    3941        m_numVertices--;
    4042        m_simplexVectorW[index] = m_simplexVectorW[m_numVertices];
Note: See TracChangeset for help on using the changeset viewer.