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