- Timestamp:
- Apr 28, 2011, 7:15:14 AM (14 years ago)
- Location:
- code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btAxisSweep3.h
r5781 r8351 151 151 152 152 virtual void rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin=btVector3(0,0,0), const btVector3& aabbMax = btVector3(0,0,0)); 153 virtual void aabbTest(const btVector3& aabbMin, const btVector3& aabbMax, btBroadphaseAabbCallback& callback); 154 153 155 154 156 void quantize(BP_FP_INT_TYPE* out, const btVector3& point, int isMax) const; … … 281 283 { 282 284 rayCallback.process(getHandle(m_pEdges[axis][i].m_handle)); 285 } 286 } 287 } 288 } 289 290 template <typename BP_FP_INT_TYPE> 291 void btAxisSweep3Internal<BP_FP_INT_TYPE>::aabbTest(const btVector3& aabbMin, const btVector3& aabbMax, btBroadphaseAabbCallback& callback) 292 { 293 if (m_raycastAccelerator) 294 { 295 m_raycastAccelerator->aabbTest(aabbMin,aabbMax,callback); 296 } else 297 { 298 //choose axis? 299 BP_FP_INT_TYPE axis = 0; 300 //for each proxy 301 for (BP_FP_INT_TYPE i=1;i<m_numHandles*2+1;i++) 302 { 303 if (m_pEdges[axis][i].IsMax()) 304 { 305 Handle* handle = getHandle(m_pEdges[axis][i].m_handle); 306 if (TestAabbAgainstAabb2(aabbMin,aabbMax,handle->m_aabbMin,handle->m_aabbMax)) 307 { 308 callback.process(handle); 309 } 283 310 } 284 311 } -
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btBroadphaseInterface.h
r5781 r8351 27 27 28 28 29 struct btBroadphaseRayCallback 29 struct btBroadphaseAabbCallback 30 { 31 virtual ~btBroadphaseAabbCallback() {} 32 virtual bool process(const btBroadphaseProxy* proxy) = 0; 33 }; 34 35 36 struct btBroadphaseRayCallback : public btBroadphaseAabbCallback 30 37 { 31 38 ///added some cached data to accelerate ray-AABB tests … … 35 42 36 43 virtual ~btBroadphaseRayCallback() {} 37 virtual bool process(const btBroadphaseProxy* proxy) = 0;38 44 }; 39 45 … … 55 61 virtual void rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin=btVector3(0,0,0), const btVector3& aabbMax = btVector3(0,0,0)) = 0; 56 62 63 virtual void aabbTest(const btVector3& aabbMin, const btVector3& aabbMax, btBroadphaseAabbCallback& callback) = 0; 64 57 65 ///calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during the set aabb 58 66 virtual void calculateOverlappingPairs(btDispatcher* dispatcher)=0; … … 66 74 67 75 ///reset broadphase internal structures, to ensure determinism/reproducability 68 virtual void resetPool(btDispatcher* dispatcher) { };76 virtual void resetPool(btDispatcher* dispatcher) { (void) dispatcher; }; 69 77 70 78 virtual void printStats() = 0; -
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h
r5781 r8351 47 47 MINKOWSKI_SUM_SHAPE_PROXYTYPE, 48 48 MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE, 49 BOX_2D_SHAPE_PROXYTYPE, 50 CONVEX_2D_SHAPE_PROXYTYPE, 49 51 CUSTOM_CONVEX_SHAPE_TYPE, 50 52 //concave shapes … … 140 142 } 141 143 144 static SIMD_FORCE_INLINE bool isNonMoving(int proxyType) 145 { 146 return (isConcave(proxyType) && !(proxyType==GIMPACT_SHAPE_PROXYTYPE)); 147 } 148 142 149 static SIMD_FORCE_INLINE bool isConcave(int proxyType) 143 150 { … … 149 156 return (proxyType == COMPOUND_SHAPE_PROXYTYPE); 150 157 } 158 159 static SIMD_FORCE_INLINE bool isSoftBody(int proxyType) 160 { 161 return (proxyType == SOFTBODY_SHAPE_PROXYTYPE); 162 } 163 151 164 static SIMD_FORCE_INLINE bool isInfinite(int proxyType) 152 165 { 153 166 return (proxyType == STATIC_PLANE_PROXYTYPE); 154 167 } 168 169 static SIMD_FORCE_INLINE bool isConvex2d(int proxyType) 170 { 171 return (proxyType == BOX_2D_SHAPE_PROXYTYPE) || (proxyType == CONVEX_2D_SHAPE_PROXYTYPE); 172 } 173 155 174 156 175 } -
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btDbvt.cpp
r5781 r8351 62 62 { 63 63 getmaxdepth(node->childs[0],depth+1,maxdepth); 64 getmaxdepth(node->childs[ 0],depth+1,maxdepth);64 getmaxdepth(node->childs[1],depth+1,maxdepth); 65 65 } else maxdepth=btMax(maxdepth,depth); 66 66 } … … 239 239 for(int i=0,ni=leaves.size();i<ni;++i) 240 240 { 241 if( dot(axis,leaves[i]->volume.Center()-org)<0)241 if(btDot(axis,leaves[i]->volume.Center()-org)<0) 242 242 left.push_back(leaves[i]); 243 243 else … … 320 320 for(int j=0;j<3;++j) 321 321 { 322 ++splitcount[j][ dot(x,axis[j])>0?1:0];322 ++splitcount[j][btDot(x,axis[j])>0?1:0]; 323 323 } 324 324 } -
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btDbvt.h
r5781 r8351 33 33 34 34 // Template implementation of ICollide 35 #ifdef WIN3235 #ifdef _WIN32 36 36 #if (defined (_MSC_VER) && _MSC_VER >= 1400) 37 37 #define DBVT_USE_TEMPLATE 1 … … 58 58 59 59 //SSE gives errors on a MSVC 7.1 60 #if def BT_USE_SSE60 #if defined (BT_USE_SSE) && defined (_WIN32) 61 61 #define DBVT_SELECT_IMPL DBVT_IMPL_SSE 62 62 #define DBVT_MERGE_IMPL DBVT_IMPL_SSE … … 93 93 94 94 #if DBVT_USE_MEMMOVE 95 #if ndef __CELLOS_LV2__95 #if !defined( __CELLOS_LV2__) && !defined(__MWERKS__) 96 96 #include <memory.h> 97 97 #endif … … 485 485 pi=btVector3(mi.x(),mi.y(),mi.z());break; 486 486 } 487 if(( dot(n,px)+o)<0) return(-1);488 if(( dot(n,pi)+o)>=0) return(+1);487 if((btDot(n,px)+o)<0) return(-1); 488 if((btDot(n,pi)+o)>=0) return(+1); 489 489 return(0); 490 490 } … … 497 497 b[(signs>>1)&1]->y(), 498 498 b[(signs>>2)&1]->z()); 499 return( dot(p,v));499 return(btDot(p,v)); 500 500 } 501 501 … … 948 948 DBVT_IPOLICY) const 949 949 { 950 (void) rayTo; 950 951 DBVT_CHECKTYPE 951 952 if(root) … … 962 963 { 963 964 const btDbvtNode* node=stack[--depth]; 964 bounds[0] = node->volume.Mins() +aabbMin;965 bounds[1] = node->volume.Maxs() +aabbMax;965 bounds[0] = node->volume.Mins()-aabbMax; 966 bounds[1] = node->volume.Maxs()-aabbMin; 966 967 btScalar tmin=1.f,lambda_min=0.f; 967 968 unsigned int result1=false; … … 1001 1002 rayDir.normalize (); 1002 1003 1003 ///what about division by zero? --> just set rayDirection[i] to INF/ 1e301004 ///what about division by zero? --> just set rayDirection[i] to INF/BT_LARGE_FLOAT 1004 1005 btVector3 rayDirectionInverse; 1005 rayDirectionInverse[0] = rayDir[0] == btScalar(0.0) ? btScalar( 1e30) : btScalar(1.0) / rayDir[0];1006 rayDirectionInverse[1] = rayDir[1] == btScalar(0.0) ? btScalar( 1e30) : btScalar(1.0) / rayDir[1];1007 rayDirectionInverse[2] = rayDir[2] == btScalar(0.0) ? btScalar( 1e30) : btScalar(1.0) / rayDir[2];1006 rayDirectionInverse[0] = rayDir[0] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[0]; 1007 rayDirectionInverse[1] = rayDir[1] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[1]; 1008 rayDirectionInverse[2] = rayDir[2] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[2]; 1008 1009 unsigned int signs[3] = { rayDirectionInverse[0] < 0.0, rayDirectionInverse[1] < 0.0, rayDirectionInverse[2] < 0.0}; 1009 1010 -
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btDbvtBroadphase.cpp
r5781 r8351 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 7 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 13 13 3. This notice may not be removed or altered from any source distribution. 14 14 */ 15 15 16 ///btDbvtBroadphase implementation by Nathanael Presson 16 17 … … 124 125 m_needcleanup = true; 125 126 m_releasepaircache = (paircache!=0)?false:true; 126 m_prediction = 1/(btScalar)2;127 m_prediction = 0; 127 128 m_stageCurrent = 0; 128 129 m_fixedleft = 0; … … 250 251 } 251 252 253 254 struct BroadphaseAabbTester : btDbvt::ICollide 255 { 256 btBroadphaseAabbCallback& m_aabbCallback; 257 BroadphaseAabbTester(btBroadphaseAabbCallback& orgCallback) 258 :m_aabbCallback(orgCallback) 259 { 260 } 261 void Process(const btDbvtNode* leaf) 262 { 263 btDbvtProxy* proxy=(btDbvtProxy*)leaf->data; 264 m_aabbCallback.process(proxy); 265 } 266 }; 267 268 void btDbvtBroadphase::aabbTest(const btVector3& aabbMin,const btVector3& aabbMax,btBroadphaseAabbCallback& aabbCallback) 269 { 270 BroadphaseAabbTester callback(aabbCallback); 271 272 const ATTRIBUTE_ALIGNED16(btDbvtVolume) bounds=btDbvtVolume::FromMM(aabbMin,aabbMax); 273 //process all children, that overlap with the given AABB bounds 274 m_sets[0].collideTV(m_sets[0].m_root,bounds,callback); 275 m_sets[1].collideTV(m_sets[1].m_root,bounds,callback); 276 277 } 278 279 280 252 281 // 253 282 void btDbvtBroadphase::setAabb( btBroadphaseProxy* absproxy, … … 315 344 } 316 345 } 346 } 347 348 349 // 350 void btDbvtBroadphase::setAabbForceUpdate( btBroadphaseProxy* absproxy, 351 const btVector3& aabbMin, 352 const btVector3& aabbMax, 353 btDispatcher* /*dispatcher*/) 354 { 355 btDbvtProxy* proxy=(btDbvtProxy*)absproxy; 356 ATTRIBUTE_ALIGNED16(btDbvtVolume) aabb=btDbvtVolume::FromMM(aabbMin,aabbMax); 357 bool docollide=false; 358 if(proxy->stage==STAGECOUNT) 359 {/* fixed -> dynamic set */ 360 m_sets[1].remove(proxy->leaf); 361 proxy->leaf=m_sets[0].insert(aabb,proxy); 362 docollide=true; 363 } 364 else 365 {/* dynamic set */ 366 ++m_updates_call; 367 /* Teleporting */ 368 m_sets[0].update(proxy->leaf,aabb); 369 ++m_updates_done; 370 docollide=true; 371 } 372 listremove(proxy,m_stageRoots[proxy->stage]); 373 proxy->m_aabbMin = aabbMin; 374 proxy->m_aabbMax = aabbMax; 375 proxy->stage = m_stageCurrent; 376 listappend(proxy,m_stageRoots[m_stageCurrent]); 377 if(docollide) 378 { 379 m_needcleanup=true; 380 if(!m_deferedcollide) 381 { 382 btDbvtTreeCollider collider(this); 383 m_sets[1].collideTTpersistentStack(m_sets[1].m_root,proxy->leaf,collider); 384 m_sets[0].collideTTpersistentStack(m_sets[0].m_root,proxy->leaf,collider); 385 } 386 } 317 387 } 318 388 … … 572 642 m_deferedcollide = false; 573 643 m_needcleanup = true; 574 m_prediction = 1/(btScalar)2;575 644 m_stageCurrent = 0; 576 645 m_fixedleft = 0; -
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btDbvtBroadphase.h
r5781 r8351 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 7 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 13 13 3. This notice may not be removed or altered from any source distribution. 14 14 */ 15 15 16 ///btDbvtBroadphase implementation by Nathanael Presson 16 17 #ifndef BT_DBVT_BROADPHASE_H … … 102 103 void collide(btDispatcher* dispatcher); 103 104 void optimize(); 104 /* btBroadphaseInterface Implementation */ 105 106 /* btBroadphaseInterface Implementation */ 105 107 btBroadphaseProxy* createProxy(const btVector3& aabbMin,const btVector3& aabbMax,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiSapProxy); 106 void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher); 107 void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher); 108 virtual void rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin=btVector3(0,0,0), const btVector3& aabbMax = btVector3(0,0,0)); 108 virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher); 109 virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher); 110 virtual void rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin=btVector3(0,0,0), const btVector3& aabbMax = btVector3(0,0,0)); 111 virtual void aabbTest(const btVector3& aabbMin, const btVector3& aabbMax, btBroadphaseAabbCallback& callback); 109 112 110 virtual void getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const; 111 void calculateOverlappingPairs(btDispatcher* dispatcher); 112 btOverlappingPairCache* getOverlappingPairCache(); 113 const btOverlappingPairCache* getOverlappingPairCache() const; 114 void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const; 115 void printStats(); 116 static void benchmark(btBroadphaseInterface*); 113 virtual void getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const; 114 virtual void calculateOverlappingPairs(btDispatcher* dispatcher); 115 virtual btOverlappingPairCache* getOverlappingPairCache(); 116 virtual const btOverlappingPairCache* getOverlappingPairCache() const; 117 virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const; 118 virtual void printStats(); 117 119 118 119 void performDeferredRemoval(btDispatcher* dispatcher);120 120 121 121 ///reset broadphase internal structures, to ensure determinism/reproducability 122 122 virtual void resetPool(btDispatcher* dispatcher); 123 123 124 void performDeferredRemoval(btDispatcher* dispatcher); 125 126 void setVelocityPrediction(btScalar prediction) 127 { 128 m_prediction = prediction; 129 } 130 btScalar getVelocityPrediction() const 131 { 132 return m_prediction; 133 } 134 135 ///this setAabbForceUpdate is similar to setAabb but always forces the aabb update. 136 ///it is not part of the btBroadphaseInterface but specific to btDbvtBroadphase. 137 ///it bypasses certain optimizations that prevent aabb updates (when the aabb shrinks), see 138 ///http://code.google.com/p/bullet/issues/detail?id=223 139 void setAabbForceUpdate( btBroadphaseProxy* absproxy,const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* /*dispatcher*/); 140 141 static void benchmark(btBroadphaseInterface*); 142 143 124 144 }; 125 145 -
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btDispatcher.h
r5781 r8351 47 47 m_useEpa(true), 48 48 m_allowedCcdPenetration(btScalar(0.04)), 49 m_useConvexConservativeDistanceUtil( true),49 m_useConvexConservativeDistanceUtil(false), 50 50 m_convexConservativeDistanceThreshold(0.0f), 51 m_convexMaxDistanceUseCPT(false), 51 52 m_stackAllocator(0) 52 53 { … … 65 66 bool m_useConvexConservativeDistanceUtil; 66 67 btScalar m_convexConservativeDistanceThreshold; 68 bool m_convexMaxDistanceUseCPT; 67 69 btStackAlloc* m_stackAllocator; 68 70 }; -
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h
r5781 r8351 134 134 virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const 135 135 { 136 aabbMin.setValue(- 1e30f,-1e30f,-1e30f);137 aabbMax.setValue( 1e30f,1e30f,1e30f);136 aabbMin.setValue(-BT_LARGE_FLOAT,-BT_LARGE_FLOAT,-BT_LARGE_FLOAT); 137 aabbMax.setValue(BT_LARGE_FLOAT,BT_LARGE_FLOAT,BT_LARGE_FLOAT); 138 138 } 139 139 -
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp
r5781 r8351 241 241 int count = m_overlappingPairArray.size(); 242 242 int oldCapacity = m_overlappingPairArray.capacity(); 243 void* mem = &m_overlappingPairArray.expand ();243 void* mem = &m_overlappingPairArray.expandNonInitializing(); 244 244 245 245 //this is where we add an actual pair, so also call the 'ghost' … … 468 468 return 0; 469 469 470 void* mem = &m_overlappingPairArray.expand ();470 void* mem = &m_overlappingPairArray.expandNonInitializing(); 471 471 btBroadphasePair* pair = new (mem) btBroadphasePair(*proxy0,*proxy1); 472 472 -
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h
r5781 r8351 458 458 virtual void sortOverlappingPairs(btDispatcher* dispatcher) 459 459 { 460 (void) dispatcher; 460 461 } 461 462 -
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp
r5781 r8351 18 18 #include "LinearMath/btAabbUtil2.h" 19 19 #include "LinearMath/btIDebugDraw.h" 20 #include "LinearMath/btSerializer.h" 20 21 21 22 #define RAYAABB2 … … 79 80 btVector3 color[4]= 80 81 { 81 btVector3( 255,0,0),82 btVector3(0, 255,0),83 btVector3(0,0, 255),84 btVector3(0, 255,255)82 btVector3(1,0,0), 83 btVector3(0,1,0), 84 btVector3(0,0,1), 85 btVector3(0,1,1) 85 86 }; 86 87 #endif //DEBUG_PATCH_COLORS … … 475 476 ///what about division by zero? --> just set rayDirection[i] to 1.0 476 477 btVector3 rayDirectionInverse; 477 rayDirectionInverse[0] = rayDir[0] == btScalar(0.0) ? btScalar( 1e30) : btScalar(1.0) / rayDir[0];478 rayDirectionInverse[1] = rayDir[1] == btScalar(0.0) ? btScalar( 1e30) : btScalar(1.0) / rayDir[1];479 rayDirectionInverse[2] = rayDir[2] == btScalar(0.0) ? btScalar( 1e30) : btScalar(1.0) / rayDir[2];478 rayDirectionInverse[0] = rayDir[0] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[0]; 479 rayDirectionInverse[1] = rayDir[1] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[1]; 480 rayDirectionInverse[2] = rayDir[2] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[2]; 480 481 unsigned int sign[3] = { rayDirectionInverse[0] < 0.0, rayDirectionInverse[1] < 0.0, rayDirectionInverse[2] < 0.0}; 481 482 #endif … … 494 495 bounds[1] = rootNode->m_aabbMaxOrg; 495 496 /* Add box cast extents */ 496 bounds[0] += aabbMin;497 bounds[1] += aabbMax;497 bounds[0] -= aabbMax; 498 bounds[1] -= aabbMin; 498 499 499 500 aabbOverlap = TestAabbAgainstAabb2(rayAabbMin,rayAabbMax,rootNode->m_aabbMinOrg,rootNode->m_aabbMaxOrg); … … 562 563 lambda_max = rayDirection.dot(rayTarget-raySource); 563 564 ///what about division by zero? --> just set rayDirection[i] to 1.0 564 rayDirection[0] = rayDirection[0] == btScalar(0.0) ? btScalar( 1e30) : btScalar(1.0) / rayDirection[0];565 rayDirection[1] = rayDirection[1] == btScalar(0.0) ? btScalar( 1e30) : btScalar(1.0) / rayDirection[1];566 rayDirection[2] = rayDirection[2] == btScalar(0.0) ? btScalar( 1e30) : btScalar(1.0) / rayDirection[2];565 rayDirection[0] = rayDirection[0] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDirection[0]; 566 rayDirection[1] = rayDirection[1] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDirection[1]; 567 rayDirection[2] = rayDirection[2] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDirection[2]; 567 568 unsigned int sign[3] = { rayDirection[0] < 0.0, rayDirection[1] < 0.0, rayDirection[2] < 0.0}; 568 569 #endif … … 618 619 bounds[1] = unQuantize(rootNode->m_quantizedAabbMax); 619 620 /* Add box cast extents */ 620 bounds[0] += aabbMin;621 bounds[1] += aabbMax;621 bounds[0] -= aabbMax; 622 bounds[1] -= aabbMin; 622 623 btVector3 normal; 623 624 #if 0 … … 831 832 } 832 833 833 unsigned btQuantizedBvh::calculateSerializeBufferSize() 834 unsigned btQuantizedBvh::calculateSerializeBufferSize() const 834 835 { 835 836 unsigned baseSize = sizeof(btQuantizedBvh) + getAlignmentSerializationPadding(); … … 842 843 } 843 844 844 bool btQuantizedBvh::serialize(void *o_alignedDataBuffer, unsigned /*i_dataBufferSize */, bool i_swapEndian) 845 bool btQuantizedBvh::serialize(void *o_alignedDataBuffer, unsigned /*i_dataBufferSize */, bool i_swapEndian) const 845 846 { 846 847 btAssert(m_subtreeHeaderCount == m_SubtreeHeaders.size()); … … 1144 1145 } 1145 1146 1146 1147 1148 1147 void btQuantizedBvh::deSerializeFloat(struct btQuantizedBvhFloatData& quantizedBvhFloatData) 1148 { 1149 m_bvhAabbMax.deSerializeFloat(quantizedBvhFloatData.m_bvhAabbMax); 1150 m_bvhAabbMin.deSerializeFloat(quantizedBvhFloatData.m_bvhAabbMin); 1151 m_bvhQuantization.deSerializeFloat(quantizedBvhFloatData.m_bvhQuantization); 1152 1153 m_curNodeIndex = quantizedBvhFloatData.m_curNodeIndex; 1154 m_useQuantization = quantizedBvhFloatData.m_useQuantization!=0; 1155 1156 { 1157 int numElem = quantizedBvhFloatData.m_numContiguousLeafNodes; 1158 m_contiguousNodes.resize(numElem); 1159 1160 if (numElem) 1161 { 1162 btOptimizedBvhNodeFloatData* memPtr = quantizedBvhFloatData.m_contiguousNodesPtr; 1163 1164 for (int i=0;i<numElem;i++,memPtr++) 1165 { 1166 m_contiguousNodes[i].m_aabbMaxOrg.deSerializeFloat(memPtr->m_aabbMaxOrg); 1167 m_contiguousNodes[i].m_aabbMinOrg.deSerializeFloat(memPtr->m_aabbMinOrg); 1168 m_contiguousNodes[i].m_escapeIndex = memPtr->m_escapeIndex; 1169 m_contiguousNodes[i].m_subPart = memPtr->m_subPart; 1170 m_contiguousNodes[i].m_triangleIndex = memPtr->m_triangleIndex; 1171 } 1172 } 1173 } 1174 1175 { 1176 int numElem = quantizedBvhFloatData.m_numQuantizedContiguousNodes; 1177 m_quantizedContiguousNodes.resize(numElem); 1178 1179 if (numElem) 1180 { 1181 btQuantizedBvhNodeData* memPtr = quantizedBvhFloatData.m_quantizedContiguousNodesPtr; 1182 for (int i=0;i<numElem;i++,memPtr++) 1183 { 1184 m_quantizedContiguousNodes[i].m_escapeIndexOrTriangleIndex = memPtr->m_escapeIndexOrTriangleIndex; 1185 m_quantizedContiguousNodes[i].m_quantizedAabbMax[0] = memPtr->m_quantizedAabbMax[0]; 1186 m_quantizedContiguousNodes[i].m_quantizedAabbMax[1] = memPtr->m_quantizedAabbMax[1]; 1187 m_quantizedContiguousNodes[i].m_quantizedAabbMax[2] = memPtr->m_quantizedAabbMax[2]; 1188 m_quantizedContiguousNodes[i].m_quantizedAabbMin[0] = memPtr->m_quantizedAabbMin[0]; 1189 m_quantizedContiguousNodes[i].m_quantizedAabbMin[1] = memPtr->m_quantizedAabbMin[1]; 1190 m_quantizedContiguousNodes[i].m_quantizedAabbMin[2] = memPtr->m_quantizedAabbMin[2]; 1191 } 1192 } 1193 } 1194 1195 m_traversalMode = btTraversalMode(quantizedBvhFloatData.m_traversalMode); 1196 1197 { 1198 int numElem = quantizedBvhFloatData.m_numSubtreeHeaders; 1199 m_SubtreeHeaders.resize(numElem); 1200 if (numElem) 1201 { 1202 btBvhSubtreeInfoData* memPtr = quantizedBvhFloatData.m_subTreeInfoPtr; 1203 for (int i=0;i<numElem;i++,memPtr++) 1204 { 1205 m_SubtreeHeaders[i].m_quantizedAabbMax[0] = memPtr->m_quantizedAabbMax[0] ; 1206 m_SubtreeHeaders[i].m_quantizedAabbMax[1] = memPtr->m_quantizedAabbMax[1]; 1207 m_SubtreeHeaders[i].m_quantizedAabbMax[2] = memPtr->m_quantizedAabbMax[2]; 1208 m_SubtreeHeaders[i].m_quantizedAabbMin[0] = memPtr->m_quantizedAabbMin[0]; 1209 m_SubtreeHeaders[i].m_quantizedAabbMin[1] = memPtr->m_quantizedAabbMin[1]; 1210 m_SubtreeHeaders[i].m_quantizedAabbMin[2] = memPtr->m_quantizedAabbMin[2]; 1211 m_SubtreeHeaders[i].m_rootNodeIndex = memPtr->m_rootNodeIndex; 1212 m_SubtreeHeaders[i].m_subtreeSize = memPtr->m_subtreeSize; 1213 } 1214 } 1215 } 1216 } 1217 1218 void btQuantizedBvh::deSerializeDouble(struct btQuantizedBvhDoubleData& quantizedBvhDoubleData) 1219 { 1220 m_bvhAabbMax.deSerializeDouble(quantizedBvhDoubleData.m_bvhAabbMax); 1221 m_bvhAabbMin.deSerializeDouble(quantizedBvhDoubleData.m_bvhAabbMin); 1222 m_bvhQuantization.deSerializeDouble(quantizedBvhDoubleData.m_bvhQuantization); 1223 1224 m_curNodeIndex = quantizedBvhDoubleData.m_curNodeIndex; 1225 m_useQuantization = quantizedBvhDoubleData.m_useQuantization!=0; 1226 1227 { 1228 int numElem = quantizedBvhDoubleData.m_numContiguousLeafNodes; 1229 m_contiguousNodes.resize(numElem); 1230 1231 if (numElem) 1232 { 1233 btOptimizedBvhNodeDoubleData* memPtr = quantizedBvhDoubleData.m_contiguousNodesPtr; 1234 1235 for (int i=0;i<numElem;i++,memPtr++) 1236 { 1237 m_contiguousNodes[i].m_aabbMaxOrg.deSerializeDouble(memPtr->m_aabbMaxOrg); 1238 m_contiguousNodes[i].m_aabbMinOrg.deSerializeDouble(memPtr->m_aabbMinOrg); 1239 m_contiguousNodes[i].m_escapeIndex = memPtr->m_escapeIndex; 1240 m_contiguousNodes[i].m_subPart = memPtr->m_subPart; 1241 m_contiguousNodes[i].m_triangleIndex = memPtr->m_triangleIndex; 1242 } 1243 } 1244 } 1245 1246 { 1247 int numElem = quantizedBvhDoubleData.m_numQuantizedContiguousNodes; 1248 m_quantizedContiguousNodes.resize(numElem); 1249 1250 if (numElem) 1251 { 1252 btQuantizedBvhNodeData* memPtr = quantizedBvhDoubleData.m_quantizedContiguousNodesPtr; 1253 for (int i=0;i<numElem;i++,memPtr++) 1254 { 1255 m_quantizedContiguousNodes[i].m_escapeIndexOrTriangleIndex = memPtr->m_escapeIndexOrTriangleIndex; 1256 m_quantizedContiguousNodes[i].m_quantizedAabbMax[0] = memPtr->m_quantizedAabbMax[0]; 1257 m_quantizedContiguousNodes[i].m_quantizedAabbMax[1] = memPtr->m_quantizedAabbMax[1]; 1258 m_quantizedContiguousNodes[i].m_quantizedAabbMax[2] = memPtr->m_quantizedAabbMax[2]; 1259 m_quantizedContiguousNodes[i].m_quantizedAabbMin[0] = memPtr->m_quantizedAabbMin[0]; 1260 m_quantizedContiguousNodes[i].m_quantizedAabbMin[1] = memPtr->m_quantizedAabbMin[1]; 1261 m_quantizedContiguousNodes[i].m_quantizedAabbMin[2] = memPtr->m_quantizedAabbMin[2]; 1262 } 1263 } 1264 } 1265 1266 m_traversalMode = btTraversalMode(quantizedBvhDoubleData.m_traversalMode); 1267 1268 { 1269 int numElem = quantizedBvhDoubleData.m_numSubtreeHeaders; 1270 m_SubtreeHeaders.resize(numElem); 1271 if (numElem) 1272 { 1273 btBvhSubtreeInfoData* memPtr = quantizedBvhDoubleData.m_subTreeInfoPtr; 1274 for (int i=0;i<numElem;i++,memPtr++) 1275 { 1276 m_SubtreeHeaders[i].m_quantizedAabbMax[0] = memPtr->m_quantizedAabbMax[0] ; 1277 m_SubtreeHeaders[i].m_quantizedAabbMax[1] = memPtr->m_quantizedAabbMax[1]; 1278 m_SubtreeHeaders[i].m_quantizedAabbMax[2] = memPtr->m_quantizedAabbMax[2]; 1279 m_SubtreeHeaders[i].m_quantizedAabbMin[0] = memPtr->m_quantizedAabbMin[0]; 1280 m_SubtreeHeaders[i].m_quantizedAabbMin[1] = memPtr->m_quantizedAabbMin[1]; 1281 m_SubtreeHeaders[i].m_quantizedAabbMin[2] = memPtr->m_quantizedAabbMin[2]; 1282 m_SubtreeHeaders[i].m_rootNodeIndex = memPtr->m_rootNodeIndex; 1283 m_SubtreeHeaders[i].m_subtreeSize = memPtr->m_subtreeSize; 1284 } 1285 } 1286 } 1287 1288 } 1289 1290 1291 1292 ///fills the dataBuffer and returns the struct name (and 0 on failure) 1293 const char* btQuantizedBvh::serialize(void* dataBuffer, btSerializer* serializer) const 1294 { 1295 btQuantizedBvhData* quantizedData = (btQuantizedBvhData*)dataBuffer; 1296 1297 m_bvhAabbMax.serialize(quantizedData->m_bvhAabbMax); 1298 m_bvhAabbMin.serialize(quantizedData->m_bvhAabbMin); 1299 m_bvhQuantization.serialize(quantizedData->m_bvhQuantization); 1300 1301 quantizedData->m_curNodeIndex = m_curNodeIndex; 1302 quantizedData->m_useQuantization = m_useQuantization; 1303 1304 quantizedData->m_numContiguousLeafNodes = m_contiguousNodes.size(); 1305 quantizedData->m_contiguousNodesPtr = (btOptimizedBvhNodeData*) (m_contiguousNodes.size() ? serializer->getUniquePointer((void*)&m_contiguousNodes[0]) : 0); 1306 if (quantizedData->m_contiguousNodesPtr) 1307 { 1308 int sz = sizeof(btOptimizedBvhNodeData); 1309 int numElem = m_contiguousNodes.size(); 1310 btChunk* chunk = serializer->allocate(sz,numElem); 1311 btOptimizedBvhNodeData* memPtr = (btOptimizedBvhNodeData*)chunk->m_oldPtr; 1312 for (int i=0;i<numElem;i++,memPtr++) 1313 { 1314 m_contiguousNodes[i].m_aabbMaxOrg.serialize(memPtr->m_aabbMaxOrg); 1315 m_contiguousNodes[i].m_aabbMinOrg.serialize(memPtr->m_aabbMinOrg); 1316 memPtr->m_escapeIndex = m_contiguousNodes[i].m_escapeIndex; 1317 memPtr->m_subPart = m_contiguousNodes[i].m_subPart; 1318 memPtr->m_triangleIndex = m_contiguousNodes[i].m_triangleIndex; 1319 } 1320 serializer->finalizeChunk(chunk,"btOptimizedBvhNodeData",BT_ARRAY_CODE,(void*)&m_contiguousNodes[0]); 1321 } 1322 1323 quantizedData->m_numQuantizedContiguousNodes = m_quantizedContiguousNodes.size(); 1324 // printf("quantizedData->m_numQuantizedContiguousNodes=%d\n",quantizedData->m_numQuantizedContiguousNodes); 1325 quantizedData->m_quantizedContiguousNodesPtr =(btQuantizedBvhNodeData*) (m_quantizedContiguousNodes.size() ? serializer->getUniquePointer((void*)&m_quantizedContiguousNodes[0]) : 0); 1326 if (quantizedData->m_quantizedContiguousNodesPtr) 1327 { 1328 int sz = sizeof(btQuantizedBvhNodeData); 1329 int numElem = m_quantizedContiguousNodes.size(); 1330 btChunk* chunk = serializer->allocate(sz,numElem); 1331 btQuantizedBvhNodeData* memPtr = (btQuantizedBvhNodeData*)chunk->m_oldPtr; 1332 for (int i=0;i<numElem;i++,memPtr++) 1333 { 1334 memPtr->m_escapeIndexOrTriangleIndex = m_quantizedContiguousNodes[i].m_escapeIndexOrTriangleIndex; 1335 memPtr->m_quantizedAabbMax[0] = m_quantizedContiguousNodes[i].m_quantizedAabbMax[0]; 1336 memPtr->m_quantizedAabbMax[1] = m_quantizedContiguousNodes[i].m_quantizedAabbMax[1]; 1337 memPtr->m_quantizedAabbMax[2] = m_quantizedContiguousNodes[i].m_quantizedAabbMax[2]; 1338 memPtr->m_quantizedAabbMin[0] = m_quantizedContiguousNodes[i].m_quantizedAabbMin[0]; 1339 memPtr->m_quantizedAabbMin[1] = m_quantizedContiguousNodes[i].m_quantizedAabbMin[1]; 1340 memPtr->m_quantizedAabbMin[2] = m_quantizedContiguousNodes[i].m_quantizedAabbMin[2]; 1341 } 1342 serializer->finalizeChunk(chunk,"btQuantizedBvhNodeData",BT_ARRAY_CODE,(void*)&m_quantizedContiguousNodes[0]); 1343 } 1344 1345 quantizedData->m_traversalMode = int(m_traversalMode); 1346 quantizedData->m_numSubtreeHeaders = m_SubtreeHeaders.size(); 1347 1348 quantizedData->m_subTreeInfoPtr = (btBvhSubtreeInfoData*) (m_SubtreeHeaders.size() ? serializer->getUniquePointer((void*)&m_SubtreeHeaders[0]) : 0); 1349 if (quantizedData->m_subTreeInfoPtr) 1350 { 1351 int sz = sizeof(btBvhSubtreeInfoData); 1352 int numElem = m_SubtreeHeaders.size(); 1353 btChunk* chunk = serializer->allocate(sz,numElem); 1354 btBvhSubtreeInfoData* memPtr = (btBvhSubtreeInfoData*)chunk->m_oldPtr; 1355 for (int i=0;i<numElem;i++,memPtr++) 1356 { 1357 memPtr->m_quantizedAabbMax[0] = m_SubtreeHeaders[i].m_quantizedAabbMax[0]; 1358 memPtr->m_quantizedAabbMax[1] = m_SubtreeHeaders[i].m_quantizedAabbMax[1]; 1359 memPtr->m_quantizedAabbMax[2] = m_SubtreeHeaders[i].m_quantizedAabbMax[2]; 1360 memPtr->m_quantizedAabbMin[0] = m_SubtreeHeaders[i].m_quantizedAabbMin[0]; 1361 memPtr->m_quantizedAabbMin[1] = m_SubtreeHeaders[i].m_quantizedAabbMin[1]; 1362 memPtr->m_quantizedAabbMin[2] = m_SubtreeHeaders[i].m_quantizedAabbMin[2]; 1363 1364 memPtr->m_rootNodeIndex = m_SubtreeHeaders[i].m_rootNodeIndex; 1365 memPtr->m_subtreeSize = m_SubtreeHeaders[i].m_subtreeSize; 1366 } 1367 serializer->finalizeChunk(chunk,"btBvhSubtreeInfoData",BT_ARRAY_CODE,(void*)&m_SubtreeHeaders[0]); 1368 } 1369 return btQuantizedBvhDataName; 1370 } 1371 1372 1373 1374 1375 -
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btQuantizedBvh.h
r5781 r8351 17 17 #define QUANTIZED_BVH_H 18 18 19 class btSerializer; 20 19 21 //#define DEBUG_CHECK_DEQUANTIZATION 1 20 22 #ifdef DEBUG_CHECK_DEQUANTIZATION … … 29 31 #include "LinearMath/btVector3.h" 30 32 #include "LinearMath/btAlignedAllocator.h" 33 34 #ifdef BT_USE_DOUBLE_PRECISION 35 #define btQuantizedBvhData btQuantizedBvhDoubleData 36 #define btOptimizedBvhNodeData btOptimizedBvhNodeDoubleData 37 #define btQuantizedBvhDataName "btQuantizedBvhDoubleData" 38 #else 39 #define btQuantizedBvhData btQuantizedBvhFloatData 40 #define btOptimizedBvhNodeData btOptimizedBvhNodeFloatData 41 #define btQuantizedBvhDataName "btQuantizedBvhFloatData" 42 #endif 43 31 44 32 45 … … 191 204 192 205 //This is only used for serialization so we don't have to add serialization directly to btAlignedObjectArray 193 int m_subtreeHeaderCount;206 mutable int m_subtreeHeaderCount; 194 207 195 208 … … 444 457 } 445 458 459 //////////////////////////////////////////////////////////////////// 446 460 447 461 /////Calculate space needed to store BVH for serialization 448 unsigned calculateSerializeBufferSize() ;462 unsigned calculateSerializeBufferSize() const; 449 463 450 464 /// Data buffer MUST be 16 byte aligned 451 virtual bool serialize(void *o_alignedDataBuffer, unsigned i_dataBufferSize, bool i_swapEndian) ;465 virtual bool serialize(void *o_alignedDataBuffer, unsigned i_dataBufferSize, bool i_swapEndian) const; 452 466 453 467 ///deSerializeInPlace loads and initializes a BVH from a buffer in memory 'in place' … … 455 469 456 470 static unsigned int getAlignmentSerializationPadding(); 471 ////////////////////////////////////////////////////////////////////// 472 473 474 virtual int calculateSerializeBufferSizeNew() const; 475 476 ///fills the dataBuffer and returns the struct name (and 0 on failure) 477 virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const; 478 479 virtual void deSerializeFloat(struct btQuantizedBvhFloatData& quantizedBvhFloatData); 480 481 virtual void deSerializeDouble(struct btQuantizedBvhDoubleData& quantizedBvhDoubleData); 482 483 484 //////////////////////////////////////////////////////////////////// 457 485 458 486 SIMD_FORCE_INLINE bool isQuantized() … … 471 499 472 500 501 struct btBvhSubtreeInfoData 502 { 503 int m_rootNodeIndex; 504 int m_subtreeSize; 505 unsigned short m_quantizedAabbMin[3]; 506 unsigned short m_quantizedAabbMax[3]; 507 }; 508 509 struct btOptimizedBvhNodeFloatData 510 { 511 btVector3FloatData m_aabbMinOrg; 512 btVector3FloatData m_aabbMaxOrg; 513 int m_escapeIndex; 514 int m_subPart; 515 int m_triangleIndex; 516 char m_pad[4]; 517 }; 518 519 struct btOptimizedBvhNodeDoubleData 520 { 521 btVector3DoubleData m_aabbMinOrg; 522 btVector3DoubleData m_aabbMaxOrg; 523 int m_escapeIndex; 524 int m_subPart; 525 int m_triangleIndex; 526 char m_pad[4]; 527 }; 528 529 530 struct btQuantizedBvhNodeData 531 { 532 unsigned short m_quantizedAabbMin[3]; 533 unsigned short m_quantizedAabbMax[3]; 534 int m_escapeIndexOrTriangleIndex; 535 }; 536 537 struct btQuantizedBvhFloatData 538 { 539 btVector3FloatData m_bvhAabbMin; 540 btVector3FloatData m_bvhAabbMax; 541 btVector3FloatData m_bvhQuantization; 542 int m_curNodeIndex; 543 int m_useQuantization; 544 int m_numContiguousLeafNodes; 545 int m_numQuantizedContiguousNodes; 546 btOptimizedBvhNodeFloatData *m_contiguousNodesPtr; 547 btQuantizedBvhNodeData *m_quantizedContiguousNodesPtr; 548 btBvhSubtreeInfoData *m_subTreeInfoPtr; 549 int m_traversalMode; 550 int m_numSubtreeHeaders; 551 552 }; 553 554 struct btQuantizedBvhDoubleData 555 { 556 btVector3DoubleData m_bvhAabbMin; 557 btVector3DoubleData m_bvhAabbMax; 558 btVector3DoubleData m_bvhQuantization; 559 int m_curNodeIndex; 560 int m_useQuantization; 561 int m_numContiguousLeafNodes; 562 int m_numQuantizedContiguousNodes; 563 btOptimizedBvhNodeDoubleData *m_contiguousNodesPtr; 564 btQuantizedBvhNodeData *m_quantizedContiguousNodesPtr; 565 566 int m_traversalMode; 567 int m_numSubtreeHeaders; 568 btBvhSubtreeInfoData *m_subTreeInfoPtr; 569 }; 570 571 572 SIMD_FORCE_INLINE int btQuantizedBvh::calculateSerializeBufferSizeNew() const 573 { 574 return sizeof(btQuantizedBvhData); 575 } 576 577 578 473 579 #endif //QUANTIZED_BVH_H -
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp
r5781 r8351 21 21 #include "LinearMath/btTransform.h" 22 22 #include "LinearMath/btMatrix3x3.h" 23 #include "LinearMath/btAabbUtil2.h" 24 23 25 #include <new> 24 26 … … 163 165 } 164 166 rayCallback.process(proxy); 167 } 168 } 169 170 171 void btSimpleBroadphase::aabbTest(const btVector3& aabbMin, const btVector3& aabbMax, btBroadphaseAabbCallback& callback) 172 { 173 for (int i=0; i <= m_LastHandleIndex; i++) 174 { 175 btSimpleBroadphaseProxy* proxy = &m_pHandles[i]; 176 if(!proxy->m_clientObject) 177 { 178 continue; 179 } 180 if (TestAabbAgainstAabb2(aabbMin,aabbMax,proxy->m_aabbMin,proxy->m_aabbMax)) 181 { 182 callback.process(proxy); 183 } 165 184 } 166 185 } -
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btSimpleBroadphase.h
r5781 r8351 137 137 138 138 virtual void rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin=btVector3(0,0,0),const btVector3& aabbMax=btVector3(0,0,0)); 139 virtual void aabbTest(const btVector3& aabbMin, const btVector3& aabbMax, btBroadphaseAabbCallback& callback); 139 140 140 141 btOverlappingPairCache* getOverlappingPairCache() … … 154 155 virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const 155 156 { 156 aabbMin.setValue(- 1e30f,-1e30f,-1e30f);157 aabbMax.setValue( 1e30f,1e30f,1e30f);157 aabbMin.setValue(-BT_LARGE_FLOAT,-BT_LARGE_FLOAT,-BT_LARGE_FLOAT); 158 aabbMax.setValue(BT_LARGE_FLOAT,BT_LARGE_FLOAT,BT_LARGE_FLOAT); 158 159 } 159 160
Note: See TracChangeset
for help on using the changeset viewer.