- Timestamp:
- Dec 13, 2008, 11:45:51 PM (16 years ago)
- Location:
- code/branches/physics/src/bullet/BulletCollision/CollisionDispatch
- Files:
-
- 4 added
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp
r2192 r2430 20 20 21 21 22 SphereTriangleDetector::SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle )22 SphereTriangleDetector::SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle,btScalar contactBreakingThreshold) 23 23 :m_sphere(sphere), 24 m_triangle(triangle) 24 m_triangle(triangle), 25 m_contactBreakingThreshold(contactBreakingThreshold) 25 26 { 26 27 … … 41 42 btTransform sphereInTr = transformB.inverseTimes(transformA); 42 43 43 if (collide(sphereInTr.getOrigin(),point,normal,depth,timeOfImpact ))44 if (collide(sphereInTr.getOrigin(),point,normal,depth,timeOfImpact,m_contactBreakingThreshold)) 44 45 { 45 46 if (swapResults) … … 94 95 95 96 ///combined discrete/continuous sphere-triangle 96 bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact )97 bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact, btScalar contactBreakingThreshold) 97 98 { 98 99 … … 116 117 } 117 118 118 ///todo: move this gContactBreakingThreshold into a proper structure 119 extern btScalar gContactBreakingThreshold; 120 121 btScalar contactMargin = gContactBreakingThreshold; 119 btScalar contactMargin = contactBreakingThreshold; 122 120 bool isInsideContactPlane = distanceFromPlane < r + contactMargin; 123 121 bool isInsideShellPlane = distanceFromPlane < r; … … 141 139 for (int i = 0; i < m_triangle->getNumEdges(); i++) { 142 140 143 bt Point3 pa;144 bt Point3 pb;141 btVector3 pa; 142 btVector3 pb; 145 143 146 144 m_triangle->getEdge(i,pa,pb); -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/SphereTriangleDetector.h
r2192 r2430 18 18 19 19 #include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h" 20 #include "LinearMath/btPoint3.h" 20 21 21 22 22 … … 31 31 virtual void getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults=false); 32 32 33 SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle );33 SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle, btScalar contactBreakingThreshold); 34 34 35 35 virtual ~SphereTriangleDetector() {}; … … 37 37 private: 38 38 39 bool collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact );39 bool collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact, btScalar contactBreakingThreshold); 40 40 bool pointInTriangle(const btVector3 vertices[], const btVector3 &normal, btVector3 *p ); 41 41 bool facecontains(const btVector3 &p,const btVector3* vertices,btVector3& normal); … … 43 43 btSphereShape* m_sphere; 44 44 btTriangleShape* m_triangle; 45 45 btScalar m_contactBreakingThreshold; 46 46 47 47 }; -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.cpp
r2192 r2430 23 23 24 24 btBoxBoxCollisionAlgorithm::btBoxBoxCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* obj0,btCollisionObject* obj1) 25 : bt CollisionAlgorithm(ci),25 : btActivatingCollisionAlgorithm(ci,obj0,obj1), 26 26 m_ownManifold(false), 27 27 m_manifoldPtr(mf) -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.h
r2192 r2430 17 17 #define BOX_BOX__COLLISION_ALGORITHM_H 18 18 19 #include " BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"19 #include "btActivatingCollisionAlgorithm.h" 20 20 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" 21 21 #include "BulletCollision/BroadphaseCollision/btDispatcher.h" … … 25 25 26 26 ///box-box collision detection 27 class btBoxBoxCollisionAlgorithm : public bt CollisionAlgorithm27 class btBoxBoxCollisionAlgorithm : public btActivatingCollisionAlgorithm 28 28 { 29 29 bool m_ownManifold; … … 32 32 public: 33 33 btBoxBoxCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci) 34 : bt CollisionAlgorithm(ci) {}34 : btActivatingCollisionAlgorithm(ci) {} 35 35 36 36 virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btBoxBoxDetector.cpp
r2192 r2430 208 208 } 209 209 q = p[n*2-2]*p[1] - p[0]*p[n*2-1]; 210 a = 1.f/(btScalar(3.0)*(a+q)); 210 if (btFabs(a+q) > SIMD_EPSILON) 211 { 212 a = 1.f/(btScalar(3.0)*(a+q)); 213 } else 214 { 215 a=1e30f; 216 } 211 217 cx = a*(cx + q*(p[n*2-2]+p[0])); 212 218 cy = a*(cy + q*(p[n*2-1]+p[1])); -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionConfiguration.h
r2192 r2430 23 23 ///btCollisionConfiguration allows to configure Bullet collision detection 24 24 ///stack allocator size, default collision algorithms and persistent manifold pool size 25 /// todo: describe the meaning25 ///@todo: describe the meaning 26 26 class btCollisionConfiguration 27 27 { -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionCreateFunc.h
r2192 r2430 18 18 19 19 #include "LinearMath/btAlignedObjectArray.h" 20 typedef btAlignedObjectArray<class btCollisionObject*> btCollisionObjectArray;21 20 class btCollisionAlgorithm; 22 21 class btCollisionObject; -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp
r2192 r2430 58 58 59 59 60 } ;60 } 61 61 62 62 … … 79 79 btCollisionObject* body0 = (btCollisionObject*)b0; 80 80 btCollisionObject* body1 = (btCollisionObject*)b1; 81 82 btScalar contactBreakingThreshold = btMin(gContactBreakingThreshold,btMin(body0->getCollisionShape()->getContactBreakingThreshold(),body1->getCollisionShape()->getContactBreakingThreshold())); 81 83 82 84 void* mem = 0; … … 90 92 91 93 } 92 btPersistentManifold* manifold = new(mem) btPersistentManifold (body0,body1,0 );94 btPersistentManifold* manifold = new(mem) btPersistentManifold (body0,body1,0,contactBreakingThreshold); 93 95 manifold->m_index1a = m_manifoldsPtr.size(); 94 96 m_manifoldsPtr.push_back(manifold); -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionObject.h
r2192 r2430 30 30 #include "LinearMath/btMotionState.h" 31 31 #include "LinearMath/btAlignedAllocator.h" 32 32 #include "LinearMath/btAlignedObjectArray.h" 33 34 35 typedef btAlignedObjectArray<class btCollisionObject*> btCollisionObjectArray; 33 36 34 37 … … 72 75 void* m_userObjectPointer; 73 76 74 ///m_internalType is reserved to distinguish Bullet's btCollisionObject, btRigidBody, btSoftBody etc.77 ///m_internalType is reserved to distinguish Bullet's btCollisionObject, btRigidBody, btSoftBody, btGhostObject etc. 75 78 ///do not assign your own m_internalType unless you write a new dynamics object class. 76 79 int m_internalType; … … 104 107 CF_KINEMATIC_OBJECT= 2, 105 108 CF_NO_CONTACT_RESPONSE = 4, 106 CF_CUSTOM_MATERIAL_CALLBACK = 8//this allows per-triangle material (friction/restitution) 109 CF_CUSTOM_MATERIAL_CALLBACK = 8,//this allows per-triangle material (friction/restitution) 110 CF_CHARACTER_OBJECT = 16 107 111 }; 108 112 … … 111 115 CO_COLLISION_OBJECT =1, 112 116 CO_RIGID_BODY, 113 CO_SOFT_BODY 117 CO_SOFT_BODY, 118 ///CO_GHOST_OBJECT keeps track of all objects overlapping its AABB and that pass its collision filter 119 ///It is useful for collision sensors, explosion objects, character controller etc. 120 CO_GHOST_OBJECT 114 121 }; 115 122 … … 177 184 } 178 185 179 int getActivationState() const { return m_activationState1;}186 SIMD_FORCE_INLINE int getActivationState() const { return m_activationState1;} 180 187 181 188 void setActivationState(int newState); … … 194 201 void activate(bool forceActivation = false); 195 202 196 inlinebool isActive() const203 SIMD_FORCE_INLINE bool isActive() const 197 204 { 198 205 return ((getActivationState() != ISLAND_SLEEPING) && (getActivationState() != DISABLE_SIMULATION)); … … 238 245 239 246 240 btBroadphaseProxy* getBroadphaseHandle()247 SIMD_FORCE_INLINE btBroadphaseProxy* getBroadphaseHandle() 241 248 { 242 249 return m_broadphaseHandle; 243 250 } 244 251 245 const btBroadphaseProxy* getBroadphaseHandle() const252 SIMD_FORCE_INLINE const btBroadphaseProxy* getBroadphaseHandle() const 246 253 { 247 254 return m_broadphaseHandle; … … 289 296 } 290 297 291 constint getIslandTag() const298 SIMD_FORCE_INLINE int getIslandTag() const 292 299 { 293 300 return m_islandTag1; … … 299 306 } 300 307 301 constint getCompanionId() const308 SIMD_FORCE_INLINE int getCompanionId() const 302 309 { 303 310 return m_companionId; … … 309 316 } 310 317 311 constbtScalar getHitFraction() const318 SIMD_FORCE_INLINE btScalar getHitFraction() const 312 319 { 313 320 return m_hitFraction; … … 320 327 321 328 322 constint getCollisionFlags() const329 SIMD_FORCE_INLINE int getCollisionFlags() const 323 330 { 324 331 return m_collisionFlags; -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
r2192 r2430 33 33 #include "LinearMath/btStackAlloc.h" 34 34 35 //#define USE_BRUTEFORCE_RAYBROADPHASE 1 36 //RECALCULATE_AABB is slower, but benefit is that you don't need to call 'stepSimulation' or 'updateAabbs' before using a rayTest 37 //#define RECALCULATE_AABB_RAYCAST 1 35 38 36 39 //When the user doesn't provide dispatcher or broadphase, create basic versions (and delete them in destructor) … … 114 117 } 115 118 119 120 116 121 void btCollisionWorld::updateAabbs() 117 122 { … … 126 131 if (colObj->isActive()) 127 132 { 128 bt Point3 minAabb,maxAabb;133 btVector3 minAabb,maxAabb; 129 134 colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb); 130 135 //need to increase the aabb for contact thresholds … … 227 232 if (collisionShape->isConvex()) 228 233 { 234 // BT_PROFILE("rayTestConvex"); 229 235 btConvexCast::CastResult castResult; 230 236 castResult.m_fraction = resultCallback.m_closestHitFraction; … … 270 276 if (collisionShape->isConcave()) 271 277 { 278 // BT_PROFILE("rayTestConcave"); 272 279 if (collisionShape->getShapeType()==TRIANGLE_MESH_SHAPE_PROXYTYPE) 273 280 { … … 318 325 } else 319 326 { 320 btTriangleMeshShape* triangleMesh = (btTriangleMeshShape*)collisionShape; 327 //generic (slower) case 328 btConcaveShape* concaveShape = (btConcaveShape*)collisionShape; 321 329 322 330 btTransform worldTocollisionObject = colObjWorldTransform.inverse(); … … 331 339 btCollisionWorld::RayResultCallback* m_resultCallback; 332 340 btCollisionObject* m_collisionObject; 333 bt TriangleMeshShape* m_triangleMesh;341 btConcaveShape* m_triangleMesh; 334 342 335 343 BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to, 336 btCollisionWorld::RayResultCallback* resultCallback, btCollisionObject* collisionObject,bt TriangleMeshShape* triangleMesh):344 btCollisionWorld::RayResultCallback* resultCallback, btCollisionObject* collisionObject,btConcaveShape* triangleMesh): 337 345 btTriangleRaycastCallback(from,to), 338 346 m_resultCallback(resultCallback), … … 364 372 365 373 366 BridgeTriangleRaycastCallback rcb(rayFromLocal,rayToLocal,&resultCallback,collisionObject, triangleMesh);374 BridgeTriangleRaycastCallback rcb(rayFromLocal,rayToLocal,&resultCallback,collisionObject,concaveShape); 367 375 rcb.m_hitFraction = resultCallback.m_closestHitFraction; 368 376 … … 372 380 rayAabbMaxLocal.setMax(rayToLocal); 373 381 374 triangleMesh->processAllTriangles(&rcb,rayAabbMinLocal,rayAabbMaxLocal);382 concaveShape->processAllTriangles(&rcb,rayAabbMinLocal,rayAabbMaxLocal); 375 383 } 376 384 } else { 377 //todo: use AABB tree or other BVH acceleration structure! 385 // BT_PROFILE("rayTestCompound"); 386 ///@todo: use AABB tree or other BVH acceleration structure, see btDbvt 378 387 if (collisionShape->isCompound()) 379 388 { … … 409 418 if (collisionShape->isConvex()) 410 419 { 420 //BT_PROFILE("convexSweepConvex"); 411 421 btConvexCast::CastResult castResult; 412 422 castResult.m_allowedPenetration = allowedPenetration; 413 castResult.m_fraction = btScalar(1.);//??423 castResult.m_fraction = resultCallback.m_closestHitFraction;//btScalar(1.);//?? 414 424 415 425 btConvexShape* convexShape = (btConvexShape*) collisionShape; … … 453 463 if (collisionShape->getShapeType()==TRIANGLE_MESH_SHAPE_PROXYTYPE) 454 464 { 465 //BT_PROFILE("convexSweepbtBvhTriangleMesh"); 455 466 btBvhTriangleMeshShape* triangleMesh = (btBvhTriangleMeshShape*)collisionShape; 456 467 btTransform worldTocollisionObject = colObjWorldTransform.inverse(); … … 509 520 } else 510 521 { 511 btBvhTriangleMeshShape* triangleMesh = (btBvhTriangleMeshShape*)collisionShape; 522 //BT_PROFILE("convexSweepConcave"); 523 btConcaveShape* concaveShape = (btConcaveShape*)collisionShape; 512 524 btTransform worldTocollisionObject = colObjWorldTransform.inverse(); 513 525 btVector3 convexFromLocal = worldTocollisionObject * convexFromTrans.getOrigin(); … … 521 533 btCollisionWorld::ConvexResultCallback* m_resultCallback; 522 534 btCollisionObject* m_collisionObject; 523 bt TriangleMeshShape* m_triangleMesh;535 btConcaveShape* m_triangleMesh; 524 536 525 537 BridgeTriangleConvexcastCallback(const btConvexShape* castShape, const btTransform& from,const btTransform& to, 526 btCollisionWorld::ConvexResultCallback* resultCallback, btCollisionObject* collisionObject,bt TriangleMeshShape* triangleMesh, const btTransform& triangleToWorld):538 btCollisionWorld::ConvexResultCallback* resultCallback, btCollisionObject* collisionObject,btConcaveShape* triangleMesh, const btTransform& triangleToWorld): 527 539 btTriangleConvexcastCallback(castShape, from,to, triangleToWorld, triangleMesh->getMargin()), 528 540 m_resultCallback(resultCallback), … … 557 569 }; 558 570 559 BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,collisionObject, triangleMesh, colObjWorldTransform);571 BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,collisionObject,concaveShape, colObjWorldTransform); 560 572 tccb.m_hitFraction = resultCallback.m_closestHitFraction; 561 573 btVector3 boxMinLocal, boxMaxLocal; … … 568 580 rayAabbMinLocal += boxMinLocal; 569 581 rayAabbMaxLocal += boxMaxLocal; 570 triangleMesh->processAllTriangles(&tccb,rayAabbMinLocal,rayAabbMaxLocal);582 concaveShape->processAllTriangles(&tccb,rayAabbMinLocal,rayAabbMaxLocal); 571 583 } 572 584 } else { 573 // todo: use AABB tree or other BVH acceleration structure!585 ///@todo : use AABB tree or other BVH acceleration structure! 574 586 if (collisionShape->isCompound()) 575 587 { 588 BT_PROFILE("convexSweepCompound"); 576 589 const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(collisionShape); 577 590 int i=0; … … 597 610 } 598 611 599 void btCollisionWorld::rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback) const 600 { 601 602 603 btTransform rayFromTrans,rayToTrans; 604 rayFromTrans.setIdentity(); 605 rayFromTrans.setOrigin(rayFromWorld); 606 rayToTrans.setIdentity(); 607 608 rayToTrans.setOrigin(rayToWorld); 609 610 /// go over all objects, and if the ray intersects their aabb, do a ray-shape query using convexCaster (CCD) 611 612 int i; 613 for (i=0;i<m_collisionObjects.size();i++) 612 613 struct btSingleRayCallback : public btBroadphaseRayCallback 614 { 615 616 btVector3 m_rayFromWorld; 617 btVector3 m_rayToWorld; 618 btTransform m_rayFromTrans; 619 btTransform m_rayToTrans; 620 btVector3 m_hitNormal; 621 622 const btCollisionWorld* m_world; 623 btCollisionWorld::RayResultCallback& m_resultCallback; 624 625 btSingleRayCallback(const btVector3& rayFromWorld,const btVector3& rayToWorld,const btCollisionWorld* world,btCollisionWorld::RayResultCallback& resultCallback) 626 :m_rayFromWorld(rayFromWorld), 627 m_rayToWorld(rayToWorld), 628 m_world(world), 629 m_resultCallback(resultCallback) 630 { 631 m_rayFromTrans.setIdentity(); 632 m_rayFromTrans.setOrigin(m_rayFromWorld); 633 m_rayToTrans.setIdentity(); 634 m_rayToTrans.setOrigin(m_rayToWorld); 635 636 btVector3 rayDir = (rayToWorld-rayFromWorld); 637 638 rayDir.normalize (); 639 ///what about division by zero? --> just set rayDirection[i] to INF/1e30 640 m_rayDirectionInverse[0] = rayDir[0] == btScalar(0.0) ? btScalar(1e30) : btScalar(1.0) / rayDir[0]; 641 m_rayDirectionInverse[1] = rayDir[1] == btScalar(0.0) ? btScalar(1e30) : btScalar(1.0) / rayDir[1]; 642 m_rayDirectionInverse[2] = rayDir[2] == btScalar(0.0) ? btScalar(1e30) : btScalar(1.0) / rayDir[2]; 643 m_signs[0] = m_rayDirectionInverse[0] < 0.0; 644 m_signs[1] = m_rayDirectionInverse[1] < 0.0; 645 m_signs[2] = m_rayDirectionInverse[2] < 0.0; 646 647 m_lambda_max = rayDir.dot(m_rayToWorld-m_rayFromWorld); 648 649 } 650 651 652 653 virtual bool process(const btBroadphaseProxy* proxy) 614 654 { 615 655 ///terminate further ray tests, once the closestHitFraction reached zero 616 if (resultCallback.m_closestHitFraction == btScalar(0.f)) 617 break; 618 619 btCollisionObject* collisionObject= m_collisionObjects[i]; 656 if (m_resultCallback.m_closestHitFraction == btScalar(0.f)) 657 return false; 658 659 btCollisionObject* collisionObject = (btCollisionObject*)proxy->m_clientObject; 660 620 661 //only perform raycast if filterMask matches 621 if(resultCallback.needsCollision(collisionObject->getBroadphaseHandle())) { 662 if(m_resultCallback.needsCollision(collisionObject->getBroadphaseHandle())) 663 { 622 664 //RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject(); 665 //btVector3 collisionObjectAabbMin,collisionObjectAabbMax; 666 667 #ifdef RECALCULATE_AABB 623 668 btVector3 collisionObjectAabbMin,collisionObjectAabbMax; 624 669 collisionObject->getCollisionShape()->getAabb(collisionObject->getWorldTransform(),collisionObjectAabbMin,collisionObjectAabbMax); 625 626 btScalar hitLambda = resultCallback.m_closestHitFraction; 627 btVector3 hitNormal; 628 if (btRayAabb(rayFromWorld,rayToWorld,collisionObjectAabbMin,collisionObjectAabbMax,hitLambda,hitNormal)) 629 { 630 rayTestSingle(rayFromTrans,rayToTrans, 670 #else 671 //getBroadphase()->getAabb(collisionObject->getBroadphaseHandle(),collisionObjectAabbMin,collisionObjectAabbMax); 672 const btVector3& collisionObjectAabbMin = collisionObject->getBroadphaseHandle()->m_aabbMin; 673 const btVector3& collisionObjectAabbMax = collisionObject->getBroadphaseHandle()->m_aabbMax; 674 #endif 675 //btScalar hitLambda = m_resultCallback.m_closestHitFraction; 676 //culling already done by broadphase 677 //if (btRayAabb(m_rayFromWorld,m_rayToWorld,collisionObjectAabbMin,collisionObjectAabbMax,hitLambda,m_hitNormal)) 678 { 679 m_world->rayTestSingle(m_rayFromTrans,m_rayToTrans, 631 680 collisionObject, 632 681 collisionObject->getCollisionShape(), 633 682 collisionObject->getWorldTransform(), 634 resultCallback);683 m_resultCallback); 635 684 } 636 685 } 637 638 } 639 640 } 641 642 void btCollisionWorld::convexSweepTest(const btConvexShape* castShape, const btTransform& convexFromWorld, const btTransform& convexToWorld, ConvexResultCallback& resultCallback) const 643 { 686 return true; 687 } 688 }; 689 690 void btCollisionWorld::rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback) const 691 { 692 BT_PROFILE("rayTest"); 693 /// use the broadphase to accelerate the search for objects, based on their aabb 694 /// and for each object with ray-aabb overlap, perform an exact ray test 695 btSingleRayCallback rayCB(rayFromWorld,rayToWorld,this,resultCallback); 696 697 #ifndef USE_BRUTEFORCE_RAYBROADPHASE 698 m_broadphasePairCache->rayTest(rayFromWorld,rayToWorld,rayCB); 699 #else 700 for (int i=0;i<this->getNumCollisionObjects();i++) 701 { 702 rayCB.process(m_collisionObjects[i]->getBroadphaseHandle()); 703 } 704 #endif //USE_BRUTEFORCE_RAYBROADPHASE 705 706 } 707 708 709 struct btSingleSweepCallback : public btBroadphaseRayCallback 710 { 711 712 btTransform m_convexFromTrans; 713 btTransform m_convexToTrans; 714 btVector3 m_hitNormal; 715 const btCollisionWorld* m_world; 716 btCollisionWorld::ConvexResultCallback& m_resultCallback; 717 btScalar m_allowedCcdPenetration; 718 const btConvexShape* m_castShape; 719 720 721 btSingleSweepCallback(const btConvexShape* castShape, const btTransform& convexFromTrans,const btTransform& convexToTrans,const btCollisionWorld* world,btCollisionWorld::ConvexResultCallback& resultCallback,btScalar allowedPenetration) 722 :m_convexFromTrans(convexFromTrans), 723 m_convexToTrans(convexToTrans), 724 m_world(world), 725 m_resultCallback(resultCallback), 726 m_allowedCcdPenetration(allowedPenetration), 727 m_castShape(castShape) 728 { 729 btVector3 unnormalizedRayDir = (m_convexToTrans.getOrigin()-m_convexFromTrans.getOrigin()); 730 btVector3 rayDir = unnormalizedRayDir.normalized(); 731 ///what about division by zero? --> just set rayDirection[i] to INF/1e30 732 m_rayDirectionInverse[0] = rayDir[0] == btScalar(0.0) ? btScalar(1e30) : btScalar(1.0) / rayDir[0]; 733 m_rayDirectionInverse[1] = rayDir[1] == btScalar(0.0) ? btScalar(1e30) : btScalar(1.0) / rayDir[1]; 734 m_rayDirectionInverse[2] = rayDir[2] == btScalar(0.0) ? btScalar(1e30) : btScalar(1.0) / rayDir[2]; 735 m_signs[0] = m_rayDirectionInverse[0] < 0.0; 736 m_signs[1] = m_rayDirectionInverse[1] < 0.0; 737 m_signs[2] = m_rayDirectionInverse[2] < 0.0; 738 739 m_lambda_max = rayDir.dot(unnormalizedRayDir); 740 741 } 742 743 virtual bool process(const btBroadphaseProxy* proxy) 744 { 745 ///terminate further convex sweep tests, once the closestHitFraction reached zero 746 if (m_resultCallback.m_closestHitFraction == btScalar(0.f)) 747 return false; 748 749 btCollisionObject* collisionObject = (btCollisionObject*)proxy->m_clientObject; 750 751 //only perform raycast if filterMask matches 752 if(m_resultCallback.needsCollision(collisionObject->getBroadphaseHandle())) { 753 //RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject(); 754 m_world->objectQuerySingle(m_castShape, m_convexFromTrans,m_convexToTrans, 755 collisionObject, 756 collisionObject->getCollisionShape(), 757 collisionObject->getWorldTransform(), 758 m_resultCallback, 759 m_allowedCcdPenetration); 760 } 761 762 return true; 763 } 764 }; 765 766 767 768 void btCollisionWorld::convexSweepTest(const btConvexShape* castShape, const btTransform& convexFromWorld, const btTransform& convexToWorld, ConvexResultCallback& resultCallback, btScalar allowedCcdPenetration) const 769 { 770 771 BT_PROFILE("convexSweepTest"); 772 /// use the broadphase to accelerate the search for objects, based on their aabb 773 /// and for each object with ray-aabb overlap, perform an exact ray test 774 /// unfortunately the implementation for rayTest and convexSweepTest duplicated, albeit practically identical 775 776 777 644 778 btTransform convexFromTrans,convexToTrans; 645 779 convexFromTrans = convexFromWorld; … … 650 784 btVector3 linVel, angVel; 651 785 btTransformUtil::calculateVelocity (convexFromTrans, convexToTrans, 1.0, linVel, angVel); 786 btVector3 zeroLinVel; 787 zeroLinVel.setValue(0,0,0); 652 788 btTransform R; 653 789 R.setIdentity (); 654 790 R.setRotation (convexFromTrans.getRotation()); 655 castShape->calculateTemporalAabb (R, linVel, angVel, 1.0, castShapeAabbMin, castShapeAabbMax); 656 } 657 791 castShape->calculateTemporalAabb (R, zeroLinVel, angVel, 1.0, castShapeAabbMin, castShapeAabbMax); 792 } 793 794 #ifndef USE_BRUTEFORCE_RAYBROADPHASE 795 796 btSingleSweepCallback convexCB(castShape,convexFromWorld,convexToWorld,this,resultCallback,allowedCcdPenetration); 797 798 m_broadphasePairCache->rayTest(convexFromTrans.getOrigin(),convexToTrans.getOrigin(),convexCB,castShapeAabbMin,castShapeAabbMax); 799 800 #else 658 801 /// go over all objects, and if the ray intersects their aabb + cast shape aabb, 659 802 // do a ray-shape query using convexCaster (CCD) … … 677 820 collisionObject->getWorldTransform(), 678 821 resultCallback, 679 getDispatchInfo().m_allowedCcdPenetration);822 allowedCcdPenetration); 680 823 } 681 824 } 682 825 } 683 684 } 826 #endif //USE_BRUTEFORCE_RAYBROADPHASE 827 } -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.h
r2192 r2430 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-2006 Erwin Coumans http:// continuousphysics.com/Bullet/3 Copyright (c) 2003-2006 Erwin Coumans http://bulletphysics.com/Bullet/ 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 23 23 * Bullet is a Collision Detection and Rigid Body Dynamics Library. The Library is Open Source and free for commercial use, under the ZLib license ( http://opensource.org/licenses/zlib-license.php ). 24 24 * 25 * There is the Physics Forum for Feedback and bteral Collision Detection and Physics discussions.26 * Please visit http://www. continuousphysics.com/Bullet/phpBB2/index.php25 * There is the Physics Forum for feedback and general Collision Detection and Physics discussions. 26 * Please visit http://www.bulletphysics.com 27 27 * 28 28 * @section install_sec Installation 29 29 * 30 30 * @subsection step1 Step 1: Download 31 * You can download the Bullet Physics Library from our website: http://www.continuousphysics.com/Bullet/31 * You can download the Bullet Physics Library from the Google Code repository: http://code.google.com/p/bullet/downloads/list 32 32 * @subsection step2 Step 2: Building 33 33 * Bullet comes with autogenerated Project Files for Microsoft Visual Studio 6, 7, 7.1 and 8. 34 34 * The main Workspace/Solution is located in Bullet/msvc/8/wksbullet.sln (replace 8 with your version). 35 35 * 36 * Under other platforms, like Linux or Mac OS-X, Bullet can be build using either using make, cmake, http://www.cmake.org , or jam, http://www.perforce.com/jam/jam.html . cmake can autogenerate Xcode, KDevelop, MSVC and other build systems. just run cmake . in the root of Bullet.36 * Under other platforms, like Linux or Mac OS-X, Bullet can be build using either using make, cmake, http://www.cmake.org , or jam, http://www.perforce.com/jam/jam.html . cmake can autogenerate Xcode, KDevelop, MSVC and other build systems. just run cmake . in the root of Bullet. 37 37 * So if you are not using MSVC or cmake, you can run ./autogen.sh ./configure to create both Makefile and Jamfile and then run make or jam. 38 38 * Jam is a build system that can build the library, demos and also autogenerate the MSVC Project Files. 39 * If you don't have jam installed, you can make jam from the included jam-2.5 sources, or download jam from ftp://ftp.perforce.com/ pub/jam/39 * If you don't have jam installed, you can make jam from the included jam-2.5 sources, or download jam from ftp://ftp.perforce.com/jam 40 40 * 41 41 * @subsection step3 Step 3: Testing demos … … 72 72 #include "LinearMath/btTransform.h" 73 73 #include "btCollisionObject.h" 74 #include "btCollisionDispatcher.h" //for definition of btCollisionObjectArray74 #include "btCollisionDispatcher.h" 75 75 #include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h" 76 76 #include "LinearMath/btAlignedObjectArray.h" … … 108 108 } 109 109 110 const btBroadphaseInterface* getBroadphase() const 111 { 112 return m_broadphasePairCache; 113 } 114 110 115 btBroadphaseInterface* getBroadphase() 111 116 { … … 131 136 virtual void updateAabbs(); 132 137 138 133 139 virtual void setDebugDrawer(btIDebugDraw* debugDrawer) 134 140 { … … 348 354 // convexTest performs a swept convex cast on all objects in the btCollisionWorld, and calls the resultCallback 349 355 // This allows for several queries: first hit, all hits, any hit, dependent on the value return by the callback. 350 void convexSweepTest (const btConvexShape* castShape, const btTransform& from, const btTransform& to, ConvexResultCallback& resultCallback ) const;356 void convexSweepTest (const btConvexShape* castShape, const btTransform& from, const btTransform& to, ConvexResultCallback& resultCallback, btScalar allowedCcdPenetration = btScalar(0.)) const; 351 357 352 358 -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp
r2192 r2430 22 22 23 23 btCompoundCollisionAlgorithm::btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped) 24 :bt CollisionAlgorithm(ci),24 :btActivatingCollisionAlgorithm(ci,body0,body1), 25 25 m_isSwapped(isSwapped), 26 26 m_sharedManifold(ci.m_manifold) -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h
r2192 r2430 17 17 #define COMPOUND_COLLISION_ALGORITHM_H 18 18 19 #include " BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"19 #include "btActivatingCollisionAlgorithm.h" 20 20 #include "BulletCollision/BroadphaseCollision/btDispatcher.h" 21 21 #include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h" … … 29 29 30 30 /// btCompoundCollisionAlgorithm supports collision between CompoundCollisionShapes and other collision shapes 31 class btCompoundCollisionAlgorithm : public bt CollisionAlgorithm31 class btCompoundCollisionAlgorithm : public btActivatingCollisionAlgorithm 32 32 { 33 33 btAlignedObjectArray<btCollisionAlgorithm*> m_childCollisionAlgorithms; -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp
r2192 r2430 28 28 29 29 btConvexConcaveCollisionAlgorithm::btConvexConcaveCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1,bool isSwapped) 30 : bt CollisionAlgorithm(ci),30 : btActivatingCollisionAlgorithm(ci,body0,body1), 31 31 m_isSwapped(isSwapped), 32 32 m_btConvexTriangleCallback(ci.m_dispatcher1,body0,body1,isSwapped) … … 73 73 { 74 74 m_dispatcher->clearManifold(m_manifoldPtr); 75 } ;75 } 76 76 77 77 … … 94 94 95 95 ///debug drawing of the overlapping triangles 96 if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && m_dispatchInfoPtr->m_debugDraw->getDebugMode() > 0)96 if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && (m_dispatchInfoPtr->m_debugDraw->getDebugMode() &btIDebugDraw::DBG_DrawWireframe )) 97 97 { 98 98 btVector3 color(255,255,0); -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h
r2192 r2430 17 17 #define CONVEX_CONCAVE_COLLISION_ALGORITHM_H 18 18 19 #include " BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"19 #include "btActivatingCollisionAlgorithm.h" 20 20 #include "BulletCollision/BroadphaseCollision/btDispatcher.h" 21 21 #include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h" … … 35 35 btVector3 m_aabbMax ; 36 36 37 37 38 btManifoldResult* m_resultOut; 38 39 39 btDispatcher* m_dispatcher; 40 40 const btDispatcherInfo* m_dispatchInfoPtr; … … 71 71 72 72 /// btConvexConcaveCollisionAlgorithm supports collision between convex shapes and (concave) trianges meshes. 73 class btConvexConcaveCollisionAlgorithm : public bt CollisionAlgorithm73 class btConvexConcaveCollisionAlgorithm : public btActivatingCollisionAlgorithm 74 74 { 75 75 … … 77 77 78 78 btConvexTriangleCallback m_btConvexTriangleCallback; 79 79 80 80 81 -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp
r2192 r2430 39 39 #include "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h" 40 40 41 #include "BulletCollision/NarrowPhaseCollision/btGjkEpa .h"41 #include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h" 42 42 #include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h" 43 43 … … 61 61 62 62 btConvexConvexAlgorithm::btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver) 63 : btCollisionAlgorithm(ci), 64 m_gjkPairDetector(0,0,simplexSolver,pdSolver), 63 : btActivatingCollisionAlgorithm(ci,body0,body1), 64 m_simplexSolver(simplexSolver), 65 m_pdSolver(pdSolver), 65 66 m_ownManifold (false), 66 67 m_manifoldPtr(mf), 67 68 m_lowLevelOfDetail(false) 69 #ifdef USE_SEPDISTANCE_UTIL2 70 ,m_sepDistance((static_cast<btConvexShape*>(body0->getCollisionShape()))->getAngularMotionDisc(), 71 (static_cast<btConvexShape*>(body1->getCollisionShape()))->getAngularMotionDisc()) 72 #endif 68 73 { 69 74 (void)body0; 70 75 (void)body1; 71 72 73 76 } 74 77 … … 108 111 resultOut->setPersistentManifold(m_manifoldPtr); 109 112 110 #ifdef USE_BT_GJKEPA 111 btConvexShape* shape0(static_cast<btConvexShape*>(body0->getCollisionShape())); 112 btConvexShape* shape1(static_cast<btConvexShape*>(body1->getCollisionShape())); 113 const btScalar radialmargin(0/*shape0->getMargin()+shape1->getMargin()*/); 114 btGjkEpaSolver::sResults results; 115 if(btGjkEpaSolver::Collide( shape0,body0->getWorldTransform(), 116 shape1,body1->getWorldTransform(), 117 radialmargin,results)) 118 { 119 dispatchInfo.m_debugDraw->drawLine(results.witnesses[1],results.witnesses[1]+results.normal,btVector3(255,0,0)); 120 resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth); 121 } 122 #else 113 123 114 124 115 btConvexShape* min0 = static_cast<btConvexShape*>(body0->getCollisionShape()); 125 116 btConvexShape* min1 = static_cast<btConvexShape*>(body1->getCollisionShape()); 117 118 #ifdef USE_SEPDISTANCE_UTIL2 119 m_sepDistance.updateSeparatingDistance(body0->getWorldTransform(),body1->getWorldTransform()); 120 if (!dispatchInfo.m_useConvexConservativeDistanceUtil || m_sepDistance.getConservativeSeparatingDistance()<=0.f) 121 #endif //USE_SEPDISTANCE_UTIL2 122 123 { 124 126 125 127 126 btGjkPairDetector::ClosestPointInput input; 128 127 128 btGjkPairDetector gjkPairDetector(min0,min1,m_simplexSolver,m_pdSolver); 129 129 //TODO: if (dispatchInfo.m_useContinuous) 130 m_gjkPairDetector.setMinkowskiA(min0); 131 m_gjkPairDetector.setMinkowskiB(min1); 132 input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingThreshold(); 133 input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared; 130 gjkPairDetector.setMinkowskiA(min0); 131 gjkPairDetector.setMinkowskiB(min1); 132 133 #ifdef USE_SEPDISTANCE_UTIL2 134 if (dispatchInfo.m_useConvexConservativeDistanceUtil) 135 { 136 input.m_maximumDistanceSquared = 1e30f; 137 } else 138 #endif //USE_SEPDISTANCE_UTIL2 139 { 140 input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingThreshold(); 141 input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared; 142 } 143 134 144 input.m_stackAlloc = dispatchInfo.m_stackAllocator; 135 136 // input.m_maximumDistanceSquared = btScalar(1e30);137 138 145 input.m_transformA = body0->getWorldTransform(); 139 146 input.m_transformB = body1->getWorldTransform(); 140 141 m_gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw); 142 #endif 147 148 gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw); 149 150 btScalar sepDist = gjkPairDetector.getCachedSeparatingDistance()+dispatchInfo.m_convexConservativeDistanceThreshold; 151 152 #ifdef USE_SEPDISTANCE_UTIL2 153 if (dispatchInfo.m_useConvexConservativeDistanceUtil) 154 { 155 m_sepDistance.initSeparatingDistance(gjkPairDetector.getCachedSeparatingAxis(),sepDist,body0->getWorldTransform(),body1->getWorldTransform()); 156 } 157 #endif //USE_SEPDISTANCE_UTIL2 158 159 160 } 143 161 144 162 if (m_ownManifold) -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h
r2192 r2430 17 17 #define CONVEX_CONVEX_ALGORITHM_H 18 18 19 #include " BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"19 #include "btActivatingCollisionAlgorithm.h" 20 20 #include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h" 21 21 #include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" … … 24 24 #include "btCollisionCreateFunc.h" 25 25 #include "btCollisionDispatcher.h" 26 #include "LinearMath/btTransformUtil.h" //for btConvexSeparatingDistanceUtil 26 27 27 28 class btConvexPenetrationDepthSolver; 28 29 30 ///Enabling USE_SEPDISTANCE_UTIL2 requires 100% reliable distance computation. However, when using large size ratios GJK can be imprecise 31 ///so the distance is not conservative. In that case, enabling this USE_SEPDISTANCE_UTIL2 would result in failing/missing collisions. 32 ///Either improve GJK for large size ratios (testing a 100 units versus a 0.1 unit object) or only enable the util 33 ///for certain pairs that have a small size ratio 34 ///#define USE_SEPDISTANCE_UTIL2 1 35 29 36 ///ConvexConvexAlgorithm collision algorithm implements time of impact, convex closest points and penetration depth calculations. 30 class btConvexConvexAlgorithm : public bt CollisionAlgorithm37 class btConvexConvexAlgorithm : public btActivatingCollisionAlgorithm 31 38 { 32 btGjkPairDetector m_gjkPairDetector; 33 public: 39 #ifdef USE_SEPDISTANCE_UTIL2 40 btConvexSeparatingDistanceUtil m_sepDistance; 41 #endif 42 btSimplexSolverInterface* m_simplexSolver; 43 btConvexPenetrationDepthSolver* m_pdSolver; 34 44 45 35 46 bool m_ownManifold; 36 47 btPersistentManifold* m_manifoldPtr; 37 48 bool m_lowLevelOfDetail; 49 50 ///cache separating vector to speedup collision detection 38 51 39 52 -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp
r2192 r2430 101 101 int maxSize2 = sizeof(btConvexConcaveCollisionAlgorithm); 102 102 int maxSize3 = sizeof(btCompoundCollisionAlgorithm); 103 int maxSize4 = sizeof(btEmptyAlgorithm);104 103 int sl = sizeof(btConvexSeparatingDistanceUtil); 104 sl = sizeof(btGjkPairDetector); 105 105 int collisionAlgorithmMaxElementSize = btMax(maxSize,maxSize2); 106 106 collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize3); 107 collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize4);108 107 109 108 if (constructionInfo.m_stackAlloc) -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h
r2192 r2430 34 34 m_persistentManifoldPool(0), 35 35 m_collisionAlgorithmPool(0), 36 m_defaultMaxPersistentManifoldPoolSize( 65535),37 m_defaultMaxCollisionAlgorithmPoolSize( 65535),38 m_defaultStackAllocatorSize( 5*1024*1024)36 m_defaultMaxPersistentManifoldPoolSize(4096), 37 m_defaultMaxCollisionAlgorithmPoolSize(4096), 38 m_defaultStackAllocatorSize(0) 39 39 { 40 40 } … … 45 45 ///btCollisionConfiguration allows to configure Bullet collision detection 46 46 ///stack allocator, pool memory allocators 47 /// todo: describe the meaning47 ///@todo: describe the meaning 48 48 class btDefaultCollisionConfiguration : public btCollisionConfiguration 49 49 { -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btManifoldResult.cpp
r2192 r2430 94 94 newPt.m_index1 = m_index1; 95 95 96 /// todo, check this for any side effects96 ///@todo, check this for any side effects 97 97 if (insertIndex >= 0) 98 98 { -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp
r2192 r2430 144 144 145 145 146 void btSimulationIslandManager::buildIslands(btDispatcher* dispatcher,btCollision ObjectArray& collisionObjects)146 void btSimulationIslandManager::buildIslands(btDispatcher* dispatcher,btCollisionWorld* collisionWorld) 147 147 { 148 148 149 149 BT_PROFILE("islandUnionFindAndQuickSort"); 150 150 151 btCollisionObjectArray& collisionObjects = collisionWorld->getCollisionObjectArray(); 152 151 153 m_islandmanifold.resize(0); 152 154 … … 239 241 { 240 242 colObj0->setActivationState( WANTS_DEACTIVATION); 243 colObj0->setDeactivationTime(0.f); 241 244 } 242 245 } … … 263 266 btCollisionObject* colObj1 = static_cast<btCollisionObject*>(manifold->getBody1()); 264 267 265 // todo: check sleeping conditions!268 ///@todo: check sleeping conditions! 266 269 if (((colObj0) && colObj0->getActivationState() != ISLAND_SLEEPING) || 267 270 ((colObj1) && colObj1->getActivationState() != ISLAND_SLEEPING)) … … 288 291 289 292 290 // 291 // todo: this is random access, it can be walked 'cache friendly'! 292 // 293 void btSimulationIslandManager::buildAndProcessIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects, IslandCallback* callback) 294 { 295 296 buildIslands(dispatcher,collisionObjects); 293 ///@todo: this is random access, it can be walked 'cache friendly'! 294 void btSimulationIslandManager::buildAndProcessIslands(btDispatcher* dispatcher,btCollisionWorld* collisionWorld, IslandCallback* callback) 295 { 296 btCollisionObjectArray& collisionObjects = collisionWorld->getCollisionObjectArray(); 297 298 buildIslands(dispatcher,collisionWorld); 297 299 298 300 int endIslandIndex=1; -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.h
r2192 r2430 20 20 #include "btCollisionCreateFunc.h" 21 21 #include "LinearMath/btAlignedObjectArray.h" 22 22 #include "btCollisionObject.h" 23 23 24 24 class btCollisionObject; … … 62 62 }; 63 63 64 void buildAndProcessIslands(btDispatcher* dispatcher,btCollision ObjectArray& collisionObjects, IslandCallback* callback);64 void buildAndProcessIslands(btDispatcher* dispatcher,btCollisionWorld* collisionWorld, IslandCallback* callback); 65 65 66 void buildIslands(btDispatcher* dispatcher,btCollision ObjectArray& collisionObjects);66 void buildIslands(btDispatcher* dispatcher,btCollisionWorld* colWorld); 67 67 68 68 }; -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp
r2192 r2430 22 22 23 23 btSphereBoxCollisionAlgorithm::btSphereBoxCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped) 24 : bt CollisionAlgorithm(ci),24 : btActivatingCollisionAlgorithm(ci,col0,col1), 25 25 m_ownManifold(false), 26 26 m_manifoldPtr(mf), -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.h
r2192 r2430 17 17 #define SPHERE_BOX_COLLISION_ALGORITHM_H 18 18 19 #include " BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"19 #include "btActivatingCollisionAlgorithm.h" 20 20 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" 21 21 #include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h" … … 27 27 /// btSphereBoxCollisionAlgorithm provides sphere-box collision detection. 28 28 /// Other features are frame-coherency (persistent data) and collision response. 29 class btSphereBoxCollisionAlgorithm : public bt CollisionAlgorithm29 class btSphereBoxCollisionAlgorithm : public btActivatingCollisionAlgorithm 30 30 { 31 31 bool m_ownManifold; -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp
r2192 r2430 20 20 21 21 btSphereSphereCollisionAlgorithm::btSphereSphereCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1) 22 : bt CollisionAlgorithm(ci),22 : btActivatingCollisionAlgorithm(ci,col0,col1), 23 23 m_ownManifold(false), 24 24 m_manifoldPtr(mf) -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h
r2192 r2430 17 17 #define SPHERE_SPHERE_COLLISION_ALGORITHM_H 18 18 19 #include " BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"19 #include "btActivatingCollisionAlgorithm.h" 20 20 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" 21 21 #include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h" … … 27 27 /// Other features are frame-coherency (persistent data) and collision response. 28 28 /// Also provides the most basic sample for custom/user btCollisionAlgorithm 29 class btSphereSphereCollisionAlgorithm : public bt CollisionAlgorithm29 class btSphereSphereCollisionAlgorithm : public btActivatingCollisionAlgorithm 30 30 { 31 31 bool m_ownManifold; … … 36 36 37 37 btSphereSphereCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci) 38 : bt CollisionAlgorithm(ci) {}38 : btActivatingCollisionAlgorithm(ci) {} 39 39 40 40 virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp
r2192 r2430 23 23 24 24 btSphereTriangleCollisionAlgorithm::btSphereTriangleCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1,bool swapped) 25 : bt CollisionAlgorithm(ci),25 : btActivatingCollisionAlgorithm(ci,col0,col1), 26 26 m_ownManifold(false), 27 27 m_manifoldPtr(mf), … … 57 57 /// report a contact. internally this will be kept persistent, and contact reduction is done 58 58 resultOut->setPersistentManifold(m_manifoldPtr); 59 SphereTriangleDetector detector(sphere,triangle );59 SphereTriangleDetector detector(sphere,triangle, m_manifoldPtr->getContactBreakingThreshold()); 60 60 61 61 btDiscreteCollisionDetectorInterface::ClosestPointInput input; 62 input.m_maximumDistanceSquared = btScalar(1e30);// todo: tighter bounds62 input.m_maximumDistanceSquared = btScalar(1e30);///@todo: tighter bounds 63 63 input.m_transformA = sphereObj->getWorldTransform(); 64 64 input.m_transformB = triObj->getWorldTransform(); -
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.h
r2192 r2430 17 17 #define SPHERE_TRIANGLE_COLLISION_ALGORITHM_H 18 18 19 #include " BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"19 #include "btActivatingCollisionAlgorithm.h" 20 20 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" 21 21 #include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h" … … 26 26 /// Other features are frame-coherency (persistent data) and collision response. 27 27 /// Also provides the most basic sample for custom/user btCollisionAlgorithm 28 class btSphereTriangleCollisionAlgorithm : public bt CollisionAlgorithm28 class btSphereTriangleCollisionAlgorithm : public btActivatingCollisionAlgorithm 29 29 { 30 30 bool m_ownManifold; … … 36 36 37 37 btSphereTriangleCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci) 38 : bt CollisionAlgorithm(ci) {}38 : btActivatingCollisionAlgorithm(ci) {} 39 39 40 40 virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
Note: See TracChangeset
for help on using the changeset viewer.