- Timestamp:
- Apr 8, 2009, 12:58:47 AM (16 years ago)
- Location:
- code/branches/questsystem5
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem5
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btAxisSweep3.cpp
r2907 r2908 20 20 #include "btAxisSweep3.h" 21 21 22 #include <assert.h> 22 23 23 24 btAxisSweep3::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 43 43 public: 44 44 45 BT_DECLARE_ALIGNED_ALLOCATOR();46 45 47 46 class Edge … … 140 139 SIMD_FORCE_INLINE Handle* getHandle(BP_FP_INT_TYPE index) const {return m_pHandles + index;} 141 140 142 v irtual void resetPool(btDispatcher* dispatcher);141 void resetPool(); 143 142 144 143 void processAllOverlappingPairs(btOverlapCallback* callback); … … 222 221 223 222 if (checkCardinality) 224 btAssert(numEdges == m_numHandles*2+1);223 assert(numEdges == m_numHandles*2+1); 225 224 } 226 225 #endif //DEBUG_BROADPHASE … … 348 347 } 349 348 350 // btAssert(bounds.HasVolume());349 //assert(bounds.HasVolume()); 351 350 352 351 // init bounds … … 454 453 BP_FP_INT_TYPE btAxisSweep3Internal<BP_FP_INT_TYPE>::allocHandle() 455 454 { 456 btAssert(m_firstFreeHandle);455 assert(m_firstFreeHandle); 457 456 458 457 BP_FP_INT_TYPE handle = m_firstFreeHandle; … … 466 465 void btAxisSweep3Internal<BP_FP_INT_TYPE>::freeHandle(BP_FP_INT_TYPE handle) 467 466 { 468 btAssert(handle > 0 && handle < m_maxHandles);467 assert(handle > 0 && handle < m_maxHandles); 469 468 470 469 getHandle(handle)->SetNextFree(m_firstFreeHandle); … … 589 588 590 589 template <typename BP_FP_INT_TYPE> 591 void btAxisSweep3Internal<BP_FP_INT_TYPE>::resetPool( btDispatcher* dispatcher)590 void btAxisSweep3Internal<BP_FP_INT_TYPE>::resetPool() 592 591 { 593 592 if (m_numHandles == 0) … … 643 642 if (!isDuplicate) 644 643 { 645 ///important to use an AABB test that is consistent with the broadphase646 644 bool hasOverlap = testAabbOverlap(pair.m_pProxy0,pair.m_pProxy1); 647 645 … … 689 687 } 690 688 689 690 691 692 691 693 } 692 694 … … 729 731 void btAxisSweep3Internal<BP_FP_INT_TYPE>::updateHandle(BP_FP_INT_TYPE handle, const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher) 730 732 { 731 // btAssert(bounds.IsFinite());732 // btAssert(bounds.HasVolume());733 // assert(bounds.IsFinite()); 734 //assert(bounds.HasVolume()); 733 735 734 736 Handle* pHandle = getHandle(handle); -
code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btBroadphaseInterface.h
r2907 r2908 65 65 virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const =0; 66 66 67 ///reset broadphase internal structures, to ensure determinism/reproducability68 virtual void resetPool(btDispatcher* dispatcher) {};69 70 67 virtual void printStats() = 0; 71 68 -
code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h
r2907 r2908 70 70 71 71 SOFTBODY_SHAPE_PROXYTYPE, 72 HFFLUID_SHAPE_PROXYTYPE, 73 HFFLUID_BUOYANT_CONVEX_SHAPE_PROXYTYPE, 72 74 73 INVALID_SHAPE_PROXYTYPE, 75 74 … … 189 188 190 189 //keep them sorted, so the std::set operations work 191 if ( proxy0.m_uniqueId < proxy1.m_uniqueId)190 if (&proxy0 < &proxy1) 192 191 { 193 192 m_pProxy0 = &proxy0; … … 230 229 bool operator() ( const btBroadphasePair& a, const btBroadphasePair& b ) 231 230 { 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) || 239 233 (a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 == b.m_pProxy1 && a.m_algorithm > b.m_algorithm); 240 234 } -
code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btDbvt.cpp
r2907 r2908 394 394 } 395 395 396 #if 0 396 // 397 397 static DBVT_INLINE btDbvtNode* walkup(btDbvtNode* n,int count) 398 398 { … … 400 400 return(n); 401 401 } 402 #endif403 402 404 403 // … … 425 424 void btDbvt::clear() 426 425 { 427 if(m_root) 428 recursedeletenode(this,m_root); 426 if(m_root) recursedeletenode(this,m_root); 429 427 btAlignedFree(m_free); 430 428 m_free=0; 431 m_lkhd = -1;432 m_stkStack.clear();433 m_opath = 0;434 435 429 } 436 430 -
code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btDbvt.h
r2907 r2908 58 58 59 59 //SSE gives errors on a MSVC 7.1 60 #if def BT_USE_SSE60 #if (defined (WIN32) && (_MSC_VER) && _MSC_VER >= 1400) && (!defined (BT_USE_DOUBLE_PRECISION)) 61 61 #define DBVT_SELECT_IMPL DBVT_IMPL_SSE 62 62 #define DBVT_MERGE_IMPL DBVT_IMPL_SSE … … 83 83 #define DBVT_PREFIX template <typename T> 84 84 #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; 86 86 #else 87 87 #define DBVT_VIRTUAL_DTOR(a) virtual ~a() {} … … 147 147 DBVT_INLINE friend bool Intersect( const btDbvtAabbMm& a, 148 148 const btDbvtAabbMm& b); 149 149 DBVT_INLINE friend bool Intersect( const btDbvtAabbMm& a, 150 const btDbvtAabbMm& b, 151 const btTransform& xform); 150 152 DBVT_INLINE friend bool Intersect( const btDbvtAabbMm& a, 151 153 const btVector3& b); … … 303 305 const btDbvtNode* root1, 304 306 DBVT_IPOLICY); 305 #if 0 307 306 308 DBVT_PREFIX 307 309 void collideTT( const btDbvtNode* root0, … … 315 317 const btTransform& xform1, 316 318 DBVT_IPOLICY); 317 #endif318 319 319 DBVT_PREFIX 320 320 void collideTV( const btDbvtNode* root, … … 531 531 } 532 532 533 533 // 534 DBVT_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 } 534 548 535 549 // … … 835 849 } 836 850 837 #if 0 851 838 852 // 839 853 DBVT_PREFIX … … 891 905 } 892 906 } 907 893 908 // 894 909 DBVT_PREFIX … … 902 917 collideTT(root0,root1,xform,policy); 903 918 } 904 #endif905 919 906 920 // -
code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btDbvtBroadphase.cpp
r2907 r2908 101 101 btDbvtProxy* pb=(btDbvtProxy*)nb->data; 102 102 #if DBVT_BP_SORTPAIRS 103 if(pa->m_uniqueId>pb->m_uniqueId) 104 btSwap(pa,pb); 103 if(pa>pb) btSwap(pa,pb); 105 104 #endif 106 105 pbp->m_paircache->addOverlappingPair(pa,pb); … … 134 133 m_updates_done = 0; 135 134 m_updates_ratio = 0; 136 m_paircache = paircache? paircache : new(btAlignedAlloc(sizeof(btHashedOverlappingPairCache),16)) btHashedOverlappingPairCache(); 135 m_paircache = paircache? 136 paircache : 137 new(btAlignedAlloc(sizeof(btHashedOverlappingPairCache),16)) btHashedOverlappingPairCache(); 137 138 m_gid = 0; 138 139 m_pid = 0; … … 210 211 } 211 212 212 struct BroadphaseRayTester : btDbvt::ICollide213 {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 226 213 void btDbvtBroadphase::rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback,const btVector3& aabbMin,const btVector3& aabbMax) 227 214 { 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 228 230 BroadphaseRayTester callback(rayCallback); 229 231 … … 340 342 } 341 343 #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 end356 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 broadphase383 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 } else391 {392 needsRemoval = true;393 }394 } else395 {396 //remove duplicate397 needsRemoval = true;398 //should have no algorithm399 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 end414 overlappingPairArray.quickSort(btBroadphasePairSortPredicate());415 overlappingPairArray.resize(overlappingPairArray.size() - invalidPair);416 }417 344 } 418 345 … … 420 347 void btDbvtBroadphase::collide(btDispatcher* dispatcher) 421 348 { 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 439 349 SPC(m_profiling.m_total); 440 350 /* optimize */ … … 492 402 if(pairs.size()>0) 493 403 { 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)); 496 406 for(int i=0;i<ni;++i) 497 407 { 498 btBroadphasePair& p=pairs[(m_cid+i)% pairs.size()];408 btBroadphasePair& p=pairs[(m_cid+i)%ci]; 499 409 btDbvtProxy* pa=(btDbvtProxy*)p.m_pProxy0; 500 410 btDbvtProxy* pb=(btDbvtProxy*)p.m_pProxy1; … … 502 412 { 503 413 #if DBVT_BP_SORTPAIRS 504 if(pa->m_uniqueId>pb->m_uniqueId) 505 btSwap(pa,pb); 414 if(pa>pb) btSwap(pa,pb); 506 415 #endif 507 416 m_paircache->removeOverlappingPair(pa,pb,dispatcher); … … 558 467 aabbMin=bounds.Mins(); 559 468 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 structures569 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 }593 469 } 594 470 … … 725 601 #undef SPC 726 602 #endif 727 -
code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btDbvtBroadphase.h
r2907 r2908 25 25 26 26 #define DBVT_BP_PROFILE 0 27 //#define DBVT_BP_SORTPAIRS 127 #define DBVT_BP_SORTPAIRS 1 28 28 #define DBVT_BP_PREVENTFALSEUPDATE 0 29 29 #define DBVT_BP_ACCURATESLEEPING 0 … … 115 115 void printStats(); 116 116 static void benchmark(btBroadphaseInterface*); 117 118 119 void performDeferredRemoval(btDispatcher* dispatcher);120 121 ///reset broadphase internal structures, to ensure determinism/reproducability122 virtual void resetPool(btDispatcher* dispatcher);123 124 117 }; 125 118 -
code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp
r2907 r2908 483 483 484 484 } 485 486 void btMultiSapBroadphase::resetPool(btDispatcher* dispatcher)487 {488 // not yet489 } -
code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h
r2907 r2908 144 144 void quicksort (btBroadphasePairArray& a, int lo, int hi); 145 145 146 ///reset broadphase internal structures, to ensure determinism/reproducability147 virtual void resetPool(btDispatcher* dispatcher);148 149 146 }; 150 147 -
code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp
r2907 r2908 20 20 #include "btDispatcher.h" 21 21 #include "btCollisionAlgorithm.h" 22 #include "LinearMath/btAabbUtil2.h"23 22 24 23 #include <stdio.h> … … 137 136 { 138 137 gFindPairs++; 139 if(proxy0->m_uniqueId>proxy1->m_uniqueId) 140 btSwap(proxy0,proxy1); 138 if(proxy0>proxy1) btSwap(proxy0,proxy1); 141 139 int proxyId1 = proxy0->getUid(); 142 140 int proxyId2 = proxy1->getUid(); … … 214 212 btBroadphasePair* btHashedOverlappingPairCache::internalAddPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) 215 213 { 216 if(proxy0->m_uniqueId>proxy1->m_uniqueId) 217 btSwap(proxy0,proxy1); 214 if(proxy0>proxy1) btSwap(proxy0,proxy1); 218 215 int proxyId1 = proxy0->getUid(); 219 216 int proxyId2 = proxy1->getUid(); … … 274 271 { 275 272 gRemovePairs++; 276 if(proxy0->m_uniqueId>proxy1->m_uniqueId) 277 btSwap(proxy0,proxy1); 273 if(proxy0>proxy1) btSwap(proxy0,proxy1); 278 274 int proxyId1 = proxy0->getUid(); 279 275 int proxyId2 = proxy1->getUid(); … … 397 393 } 398 394 399 void btHashedOverlappingPairCache::sortOverlappingPairs(btDispatcher* dispatcher)400 {401 ///need to keep hashmap in sync with pair address, so rebuild all402 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 }428 395 429 396 … … 463 430 { 464 431 //don't add overlap with own 465 btAssert(proxy0 != proxy1);432 assert(proxy0 != proxy1); 466 433 467 434 if (!needsBroadphaseCollision(proxy0,proxy1)) … … 494 461 if (findIndex < m_overlappingPairArray.size()) 495 462 { 496 // btAssert(it != m_overlappingPairSet.end());463 //assert(it != m_overlappingPairSet.end()); 497 464 btBroadphasePair* pair = &m_overlappingPairArray[findIndex]; 498 465 return pair; … … 524 491 { 525 492 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); 529 495 m_overlappingPairArray.pop_back(); 530 496 gOverlappingPairs--; … … 626 592 processAllOverlappingPairs(&removeCallback,dispatcher); 627 593 } 628 629 void btSortedOverlappingPairCache::sortOverlappingPairs(btDispatcher* dispatcher)630 {631 //should already be sorted632 }633 -
code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h
r2907 r2908 84 84 85 85 virtual void setInternalGhostPairCallback(btOverlappingPairCallback* ghostPairCallback)=0; 86 87 virtual void sortOverlappingPairs(btDispatcher* dispatcher) = 0;88 89 86 90 87 }; … … 263 260 } 264 261 265 virtual void sortOverlappingPairs(btDispatcher* dispatcher); 266 267 268 protected: 262 public: 269 263 270 264 btAlignedObjectArray<int> m_hashTable; … … 376 370 } 377 371 378 virtual void sortOverlappingPairs(btDispatcher* dispatcher);379 380 372 381 373 }; … … 456 448 } 457 449 458 virtual void sortOverlappingPairs(btDispatcher* dispatcher)459 {460 }461 450 462 451 -
code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp
r2907 r2908 470 470 471 471 #ifdef RAYAABB2 472 btVector3 rayFrom = raySource; 472 473 btVector3 rayDir = (rayTarget-raySource); 473 474 rayDir.normalize (); … … 558 559 559 560 #ifdef RAYAABB2 561 btVector3 rayFrom = raySource; 560 562 btVector3 rayDirection = (rayTarget-raySource); 561 563 rayDirection.normalize (); … … 816 818 #include <new> 817 819 818 #if 0819 820 //PCK: consts 820 821 static const unsigned BVH_ALIGNMENT = 16; … … 822 823 823 824 static const unsigned BVH_ALIGNMENT_BLOCKS = 2; 824 #endif 825 825 826 826 827 … … 1146 1147 1147 1148 1148 -
code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp
r2907 r2908 325 325 } 326 326 327 void btSimpleBroadphase::resetPool(btDispatcher* dispatcher) 328 { 329 //not yet 330 } 327 328 -
code/branches/questsystem5/src/bullet/BulletCollision/BroadphaseCollision/btSimpleBroadphase.h
r2907 r2908 109 109 } 110 110 111 ///reset broadphase internal structures, to ensure determinism/reproducability112 virtual void resetPool(btDispatcher* dispatcher);113 114 111 115 112 void validate();
Note: See TracChangeset
for help on using the changeset viewer.