Changeset 8393 for code/trunk/src/external/bullet/BulletCollision
- Timestamp:
- May 3, 2011, 5:07:42 AM (14 years ago)
- Location:
- code/trunk/src/external/bullet/BulletCollision
- Files:
-
- 4 added
- 97 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btAxisSweep3.h
r8351 r8393 17 17 // 3. This notice may not be removed or altered from any source distribution. 18 18 19 #ifndef AXIS_SWEEP_3_H20 #define AXIS_SWEEP_3_H19 #ifndef BT_AXIS_SWEEP_3_H 20 #define BT_AXIS_SWEEP_3_H 21 21 22 22 #include "LinearMath/btVector3.h" -
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btBroadphaseInterface.h
r8351 r8393 14 14 */ 15 15 16 #ifndef B ROADPHASE_INTERFACE_H17 #define B ROADPHASE_INTERFACE_H16 #ifndef BT_BROADPHASE_INTERFACE_H 17 #define BT_BROADPHASE_INTERFACE_H 18 18 19 19 … … 80 80 }; 81 81 82 #endif //B ROADPHASE_INTERFACE_H82 #endif //BT_BROADPHASE_INTERFACE_H -
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h
r8351 r8393 14 14 */ 15 15 16 #ifndef B ROADPHASE_PROXY_H17 #define B ROADPHASE_PROXY_H16 #ifndef BT_BROADPHASE_PROXY_H 17 #define BT_BROADPHASE_PROXY_H 18 18 19 19 #include "LinearMath/btScalar.h" //for SIMD_FORCE_INLINE … … 267 267 268 268 269 #endif //B ROADPHASE_PROXY_H270 269 #endif //BT_BROADPHASE_PROXY_H 270 -
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h
r5781 r8393 14 14 */ 15 15 16 #ifndef COLLISION_ALGORITHM_H17 #define COLLISION_ALGORITHM_H16 #ifndef BT_COLLISION_ALGORITHM_H 17 #define BT_COLLISION_ALGORITHM_H 18 18 19 19 #include "LinearMath/btScalar.h" … … 45 45 btPersistentManifold* m_manifold; 46 46 47 int getDispatcherId();47 // int getDispatcherId(); 48 48 49 49 }; … … 60 60 61 61 protected: 62 int getDispatcherId();62 // int getDispatcherId(); 63 63 64 64 public: … … 78 78 79 79 80 #endif // COLLISION_ALGORITHM_H80 #endif //BT_COLLISION_ALGORITHM_H -
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btDispatcher.h
r8351 r8393 14 14 */ 15 15 16 #ifndef _DISPATCHER_H 17 #define _DISPATCHER_H 18 16 #ifndef BT_DISPATCHER_H 17 #define BT_DISPATCHER_H 19 18 #include "LinearMath/btScalar.h" 20 19 … … 28 27 class btPersistentManifold; 29 28 class btStackAlloc; 29 class btPoolAllocator; 30 30 31 31 struct btDispatcherInfo … … 41 41 m_dispatchFunc(DISPATCH_DISCRETE), 42 42 m_timeOfImpact(btScalar(1.)), 43 m_useContinuous( false),43 m_useContinuous(true), 44 44 m_debugDraw(0), 45 45 m_enableSatConvex(false), … … 49 49 m_useConvexConservativeDistanceUtil(false), 50 50 m_convexConservativeDistanceThreshold(0.0f), 51 m_convexMaxDistanceUseCPT(false),52 51 m_stackAllocator(0) 53 52 { … … 66 65 bool m_useConvexConservativeDistanceUtil; 67 66 btScalar m_convexConservativeDistanceThreshold; 68 bool m_convexMaxDistanceUseCPT;69 67 btStackAlloc* m_stackAllocator; 70 68 }; … … 99 97 virtual btPersistentManifold** getInternalManifoldPointer() = 0; 100 98 99 virtual btPoolAllocator* getInternalManifoldPool() = 0; 100 101 virtual const btPoolAllocator* getInternalManifoldPool() const = 0; 102 101 103 virtual void* allocateCollisionAlgorithm(int size) = 0; 102 104 … … 106 108 107 109 108 #endif // _DISPATCHER_H110 #endif //BT_DISPATCHER_H -
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h
r8351 r8393 14 14 */ 15 15 16 #ifndef OVERLAPPING_PAIR_CACHE_H17 #define OVERLAPPING_PAIR_CACHE_H16 #ifndef BT_OVERLAPPING_PAIR_CACHE_H 17 #define BT_OVERLAPPING_PAIR_CACHE_H 18 18 19 19 … … 465 465 466 466 467 #endif // OVERLAPPING_PAIR_CACHE_H468 469 467 #endif //BT_OVERLAPPING_PAIR_CACHE_H 468 469 -
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btQuantizedBvh.h
r8351 r8393 14 14 */ 15 15 16 #ifndef QUANTIZED_BVH_H17 #define QUANTIZED_BVH_H16 #ifndef BT_QUANTIZED_BVH_H 17 #define BT_QUANTIZED_BVH_H 18 18 19 19 class btSerializer; … … 577 577 578 578 579 #endif // QUANTIZED_BVH_H579 #endif //BT_QUANTIZED_BVH_H -
code/trunk/src/external/bullet/BulletCollision/BroadphaseCollision/btSimpleBroadphase.h
r8351 r8393 14 14 */ 15 15 16 #ifndef SIMPLE_BROADPHASE_H17 #define SIMPLE_BROADPHASE_H16 #ifndef BT_SIMPLE_BROADPHASE_H 17 #define BT_SIMPLE_BROADPHASE_H 18 18 19 19 … … 168 168 169 169 170 #endif // SIMPLE_BROADPHASE_H170 #endif //BT_SIMPLE_BROADPHASE_H 171 171 -
code/trunk/src/external/bullet/BulletCollision/CMakeLists.txt
r8351 r8393 50 50 CollisionShapes/btConvexInternalShape.cpp 51 51 CollisionShapes/btConvexPointCloudShape.cpp 52 CollisionShapes/btConvexPolyhedron.cpp 52 53 CollisionShapes/btConvexShape.cpp 53 54 CollisionShapes/btConvex2dShape.cpp … … 88 89 89 90 COMPILATION_END 91 92 # Raises compiler errors when compiled inside the compilation 93 NarrowPhaseCollision/btPolyhedralContactClipping.cpp 90 94 91 95 # Headers … … 140 144 CollisionShapes/btConvexInternalShape.h 141 145 CollisionShapes/btConvexPointCloudShape.h 146 CollisionShapes/btConvexPolyhedron.h 142 147 CollisionShapes/btConvexShape.h 143 148 CollisionShapes/btConvex2dShape.h … … 184 189 NarrowPhaseCollision/btSubSimplexConvexCast.h 185 190 NarrowPhaseCollision/btVoronoiSimplexSolver.h 191 NarrowPhaseCollision/btPolyhedralContactClipping.h 186 192 ) -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp
r8351 r8393 58 58 } 59 59 60 #define MAX_OVERLAP btScalar(0.)61 62 60 63 61 … … 94 92 } 95 93 96 ///combined discrete/continuous sphere-triangle97 94 bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact, btScalar contactBreakingThreshold) 98 95 { 99 96 100 97 const btVector3* vertices = &m_triangle->getVertexPtr(0); 101 const btVector3& c = sphereCenter; 102 btScalar r = m_sphere->getRadius(); 103 104 btVector3 delta (0,0,0); 98 99 btScalar radius = m_sphere->getRadius(); 100 btScalar radiusWithThreshold = radius + contactBreakingThreshold; 105 101 106 102 btVector3 normal = (vertices[1]-vertices[0]).cross(vertices[2]-vertices[0]); 107 103 normal.normalize(); 108 btVector3 p1ToCentre = c- vertices[0];104 btVector3 p1ToCentre = sphereCenter - vertices[0]; 109 105 btScalar distanceFromPlane = p1ToCentre.dot(normal); 110 106 … … 112 108 { 113 109 //triangle facing the other way 114 115 110 distanceFromPlane *= btScalar(-1.); 116 111 normal *= btScalar(-1.); 117 112 } 118 113 119 btScalar contactMargin = contactBreakingThreshold; 120 bool isInsideContactPlane = distanceFromPlane < r + contactMargin; 121 bool isInsideShellPlane = distanceFromPlane < r; 122 123 btScalar deltaDotNormal = delta.dot(normal); 124 if (!isInsideShellPlane && deltaDotNormal >= btScalar(0.0)) 125 return false; 126 114 bool isInsideContactPlane = distanceFromPlane < radiusWithThreshold; 115 127 116 // Check for contact / intersection 128 117 bool hasContact = false; 129 118 btVector3 contactPoint; 130 119 if (isInsideContactPlane) { 131 if (facecontains( c,vertices,normal)) {120 if (facecontains(sphereCenter,vertices,normal)) { 132 121 // Inside the contact wedge - touches a point on the shell plane 133 122 hasContact = true; 134 contactPoint = c- normal*distanceFromPlane;123 contactPoint = sphereCenter - normal*distanceFromPlane; 135 124 } else { 136 125 // Could be inside one of the contact capsules 137 btScalar contactCapsuleRadiusSqr = (r + contactMargin) * (r + contactMargin);126 btScalar contactCapsuleRadiusSqr = radiusWithThreshold*radiusWithThreshold; 138 127 btVector3 nearestOnEdge; 139 128 for (int i = 0; i < m_triangle->getNumEdges(); i++) { … … 144 133 m_triangle->getEdge(i,pa,pb); 145 134 146 btScalar distanceSqr = SegmentSqrDistance(pa,pb, c, nearestOnEdge);135 btScalar distanceSqr = SegmentSqrDistance(pa,pb,sphereCenter, nearestOnEdge); 147 136 if (distanceSqr < contactCapsuleRadiusSqr) { 148 137 // Yep, we're inside a capsule … … 156 145 157 146 if (hasContact) { 158 btVector3 contactToCentre = c- contactPoint;147 btVector3 contactToCentre = sphereCenter - contactPoint; 159 148 btScalar distanceSqr = contactToCentre.length2(); 160 if (distanceSqr < (r - MAX_OVERLAP)*(r - MAX_OVERLAP)) { 161 btScalar distance = btSqrt(distanceSqr); 162 resultNormal = contactToCentre; 163 resultNormal.normalize(); 164 point = contactPoint; 165 depth = -(r-distance); 149 150 if (distanceSqr < radiusWithThreshold*radiusWithThreshold) 151 { 152 if (distanceSqr>SIMD_EPSILON) 153 { 154 btScalar distance = btSqrt(distanceSqr); 155 resultNormal = contactToCentre; 156 resultNormal.normalize(); 157 point = contactPoint; 158 depth = -(radius-distance); 159 } else 160 { 161 btScalar distance = 0.f; 162 resultNormal = normal; 163 point = contactPoint; 164 depth = -radius; 165 } 166 166 return true; 167 167 } 168 169 if (delta.dot(contactToCentre) >= btScalar(0.0))170 return false;171 172 // Moving towards the contact point -> collision173 point = contactPoint;174 timeOfImpact = btScalar(0.0);175 return true;176 168 } 177 169 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/SphereTriangleDetector.h
r8351 r8393 14 14 */ 15 15 16 #ifndef SPHERE_TRIANGLE_DETECTOR_H17 #define SPHERE_TRIANGLE_DETECTOR_H16 #ifndef BT_SPHERE_TRIANGLE_DETECTOR_H 17 #define BT_SPHERE_TRIANGLE_DETECTOR_H 18 18 19 19 #include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h" … … 48 48 49 49 }; 50 #endif // SPHERE_TRIANGLE_DETECTOR_H50 #endif //BT_SPHERE_TRIANGLE_DETECTOR_H 51 51 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.h
r8351 r8393 14 14 */ 15 15 16 #ifndef B OX_2D_BOX_2D__COLLISION_ALGORITHM_H17 #define B OX_2D_BOX_2D__COLLISION_ALGORITHM_H16 #ifndef BT_BOX_2D_BOX_2D__COLLISION_ALGORITHM_H 17 #define BT_BOX_2D_BOX_2D__COLLISION_ALGORITHM_H 18 18 19 19 #include "BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h" … … 63 63 }; 64 64 65 #endif //B OX_2D_BOX_2D__COLLISION_ALGORITHM_H65 #endif //BT_BOX_2D_BOX_2D__COLLISION_ALGORITHM_H 66 66 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.h
r5781 r8393 14 14 */ 15 15 16 #ifndef B OX_BOX__COLLISION_ALGORITHM_H17 #define B OX_BOX__COLLISION_ALGORITHM_H16 #ifndef BT_BOX_BOX__COLLISION_ALGORITHM_H 17 #define BT_BOX_BOX__COLLISION_ALGORITHM_H 18 18 19 19 #include "btActivatingCollisionAlgorithm.h" … … 63 63 }; 64 64 65 #endif //B OX_BOX__COLLISION_ALGORITHM_H65 #endif //BT_BOX_BOX__COLLISION_ALGORITHM_H 66 66 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btBoxBoxDetector.h
r5781 r8393 17 17 3. This notice may not be removed or altered from any source distribution. 18 18 */ 19 #ifndef B OX_BOX_DETECTOR_H20 #define B OX_BOX_DETECTOR_H19 #ifndef BT_BOX_BOX_DETECTOR_H 20 #define BT_BOX_BOX_DETECTOR_H 21 21 22 22 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionConfiguration.h
r5781 r8393 16 16 #ifndef BT_COLLISION_CONFIGURATION 17 17 #define BT_COLLISION_CONFIGURATION 18 18 19 struct btCollisionAlgorithmCreateFunc; 19 20 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionCreateFunc.h
r5781 r8393 14 14 */ 15 15 16 #ifndef COLLISION_CREATE_FUNC17 #define COLLISION_CREATE_FUNC16 #ifndef BT_COLLISION_CREATE_FUNC 17 #define BT_COLLISION_CREATE_FUNC 18 18 19 19 #include "LinearMath/btAlignedObjectArray.h" … … 42 42 } 43 43 }; 44 #endif // COLLISION_CREATE_FUNC44 #endif //BT_COLLISION_CREATE_FUNC 45 45 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp
r8351 r8393 93 93 } else 94 94 { 95 mem = btAlignedAlloc(sizeof(btPersistentManifold),16); 96 95 //we got a pool memory overflow, by default we fallback to dynamically allocate memory. If we require a contiguous contact pool then assert. 96 if ((m_dispatcherFlags&CD_DISABLE_CONTACTPOOL_DYNAMIC_ALLOCATION)==0) 97 { 98 mem = btAlignedAlloc(sizeof(btPersistentManifold),16); 99 } else 100 { 101 btAssert(0); 102 //make sure to increase the m_defaultMaxPersistentManifoldPoolSize in the btDefaultCollisionConstructionInfo/btDefaultCollisionConfiguration 103 return 0; 104 } 97 105 } 98 106 btPersistentManifold* manifold = new(mem) btPersistentManifold (body0,body1,0,contactBreakingThreshold,contactProcessingThreshold); … … 173 181 { 174 182 //broadphase filtering already deals with this 175 if ((body0->isStaticObject() || body0->isKinematicObject()) && 176 (body1->isStaticObject() || body1->isKinematicObject())) 183 if (body0->isStaticOrKinematicObject() && body1->isStaticOrKinematicObject()) 177 184 { 178 185 m_dispatcherFlags |= btCollisionDispatcher::CD_STATIC_STATIC_REPORTED; -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionDispatcher.h
r8351 r8393 14 14 */ 15 15 16 #ifndef COLLISION__DISPATCHER_H17 #define COLLISION__DISPATCHER_H16 #ifndef BT_COLLISION__DISPATCHER_H 17 #define BT_COLLISION__DISPATCHER_H 18 18 19 19 #include "BulletCollision/BroadphaseCollision/btDispatcher.h" … … 43 43 class btCollisionDispatcher : public btDispatcher 44 44 { 45 46 protected: 47 45 48 int m_dispatcherFlags; 46 49 47 50 btAlignedObjectArray<btPersistentManifold*> m_manifoldsPtr; 48 51 … … 65 68 { 66 69 CD_STATIC_STATIC_REPORTED = 1, 67 CD_USE_RELATIVE_CONTACT_BREAKING_THRESHOLD = 2 70 CD_USE_RELATIVE_CONTACT_BREAKING_THRESHOLD = 2, 71 CD_DISABLE_CONTACTPOOL_DYNAMIC_ALLOCATION = 4 68 72 }; 69 73 … … 75 79 void setDispatcherFlags(int flags) 76 80 { 77 (void) flags; 78 m_dispatcherFlags = 0; 81 m_dispatcherFlags = flags; 79 82 } 80 83 … … 154 157 } 155 158 159 virtual btPoolAllocator* getInternalManifoldPool() 160 { 161 return m_persistentManifoldPoolAllocator; 162 } 163 164 virtual const btPoolAllocator* getInternalManifoldPool() const 165 { 166 return m_persistentManifoldPoolAllocator; 167 } 168 156 169 }; 157 170 158 #endif // COLLISION__DISPATCHER_H171 #endif //BT_COLLISION__DISPATCHER_H 159 172 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionObject.h
r8351 r8393 14 14 */ 15 15 16 #ifndef COLLISION_OBJECT_H17 #define COLLISION_OBJECT_H16 #ifndef BT_COLLISION_OBJECT_H 17 #define BT_COLLISION_OBJECT_H 18 18 19 19 #include "LinearMath/btTransform.h" … … 522 522 523 523 524 #endif // COLLISION_OBJECT_H524 #endif //BT_COLLISION_OBJECT_H -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
r8351 r8393 29 29 #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" 30 30 #include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h" 31 #include "BulletCollision/BroadphaseCollision/btDbvt.h" 31 32 #include "LinearMath/btAabbUtil2.h" 32 33 #include "LinearMath/btQuickprof.h" 33 34 #include "LinearMath/btStackAlloc.h" 34 35 #include "LinearMath/btSerializer.h" 36 #include "BulletCollision/CollisionShapes/btConvexPolyhedron.h" 37 38 //#define DISABLE_DBVT_COMPOUNDSHAPE_RAYCAST_ACCELERATION 39 35 40 36 41 //#define USE_BRUTEFORCE_RAYBROADPHASE 1 … … 151 156 maxAabb += contactThreshold; 152 157 158 if(getDispatchInfo().m_useContinuous && colObj->getInternalType()==btCollisionObject::CO_RIGID_BODY) 159 { 160 btVector3 minAabb2,maxAabb2; 161 colObj->getCollisionShape()->getAabb(colObj->getInterpolationWorldTransform(),minAabb2,maxAabb2); 162 minAabb2 -= contactThreshold; 163 maxAabb2 += contactThreshold; 164 minAabb.setMin(minAabb2); 165 maxAabb.setMax(maxAabb2); 166 } 167 153 168 btBroadphaseInterface* bp = (btBroadphaseInterface*)m_broadphasePairCache; 154 169 … … 421 436 } else { 422 437 // BT_PROFILE("rayTestCompound"); 423 ///@todo: use AABB tree or other BVH acceleration structure, see btDbvt424 438 if (collisionShape->isCompound()) 425 439 { 440 struct LocalInfoAdder2 : public RayResultCallback 441 { 442 RayResultCallback* m_userCallback; 443 int m_i; 444 445 LocalInfoAdder2 (int i, RayResultCallback *user) 446 : m_userCallback(user), m_i(i) 447 { 448 m_closestHitFraction = m_userCallback->m_closestHitFraction; 449 } 450 virtual bool needsCollision(btBroadphaseProxy* p) const 451 { 452 return m_userCallback->needsCollision(p); 453 } 454 455 virtual btScalar addSingleResult (btCollisionWorld::LocalRayResult &r, bool b) 456 { 457 btCollisionWorld::LocalShapeInfo shapeInfo; 458 shapeInfo.m_shapePart = -1; 459 shapeInfo.m_triangleIndex = m_i; 460 if (r.m_localShapeInfo == NULL) 461 r.m_localShapeInfo = &shapeInfo; 462 463 const btScalar result = m_userCallback->addSingleResult(r, b); 464 m_closestHitFraction = m_userCallback->m_closestHitFraction; 465 return result; 466 } 467 }; 468 469 struct RayTester : btDbvt::ICollide 470 { 471 btCollisionObject* m_collisionObject; 472 const btCompoundShape* m_compoundShape; 473 const btTransform& m_colObjWorldTransform; 474 const btTransform& m_rayFromTrans; 475 const btTransform& m_rayToTrans; 476 RayResultCallback& m_resultCallback; 477 478 RayTester(btCollisionObject* collisionObject, 479 const btCompoundShape* compoundShape, 480 const btTransform& colObjWorldTransform, 481 const btTransform& rayFromTrans, 482 const btTransform& rayToTrans, 483 RayResultCallback& resultCallback): 484 m_collisionObject(collisionObject), 485 m_compoundShape(compoundShape), 486 m_colObjWorldTransform(colObjWorldTransform), 487 m_rayFromTrans(rayFromTrans), 488 m_rayToTrans(rayToTrans), 489 m_resultCallback(resultCallback) 490 { 491 492 } 493 494 void Process(int i) 495 { 496 const btCollisionShape* childCollisionShape = m_compoundShape->getChildShape(i); 497 const btTransform& childTrans = m_compoundShape->getChildTransform(i); 498 btTransform childWorldTrans = m_colObjWorldTransform * childTrans; 499 500 // replace collision shape so that callback can determine the triangle 501 btCollisionShape* saveCollisionShape = m_collisionObject->getCollisionShape(); 502 m_collisionObject->internalSetTemporaryCollisionShape((btCollisionShape*)childCollisionShape); 503 504 LocalInfoAdder2 my_cb(i, &m_resultCallback); 505 506 rayTestSingle( 507 m_rayFromTrans, 508 m_rayToTrans, 509 m_collisionObject, 510 childCollisionShape, 511 childWorldTrans, 512 my_cb); 513 514 // restore 515 m_collisionObject->internalSetTemporaryCollisionShape(saveCollisionShape); 516 } 517 518 void Process(const btDbvtNode* leaf) 519 { 520 Process(leaf->dataAsInt); 521 } 522 }; 523 426 524 const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(collisionShape); 427 int i=0; 428 for (i=0;i<compoundShape->getNumChildShapes();i++) 429 { 430 btTransform childTrans = compoundShape->getChildTransform(i); 431 const btCollisionShape* childCollisionShape = compoundShape->getChildShape(i); 432 btTransform childWorldTrans = colObjWorldTransform * childTrans; 433 // replace collision shape so that callback can determine the triangle 434 btCollisionShape* saveCollisionShape = collisionObject->getCollisionShape(); 435 collisionObject->internalSetTemporaryCollisionShape((btCollisionShape*)childCollisionShape); 436 struct LocalInfoAdder2 : public RayResultCallback { 437 RayResultCallback* m_userCallback; 438 int m_i; 439 LocalInfoAdder2 (int i, RayResultCallback *user) 440 : m_userCallback(user), 441 m_i(i) 442 { 443 m_closestHitFraction = m_userCallback->m_closestHitFraction; 444 } 445 virtual btScalar addSingleResult (btCollisionWorld::LocalRayResult &r, bool b) 446 { 447 btCollisionWorld::LocalShapeInfo shapeInfo; 448 shapeInfo.m_shapePart = -1; 449 shapeInfo.m_triangleIndex = m_i; 450 if (r.m_localShapeInfo == NULL) 451 r.m_localShapeInfo = &shapeInfo; 452 453 const btScalar result = m_userCallback->addSingleResult(r, b); 454 m_closestHitFraction = m_userCallback->m_closestHitFraction; 455 return result; 456 } 457 }; 458 459 LocalInfoAdder2 my_cb(i, &resultCallback); 460 461 rayTestSingle(rayFromTrans,rayToTrans, 462 collisionObject, 463 childCollisionShape, 464 childWorldTrans, 465 my_cb); 466 // restore 467 collisionObject->internalSetTemporaryCollisionShape(saveCollisionShape); 525 const btDbvt* dbvt = compoundShape->getDynamicAabbTree(); 526 527 528 RayTester rayCB( 529 collisionObject, 530 compoundShape, 531 colObjWorldTransform, 532 rayFromTrans, 533 rayToTrans, 534 resultCallback); 535 #ifndef DISABLE_DBVT_COMPOUNDSHAPE_RAYCAST_ACCELERATION 536 if (dbvt) 537 { 538 btVector3 localRayFrom = colObjWorldTransform.inverseTimes(rayFromTrans).getOrigin(); 539 btVector3 localRayTo = colObjWorldTransform.inverseTimes(rayToTrans).getOrigin(); 540 btDbvt::rayTest(dbvt->m_root, localRayFrom , localRayTo, rayCB); 541 } 542 else 543 #endif //DISABLE_DBVT_COMPOUNDSHAPE_RAYCAST_ACCELERATION 544 { 545 for (int i = 0, n = compoundShape->getNumChildShapes(); i < n; ++i) 546 { 547 rayCB.Process(i); 548 } 468 549 } 469 550 } … … 577 658 BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,collisionObject,triangleMesh, colObjWorldTransform); 578 659 tccb.m_hitFraction = resultCallback.m_closestHitFraction; 660 tccb.m_allowedPenetration = allowedPenetration; 579 661 btVector3 boxMinLocal, boxMaxLocal; 580 662 castShape->getAabb(rotationXform, boxMinLocal, boxMaxLocal); … … 582 664 } else 583 665 { 584 //BT_PROFILE("convexSweepConcave"); 585 btConcaveShape* concaveShape = (btConcaveShape*)collisionShape; 586 btTransform worldTocollisionObject = colObjWorldTransform.inverse(); 587 btVector3 convexFromLocal = worldTocollisionObject * convexFromTrans.getOrigin(); 588 btVector3 convexToLocal = worldTocollisionObject * convexToTrans.getOrigin(); 589 // rotation of box in local mesh space = MeshRotation^-1 * ConvexToRotation 590 btTransform rotationXform = btTransform(worldTocollisionObject.getBasis() * convexToTrans.getBasis()); 591 592 //ConvexCast::CastResult 593 struct BridgeTriangleConvexcastCallback : public btTriangleConvexcastCallback 594 { 595 btCollisionWorld::ConvexResultCallback* m_resultCallback; 596 btCollisionObject* m_collisionObject; 597 btConcaveShape* m_triangleMesh; 598 599 BridgeTriangleConvexcastCallback(const btConvexShape* castShape, const btTransform& from,const btTransform& to, 600 btCollisionWorld::ConvexResultCallback* resultCallback, btCollisionObject* collisionObject,btConcaveShape* triangleMesh, const btTransform& triangleToWorld): 601 btTriangleConvexcastCallback(castShape, from,to, triangleToWorld, triangleMesh->getMargin()), 602 m_resultCallback(resultCallback), 603 m_collisionObject(collisionObject), 604 m_triangleMesh(triangleMesh) 605 { 666 if (collisionShape->getShapeType()==STATIC_PLANE_PROXYTYPE) 667 { 668 btConvexCast::CastResult castResult; 669 castResult.m_allowedPenetration = allowedPenetration; 670 castResult.m_fraction = resultCallback.m_closestHitFraction; 671 btStaticPlaneShape* planeShape = (btStaticPlaneShape*) collisionShape; 672 btContinuousConvexCollision convexCaster1(castShape,planeShape); 673 btConvexCast* castPtr = &convexCaster1; 674 675 if (castPtr->calcTimeOfImpact(convexFromTrans,convexToTrans,colObjWorldTransform,colObjWorldTransform,castResult)) 676 { 677 //add hit 678 if (castResult.m_normal.length2() > btScalar(0.0001)) 679 { 680 if (castResult.m_fraction < resultCallback.m_closestHitFraction) 681 { 682 castResult.m_normal.normalize(); 683 btCollisionWorld::LocalConvexResult localConvexResult 684 ( 685 collisionObject, 686 0, 687 castResult.m_normal, 688 castResult.m_hitPoint, 689 castResult.m_fraction 690 ); 691 692 bool normalInWorldSpace = true; 693 resultCallback.addSingleResult(localConvexResult, normalInWorldSpace); 694 } 695 } 606 696 } 607 697 608 609 virtual btScalar reportHit(const btVector3& hitNormalLocal, const btVector3& hitPointLocal, btScalar hitFraction, int partId, int triangleIndex ) 610 { 611 btCollisionWorld::LocalShapeInfo shapeInfo; 612 shapeInfo.m_shapePart = partId; 613 shapeInfo.m_triangleIndex = triangleIndex; 614 if (hitFraction <= m_resultCallback->m_closestHitFraction) 698 } else 699 { 700 //BT_PROFILE("convexSweepConcave"); 701 btConcaveShape* concaveShape = (btConcaveShape*)collisionShape; 702 btTransform worldTocollisionObject = colObjWorldTransform.inverse(); 703 btVector3 convexFromLocal = worldTocollisionObject * convexFromTrans.getOrigin(); 704 btVector3 convexToLocal = worldTocollisionObject * convexToTrans.getOrigin(); 705 // rotation of box in local mesh space = MeshRotation^-1 * ConvexToRotation 706 btTransform rotationXform = btTransform(worldTocollisionObject.getBasis() * convexToTrans.getBasis()); 707 708 //ConvexCast::CastResult 709 struct BridgeTriangleConvexcastCallback : public btTriangleConvexcastCallback 710 { 711 btCollisionWorld::ConvexResultCallback* m_resultCallback; 712 btCollisionObject* m_collisionObject; 713 btConcaveShape* m_triangleMesh; 714 715 BridgeTriangleConvexcastCallback(const btConvexShape* castShape, const btTransform& from,const btTransform& to, 716 btCollisionWorld::ConvexResultCallback* resultCallback, btCollisionObject* collisionObject,btConcaveShape* triangleMesh, const btTransform& triangleToWorld): 717 btTriangleConvexcastCallback(castShape, from,to, triangleToWorld, triangleMesh->getMargin()), 718 m_resultCallback(resultCallback), 719 m_collisionObject(collisionObject), 720 m_triangleMesh(triangleMesh) 615 721 { 616 617 btCollisionWorld::LocalConvexResult convexResult618 (m_collisionObject,619 &shapeInfo,620 hitNormalLocal,621 hitPointLocal,622 hitFraction);623 624 bool normalInWorldSpace = false;625 626 return m_resultCallback->addSingleResult(convexResult,normalInWorldSpace);627 722 } 628 return hitFraction; 629 } 630 631 }; 632 633 BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,collisionObject,concaveShape, colObjWorldTransform); 634 tccb.m_hitFraction = resultCallback.m_closestHitFraction; 635 btVector3 boxMinLocal, boxMaxLocal; 636 castShape->getAabb(rotationXform, boxMinLocal, boxMaxLocal); 637 638 btVector3 rayAabbMinLocal = convexFromLocal; 639 rayAabbMinLocal.setMin(convexToLocal); 640 btVector3 rayAabbMaxLocal = convexFromLocal; 641 rayAabbMaxLocal.setMax(convexToLocal); 642 rayAabbMinLocal += boxMinLocal; 643 rayAabbMaxLocal += boxMaxLocal; 644 concaveShape->processAllTriangles(&tccb,rayAabbMinLocal,rayAabbMaxLocal); 723 724 725 virtual btScalar reportHit(const btVector3& hitNormalLocal, const btVector3& hitPointLocal, btScalar hitFraction, int partId, int triangleIndex ) 726 { 727 btCollisionWorld::LocalShapeInfo shapeInfo; 728 shapeInfo.m_shapePart = partId; 729 shapeInfo.m_triangleIndex = triangleIndex; 730 if (hitFraction <= m_resultCallback->m_closestHitFraction) 731 { 732 733 btCollisionWorld::LocalConvexResult convexResult 734 (m_collisionObject, 735 &shapeInfo, 736 hitNormalLocal, 737 hitPointLocal, 738 hitFraction); 739 740 bool normalInWorldSpace = false; 741 742 return m_resultCallback->addSingleResult(convexResult,normalInWorldSpace); 743 } 744 return hitFraction; 745 } 746 747 }; 748 749 BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,collisionObject,concaveShape, colObjWorldTransform); 750 tccb.m_hitFraction = resultCallback.m_closestHitFraction; 751 tccb.m_allowedPenetration = allowedPenetration; 752 btVector3 boxMinLocal, boxMaxLocal; 753 castShape->getAabb(rotationXform, boxMinLocal, boxMaxLocal); 754 755 btVector3 rayAabbMinLocal = convexFromLocal; 756 rayAabbMinLocal.setMin(convexToLocal); 757 btVector3 rayAabbMaxLocal = convexFromLocal; 758 rayAabbMaxLocal.setMax(convexToLocal); 759 rayAabbMinLocal += boxMinLocal; 760 rayAabbMaxLocal += boxMaxLocal; 761 concaveShape->processAllTriangles(&tccb,rayAabbMinLocal,rayAabbMaxLocal); 762 } 645 763 } 646 764 } else { … … 667 785 { 668 786 m_closestHitFraction = m_userCallback->m_closestHitFraction; 787 } 788 virtual bool needsCollision(btBroadphaseProxy* p) const 789 { 790 return m_userCallback->needsCollision(p); 669 791 } 670 792 virtual btScalar addSingleResult (btCollisionWorld::LocalConvexResult& r, bool b) … … 1152 1274 1153 1275 int upAxis = capsuleShape->getUpAxis(); 1154 1155 1156 btVector3 capStart(0.f,0.f,0.f); 1157 capStart[upAxis] = -halfHeight; 1158 1159 btVector3 capEnd(0.f,0.f,0.f); 1160 capEnd[upAxis] = halfHeight; 1161 1162 // Draw the ends 1163 { 1164 1165 btTransform childTransform = worldTransform; 1166 childTransform.getOrigin() = worldTransform * capStart; 1167 getDebugDrawer()->drawSphere(radius, childTransform, color); 1168 } 1169 1170 { 1171 btTransform childTransform = worldTransform; 1172 childTransform.getOrigin() = worldTransform * capEnd; 1173 getDebugDrawer()->drawSphere(radius, childTransform, color); 1174 } 1175 1176 // Draw some additional lines 1177 btVector3 start = worldTransform.getOrigin(); 1178 1179 1180 capStart[(upAxis+1)%3] = radius; 1181 capEnd[(upAxis+1)%3] = radius; 1182 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color); 1183 capStart[(upAxis+1)%3] = -radius; 1184 capEnd[(upAxis+1)%3] = -radius; 1185 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color); 1186 1187 capStart[(upAxis+1)%3] = 0.f; 1188 capEnd[(upAxis+1)%3] = 0.f; 1189 1190 capStart[(upAxis+2)%3] = radius; 1191 capEnd[(upAxis+2)%3] = radius; 1192 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color); 1193 capStart[(upAxis+2)%3] = -radius; 1194 capEnd[(upAxis+2)%3] = -radius; 1195 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color); 1196 1197 1276 getDebugDrawer()->drawCapsule(radius, halfHeight, upAxis, worldTransform, color); 1198 1277 break; 1199 1278 } … … 1203 1282 btScalar radius = coneShape->getRadius();//+coneShape->getMargin(); 1204 1283 btScalar height = coneShape->getHeight();//+coneShape->getMargin(); 1205 btVector3 start = worldTransform.getOrigin();1206 1284 1207 1285 int upAxis= coneShape->getConeUpIndex(); 1208 1209 1210 btVector3 offsetHeight(0,0,0); 1211 offsetHeight[upAxis] = height * btScalar(0.5); 1212 btVector3 offsetRadius(0,0,0); 1213 offsetRadius[(upAxis+1)%3] = radius; 1214 btVector3 offset2Radius(0,0,0); 1215 offset2Radius[(upAxis+2)%3] = radius; 1216 1217 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight+offsetRadius),color); 1218 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight-offsetRadius),color); 1219 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight+offset2Radius),color); 1220 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight-offset2Radius),color); 1221 1222 // Drawing the base of the cone 1223 btVector3 yaxis(0,0,0); 1224 yaxis[upAxis] = btScalar(1.0); 1225 btVector3 xaxis(0,0,0); 1226 xaxis[(upAxis+1)%3] = btScalar(1.0); 1227 getDebugDrawer()->drawArc(start-worldTransform.getBasis()*(offsetHeight),worldTransform.getBasis()*yaxis,worldTransform.getBasis()*xaxis,radius,radius,0,SIMD_2_PI,color,false,10.0); 1228 break; 1286 getDebugDrawer()->drawCone(radius, height, upAxis, worldTransform, color); 1287 break; 1229 1288 1230 1289 } … … 1235 1294 btScalar radius = cylinder->getRadius(); 1236 1295 btScalar halfHeight = cylinder->getHalfExtentsWithMargin()[upAxis]; 1237 btVector3 start = worldTransform.getOrigin(); 1238 btVector3 offsetHeight(0,0,0); 1239 offsetHeight[upAxis] = halfHeight; 1240 btVector3 offsetRadius(0,0,0); 1241 offsetRadius[(upAxis+1)%3] = radius; 1242 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight+offsetRadius),start+worldTransform.getBasis() * (-offsetHeight+offsetRadius),color); 1243 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight-offsetRadius),start+worldTransform.getBasis() * (-offsetHeight-offsetRadius),color); 1244 1245 // Drawing top and bottom caps of the cylinder 1246 btVector3 yaxis(0,0,0); 1247 yaxis[upAxis] = btScalar(1.0); 1248 btVector3 xaxis(0,0,0); 1249 xaxis[(upAxis+1)%3] = btScalar(1.0); 1250 getDebugDrawer()->drawArc(start-worldTransform.getBasis()*(offsetHeight),worldTransform.getBasis()*yaxis,worldTransform.getBasis()*xaxis,radius,radius,0,SIMD_2_PI,color,false,btScalar(10.0)); 1251 getDebugDrawer()->drawArc(start+worldTransform.getBasis()*(offsetHeight),worldTransform.getBasis()*yaxis,worldTransform.getBasis()*xaxis,radius,radius,0,SIMD_2_PI,color,false,btScalar(10.0)); 1296 getDebugDrawer()->drawCylinder(radius, halfHeight, upAxis, worldTransform, color); 1252 1297 break; 1253 1298 } … … 1258 1303 btScalar planeConst = staticPlaneShape->getPlaneConstant(); 1259 1304 const btVector3& planeNormal = staticPlaneShape->getPlaneNormal(); 1260 btVector3 planeOrigin = planeNormal * planeConst; 1261 btVector3 vec0,vec1; 1262 btPlaneSpace1(planeNormal,vec0,vec1); 1263 btScalar vecLen = 100.f; 1264 btVector3 pt0 = planeOrigin + vec0*vecLen; 1265 btVector3 pt1 = planeOrigin - vec0*vecLen; 1266 btVector3 pt2 = planeOrigin + vec1*vecLen; 1267 btVector3 pt3 = planeOrigin - vec1*vecLen; 1268 getDebugDrawer()->drawLine(worldTransform*pt0,worldTransform*pt1,color); 1269 getDebugDrawer()->drawLine(worldTransform*pt2,worldTransform*pt3,color); 1305 getDebugDrawer()->drawPlane(planeNormal, planeConst,worldTransform, color); 1270 1306 break; 1271 1307 … … 1305 1341 1306 1342 int i; 1307 for (i=0;i<polyshape->getNumEdges();i++) 1308 { 1309 btVector3 a,b; 1310 polyshape->getEdge(i,a,b); 1311 btVector3 wa = worldTransform * a; 1312 btVector3 wb = worldTransform * b; 1313 getDebugDrawer()->drawLine(wa,wb,color); 1314 1343 if (polyshape->getConvexPolyhedron()) 1344 { 1345 const btConvexPolyhedron* poly = polyshape->getConvexPolyhedron(); 1346 for (i=0;i<poly->m_faces.size();i++) 1347 { 1348 btVector3 centroid(0,0,0); 1349 int numVerts = poly->m_faces[i].m_indices.size(); 1350 if (numVerts) 1351 { 1352 int lastV = poly->m_faces[i].m_indices[numVerts-1]; 1353 for (int v=0;v<poly->m_faces[i].m_indices.size();v++) 1354 { 1355 int curVert = poly->m_faces[i].m_indices[v]; 1356 centroid+=poly->m_vertices[curVert]; 1357 getDebugDrawer()->drawLine(worldTransform*poly->m_vertices[lastV],worldTransform*poly->m_vertices[curVert],color); 1358 lastV = curVert; 1359 } 1360 } 1361 centroid*= 1./btScalar(numVerts); 1362 1363 btVector3 normalColor(1,1,0); 1364 btVector3 faceNormal(poly->m_faces[i].m_plane[0],poly->m_faces[i].m_plane[1],poly->m_faces[i].m_plane[2]); 1365 getDebugDrawer()->drawLine(worldTransform*centroid,worldTransform*(centroid+faceNormal),normalColor); 1366 1367 1368 } 1369 1370 1371 } else 1372 { 1373 for (i=0;i<polyshape->getNumEdges();i++) 1374 { 1375 btVector3 a,b; 1376 polyshape->getEdge(i,a,b); 1377 btVector3 wa = worldTransform * a; 1378 btVector3 wb = worldTransform * b; 1379 getDebugDrawer()->drawLine(wa,wb,color); 1380 } 1315 1381 } 1316 1382 … … 1381 1447 btVector3 colorvec(1,0,0); 1382 1448 colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb); 1449 btVector3 contactThreshold(gContactBreakingThreshold,gContactBreakingThreshold,gContactBreakingThreshold); 1450 minAabb -= contactThreshold; 1451 maxAabb += contactThreshold; 1452 1453 btVector3 minAabb2,maxAabb2; 1454 1455 if(colObj->getInternalType()==btCollisionObject::CO_RIGID_BODY) 1456 { 1457 colObj->getCollisionShape()->getAabb(colObj->getInterpolationWorldTransform(),minAabb2,maxAabb2); 1458 minAabb2 -= contactThreshold; 1459 maxAabb2 += contactThreshold; 1460 minAabb.setMin(minAabb2); 1461 maxAabb.setMax(maxAabb2); 1462 } 1463 1383 1464 m_debugDrawer->drawAabb(minAabb,maxAabb,colorvec); 1384 1465 } -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.h
r8351 r8393 63 63 64 64 65 #ifndef COLLISION_WORLD_H66 #define COLLISION_WORLD_H65 #ifndef BT_COLLISION_WORLD_H 66 #define BT_COLLISION_WORLD_H 67 67 68 68 class btStackAlloc; … … 507 507 508 508 509 #endif // COLLISION_WORLD_H509 #endif //BT_COLLISION_WORLD_H -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp
r8351 r8393 235 235 } 236 236 } 237 manifoldArray. clear();237 manifoldArray.resize(0); 238 238 } 239 239 } -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h
r5781 r8393 14 14 */ 15 15 16 #ifndef COMPOUND_COLLISION_ALGORITHM_H17 #define COMPOUND_COLLISION_ALGORITHM_H16 #ifndef BT_COMPOUND_COLLISION_ALGORITHM_H 17 #define BT_COMPOUND_COLLISION_ALGORITHM_H 18 18 19 19 #include "btActivatingCollisionAlgorithm.h" … … 84 84 }; 85 85 86 #endif // COMPOUND_COLLISION_ALGORITHM_H86 #endif //BT_COMPOUND_COLLISION_ALGORITHM_H -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.h
r8351 r8393 14 14 */ 15 15 16 #ifndef CONVEX_2D_CONVEX_2D_ALGORITHM_H17 #define CONVEX_2D_CONVEX_2D_ALGORITHM_H16 #ifndef BT_CONVEX_2D_CONVEX_2D_ALGORITHM_H 17 #define BT_CONVEX_2D_CONVEX_2D_ALGORITHM_H 18 18 19 19 #include "BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h" … … 93 93 }; 94 94 95 #endif // CONVEX_2D_CONVEX_2D_ALGORITHM_H95 #endif //BT_CONVEX_2D_CONVEX_2D_ALGORITHM_H -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp
r8351 r8393 92 92 93 93 94 94 #if 0 95 95 ///debug drawing of the overlapping triangles 96 96 if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && (m_dispatchInfoPtr->m_debugDraw->getDebugMode() &btIDebugDraw::DBG_DrawWireframe )) … … 101 101 m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]),tr(triangle[2]),color); 102 102 m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(triangle[0]),color); 103 104 //btVector3 center = triangle[0] + triangle[1]+triangle[2]; 105 //center *= btScalar(0.333333); 106 //m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[0]),tr(center),color); 107 //m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]),tr(center),color); 108 //m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(center),color); 109 110 } 111 112 113 //btCollisionObject* colObj = static_cast<btCollisionObject*>(m_convexProxy->m_clientObject); 103 } 104 #endif 114 105 115 106 if (m_convexBody->getCollisionShape()->isConvex()) … … 120 111 btCollisionShape* tmpShape = ob->getCollisionShape(); 121 112 ob->internalSetTemporaryCollisionShape( &tm ); 122 113 123 114 btCollisionAlgorithm* colAlgo = ci.m_dispatcher1->findAlgorithm(m_convexBody,m_triBody,m_manifoldPtr); 124 115 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h
r5781 r8393 14 14 */ 15 15 16 #ifndef CONVEX_CONCAVE_COLLISION_ALGORITHM_H17 #define CONVEX_CONCAVE_COLLISION_ALGORITHM_H16 #ifndef BT_CONVEX_CONCAVE_COLLISION_ALGORITHM_H 17 #define BT_CONVEX_CONCAVE_COLLISION_ALGORITHM_H 18 18 19 19 #include "btActivatingCollisionAlgorithm.h" … … 114 114 }; 115 115 116 #endif // CONVEX_CONCAVE_COLLISION_ALGORITHM_H116 #endif //BT_CONVEX_CONCAVE_COLLISION_ALGORITHM_H -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp
r8351 r8393 27 27 #include "BulletCollision/CollisionShapes/btConvexShape.h" 28 28 #include "BulletCollision/CollisionShapes/btCapsuleShape.h" 29 #include "BulletCollision/CollisionShapes/btTriangleShape.h" 30 29 31 30 32 … … 49 51 #include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h" 50 52 #include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h" 51 53 #include "BulletCollision/NarrowPhaseCollision/btPolyhedralContactClipping.h" 52 54 53 55 … … 332 334 333 335 336 337 334 338 #ifdef USE_SEPDISTANCE_UTIL2 335 339 if (dispatchInfo.m_useConvexConservativeDistanceUtil) … … 358 362 #endif //USE_SEPDISTANCE_UTIL2 359 363 { 360 if (dispatchInfo.m_convexMaxDistanceUseCPT) 361 { 362 input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactProcessingThreshold(); 363 } else 364 { 365 input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingThreshold(); 366 } 364 //if (dispatchInfo.m_convexMaxDistanceUseCPT) 365 //{ 366 // input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactProcessingThreshold(); 367 //} else 368 //{ 369 input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingThreshold(); 370 // } 371 367 372 input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared; 368 373 } … … 372 377 input.m_transformB = body1->getWorldTransform(); 373 378 374 gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw); 379 375 380 376 381 … … 389 394 } 390 395 #endif //USE_SEPDISTANCE_UTIL2 396 397 if (min0->isPolyhedral() && min1->isPolyhedral()) 398 { 399 400 401 struct btDummyResult : public btDiscreteCollisionDetectorInterface::Result 402 { 403 virtual void setShapeIdentifiersA(int partId0,int index0){} 404 virtual void setShapeIdentifiersB(int partId1,int index1){} 405 virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth) 406 { 407 } 408 }; 409 410 btDummyResult dummy; 411 412 413 btPolyhedralConvexShape* polyhedronA = (btPolyhedralConvexShape*) min0; 414 btPolyhedralConvexShape* polyhedronB = (btPolyhedralConvexShape*) min1; 415 if (polyhedronA->getConvexPolyhedron() && polyhedronB->getConvexPolyhedron()) 416 { 417 418 419 gjkPairDetector.getClosestPoints(input,dummy,dispatchInfo.m_debugDraw); 420 421 422 btScalar threshold = m_manifoldPtr->getContactBreakingThreshold(); 423 424 btScalar minDist = 0.f; 425 btVector3 sepNormalWorldSpace; 426 bool foundSepAxis = true; 427 428 if (dispatchInfo.m_enableSatConvex) 429 { 430 foundSepAxis = btPolyhedralContactClipping::findSeparatingAxis( 431 *polyhedronA->getConvexPolyhedron(), *polyhedronB->getConvexPolyhedron(), 432 body0->getWorldTransform(), 433 body1->getWorldTransform(), 434 sepNormalWorldSpace); 435 } else 436 { 437 sepNormalWorldSpace = gjkPairDetector.getCachedSeparatingAxis().normalized(); 438 minDist = gjkPairDetector.getCachedSeparatingDistance(); 439 } 440 if (foundSepAxis) 441 { 442 // printf("sepNormalWorldSpace=%f,%f,%f\n",sepNormalWorldSpace.getX(),sepNormalWorldSpace.getY(),sepNormalWorldSpace.getZ()); 443 444 btPolyhedralContactClipping::clipHullAgainstHull(sepNormalWorldSpace, *polyhedronA->getConvexPolyhedron(), *polyhedronB->getConvexPolyhedron(), 445 body0->getWorldTransform(), 446 body1->getWorldTransform(), minDist-threshold, threshold, *resultOut); 447 448 } 449 if (m_ownManifold) 450 { 451 resultOut->refreshContactPoints(); 452 } 453 return; 454 455 } else 456 { 457 //we can also deal with convex versus triangle (without connectivity data) 458 if (polyhedronA->getConvexPolyhedron() && polyhedronB->getShapeType()==TRIANGLE_SHAPE_PROXYTYPE) 459 { 460 gjkPairDetector.getClosestPoints(input,dummy,dispatchInfo.m_debugDraw); 461 462 btVector3 sepNormalWorldSpace = gjkPairDetector.getCachedSeparatingAxis().normalized(); 463 464 btVertexArray vertices; 465 btTriangleShape* tri = (btTriangleShape*)polyhedronB; 466 vertices.push_back( body1->getWorldTransform()*tri->m_vertices1[0]); 467 vertices.push_back( body1->getWorldTransform()*tri->m_vertices1[1]); 468 vertices.push_back( body1->getWorldTransform()*tri->m_vertices1[2]); 469 470 btScalar threshold = m_manifoldPtr->getContactBreakingThreshold(); 471 btScalar minDist = gjkPairDetector.getCachedSeparatingDistance(); 472 btPolyhedralContactClipping::clipFaceAgainstHull(sepNormalWorldSpace, *polyhedronA->getConvexPolyhedron(), 473 body0->getWorldTransform(), vertices, minDist-threshold, threshold, *resultOut); 474 475 476 if (m_ownManifold) 477 { 478 resultOut->refreshContactPoints(); 479 } 480 481 return; 482 } 483 484 } 485 486 487 } 488 489 gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw); 391 490 392 491 //now perform 'm_numPerturbationIterations' collision queries with the perturbated collision objects -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h
r8351 r8393 14 14 */ 15 15 16 #ifndef CONVEX_CONVEX_ALGORITHM_H17 #define CONVEX_CONVEX_ALGORITHM_H16 #ifndef BT_CONVEX_CONVEX_ALGORITHM_H 17 #define BT_CONVEX_CONVEX_ALGORITHM_H 18 18 19 19 #include "btActivatingCollisionAlgorithm.h" … … 107 107 }; 108 108 109 #endif // CONVEX_CONVEX_ALGORITHM_H109 #endif //BT_CONVEX_CONVEX_ALGORITHM_H -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h
r8351 r8393 14 14 */ 15 15 16 #ifndef CONVEX_PLANE_COLLISION_ALGORITHM_H17 #define CONVEX_PLANE_COLLISION_ALGORITHM_H16 #ifndef BT_CONVEX_PLANE_COLLISION_ALGORITHM_H 17 #define BT_CONVEX_PLANE_COLLISION_ALGORITHM_H 18 18 19 19 #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" … … 81 81 }; 82 82 83 #endif // CONVEX_PLANE_COLLISION_ALGORITHM_H83 #endif //BT_CONVEX_PLANE_COLLISION_ALGORITHM_H 84 84 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h
r5781 r8393 14 14 */ 15 15 16 #ifndef EMPTY_ALGORITH17 #define EMPTY_ALGORITH16 #ifndef BT_EMPTY_ALGORITH 17 #define BT_EMPTY_ALGORITH 18 18 #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" 19 19 #include "btCollisionCreateFunc.h" … … 52 52 } ATTRIBUTE_ALIGNED(16); 53 53 54 #endif // EMPTY_ALGORITH54 #endif //BT_EMPTY_ALGORITH -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btInternalEdgeUtility.cpp
r8351 r8393 2 2 3 3 #include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h" 4 #include "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h" 4 5 #include "BulletCollision/CollisionShapes/btTriangleShape.h" 5 6 #include "BulletCollision/CollisionDispatch/btCollisionObject.h" … … 9 10 10 11 //#define DEBUG_INTERNAL_EDGE 11 12 12 13 13 #ifdef DEBUG_INTERNAL_EDGE … … 457 457 return; 458 458 459 btBvhTriangleMeshShape* trimesh = (btBvhTriangleMeshShape*)colObj0->getRootCollisionShape(); 460 btTriangleInfoMap* triangleInfoMapPtr = (btTriangleInfoMap*) trimesh->getTriangleInfoMap(); 459 btBvhTriangleMeshShape* trimesh = 0; 460 461 if( colObj0->getRootCollisionShape()->getShapeType() == SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE ) 462 trimesh = ((btScaledBvhTriangleMeshShape*)colObj0->getRootCollisionShape())->getChildShape(); 463 else 464 trimesh = (btBvhTriangleMeshShape*)colObj0->getRootCollisionShape(); 465 466 btTriangleInfoMap* triangleInfoMapPtr = (btTriangleInfoMap*) trimesh->getTriangleInfoMap(); 461 467 if (!triangleInfoMapPtr) 462 468 return; … … 502 508 btVector3 localContactNormalOnB = colObj0->getWorldTransform().getBasis().transpose() * cp.m_normalWorldOnB; 503 509 localContactNormalOnB.normalize();//is this necessary? 504 505 if ((info->m_edgeV0V1Angle)< SIMD_2_PI) 510 511 // Get closest edge 512 int bestedge=-1; 513 float disttobestedge=BT_LARGE_FLOAT; 514 // 515 // Edge 0 -> 1 516 if (btFabs(info->m_edgeV0V1Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold) 517 { 518 btVector3 nearest; 519 btNearestPointInLineSegment( cp.m_localPointB, v0, v1, nearest ); 520 float len=(contact-nearest).length(); 521 // 522 if( len < disttobestedge ) 523 { 524 bestedge=0; 525 disttobestedge=len; 526 } 527 } 528 // Edge 1 -> 2 529 if (btFabs(info->m_edgeV1V2Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold) 530 { 531 btVector3 nearest; 532 btNearestPointInLineSegment( cp.m_localPointB, v1, v2, nearest ); 533 float len=(contact-nearest).length(); 534 // 535 if( len < disttobestedge ) 536 { 537 bestedge=1; 538 disttobestedge=len; 539 } 540 } 541 // Edge 2 -> 0 542 if (btFabs(info->m_edgeV2V0Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold) 543 { 544 btVector3 nearest; 545 btNearestPointInLineSegment( cp.m_localPointB, v2, v0, nearest ); 546 float len=(contact-nearest).length(); 547 // 548 if( len < disttobestedge ) 549 { 550 bestedge=2; 551 disttobestedge=len; 552 } 553 } 554 555 #ifdef BT_INTERNAL_EDGE_DEBUG_DRAW 556 btVector3 upfix=tri_normal * btVector3(0.1f,0.1f,0.1f); 557 btDebugDrawLine(tr * v0 + upfix, tr * v1 + upfix, red ); 558 #endif 559 if (btFabs(info->m_edgeV0V1Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold) 506 560 { 507 561 #ifdef BT_INTERNAL_EDGE_DEBUG_DRAW … … 510 564 btScalar len = (contact-nearest).length(); 511 565 if(len<triangleInfoMapPtr->m_edgeDistanceThreshold) 566 if( bestedge==0 ) 512 567 { 513 568 btVector3 edge(v0-v1); … … 578 633 #endif //BT_INTERNAL_EDGE_DEBUG_DRAW 579 634 580 if ((info->m_edgeV1V2Angle)< SIMD_2_PI) 635 #ifdef BT_INTERNAL_EDGE_DEBUG_DRAW 636 btDebugDrawLine(tr * v1 + upfix, tr * v2 + upfix , green ); 637 #endif 638 639 if (btFabs(info->m_edgeV1V2Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold) 581 640 { 582 641 #ifdef BT_INTERNAL_EDGE_DEBUG_DRAW … … 588 647 btScalar len = (contact-nearest).length(); 589 648 if(len<triangleInfoMapPtr->m_edgeDistanceThreshold) 649 if( bestedge==1 ) 590 650 { 591 651 isNearEdge = true; … … 659 719 btDebugDrawLine(tr*nearest,tr*cp.m_localPointB,blue); 660 720 #endif //BT_INTERNAL_EDGE_DEBUG_DRAW 661 662 if ((info->m_edgeV2V0Angle)< SIMD_2_PI) 721 #ifdef BT_INTERNAL_EDGE_DEBUG_DRAW 722 btDebugDrawLine(tr * v2 + upfix, tr * v0 + upfix , blue ); 723 #endif 724 725 if (btFabs(info->m_edgeV2V0Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold) 663 726 { 664 727 … … 669 732 btScalar len = (contact-nearest).length(); 670 733 if(len<triangleInfoMapPtr->m_edgeDistanceThreshold) 734 if( bestedge==2 ) 671 735 { 672 736 isNearEdge = true; … … 760 824 } else 761 825 { 826 btVector3 newNormal = tri_normal *frontFacing; 827 //if the tri_normal is pointing opposite direction as the current local contact normal, skip it 828 btScalar d = newNormal.dot(localContactNormalOnB) ; 829 if (d< 0) 830 { 831 return; 832 } 762 833 //modify the normal to be the triangle normal (or backfacing normal) 763 cp.m_normalWorldOnB = colObj0->getWorldTransform().getBasis() *(tri_normal *frontFacing); 764 } 765 766 834 cp.m_normalWorldOnB = colObj0->getWorldTransform().getBasis() *newNormal; 835 } 836 767 837 // Reproject collision point along normal. 768 838 cp.m_positionWorldOnB = cp.m_positionWorldOnA - cp.m_normalWorldOnB * cp.m_distance1; -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btManifoldResult.cpp
r8351 r8393 64 64 btAssert(m_manifoldPtr); 65 65 //order in manifold needs to match 66 67 if (depth > m_manifoldPtr->getContactBreakingThreshold()) 66 67 // if (depth > m_manifoldPtr->getContactBreakingThreshold()) 68 if (depth > m_manifoldPtr->getContactProcessingThreshold()) 68 69 return; 69 70 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btManifoldResult.h
r8351 r8393 15 15 16 16 17 #ifndef MANIFOLD_RESULT_H18 #define MANIFOLD_RESULT_H17 #ifndef BT_MANIFOLD_RESULT_H 18 #define BT_MANIFOLD_RESULT_H 19 19 20 20 class btCollisionObject; … … 126 126 }; 127 127 128 #endif // MANIFOLD_RESULT_H128 #endif //BT_MANIFOLD_RESULT_H -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp
r8351 r8393 393 393 394 394 395 bool islandSleeping = false;395 bool islandSleeping = true; 396 396 397 397 for (endIslandIndex = startIslandIndex;(endIslandIndex<numElem) && (getUnionFind().getElement(endIslandIndex).m_id == islandId);endIslandIndex++) … … 400 400 btCollisionObject* colObj0 = collisionObjects[i]; 401 401 m_islandBodies.push_back(colObj0); 402 if ( !colObj0->isActive())403 islandSleeping = true;402 if (colObj0->isActive()) 403 islandSleeping = false; 404 404 } 405 405 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.h
r5781 r8393 14 14 */ 15 15 16 #ifndef SIMULATION_ISLAND_MANAGER_H17 #define SIMULATION_ISLAND_MANAGER_H16 #ifndef BT_SIMULATION_ISLAND_MANAGER_H 17 #define BT_SIMULATION_ISLAND_MANAGER_H 18 18 19 19 #include "BulletCollision/CollisionDispatch/btUnionFind.h" … … 78 78 }; 79 79 80 #endif // SIMULATION_ISLAND_MANAGER_H80 #endif //BT_SIMULATION_ISLAND_MANAGER_H 81 81 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.h
r5781 r8393 14 14 */ 15 15 16 #ifndef SPHERE_BOX_COLLISION_ALGORITHM_H17 #define SPHERE_BOX_COLLISION_ALGORITHM_H16 #ifndef BT_SPHERE_BOX_COLLISION_ALGORITHM_H 17 #define BT_SPHERE_BOX_COLLISION_ALGORITHM_H 18 18 19 19 #include "btActivatingCollisionAlgorithm.h" … … 72 72 }; 73 73 74 #endif // SPHERE_BOX_COLLISION_ALGORITHM_H74 #endif //BT_SPHERE_BOX_COLLISION_ALGORITHM_H 75 75 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h
r5781 r8393 14 14 */ 15 15 16 #ifndef SPHERE_SPHERE_COLLISION_ALGORITHM_H17 #define SPHERE_SPHERE_COLLISION_ALGORITHM_H16 #ifndef BT_SPHERE_SPHERE_COLLISION_ALGORITHM_H 17 #define BT_SPHERE_SPHERE_COLLISION_ALGORITHM_H 18 18 19 19 #include "btActivatingCollisionAlgorithm.h" … … 63 63 }; 64 64 65 #endif // SPHERE_SPHERE_COLLISION_ALGORITHM_H65 #endif //BT_SPHERE_SPHERE_COLLISION_ALGORITHM_H 66 66 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.h
r5781 r8393 14 14 */ 15 15 16 #ifndef SPHERE_TRIANGLE_COLLISION_ALGORITHM_H17 #define SPHERE_TRIANGLE_COLLISION_ALGORITHM_H16 #ifndef BT_SPHERE_TRIANGLE_COLLISION_ALGORITHM_H 17 #define BT_SPHERE_TRIANGLE_COLLISION_ALGORITHM_H 18 18 19 19 #include "btActivatingCollisionAlgorithm.h" … … 66 66 }; 67 67 68 #endif // SPHERE_TRIANGLE_COLLISION_ALGORITHM_H68 #endif //BT_SPHERE_TRIANGLE_COLLISION_ALGORITHM_H 69 69 -
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btUnionFind.h
r8351 r8393 14 14 */ 15 15 16 #ifndef UNION_FIND_H17 #define UNION_FIND_H16 #ifndef BT_UNION_FIND_H 17 #define BT_UNION_FIND_H 18 18 19 19 #include "LinearMath/btAlignedObjectArray.h" … … 127 127 128 128 129 #endif // UNION_FIND_H129 #endif //BT_UNION_FIND_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btBox2dShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef OBB_BOX_2D_SHAPE_H17 #define OBB_BOX_2D_SHAPE_H16 #ifndef BT_OBB_BOX_2D_SHAPE_H 17 #define BT_OBB_BOX_2D_SHAPE_H 18 18 19 19 #include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h" … … 359 359 }; 360 360 361 #endif // OBB_BOX_2D_SHAPE_H362 363 361 #endif //BT_OBB_BOX_2D_SHAPE_H 362 363 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btBoxShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef OBB_BOX_MINKOWSKI_H17 #define OBB_BOX_MINKOWSKI_H16 #ifndef BT_OBB_BOX_MINKOWSKI_H 17 #define BT_OBB_BOX_MINKOWSKI_H 18 18 19 19 #include "btPolyhedralConvexShape.h" … … 146 146 virtual void getVertex(int i,btVector3& vtx) const 147 147 { 148 btVector3 halfExtents = getHalfExtentsWith outMargin();148 btVector3 halfExtents = getHalfExtentsWithMargin(); 149 149 150 150 vtx = btVector3( … … 314 314 315 315 316 #endif // OBB_BOX_MINKOWSKI_H317 318 316 #endif //BT_OBB_BOX_MINKOWSKI_H 317 318 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp
r8351 r8393 278 278 279 279 unsigned int* gfxbase = (unsigned int*)(indexbase+nodeTriangleIndex*indexstride); 280 btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT );280 btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT||indicestype==PHY_UCHAR); 281 281 282 282 const btVector3& meshScaling = m_meshInterface->getScaling(); … … 284 284 { 285 285 286 int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]: gfxbase[j];286 int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:indicestype==PHY_INTEGER?gfxbase[j]:((unsigned char*)gfxbase)[j]; 287 287 288 288 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef B VH_TRIANGLE_MESH_SHAPE_H17 #define B VH_TRIANGLE_MESH_SHAPE_H16 #ifndef BT_BVH_TRIANGLE_MESH_SHAPE_H 17 #define BT_BVH_TRIANGLE_MESH_SHAPE_H 18 18 19 19 #include "btTriangleMeshShape.h" … … 40 40 BT_DECLARE_ALIGNED_ALLOCATOR(); 41 41 42 btBvhTriangleMeshShape() : btTriangleMeshShape(0),m_bvh(0),m_triangleInfoMap(0),m_ownsBvh(false) {m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE;};42 43 43 btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true); 44 44 … … 137 137 138 138 139 #endif //B VH_TRIANGLE_MESH_SHAPE_H139 #endif //BT_BVH_TRIANGLE_MESH_SHAPE_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btCollisionMargin.h
r8351 r8393 14 14 */ 15 15 16 #ifndef COLLISION_MARGIN_H17 #define COLLISION_MARGIN_H16 #ifndef BT_COLLISION_MARGIN_H 17 #define BT_COLLISION_MARGIN_H 18 18 19 19 //used by Gjk and some other algorithms … … 23 23 24 24 25 #endif // COLLISION_MARGIN_H25 #endif //BT_COLLISION_MARGIN_H 26 26 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btCollisionShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef COLLISION_SHAPE_H17 #define COLLISION_SHAPE_H16 #ifndef BT_COLLISION_SHAPE_H 17 #define BT_COLLISION_SHAPE_H 18 18 19 19 #include "LinearMath/btTransform.h" … … 147 147 148 148 149 #endif // COLLISION_SHAPE_H149 #endif //BT_COLLISION_SHAPE_H 150 150 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btCompoundShape.cpp
r8351 r8393 86 86 } 87 87 88 void btCompoundShape::updateChildTransform(int childIndex, const btTransform& newChildTransform )88 void btCompoundShape::updateChildTransform(int childIndex, const btTransform& newChildTransform,bool shouldRecalculateLocalAabb) 89 89 { 90 90 m_children[childIndex].m_transform = newChildTransform; … … 100 100 } 101 101 102 recalculateLocalAabb(); 102 if (shouldRecalculateLocalAabb) 103 { 104 recalculateLocalAabb(); 105 } 103 106 } 104 107 … … 284 287 m_children[i].m_childShape->setLocalScaling(childScale); 285 288 childTrans.setOrigin((childTrans.getOrigin())*scaling); 286 updateChildTransform(i, childTrans );287 recalculateLocalAabb();288 }289 updateChildTransform(i, childTrans,false); 290 } 291 289 292 m_localScaling = scaling; 293 recalculateLocalAabb(); 294 290 295 } 291 296 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btCompoundShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef COMPOUND_SHAPE_H17 #define COMPOUND_SHAPE_H16 #ifndef BT_COMPOUND_SHAPE_H 17 #define BT_COMPOUND_SHAPE_H 18 18 19 19 #include "btCollisionShape.h" … … 107 107 108 108 ///set a new transform for a child, and update internal data structures (local aabb and dynamic tree) 109 void updateChildTransform(int childIndex, const btTransform& newChildTransform );109 void updateChildTransform(int childIndex, const btTransform& newChildTransform, bool shouldRecalculateLocalAabb = true); 110 110 111 111 … … 144 144 } 145 145 146 147 btDbvt* getDynamicAabbTree() 146 const btDbvt* getDynamicAabbTree() const 147 { 148 return m_dynamicAabbTree; 149 } 150 151 btDbvt* getDynamicAabbTree() 148 152 { 149 153 return m_dynamicAabbTree; … … 206 210 207 211 208 #endif // COMPOUND_SHAPE_H212 #endif //BT_COMPOUND_SHAPE_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btConcaveShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef CONCAVE_SHAPE_H17 #define CONCAVE_SHAPE_H16 #ifndef BT_CONCAVE_SHAPE_H 17 #define BT_CONCAVE_SHAPE_H 18 18 19 19 #include "btCollisionShape.h" … … 58 58 }; 59 59 60 #endif // CONCAVE_SHAPE_H60 #endif //BT_CONCAVE_SHAPE_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btConeShape.cpp
r8351 r8393 132 132 133 133 134 void btConeShape::setLocalScaling(const btVector3& scaling) 135 { 136 int axis = m_coneIndices[1]; 137 int r1 = m_coneIndices[0]; 138 int r2 = m_coneIndices[2]; 139 m_height *= scaling[axis] / m_localScaling[axis]; 140 m_radius *= (scaling[r1] / m_localScaling[r1] + scaling[r2] / m_localScaling[r2]) / 2; 141 m_sinAngle = (m_radius / btSqrt(m_radius * m_radius + m_height * m_height)); 142 btConvexInternalShape::setLocalScaling(scaling); 143 } -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btConeShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef CONE_MINKOWSKI_H17 #define CONE_MINKOWSKI_H16 #ifndef BT_CONE_MINKOWSKI_H 17 #define BT_CONE_MINKOWSKI_H 18 18 19 19 #include "btConvexInternalShape.h" … … 82 82 return m_coneIndices[1]; 83 83 } 84 85 virtual void setLocalScaling(const btVector3& scaling); 86 84 87 }; 85 88 … … 97 100 btConeShapeZ(btScalar radius,btScalar height); 98 101 }; 99 #endif // CONE_MINKOWSKI_H102 #endif //BT_CONE_MINKOWSKI_H 100 103 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btConvex2dShape.h
r8351 r8393 20 20 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types 21 21 22 ///The btConvex2dShape allows to use arbitrary convex shapes a re2d convex shapes, with the Z component assumed to be 0.22 ///The btConvex2dShape allows to use arbitrary convex shapes as 2d convex shapes, with the Z component assumed to be 0. 23 23 ///For 2d boxes, the btBox2dShape is recommended. 24 24 class btConvex2dShape : public btConvexShape -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btConvexHullShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef CONVEX_HULL_SHAPE_H17 #define CONVEX_HULL_SHAPE_H16 #ifndef BT_CONVEX_HULL_SHAPE_H 17 #define BT_CONVEX_HULL_SHAPE_H 18 18 19 19 #include "btPolyhedralConvexShape.h" … … 117 117 118 118 119 #endif // CONVEX_HULL_SHAPE_H119 #endif //BT_CONVEX_HULL_SHAPE_H 120 120 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btConvexShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef CONVEX_SHAPE_INTERFACE117 #define CONVEX_SHAPE_INTERFACE116 #ifndef BT_CONVEX_SHAPE_INTERFACE1 17 #define BT_CONVEX_SHAPE_INTERFACE1 18 18 19 19 #include "btCollisionShape.h" … … 80 80 81 81 82 #endif // CONVEX_SHAPE_INTERFACE182 #endif //BT_CONVEX_SHAPE_INTERFACE1 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h
r8351 r8393 13 13 3. This notice may not be removed or altered from any source distribution. 14 14 */ 15 #ifndef CONVEX_TRIANGLEMESH_SHAPE_H16 #define CONVEX_TRIANGLEMESH_SHAPE_H15 #ifndef BT_CONVEX_TRIANGLEMESH_SHAPE_H 16 #define BT_CONVEX_TRIANGLEMESH_SHAPE_H 17 17 18 18 … … 70 70 71 71 72 #endif // CONVEX_TRIANGLEMESH_SHAPE_H72 #endif //BT_CONVEX_TRIANGLEMESH_SHAPE_H 73 73 74 74 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btCylinderShape.cpp
r8351 r8393 48 48 void btCylinderShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const 49 49 { 50 //approximation of box shape, todo: implement cylinder shape inertia before people notice ;-) 50 51 //Until Bullet 2.77 a box approximation was used, so uncomment this if you need backwards compatibility 52 //#define USE_BOX_INERTIA_APPROXIMATION 1 53 #ifndef USE_BOX_INERTIA_APPROXIMATION 54 55 /* 56 cylinder is defined as following: 57 * 58 * - principle axis aligned along y by default, radius in x, z-value not used 59 * - for btCylinderShapeX: principle axis aligned along x, radius in y direction, z-value not used 60 * - for btCylinderShapeZ: principle axis aligned along z, radius in x direction, y-value not used 61 * 62 */ 63 64 btScalar radius2; // square of cylinder radius 65 btScalar height2; // square of cylinder height 66 btVector3 halfExtents = getHalfExtentsWithMargin(); // get cylinder dimension 67 btScalar div12 = mass / 12.f; 68 btScalar div4 = mass / 4.f; 69 btScalar div2 = mass / 2.f; 70 int idxRadius, idxHeight; 71 72 switch (m_upAxis) // get indices of radius and height of cylinder 73 { 74 case 0: // cylinder is aligned along x 75 idxRadius = 1; 76 idxHeight = 0; 77 break; 78 case 2: // cylinder is aligned along z 79 idxRadius = 0; 80 idxHeight = 2; 81 break; 82 default: // cylinder is aligned along y 83 idxRadius = 0; 84 idxHeight = 1; 85 } 86 87 // calculate squares 88 radius2 = halfExtents[idxRadius] * halfExtents[idxRadius]; 89 height2 = btScalar(4.) * halfExtents[idxHeight] * halfExtents[idxHeight]; 90 91 // calculate tensor terms 92 btScalar t1 = div12 * height2 + div4 * radius2; 93 btScalar t2 = div2 * radius2; 94 95 switch (m_upAxis) // set diagonal elements of inertia tensor 96 { 97 case 0: // cylinder is aligned along x 98 inertia.setValue(t2,t1,t1); 99 break; 100 case 2: // cylinder is aligned along z 101 inertia.setValue(t1,t1,t2); 102 break; 103 default: // cylinder is aligned along y 104 inertia.setValue(t1,t2,t1); 105 } 106 #else //USE_BOX_INERTIA_APPROXIMATION 107 //approximation of box shape 51 108 btVector3 halfExtents = getHalfExtentsWithMargin(); 52 109 … … 58 115 mass/(btScalar(12.0)) * (lx*lx + lz*lz), 59 116 mass/(btScalar(12.0)) * (lx*lx + ly*ly)); 60 117 #endif //USE_BOX_INERTIA_APPROXIMATION 61 118 } 62 119 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btCylinderShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef CYLINDER_MINKOWSKI_H17 #define CYLINDER_MINKOWSKI_H16 #ifndef BT_CYLINDER_MINKOWSKI_H 17 #define BT_CYLINDER_MINKOWSKI_H 18 18 19 19 #include "btBoxShape.h" … … 197 197 198 198 199 #endif // CYLINDER_MINKOWSKI_H200 199 #endif //BT_CYLINDER_MINKOWSKI_H 200 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btEmptyShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef EMPTY_SHAPE_H17 #define EMPTY_SHAPE_H16 #ifndef BT_EMPTY_SHAPE_H 17 #define BT_EMPTY_SHAPE_H 18 18 19 19 #include "btConcaveShape.h" … … 68 68 69 69 70 #endif // EMPTY_SHAPE_H70 #endif //BT_EMPTY_SHAPE_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef HEIGHTFIELD_TERRAIN_SHAPE_H17 #define HEIGHTFIELD_TERRAIN_SHAPE_H16 #ifndef BT_HEIGHTFIELD_TERRAIN_SHAPE_H 17 #define BT_HEIGHTFIELD_TERRAIN_SHAPE_H 18 18 19 19 #include "btConcaveShape.h" … … 159 159 }; 160 160 161 #endif // HEIGHTFIELD_TERRAIN_SHAPE_H161 #endif //BT_HEIGHTFIELD_TERRAIN_SHAPE_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btMaterial.h
r8351 r8393 16 16 /// This file was created by Alex Silverman 17 17 18 #ifndef MATERIAL_H19 #define MATERIAL_H18 #ifndef BT_MATERIAL_H 19 #define BT_MATERIAL_H 20 20 21 21 // Material class to be used by btMultimaterialTriangleMeshShape to store triangle properties … … 32 32 }; 33 33 34 #endif // MATERIAL_H34 #endif // BT_MATERIAL_H 35 35 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btMinkowskiSumShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef MINKOWSKI_SUM_SHAPE_H17 #define MINKOWSKI_SUM_SHAPE_H16 #ifndef BT_MINKOWSKI_SUM_SHAPE_H 17 #define BT_MINKOWSKI_SUM_SHAPE_H 18 18 19 19 #include "btConvexInternalShape.h" … … 58 58 }; 59 59 60 #endif // MINKOWSKI_SUM_SHAPE_H60 #endif //BT_MINKOWSKI_SUM_SHAPE_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btMultiSphereShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef MULTI_SPHERE_MINKOWSKI_H17 #define MULTI_SPHERE_MINKOWSKI_H16 #ifndef BT_MULTI_SPHERE_MINKOWSKI_H 17 #define BT_MULTI_SPHERE_MINKOWSKI_H 18 18 19 19 #include "btConvexInternalShape.h" … … 97 97 98 98 99 #endif // MULTI_SPHERE_MINKOWSKI_H99 #endif //BT_MULTI_SPHERE_MINKOWSKI_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h
r8351 r8393 16 16 /// This file was created by Alex Silverman 17 17 18 #ifndef B VH_TRIANGLE_MATERIAL_MESH_SHAPE_H19 #define B VH_TRIANGLE_MATERIAL_MESH_SHAPE_H18 #ifndef BT_BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H 19 #define BT_BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H 20 20 21 21 #include "btBvhTriangleMeshShape.h" … … 32 32 BT_DECLARE_ALIGNED_ALLOCATOR(); 33 33 34 btMultimaterialTriangleMeshShape(): btBvhTriangleMeshShape() {m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;}35 34 btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true): 36 35 btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, buildBvh) … … 119 118 ; 120 119 121 #endif //B VH_TRIANGLE_MATERIAL_MESH_SHAPE_H120 #endif //BT_BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btOptimizedBvh.h
r8351 r8393 16 16 ///Contains contributions from Disney Studio's 17 17 18 #ifndef OPTIMIZED_BVH_H19 #define OPTIMIZED_BVH_H18 #ifndef BT_OPTIMIZED_BVH_H 19 #define BT_OPTIMIZED_BVH_H 20 20 21 21 #include "BulletCollision/BroadphaseCollision/btQuantizedBvh.h" … … 61 61 62 62 63 #endif // OPTIMIZED_BVH_H63 #endif //BT_OPTIMIZED_BVH_H 64 64 65 65 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
r8351 r8393 15 15 16 16 #include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h" 17 18 btPolyhedralConvexShape::btPolyhedralConvexShape() :btConvexInternalShape() 19 { 20 17 #include "btConvexPolyhedron.h" 18 #include "LinearMath/btConvexHullComputer.h" 19 #include <new> 20 21 btPolyhedralConvexShape::btPolyhedralConvexShape() :btConvexInternalShape(), 22 m_polyhedron(0) 23 { 24 25 } 26 27 btPolyhedralConvexShape::~btPolyhedralConvexShape() 28 { 29 if (m_polyhedron) 30 { 31 btAlignedFree(m_polyhedron); 32 } 33 } 34 35 bool btPolyhedralConvexShape::initializePolyhedralFeatures() 36 { 37 if (m_polyhedron) 38 btAlignedFree(m_polyhedron); 39 40 void* mem = btAlignedAlloc(sizeof(btConvexPolyhedron),16); 41 m_polyhedron = new (mem) btConvexPolyhedron; 42 43 btAlignedObjectArray<btVector3> tmpVertices; 44 for (int i=0;i<getNumVertices();i++) 45 { 46 btVector3& newVertex = tmpVertices.expand(); 47 getVertex(i,newVertex); 48 } 49 50 btConvexHullComputer conv; 51 conv.compute(&tmpVertices[0].getX(), sizeof(btVector3),tmpVertices.size(),0.f,0.f); 52 53 54 55 btAlignedObjectArray<btVector3> faceNormals; 56 int numFaces = conv.faces.size(); 57 faceNormals.resize(numFaces); 58 btConvexHullComputer* convexUtil = &conv; 59 60 61 62 m_polyhedron->m_faces.resize(numFaces); 63 int numVertices = convexUtil->vertices.size(); 64 m_polyhedron->m_vertices.resize(numVertices); 65 for (int p=0;p<numVertices;p++) 66 { 67 m_polyhedron->m_vertices[p] = convexUtil->vertices[p]; 68 } 69 70 for (int i=0;i<numFaces;i++) 71 { 72 int face = convexUtil->faces[i]; 73 //printf("face=%d\n",face); 74 const btConvexHullComputer::Edge* firstEdge = &convexUtil->edges[face]; 75 const btConvexHullComputer::Edge* edge = firstEdge; 76 77 btVector3 edges[3]; 78 int numEdges = 0; 79 //compute face normals 80 81 btScalar maxCross2 = 0.f; 82 int chosenEdge = -1; 83 84 do 85 { 86 87 int src = edge->getSourceVertex(); 88 m_polyhedron->m_faces[i].m_indices.push_back(src); 89 int targ = edge->getTargetVertex(); 90 btVector3 wa = convexUtil->vertices[src]; 91 92 btVector3 wb = convexUtil->vertices[targ]; 93 btVector3 newEdge = wb-wa; 94 newEdge.normalize(); 95 if (numEdges<2) 96 edges[numEdges++] = newEdge; 97 98 edge = edge->getNextEdgeOfFace(); 99 } while (edge!=firstEdge); 100 101 btScalar planeEq = 1e30f; 102 103 104 if (numEdges==2) 105 { 106 faceNormals[i] = edges[0].cross(edges[1]); 107 faceNormals[i].normalize(); 108 m_polyhedron->m_faces[i].m_plane[0] = -faceNormals[i].getX(); 109 m_polyhedron->m_faces[i].m_plane[1] = -faceNormals[i].getY(); 110 m_polyhedron->m_faces[i].m_plane[2] = -faceNormals[i].getZ(); 111 m_polyhedron->m_faces[i].m_plane[3] = planeEq; 112 113 } 114 else 115 { 116 btAssert(0);//degenerate? 117 faceNormals[i].setZero(); 118 } 119 120 for (int v=0;v<m_polyhedron->m_faces[i].m_indices.size();v++) 121 { 122 btScalar eq = m_polyhedron->m_vertices[m_polyhedron->m_faces[i].m_indices[v]].dot(faceNormals[i]); 123 if (planeEq>eq) 124 { 125 planeEq=eq; 126 } 127 } 128 m_polyhedron->m_faces[i].m_plane[3] = planeEq; 129 } 130 131 132 if (m_polyhedron->m_faces.size() && conv.vertices.size()) 133 { 134 135 for (int f=0;f<m_polyhedron->m_faces.size();f++) 136 { 137 138 btVector3 planeNormal(m_polyhedron->m_faces[f].m_plane[0],m_polyhedron->m_faces[f].m_plane[1],m_polyhedron->m_faces[f].m_plane[2]); 139 btScalar planeEq = m_polyhedron->m_faces[f].m_plane[3]; 140 141 btVector3 supVec = localGetSupportingVertex(-planeNormal); 142 143 if (supVec.dot(planeNormal)<planeEq) 144 { 145 m_polyhedron->m_faces[f].m_plane[0] *= -1; 146 m_polyhedron->m_faces[f].m_plane[1] *= -1; 147 m_polyhedron->m_faces[f].m_plane[2] *= -1; 148 m_polyhedron->m_faces[f].m_plane[3] *= -1; 149 int numVerts = m_polyhedron->m_faces[f].m_indices.size(); 150 for (int v=0;v<numVerts/2;v++) 151 { 152 btSwap(m_polyhedron->m_faces[f].m_indices[v],m_polyhedron->m_faces[f].m_indices[numVerts-1-v]); 153 } 154 } 155 } 156 } 157 158 159 160 m_polyhedron->initialize(); 161 162 return true; 21 163 } 22 164 … … 192 334 } 193 335 336 337 338 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef B U_SHAPE17 #define B U_SHAPE16 #ifndef BT_POLYHEDRAL_CONVEX_SHAPE_H 17 #define BT_POLYHEDRAL_CONVEX_SHAPE_H 18 18 19 19 #include "LinearMath/btMatrix3x3.h" 20 20 #include "btConvexInternalShape.h" 21 class btConvexPolyhedron; 21 22 22 23 … … 24 25 class btPolyhedralConvexShape : public btConvexInternalShape 25 26 { 27 26 28 27 29 protected: 28 30 31 btConvexPolyhedron* m_polyhedron; 32 29 33 public: 30 34 31 35 btPolyhedralConvexShape(); 36 37 virtual ~btPolyhedralConvexShape(); 38 39 ///optional method mainly used to generate multiple contact points by clipping polyhedral features (faces/edges) 40 virtual bool initializePolyhedralFeatures(); 41 42 const btConvexPolyhedron* getConvexPolyhedron() const 43 { 44 return m_polyhedron; 45 } 32 46 33 47 //brute force implementations … … 96 110 }; 97 111 98 #endif //B U_SHAPE112 #endif //BT_POLYHEDRAL_CONVEX_SHAPE_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp
r8351 r8393 63 63 scaledAabbMin[1] = m_localScaling.getY() >= 0. ? aabbMin[1] * invLocalScaling[1] : aabbMax[1] * invLocalScaling[1]; 64 64 scaledAabbMin[2] = m_localScaling.getZ() >= 0. ? aabbMin[2] * invLocalScaling[2] : aabbMax[2] * invLocalScaling[2]; 65 scaledAabbMin[3] = 0.f; 65 66 66 67 scaledAabbMax[0] = m_localScaling.getX() <= 0. ? aabbMin[0] * invLocalScaling[0] : aabbMax[0] * invLocalScaling[0]; 67 68 scaledAabbMax[1] = m_localScaling.getY() <= 0. ? aabbMin[1] * invLocalScaling[1] : aabbMax[1] * invLocalScaling[1]; 68 69 scaledAabbMax[2] = m_localScaling.getZ() <= 0. ? aabbMin[2] * invLocalScaling[2] : aabbMax[2] * invLocalScaling[2]; 70 scaledAabbMax[3] = 0.f; 69 71 70 72 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef SCALED_BVH_TRIANGLE_MESH_SHAPE_H17 #define SCALED_BVH_TRIANGLE_MESH_SHAPE_H16 #ifndef BT_SCALED_BVH_TRIANGLE_MESH_SHAPE_H 17 #define BT_SCALED_BVH_TRIANGLE_MESH_SHAPE_H 18 18 19 19 #include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h" … … 58 58 virtual const char* getName()const {return "SCALEDBVHTRIANGLEMESH";} 59 59 60 virtual int calculateSerializeBufferSize() const; 61 62 ///fills the dataBuffer and returns the struct name (and 0 on failure) 63 virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const; 64 60 65 }; 61 66 62 #endif //BVH_TRIANGLE_MESH_SHAPE_H 67 ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 68 struct btScaledTriangleMeshShapeData 69 { 70 btTriangleMeshShapeData m_trimeshShapeData; 71 72 btVector3FloatData m_localScaling; 73 }; 74 75 76 SIMD_FORCE_INLINE int btScaledBvhTriangleMeshShape::calculateSerializeBufferSize() const 77 { 78 return sizeof(btScaledTriangleMeshShapeData); 79 } 80 81 82 ///fills the dataBuffer and returns the struct name (and 0 on failure) 83 SIMD_FORCE_INLINE const char* btScaledBvhTriangleMeshShape::serialize(void* dataBuffer, btSerializer* serializer) const 84 { 85 btScaledTriangleMeshShapeData* scaledMeshData = (btScaledTriangleMeshShapeData*) dataBuffer; 86 m_bvhTriMeshShape->serialize(&scaledMeshData->m_trimeshShapeData,serializer); 87 scaledMeshData->m_trimeshShapeData.m_collisionShapeData.m_shapeType = SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE; 88 m_localScaling.serializeFloat(scaledMeshData->m_localScaling); 89 return "btScaledTriangleMeshShapeData"; 90 } 91 92 93 #endif //BT_SCALED_BVH_TRIANGLE_MESH_SHAPE_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btShapeHull.h
r8351 r8393 16 16 ///btShapeHull implemented by John McCutchan. 17 17 18 #ifndef _SHAPE_HULL_H19 #define _SHAPE_HULL_H18 #ifndef BT_SHAPE_HULL_H 19 #define BT_SHAPE_HULL_H 20 20 21 21 #include "LinearMath/btAlignedObjectArray.h" … … 57 57 }; 58 58 59 #endif // _SHAPE_HULL_H59 #endif //BT_SHAPE_HULL_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btSphereShape.h
r8351 r8393 13 13 3. This notice may not be removed or altered from any source distribution. 14 14 */ 15 #ifndef SPHERE_MINKOWSKI_H16 #define SPHERE_MINKOWSKI_H15 #ifndef BT_SPHERE_MINKOWSKI_H 16 #define BT_SPHERE_MINKOWSKI_H 17 17 18 18 #include "btConvexInternalShape.h" … … 71 71 72 72 73 #endif // SPHERE_MINKOWSKI_H73 #endif //BT_SPHERE_MINKOWSKI_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btStaticPlaneShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef STATIC_PLANE_SHAPE_H17 #define STATIC_PLANE_SHAPE_H16 #ifndef BT_STATIC_PLANE_SHAPE_H 17 #define BT_STATIC_PLANE_SHAPE_H 18 18 19 19 #include "btConcaveShape.h" … … 98 98 99 99 100 #endif // STATIC_PLANE_SHAPE_H100 #endif //BT_STATIC_PLANE_SHAPE_H 101 101 102 102 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btStridingMeshInterface.cpp
r8351 r8393 89 89 break; 90 90 } 91 case PHY_UCHAR: 92 { 93 for (gfxindex=0;gfxindex<numtriangles;gfxindex++) 94 { 95 unsigned char* tri_indices= (unsigned char*)(indexbase+gfxindex*indexstride); 96 graphicsbase = (float*)(vertexbase+tri_indices[0]*stride); 97 triangle[0].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ()); 98 graphicsbase = (float*)(vertexbase+tri_indices[1]*stride); 99 triangle[1].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(), graphicsbase[2]*meshScaling.getZ()); 100 graphicsbase = (float*)(vertexbase+tri_indices[2]*stride); 101 triangle[2].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(), graphicsbase[2]*meshScaling.getZ()); 102 callback->internalProcessTriangleIndex(triangle,part,gfxindex); 103 } 104 break; 105 } 91 106 default: 92 107 btAssert((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT)); … … 121 136 { 122 137 unsigned short int* tri_indices= (unsigned short int*)(indexbase+gfxindex*indexstride); 138 graphicsbase = (double*)(vertexbase+tri_indices[0]*stride); 139 triangle[0].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(),(btScalar)graphicsbase[2]*meshScaling.getZ()); 140 graphicsbase = (double*)(vertexbase+tri_indices[1]*stride); 141 triangle[1].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(), (btScalar)graphicsbase[2]*meshScaling.getZ()); 142 graphicsbase = (double*)(vertexbase+tri_indices[2]*stride); 143 triangle[2].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(), (btScalar)graphicsbase[2]*meshScaling.getZ()); 144 callback->internalProcessTriangleIndex(triangle,part,gfxindex); 145 } 146 break; 147 } 148 case PHY_UCHAR: 149 { 150 for (gfxindex=0;gfxindex<numtriangles;gfxindex++) 151 { 152 unsigned char* tri_indices= (unsigned char*)(indexbase+gfxindex*indexstride); 123 153 graphicsbase = (double*)(vertexbase+tri_indices[0]*stride); 124 154 triangle[0].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(),(btScalar)graphicsbase[2]*meshScaling.getZ()); … … 267 297 break; 268 298 } 299 case PHY_UCHAR: 300 { 301 if (numtriangles) 302 { 303 btChunk* chunk = serializer->allocate(sizeof(btCharIndexTripletData),numtriangles); 304 btCharIndexTripletData* tmpIndices = (btCharIndexTripletData*)chunk->m_oldPtr; 305 memPtr->m_3indices8 = (btCharIndexTripletData*) serializer->getUniquePointer(tmpIndices); 306 for (gfxindex=0;gfxindex<numtriangles;gfxindex++) 307 { 308 unsigned char* tri_indices= (unsigned char*)(indexbase+gfxindex*indexstride); 309 tmpIndices[gfxindex].m_values[0] = tri_indices[0]; 310 tmpIndices[gfxindex].m_values[1] = tri_indices[1]; 311 tmpIndices[gfxindex].m_values[2] = tri_indices[2]; 312 } 313 serializer->finalizeChunk(chunk,"btCharIndexTripletData",BT_ARRAY_CODE,(void*)chunk->m_oldPtr); 314 } 315 break; 316 } 269 317 default: 270 318 { -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btStridingMeshInterface.h
r8351 r8393 14 14 */ 15 15 16 #ifndef STRIDING_MESHINTERFACE_H17 #define STRIDING_MESHINTERFACE_H16 #ifndef BT_STRIDING_MESHINTERFACE_H 17 #define BT_STRIDING_MESHINTERFACE_H 18 18 19 19 #include "LinearMath/btVector3.h" … … 117 117 }; 118 118 119 struct btCharIndexTripletData 120 { 121 unsigned char m_values[3]; 122 char m_pad; 123 }; 124 125 119 126 ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 120 127 struct btMeshPartData … … 125 132 btIntIndexData *m_indices32; 126 133 btShortIntIndexTripletData *m_3indices16; 134 btCharIndexTripletData *m_3indices8; 127 135 128 136 btShortIntIndexData *m_indices16;//backwards compatibility … … 152 160 153 161 154 #endif // STRIDING_MESHINTERFACE_H162 #endif //BT_STRIDING_MESHINTERFACE_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btTetrahedronShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef B U_SIMPLEX_1TO4_SHAPE17 #define B U_SIMPLEX_1TO4_SHAPE16 #ifndef BT_SIMPLEX_1TO4_SHAPE 17 #define BT_SIMPLEX_1TO4_SHAPE 18 18 19 19 … … 72 72 }; 73 73 74 #endif //B U_SIMPLEX_1TO4_SHAPE74 #endif //BT_SIMPLEX_1TO4_SHAPE -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btTriangleCallback.h
r8351 r8393 14 14 */ 15 15 16 #ifndef TRIANGLE_CALLBACK_H17 #define TRIANGLE_CALLBACK_H16 #ifndef BT_TRIANGLE_CALLBACK_H 17 #define BT_TRIANGLE_CALLBACK_H 18 18 19 19 #include "LinearMath/btVector3.h" … … 40 40 41 41 42 #endif // TRIANGLE_CALLBACK_H42 #endif //BT_TRIANGLE_CALLBACK_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btTriangleInfoMap.h
r8351 r8393 62 62 btScalar m_equalVertexThreshold; ///used to compute connectivity: if the distance between two vertices is smaller than m_equalVertexThreshold, they are considered to be 'shared' 63 63 btScalar m_edgeDistanceThreshold; ///used to determine edge contacts: if the closest distance between a contact point and an edge is smaller than this distance threshold it is considered to "hit the edge" 64 btScalar m_maxEdgeAngleThreshold; //ignore edges that connect triangles at an angle larger than this m_maxEdgeAngleThreshold 64 65 btScalar m_zeroAreaThreshold; ///used to determine if a triangle is degenerate (length squared of cross product of 2 triangle edges < threshold) 65 66 … … 72 73 m_edgeDistanceThreshold = btScalar(0.1); 73 74 m_zeroAreaThreshold = btScalar(0.0001)*btScalar(0.0001); 75 m_maxEdgeAngleThreshold = SIMD_2_PI; 74 76 } 75 77 virtual ~btTriangleInfoMap() {} -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btTriangleMesh.h
r8351 r8393 14 14 */ 15 15 16 #ifndef TRIANGLE_MESH_H17 #define TRIANGLE_MESH_H16 #ifndef BT_TRIANGLE_MESH_H 17 #define BT_TRIANGLE_MESH_H 18 18 19 19 #include "btTriangleIndexVertexArray.h" … … 66 66 }; 67 67 68 #endif // TRIANGLE_MESH_H68 #endif //BT_TRIANGLE_MESH_H 69 69 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btTriangleMeshShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef TRIANGLE_MESH_SHAPE_H17 #define TRIANGLE_MESH_SHAPE_H16 #ifndef BT_TRIANGLE_MESH_SHAPE_H 17 #define BT_TRIANGLE_MESH_SHAPE_H 18 18 19 19 #include "btConcaveShape.h" … … 87 87 88 88 89 #endif // TRIANGLE_MESH_SHAPE_H89 #endif //BT_TRIANGLE_MESH_SHAPE_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btTriangleShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef OBB_TRIANGLE_MINKOWSKI_H17 #define OBB_TRIANGLE_MINKOWSKI_H16 #ifndef BT_OBB_TRIANGLE_MINKOWSKI_H 17 #define BT_OBB_TRIANGLE_MINKOWSKI_H 18 18 19 19 #include "btConvexShape.h" … … 179 179 }; 180 180 181 #endif // OBB_TRIANGLE_MINKOWSKI_H181 #endif //BT_OBB_TRIANGLE_MINKOWSKI_H 182 182 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btUniformScalingShape.cpp
r8351 r8393 65 65 66 66 ///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version 67 void btUniformScalingShape::getAabb(const btTransform& t ,btVector3& aabbMin,btVector3& aabbMax) const67 void btUniformScalingShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const 68 68 { 69 m_childConvexShape->getAabb(t,aabbMin,aabbMax); 70 btVector3 aabbCenter = (aabbMax+aabbMin)*btScalar(0.5); 71 btVector3 scaledAabbHalfExtends = (aabbMax-aabbMin)*btScalar(0.5)*m_uniformScalingFactor; 72 73 aabbMin = aabbCenter - scaledAabbHalfExtends; 74 aabbMax = aabbCenter + scaledAabbHalfExtends; 69 getAabbSlow(trans,aabbMin,aabbMax); 75 70 76 71 } … … 78 73 void btUniformScalingShape::getAabbSlow(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const 79 74 { 80 m_childConvexShape->getAabbSlow(t,aabbMin,aabbMax); 81 btVector3 aabbCenter = (aabbMax+aabbMin)*btScalar(0.5); 82 btVector3 scaledAabbHalfExtends = (aabbMax-aabbMin)*btScalar(0.5)*m_uniformScalingFactor; 75 #if 1 76 btVector3 _directions[] = 77 { 78 btVector3( 1., 0., 0.), 79 btVector3( 0., 1., 0.), 80 btVector3( 0., 0., 1.), 81 btVector3( -1., 0., 0.), 82 btVector3( 0., -1., 0.), 83 btVector3( 0., 0., -1.) 84 }; 85 86 btVector3 _supporting[] = 87 { 88 btVector3( 0., 0., 0.), 89 btVector3( 0., 0., 0.), 90 btVector3( 0., 0., 0.), 91 btVector3( 0., 0., 0.), 92 btVector3( 0., 0., 0.), 93 btVector3( 0., 0., 0.) 94 }; 83 95 84 aabbMin = aabbCenter - scaledAabbHalfExtends; 85 aabbMax = aabbCenter + scaledAabbHalfExtends; 96 for (int i=0;i<6;i++) 97 { 98 _directions[i] = _directions[i]*t.getBasis(); 99 } 100 101 batchedUnitVectorGetSupportingVertexWithoutMargin(_directions, _supporting, 6); 102 103 btVector3 aabbMin1(0,0,0),aabbMax1(0,0,0); 104 105 for ( int i = 0; i < 3; ++i ) 106 { 107 aabbMax1[i] = t(_supporting[i])[i]; 108 aabbMin1[i] = t(_supporting[i + 3])[i]; 109 } 110 btVector3 marginVec(getMargin(),getMargin(),getMargin()); 111 aabbMin = aabbMin1-marginVec; 112 aabbMax = aabbMax1+marginVec; 113 114 #else 115 116 btScalar margin = getMargin(); 117 for (int i=0;i<3;i++) 118 { 119 btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.)); 120 vec[i] = btScalar(1.); 121 btVector3 sv = localGetSupportingVertex(vec*t.getBasis()); 122 btVector3 tmp = t(sv); 123 aabbMax[i] = tmp[i]+margin; 124 vec[i] = btScalar(-1.); 125 sv = localGetSupportingVertex(vec*t.getBasis()); 126 tmp = t(sv); 127 aabbMin[i] = tmp[i]-margin; 128 } 129 130 #endif 86 131 } 87 132 -
code/trunk/src/external/bullet/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp
r8351 r8393 23 23 #include "btGjkPairDetector.h" 24 24 #include "btPointCollector.h" 25 #include "BulletCollision/CollisionShapes/btStaticPlaneShape.h" 25 26 26 27 … … 29 30 :m_simplexSolver(simplexSolver), 30 31 m_penetrationDepthSolver(penetrationDepthSolver), 31 m_convexA(convexA),m_convexB(convexB) 32 { 33 } 32 m_convexA(convexA),m_convexB1(convexB),m_planeShape(0) 33 { 34 } 35 36 37 btContinuousConvexCollision::btContinuousConvexCollision( const btConvexShape* convexA,const btStaticPlaneShape* plane) 38 :m_simplexSolver(0), 39 m_penetrationDepthSolver(0), 40 m_convexA(convexA),m_convexB1(0),m_planeShape(plane) 41 { 42 } 43 34 44 35 45 /// This maximum should not be necessary. It allows for untested/degenerate cases in production code. 36 46 /// You don't want your game ever to lock-up. 37 47 #define MAX_ITERATIONS 64 48 49 void btContinuousConvexCollision::computeClosestPoints( const btTransform& transA, const btTransform& transB,btPointCollector& pointCollector) 50 { 51 if (m_convexB1) 52 { 53 m_simplexSolver->reset(); 54 btGjkPairDetector gjk(m_convexA,m_convexB1,m_convexA->getShapeType(),m_convexB1->getShapeType(),m_convexA->getMargin(),m_convexB1->getMargin(),m_simplexSolver,m_penetrationDepthSolver); 55 btGjkPairDetector::ClosestPointInput input; 56 input.m_transformA = transA; 57 input.m_transformB = transB; 58 gjk.getClosestPoints(input,pointCollector,0); 59 } else 60 { 61 //convex versus plane 62 const btConvexShape* convexShape = m_convexA; 63 const btStaticPlaneShape* planeShape = m_planeShape; 64 65 bool hasCollision = false; 66 const btVector3& planeNormal = planeShape->getPlaneNormal(); 67 const btScalar& planeConstant = planeShape->getPlaneConstant(); 68 69 btTransform convexWorldTransform = transA; 70 btTransform convexInPlaneTrans; 71 convexInPlaneTrans= transB.inverse() * convexWorldTransform; 72 btTransform planeInConvex; 73 planeInConvex= convexWorldTransform.inverse() * transB; 74 75 btVector3 vtx = convexShape->localGetSupportingVertex(planeInConvex.getBasis()*-planeNormal); 76 77 btVector3 vtxInPlane = convexInPlaneTrans(vtx); 78 btScalar distance = (planeNormal.dot(vtxInPlane) - planeConstant); 79 80 btVector3 vtxInPlaneProjected = vtxInPlane - distance*planeNormal; 81 btVector3 vtxInPlaneWorld = transB * vtxInPlaneProjected; 82 btVector3 normalOnSurfaceB = transB.getBasis() * planeNormal; 83 84 pointCollector.addContactPoint( 85 normalOnSurfaceB, 86 vtxInPlaneWorld, 87 distance); 88 } 89 } 38 90 39 91 bool btContinuousConvexCollision::calcTimeOfImpact( … … 45 97 { 46 98 47 m_simplexSolver->reset();48 99 49 100 /// compute linear and angular velocity for this interval, to interpolate … … 54 105 55 106 btScalar boundingRadiusA = m_convexA->getAngularMotionDisc(); 56 btScalar boundingRadiusB = m_convexB ->getAngularMotionDisc();107 btScalar boundingRadiusB = m_convexB1?m_convexB1->getAngularMotionDisc():0.f; 57 108 58 109 btScalar maxAngularProjectedVelocity = angVelA.length() * boundingRadiusA + angVelB.length() * boundingRadiusB; … … 65 116 66 117 67 btScalar radius = btScalar(0.001);68 118 69 119 btScalar lambda = btScalar(0.); … … 84 134 85 135 86 btTransform identityTrans; 87 identityTrans.setIdentity(); 88 89 btSphereShape raySphere(btScalar(0.0)); 90 raySphere.setMargin(btScalar(0.)); 91 92 136 btScalar radius = 0.001f; 93 137 // result.drawCoordSystem(sphereTr); 94 138 … … 96 140 97 141 { 98 99 btGjkPairDetector gjk(m_convexA,m_convexB,m_convexA->getShapeType(),m_convexB->getShapeType(),m_convexA->getMargin(),m_convexB->getMargin(),m_simplexSolver,m_penetrationDepthSolver);100 btGjkPairDetector::ClosestPointInput input;101 142 102 //we don't use margins during CCD 103 // gjk.setIgnoreMargin(true); 104 105 input.m_transformA = fromA; 106 input.m_transformB = fromB; 107 gjk.getClosestPoints(input,pointCollector1,0); 143 computeClosestPoints(fromA,fromB,pointCollector1); 108 144 109 145 hasResult = pointCollector1.m_hasResult; … … 114 150 { 115 151 btScalar dist; 116 dist = pointCollector1.m_distance ;152 dist = pointCollector1.m_distance + result.m_allowedPenetration; 117 153 n = pointCollector1.m_normalOnBInWorld; 118 119 154 btScalar projectedLinearVelocity = relLinVel.dot(n); 120 155 if ((projectedLinearVelocity+ maxAngularProjectedVelocity)<=SIMD_EPSILON) 156 return false; 157 121 158 //not close enough 122 159 while (dist > radius) … … 126 163 result.m_debugDrawer->drawSphere(c,0.2f,btVector3(1,1,1)); 127 164 } 128 numIter++;129 if (numIter > maxIter)130 {131 return false; //todo: report a failure132 }133 165 btScalar dLambda = btScalar(0.); 134 166 135 167 projectedLinearVelocity = relLinVel.dot(n); 136 168 137 //calculate safe moving fraction from distance / (linear+rotational velocity)138 139 //btScalar clippedDist = GEN_min(angularConservativeRadius,dist);140 //btScalar clippedDist = dist;141 169 142 170 //don't report time of impact for motion away from the contact normal (or causes minor penetration) … … 183 211 184 212 btPointCollector pointCollector; 185 btGjkPairDetector gjk(m_convexA,m_convexB,m_simplexSolver,m_penetrationDepthSolver); 186 btGjkPairDetector::ClosestPointInput input; 187 input.m_transformA = interpolatedTransA; 188 input.m_transformB = interpolatedTransB; 189 gjk.getClosestPoints(input,pointCollector,0); 213 computeClosestPoints(interpolatedTransA,interpolatedTransB,pointCollector); 214 190 215 if (pointCollector.m_hasResult) 191 216 { 192 if (pointCollector.m_distance < btScalar(0.)) 193 { 194 //degenerate ?! 195 result.m_fraction = lastLambda; 196 n = pointCollector.m_normalOnBInWorld; 197 result.m_normal=n;//.setValue(1,1,1);// = n; 198 result.m_hitPoint = pointCollector.m_pointInWorld; 199 return true; 200 } 217 dist = pointCollector.m_distance+result.m_allowedPenetration; 201 218 c = pointCollector.m_pointInWorld; 202 219 n = pointCollector.m_normalOnBInWorld; 203 dist = pointCollector.m_distance;204 220 } else 205 221 { 206 //?? 207 return false; 208 } 209 210 222 result.reportFailure(-1, numIter); 223 return false; 224 } 225 226 numIter++; 227 if (numIter > maxIter) 228 { 229 result.reportFailure(-2, numIter); 230 return false; 231 } 211 232 } 212 233 213 if ((projectedLinearVelocity+ maxAngularProjectedVelocity)<=result.m_allowedPenetration)//SIMD_EPSILON)214 return false;215 216 234 result.m_fraction = lambda; 217 235 result.m_normal = n; … … 222 240 return false; 223 241 224 /* 225 //todo: 226 //if movement away from normal, discard result 227 btVector3 move = transBLocalTo.getOrigin() - transBLocalFrom.getOrigin(); 228 if (result.m_fraction < btScalar(1.)) 229 { 230 if (move.dot(result.m_normal) <= btScalar(0.)) 231 { 232 } 233 } 234 */ 235 236 } 242 } 243 -
code/trunk/src/external/bullet/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h
r5781 r8393 15 15 16 16 17 #ifndef CONTINUOUS_COLLISION_CONVEX_CAST_H18 #define CONTINUOUS_COLLISION_CONVEX_CAST_H17 #ifndef BT_CONTINUOUS_COLLISION_CONVEX_CAST_H 18 #define BT_CONTINUOUS_COLLISION_CONVEX_CAST_H 19 19 20 20 #include "btConvexCast.h" … … 22 22 class btConvexPenetrationDepthSolver; 23 23 class btConvexShape; 24 class btStaticPlaneShape; 24 25 25 26 /// btContinuousConvexCollision implements angular and linear time of impact for convex objects. … … 32 33 btConvexPenetrationDepthSolver* m_penetrationDepthSolver; 33 34 const btConvexShape* m_convexA; 34 const btConvexShape* m_convexB; 35 //second object is either a convex or a plane (code sharing) 36 const btConvexShape* m_convexB1; 37 const btStaticPlaneShape* m_planeShape; 35 38 39 void computeClosestPoints( const btTransform& transA, const btTransform& transB,struct btPointCollector& pointCollector); 36 40 37 41 public: 38 42 39 43 btContinuousConvexCollision (const btConvexShape* shapeA,const btConvexShape* shapeB ,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver); 44 45 btContinuousConvexCollision(const btConvexShape* shapeA,const btStaticPlaneShape* plane ); 40 46 41 47 virtual bool calcTimeOfImpact( … … 49 55 }; 50 56 51 #endif //CONTINUOUS_COLLISION_CONVEX_CAST_H52 57 58 #endif //BT_CONTINUOUS_COLLISION_CONVEX_CAST_H 59 -
code/trunk/src/external/bullet/BulletCollision/NarrowPhaseCollision/btConvexCast.h
r8351 r8393 15 15 16 16 17 #ifndef CONVEX_CAST_H18 #define CONVEX_CAST_H17 #ifndef BT_CONVEX_CAST_H 18 #define BT_CONVEX_CAST_H 19 19 20 20 #include "LinearMath/btTransform.h" … … 40 40 virtual void DebugDraw(btScalar fraction) {(void)fraction;} 41 41 virtual void drawCoordSystem(const btTransform& trans) {(void)trans;} 42 42 virtual void reportFailure(int errNo, int numIterations) {(void)errNo;(void)numIterations;} 43 43 CastResult() 44 44 :m_fraction(btScalar(BT_LARGE_FLOAT)), … … 71 71 }; 72 72 73 #endif // CONVEX_CAST_H73 #endif //BT_CONVEX_CAST_H -
code/trunk/src/external/bullet/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h
r8351 r8393 15 15 16 16 17 #ifndef __CONVEX_PENETRATION_DEPTH_H18 #define __CONVEX_PENETRATION_DEPTH_H17 #ifndef BT_CONVEX_PENETRATION_DEPTH_H 18 #define BT_CONVEX_PENETRATION_DEPTH_H 19 19 20 20 class btStackAlloc; … … 39 39 40 40 }; 41 #endif // CONVEX_PENETRATION_DEPTH_H41 #endif //BT_CONVEX_PENETRATION_DEPTH_H 42 42 -
code/trunk/src/external/bullet/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h
r8351 r8393 15 15 16 16 17 #ifndef DISCRETE_COLLISION_DETECTOR1_INTERFACE_H 18 #define DISCRETE_COLLISION_DETECTOR1_INTERFACE_H 17 #ifndef BT_DISCRETE_COLLISION_DETECTOR1_INTERFACE_H 18 #define BT_DISCRETE_COLLISION_DETECTOR1_INTERFACE_H 19 19 20 #include "LinearMath/btTransform.h" 20 21 #include "LinearMath/btVector3.h" … … 87 88 }; 88 89 89 #endif //DISCRETE_COLLISION_DETECTOR_INTERFACE1_H 90 #endif //BT_DISCRETE_COLLISION_DETECTOR1_INTERFACE_H 91 -
code/trunk/src/external/bullet/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h
r5781 r8393 16 16 17 17 18 #ifndef GJK_CONVEX_CAST_H19 #define GJK_CONVEX_CAST_H18 #ifndef BT_GJK_CONVEX_CAST_H 19 #define BT_GJK_CONVEX_CAST_H 20 20 21 21 #include "BulletCollision/CollisionShapes/btCollisionMargin.h" … … 48 48 }; 49 49 50 #endif // GJK_CONVEX_CAST_H50 #endif //BT_GJK_CONVEX_CAST_H -
code/trunk/src/external/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpa2.h
r8351 r8393 23 23 GJK-EPA collision solver by Nathanael Presson, 2008 24 24 */ 25 #ifndef _68DA1F85_90B7_4bb0_A705_83B4040A75C6_ 26 #define _68DA1F85_90B7_4bb0_A705_83B4040A75C6_ 25 #ifndef BT_GJK_EPA2_H 26 #define BT_GJK_EPA2_H 27 27 28 #include "BulletCollision/CollisionShapes/btConvexShape.h" 28 29 … … 71 72 }; 72 73 73 #endif 74 #endif //BT_GJK_EPA2_H 75 -
code/trunk/src/external/bullet/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp
r8351 r8393 255 255 #endif // 256 256 257 m_cachedSeparatingAxis = newCachedSeparatingAxis;258 257 259 258 //redundant m_simplexSolver->compute_points(pointOnA, pointOnB); … … 262 261 if (previousSquaredDistance - squaredDistance <= SIMD_EPSILON * previousSquaredDistance) 263 262 { 264 m_simplexSolver->backup_closest(m_cachedSeparatingAxis);263 // m_simplexSolver->backup_closest(m_cachedSeparatingAxis); 265 264 checkSimplex = true; 266 265 m_degenerateSimplex = 12; … … 268 267 break; 269 268 } 269 270 m_cachedSeparatingAxis = newCachedSeparatingAxis; 270 271 271 272 //degeneracy, this is typically due to invalid/uninitialized worldtransforms for a btCollisionObject … … 295 296 { 296 297 //do we need this backup_closest here ? 297 m_simplexSolver->backup_closest(m_cachedSeparatingAxis);298 // m_simplexSolver->backup_closest(m_cachedSeparatingAxis); 298 299 m_degenerateSimplex = 13; 299 300 break; … … 304 305 { 305 306 m_simplexSolver->compute_points(pointOnA, pointOnB); 306 normalInB = pointOnA-pointOnB;307 normalInB = m_cachedSeparatingAxis; 307 308 btScalar lenSqr =m_cachedSeparatingAxis.length2(); 308 309 -
code/trunk/src/external/bullet/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h
r8351 r8393 17 17 18 18 19 #ifndef GJK_PAIR_DETECTOR_H20 #define GJK_PAIR_DETECTOR_H19 #ifndef BT_GJK_PAIR_DETECTOR_H 20 #define BT_GJK_PAIR_DETECTOR_H 21 21 22 22 #include "btDiscreteCollisionDetectorInterface.h" … … 101 101 }; 102 102 103 #endif // GJK_PAIR_DETECTOR_H103 #endif //BT_GJK_PAIR_DETECTOR_H -
code/trunk/src/external/bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h
r8351 r8393 14 14 */ 15 15 16 #ifndef MANIFOLD_CONTACT_POINT_H17 #define MANIFOLD_CONTACT_POINT_H16 #ifndef BT_MANIFOLD_CONTACT_POINT_H 17 #define BT_MANIFOLD_CONTACT_POINT_H 18 18 19 19 #include "LinearMath/btVector3.h" 20 20 #include "LinearMath/btTransformUtil.h" 21 21 22 // Don't change following order of parameters 23 ATTRIBUTE_ALIGNED16(struct) PfxConstraintRow { 24 btScalar mNormal[3]; 25 btScalar mRhs; 26 btScalar mJacDiagInv; 27 btScalar mLowerLimit; 28 btScalar mUpperLimit; 29 btScalar mAccumImpulse; 30 }; 31 22 #ifdef PFX_USE_FREE_VECTORMATH 23 #include "physics_effects/base_level/solver/pfx_constraint_row.h" 24 typedef sce::PhysicsEffects::PfxConstraintRow btConstraintRow; 25 #else 26 // Don't change following order of parameters 27 ATTRIBUTE_ALIGNED16(struct) btConstraintRow { 28 btScalar m_normal[3]; 29 btScalar m_rhs; 30 btScalar m_jacDiagInv; 31 btScalar m_lowerLimit; 32 btScalar m_upperLimit; 33 btScalar m_accumImpulse; 34 }; 35 typedef btConstraintRow PfxConstraintRow; 36 #endif //PFX_USE_FREE_VECTORMATH 32 37 33 38 … … 72 77 m_lifeTime(0) 73 78 { 74 mConstraintRow[0].m AccumImpulse = 0.f;75 mConstraintRow[1].m AccumImpulse = 0.f;76 mConstraintRow[2].m AccumImpulse = 0.f;79 mConstraintRow[0].m_accumImpulse = 0.f; 80 mConstraintRow[1].m_accumImpulse = 0.f; 81 mConstraintRow[2].m_accumImpulse = 0.f; 77 82 } 78 83 … … 114 119 115 120 116 PfxConstraintRow mConstraintRow[3];121 btConstraintRow mConstraintRow[3]; 117 122 118 123 … … 151 156 }; 152 157 153 #endif // MANIFOLD_CONTACT_POINT_H158 #endif //BT_MANIFOLD_CONTACT_POINT_H -
code/trunk/src/external/bullet/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h
r8351 r8393 14 14 */ 15 15 16 #ifndef MINKOWSKI_PENETRATION_DEPTH_SOLVER_H17 #define MINKOWSKI_PENETRATION_DEPTH_SOLVER_H16 #ifndef BT_MINKOWSKI_PENETRATION_DEPTH_SOLVER_H 17 #define BT_MINKOWSKI_PENETRATION_DEPTH_SOLVER_H 18 18 19 19 #include "btConvexPenetrationDepthSolver.h" … … 37 37 }; 38 38 39 #endif // MINKOWSKI_PENETRATION_DEPTH_SOLVER_H39 #endif //BT_MINKOWSKI_PENETRATION_DEPTH_SOLVER_H 40 40 -
code/trunk/src/external/bullet/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h
r8351 r8393 14 14 */ 15 15 16 #ifndef PERSISTENT_MANIFOLD_H17 #define PERSISTENT_MANIFOLD_H16 #ifndef BT_PERSISTENT_MANIFOLD_H 17 #define BT_PERSISTENT_MANIFOLD_H 18 18 19 19 … … 33 33 extern ContactProcessedCallback gContactProcessedCallback; 34 34 35 35 //the enum starts at 1024 to avoid type conflicts with btTypedConstraint 36 36 enum btContactManifoldTypes 37 37 { 38 BT_PERSISTENT_MANIFOLD_TYPE = 1,39 MAX_CONTACT_MANIFOLD_TYPE38 MIN_CONTACT_MANIFOLD_TYPE = 1024, 39 BT_PERSISTENT_MANIFOLD_TYPE 40 40 }; 41 41 … … 147 147 //get rid of duplicated userPersistentData pointer 148 148 m_pointCache[lastUsedIndex].m_userPersistentData = 0; 149 m_pointCache[lastUsedIndex].mConstraintRow[0].m AccumImpulse = 0.f;150 m_pointCache[lastUsedIndex].mConstraintRow[1].m AccumImpulse = 0.f;151 m_pointCache[lastUsedIndex].mConstraintRow[2].m AccumImpulse = 0.f;149 m_pointCache[lastUsedIndex].mConstraintRow[0].m_accumImpulse = 0.f; 150 m_pointCache[lastUsedIndex].mConstraintRow[1].m_accumImpulse = 0.f; 151 m_pointCache[lastUsedIndex].mConstraintRow[2].m_accumImpulse = 0.f; 152 152 153 153 m_pointCache[lastUsedIndex].m_appliedImpulse = 0.f; … … 168 168 #ifdef MAINTAIN_PERSISTENCY 169 169 int lifeTime = m_pointCache[insertIndex].getLifeTime(); 170 btScalar appliedImpulse = m_pointCache[insertIndex].mConstraintRow[0].m AccumImpulse;171 btScalar appliedLateralImpulse1 = m_pointCache[insertIndex].mConstraintRow[1].m AccumImpulse;172 btScalar appliedLateralImpulse2 = m_pointCache[insertIndex].mConstraintRow[2].m AccumImpulse;170 btScalar appliedImpulse = m_pointCache[insertIndex].mConstraintRow[0].m_accumImpulse; 171 btScalar appliedLateralImpulse1 = m_pointCache[insertIndex].mConstraintRow[1].m_accumImpulse; 172 btScalar appliedLateralImpulse2 = m_pointCache[insertIndex].mConstraintRow[2].m_accumImpulse; 173 173 // bool isLateralFrictionInitialized = m_pointCache[insertIndex].m_lateralFrictionInitialized; 174 174 … … 185 185 m_pointCache[insertIndex].m_appliedImpulseLateral2 = appliedLateralImpulse2; 186 186 187 m_pointCache[insertIndex].mConstraintRow[0].m AccumImpulse = appliedImpulse;188 m_pointCache[insertIndex].mConstraintRow[1].m AccumImpulse = appliedLateralImpulse1;189 m_pointCache[insertIndex].mConstraintRow[2].m AccumImpulse = appliedLateralImpulse2;187 m_pointCache[insertIndex].mConstraintRow[0].m_accumImpulse = appliedImpulse; 188 m_pointCache[insertIndex].mConstraintRow[1].m_accumImpulse = appliedLateralImpulse1; 189 m_pointCache[insertIndex].mConstraintRow[2].m_accumImpulse = appliedLateralImpulse2; 190 190 191 191 … … 200 200 bool validContactDistance(const btManifoldPoint& pt) const 201 201 { 202 return pt.m_distance1 <= getContactBreakingThreshold(); 202 if (pt.m_lifeTime >1) 203 { 204 return pt.m_distance1 <= getContactBreakingThreshold(); 205 } 206 return pt.m_distance1 <= getContactProcessingThreshold(); 207 203 208 } 204 209 /// calculated new worldspace coordinates and depth, and reject points that exceed the collision margin … … 225 230 226 231 227 #endif // PERSISTENT_MANIFOLD_H232 #endif //BT_PERSISTENT_MANIFOLD_H -
code/trunk/src/external/bullet/BulletCollision/NarrowPhaseCollision/btPointCollector.h
r8351 r8393 14 14 */ 15 15 16 #ifndef POINT_COLLECTOR_H17 #define POINT_COLLECTOR_H16 #ifndef BT_POINT_COLLECTOR_H 17 #define BT_POINT_COLLECTOR_H 18 18 19 19 #include "btDiscreteCollisionDetectorInterface.h" … … 61 61 }; 62 62 63 #endif // POINT_COLLECTOR_H63 #endif //BT_POINT_COLLECTOR_H 64 64 -
code/trunk/src/external/bullet/BulletCollision/NarrowPhaseCollision/btRaycastCallback.cpp
r5781 r8393 125 125 m_convexShapeTo = convexShapeTo; 126 126 m_triangleToWorld = triangleToWorld; 127 m_hitFraction = 1.0; 128 m_triangleCollisionMargin = triangleCollisionMargin; 127 m_hitFraction = 1.0f; 128 m_triangleCollisionMargin = triangleCollisionMargin; 129 m_allowedPenetration = 0.f; 129 130 } 130 131 … … 149 150 btConvexCast::CastResult castResult; 150 151 castResult.m_fraction = btScalar(1.); 152 castResult.m_allowedPenetration = m_allowedPenetration; 151 153 if (convexCaster.calcTimeOfImpact(m_convexShapeFrom,m_convexShapeTo,m_triangleToWorld, m_triangleToWorld, castResult)) 152 154 { -
code/trunk/src/external/bullet/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h
r5781 r8393 14 14 */ 15 15 16 #ifndef RAYCAST_TRI_CALLBACK_H17 #define RAYCAST_TRI_CALLBACK_H16 #ifndef BT_RAYCAST_TRI_CALLBACK_H 17 #define BT_RAYCAST_TRI_CALLBACK_H 18 18 19 19 #include "BulletCollision/CollisionShapes/btTriangleCallback.h" … … 59 59 btTransform m_triangleToWorld; 60 60 btScalar m_hitFraction; 61 btScalar m_triangleCollisionMargin; 61 btScalar m_triangleCollisionMargin; 62 btScalar m_allowedPenetration; 62 63 63 64 btTriangleConvexcastCallback (const btConvexShape* convexShape, const btTransform& convexShapeFrom, const btTransform& convexShapeTo, const btTransform& triangleToWorld, const btScalar triangleCollisionMargin); … … 68 69 }; 69 70 70 #endif // RAYCAST_TRI_CALLBACK_H71 #endif //BT_RAYCAST_TRI_CALLBACK_H 71 72 -
code/trunk/src/external/bullet/BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h
r5781 r8393 16 16 17 17 18 #ifndef SIMPLEX_SOLVER_INTERFACE_H19 #define SIMPLEX_SOLVER_INTERFACE_H18 #ifndef BT_SIMPLEX_SOLVER_INTERFACE_H 19 #define BT_SIMPLEX_SOLVER_INTERFACE_H 20 20 21 21 #include "LinearMath/btVector3.h" … … 60 60 }; 61 61 #endif 62 #endif // SIMPLEX_SOLVER_INTERFACE_H62 #endif //BT_SIMPLEX_SOLVER_INTERFACE_H 63 63 -
code/trunk/src/external/bullet/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h
r5781 r8393 15 15 16 16 17 #ifndef SUBSIMPLEX_CONVEX_CAST_H18 #define SUBSIMPLEX_CONVEX_CAST_H17 #ifndef BT_SUBSIMPLEX_CONVEX_CAST_H 18 #define BT_SUBSIMPLEX_CONVEX_CAST_H 19 19 20 20 #include "btConvexCast.h" … … 48 48 }; 49 49 50 #endif // SUBSIMPLEX_CONVEX_CAST_H50 #endif //BT_SUBSIMPLEX_CONVEX_CAST_H -
code/trunk/src/external/bullet/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h
r8351 r8393 16 16 17 17 18 #ifndef btVoronoiSimplexSolver_H19 #define btVoronoiSimplexSolver_H18 #ifndef BT_VORONOI_SIMPLEX_SOLVER_H 19 #define BT_VORONOI_SIMPLEX_SOLVER_H 20 20 21 21 #include "btSimplexSolverInterface.h" … … 176 176 }; 177 177 178 #endif //VoronoiSimplexSolver 178 #endif //BT_VORONOI_SIMPLEX_SOLVER_H 179
Note: See TracChangeset
for help on using the changeset viewer.