Bullet Collision Detection & Physics Library
btCollisionWorld.cpp
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15
16#include "btCollisionWorld.h"
37
38//#define DISABLE_DBVT_COMPOUNDSHAPE_RAYCAST_ACCELERATION
39
40
41//#define USE_BRUTEFORCE_RAYBROADPHASE 1
42//RECALCULATE_AABB is slower, but benefit is that you don't need to call 'stepSimulation' or 'updateAabbs' before using a rayTest
43//#define RECALCULATE_AABB_RAYCAST 1
44
45//When the user doesn't provide dispatcher or broadphase, create basic versions (and delete them in destructor)
49
50
52
53//for debug rendering
66
67
68
70:m_dispatcher1(dispatcher),
71m_broadphasePairCache(pairCache),
72m_debugDrawer(0),
73m_forceUpdateAllAabbs(true)
74{
75}
76
77
79{
80
81 //clean up remaining objects
82 int i;
83 for (i=0;i<m_collisionObjects.size();i++)
84 {
86
87 btBroadphaseProxy* bp = collisionObject->getBroadphaseHandle();
88 if (bp)
89 {
90 //
91 // only clear the cached algorithms
92 //
95 collisionObject->setBroadphaseHandle(0);
96 }
97 }
98
99
100}
101
102
103
104
105
106
107
108
109
110
112{
113
115
116 //check that the object isn't already added
118 btAssert(collisionObject->getWorldArrayIndex() == -1); // do not add the same object to more than one collision world
119
120 collisionObject->setWorldArrayIndex(m_collisionObjects.size());
122
123 //calculate new AABB
124 btTransform trans = collisionObject->getWorldTransform();
125
128 collisionObject->getCollisionShape()->getAabb(trans,minAabb,maxAabb);
129
130 int type = collisionObject->getCollisionShape()->getShapeType();
131 collisionObject->setBroadphaseHandle( getBroadphase()->createProxy(
132 minAabb,
133 maxAabb,
134 type,
138 m_dispatcher1)) ;
139
140
141
142
143
144}
145
146
147
149{
151 colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb);
152 //need to increase the aabb for contact thresholds
156
157 if(getDispatchInfo().m_useContinuous && colObj->getInternalType()==btCollisionObject::CO_RIGID_BODY && !colObj->isStaticOrKinematicObject())
158 {
160 colObj->getCollisionShape()->getAabb(colObj->getInterpolationWorldTransform(),minAabb2,maxAabb2);
164 maxAabb.setMax(maxAabb2);
165 }
166
168
169 //moving objects should be moderately sized, probably something wrong if not
170 if ( colObj->isStaticObject() || ((maxAabb-minAabb).length2() < btScalar(1e12)))
171 {
172 bp->setAabb(colObj->getBroadphaseHandle(),minAabb,maxAabb, m_dispatcher1);
173 } else
174 {
175 //something went wrong, investigate
176 //this assert is unwanted in 3D modelers (danger of loosing work)
177 colObj->setActivationState(DISABLE_SIMULATION);
178
179 static bool reportMe = true;
180 if (reportMe && m_debugDrawer)
181 {
182 reportMe = false;
183 m_debugDrawer->reportErrorWarning("Overflow in AABB, object removed from simulation");
184 m_debugDrawer->reportErrorWarning("If you can reproduce this, please email bugs@continuousphysics.com\n");
185 m_debugDrawer->reportErrorWarning("Please include above information, your Platform, version of OS.\n");
186 m_debugDrawer->reportErrorWarning("Thanks.\n");
187 }
188 }
189}
190
192{
193 BT_PROFILE("updateAabbs");
194
196 for ( int i=0;i<m_collisionObjects.size();i++)
197 {
199 btAssert(colObj->getWorldArrayIndex() == i);
200
201 //only update aabb of active objects
202 if (m_forceUpdateAllAabbs || colObj->isActive())
203 {
205 }
206 }
207}
208
209
211{
212 BT_PROFILE("calculateOverlappingPairs");
214}
215
217{
218 BT_PROFILE("performDiscreteCollisionDetection");
219
221
222 updateAabbs();
223
225
227 {
228 BT_PROFILE("dispatchAllCollisionPairs");
229 if (dispatcher)
231 }
232
233}
234
235
236
238{
239
240
241 //bool removeFromBroadphase = false;
242
243 {
244
245 btBroadphaseProxy* bp = collisionObject->getBroadphaseHandle();
246 if (bp)
247 {
248 //
249 // only clear the cached algorithms
250 //
253 collisionObject->setBroadphaseHandle(0);
254 }
255 }
256
257
258 int iObj = collisionObject->getWorldArrayIndex();
259// btAssert(iObj >= 0 && iObj < m_collisionObjects.size()); // trying to remove an object that was never added or already removed previously?
260 if (iObj >= 0 && iObj < m_collisionObjects.size())
261 {
266 {
267 m_collisionObjects[iObj]->setWorldArrayIndex(iObj);
268 }
269 }
270 else
271 {
272 // slow linear search
273 //swapremove
275 }
276 collisionObject->setWorldArrayIndex(-1);
277}
278
279
285{
288}
289
293{
295 pointShape.setMargin(0.f);
297 const btCollisionShape* collisionShape = collisionObjectWrap->getCollisionShape();
298 const btTransform& colObjWorldTransform = collisionObjectWrap->getWorldTransform();
299
300 if (collisionShape->isConvex())
301 {
302 // BT_PROFILE("rayTestConvex");
304 castResult.m_fraction = resultCallback.m_closestHitFraction;
305
309
311
312 //btContinuousConvexCollision convexCaster(castShape,convexShape,&simplexSolver,0);
313
315 //use kF_UseSubSimplexConvexCastRaytest by default
318 else
320
322
324 {
325 //add hit
326 if (castResult.m_normal.length2() > btScalar(0.0001))
327 {
328 if (castResult.m_fraction < resultCallback.m_closestHitFraction)
329 {
330 //todo: figure out what this is about. When is rayFromTest.getBasis() not identity?
331#ifdef USE_SUBSIMPLEX_CONVEX_CAST
332 //rotate normal into worldspace
333 castResult.m_normal = rayFromTrans.getBasis() * castResult.m_normal;
334#endif //USE_SUBSIMPLEX_CONVEX_CAST
335
336 castResult.m_normal.normalize();
338 (
339 collisionObjectWrap->getCollisionObject(),
340 0,
341 castResult.m_normal,
342 castResult.m_fraction
343 );
344
345 bool normalInWorldSpace = true;
347
348 }
349 }
350 }
351 } else {
352 if (collisionShape->isConcave())
353 {
354
355 //ConvexCast::CastResult
357 {
358 btCollisionWorld::RayResultCallback* m_resultCallback;
359 const btCollisionObject* m_collisionObject;
361
363
366 //@BP Mod
368 m_resultCallback(resultCallback),
369 m_collisionObject(collisionObject),
372 {
373 }
374
375
376 virtual btScalar reportHit(const btVector3& hitNormalLocal, btScalar hitFraction, int partId, int triangleIndex )
377 {
380 shapeInfo.m_triangleIndex = triangleIndex;
381
383
385 (m_collisionObject,
386 &shapeInfo,
389
390 bool normalInWorldSpace = true;
391 return m_resultCallback->addSingleResult(rayResult,normalInWorldSpace);
392 }
393
394 };
395
399
400 // BT_PROFILE("rayTestConcave");
402 {
405
407 rcb.m_hitFraction = resultCallback.m_closestHitFraction;
408 triangleMesh->performRaycast(&rcb,rayFromLocal,rayToLocal);
409 }
410 else
411 {
412 //generic (slower) case
414
416
419
420 //ConvexCast::CastResult
421
423 {
424 btCollisionWorld::RayResultCallback* m_resultCallback;
425 const btCollisionObject* m_collisionObject;
427
429
432 //@BP Mod
434 m_resultCallback(resultCallback),
435 m_collisionObject(collisionObject),
438 {
439 }
440
441
442 virtual btScalar reportHit(const btVector3& hitNormalLocal, btScalar hitFraction, int partId, int triangleIndex )
443 {
446 shapeInfo.m_triangleIndex = triangleIndex;
447
449
451 (m_collisionObject,
452 &shapeInfo,
455
456 bool normalInWorldSpace = true;
457 return m_resultCallback->addSingleResult(rayResult,normalInWorldSpace);
458 }
459
460 };
461
462
464 rcb.m_hitFraction = resultCallback.m_closestHitFraction;
465
470
471 concaveShape->processAllTriangles(&rcb,rayAabbMinLocal,rayAabbMaxLocal);
472 }
473 } else {
474 // BT_PROFILE("rayTestCompound");
475 if (collisionShape->isCompound())
476 {
477 struct LocalInfoAdder2 : public RayResultCallback
478 {
480 int m_i;
481
483 : m_userCallback(user), m_i(i)
484 {
485 m_closestHitFraction = m_userCallback->m_closestHitFraction;
486 m_flags = m_userCallback->m_flags;
487 }
488 virtual bool needsCollision(btBroadphaseProxy* p) const
489 {
490 return m_userCallback->needsCollision(p);
491 }
492
493 virtual btScalar addSingleResult (btCollisionWorld::LocalRayResult &r, bool b)
494 {
497 shapeInfo.m_triangleIndex = m_i;
498 if (r.m_localShapeInfo == NULL)
499 r.m_localShapeInfo = &shapeInfo;
500
501 const btScalar result = m_userCallback->addSingleResult(r, b);
502 m_closestHitFraction = m_userCallback->m_closestHitFraction;
503 return result;
504 }
505 };
506
508 {
509 const btCollisionObject* m_collisionObject;
510 const btCompoundShape* m_compoundShape;
512 const btTransform& m_rayFromTrans;
513 const btTransform& m_rayToTrans;
514 RayResultCallback& m_resultCallback;
515
520 const btTransform& rayToTrans,
522 m_collisionObject(collisionObject),
523 m_compoundShape(compoundShape),
525 m_rayFromTrans(rayFromTrans),
526 m_rayToTrans(rayToTrans),
527 m_resultCallback(resultCallback)
528 {
529
530 }
531
532 void ProcessLeaf(int i)
533 {
534 const btCollisionShape* childCollisionShape = m_compoundShape->getChildShape(i);
535 const btTransform& childTrans = m_compoundShape->getChildTransform(i);
537
539 // replace collision shape so that callback can determine the triangle
540
541
542
543 LocalInfoAdder2 my_cb(i, &m_resultCallback);
544
545 rayTestSingleInternal(
546 m_rayFromTrans,
547 m_rayToTrans,
548 &tmpOb,
549 my_cb);
550
551 }
552
553 void Process(const btDbvtNode* leaf)
554 {
555 ProcessLeaf(leaf->dataAsInt);
556 }
557 };
558
559 const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(collisionShape);
560 const btDbvt* dbvt = compoundShape->getDynamicAabbTree();
561
562
564 collisionObjectWrap->getCollisionObject(),
570#ifndef DISABLE_DBVT_COMPOUNDSHAPE_RAYCAST_ACCELERATION
571 if (dbvt)
572 {
573 btVector3 localRayFrom = colObjWorldTransform.inverseTimes(rayFromTrans).getOrigin();
574 btVector3 localRayTo = colObjWorldTransform.inverseTimes(rayToTrans).getOrigin();
576 }
577 else
578#endif //DISABLE_DBVT_COMPOUNDSHAPE_RAYCAST_ACCELERATION
579 {
580 for (int i = 0, n = compoundShape->getNumChildShapes(); i < n; ++i)
581 {
582 rayCB.ProcessLeaf(i);
583 }
584 }
585 }
586 }
587 }
588}
589
595{
598}
599
603{
604 const btCollisionShape* collisionShape = colObjWrap->getCollisionShape();
605 const btTransform& colObjWorldTransform = colObjWrap->getWorldTransform();
606
607 if (collisionShape->isConvex())
608 {
609 //BT_PROFILE("convexSweepConvex");
612 castResult.m_fraction = resultCallback.m_closestHitFraction;//btScalar(1.);//??
613
617
619 //btGjkConvexCast convexCaster2(castShape,convexShape,&simplexSolver);
620 //btSubsimplexConvexCast convexCaster3(castShape,convexShape,&simplexSolver);
621
623
624
625
627 {
628 //add hit
629 if (castResult.m_normal.length2() > btScalar(0.0001))
630 {
631 if (castResult.m_fraction < resultCallback.m_closestHitFraction)
632 {
633 castResult.m_normal.normalize();
635 (
636 colObjWrap->getCollisionObject(),
637 0,
638 castResult.m_normal,
639 castResult.m_hitPoint,
640 castResult.m_fraction
641 );
642
643 bool normalInWorldSpace = true;
645
646 }
647 }
648 }
649 } else {
650 if (collisionShape->isConcave())
651 {
653 {
654 //BT_PROFILE("convexSweepbtBvhTriangleMesh");
659 // rotation of box in local mesh space = MeshRotation^-1 * ConvexToRotation
661
662 //ConvexCast::CastResult
664 {
666 const btCollisionObject* m_collisionObject;
668
672 m_resultCallback(resultCallback),
673 m_collisionObject(collisionObject),
675 {
676 }
677
678
680 {
683 shapeInfo.m_triangleIndex = triangleIndex;
684 if (hitFraction <= m_resultCallback->m_closestHitFraction)
685 {
686
688 (m_collisionObject,
689 &shapeInfo,
693
694 bool normalInWorldSpace = true;
695
696
697 return m_resultCallback->addSingleResult(convexResult,normalInWorldSpace);
698 }
699 return hitFraction;
700 }
701
702 };
703
705 tccb.m_hitFraction = resultCallback.m_closestHitFraction;
706 tccb.m_allowedPenetration = allowedPenetration;
710 } else
711 {
712 if (collisionShape->getShapeType()==STATIC_PLANE_PROXYTYPE)
713 {
716 castResult.m_fraction = resultCallback.m_closestHitFraction;
720
722 {
723 //add hit
724 if (castResult.m_normal.length2() > btScalar(0.0001))
725 {
726 if (castResult.m_fraction < resultCallback.m_closestHitFraction)
727 {
728 castResult.m_normal.normalize();
730 (
731 colObjWrap->getCollisionObject(),
732 0,
733 castResult.m_normal,
734 castResult.m_hitPoint,
735 castResult.m_fraction
736 );
737
738 bool normalInWorldSpace = true;
740 }
741 }
742 }
743
744 } else
745 {
746 //BT_PROFILE("convexSweepConcave");
751 // rotation of box in local mesh space = MeshRotation^-1 * ConvexToRotation
753
754 //ConvexCast::CastResult
756 {
758 const btCollisionObject* m_collisionObject;
760
764 m_resultCallback(resultCallback),
765 m_collisionObject(collisionObject),
767 {
768 }
769
770
772 {
775 shapeInfo.m_triangleIndex = triangleIndex;
776 if (hitFraction <= m_resultCallback->m_closestHitFraction)
777 {
778
780 (m_collisionObject,
781 &shapeInfo,
785
786 bool normalInWorldSpace = true;
787
788 return m_resultCallback->addSingleResult(convexResult,normalInWorldSpace);
789 }
790 return hitFraction;
791 }
792
793 };
794
796 tccb.m_hitFraction = resultCallback.m_closestHitFraction;
797 tccb.m_allowedPenetration = allowedPenetration;
800
807 concaveShape->processAllTriangles(&tccb,rayAabbMinLocal,rayAabbMaxLocal);
808 }
809 }
810 } else {
811 if (collisionShape->isCompound())
812 {
814 {
824 :
825 m_colObjWrap(colObjWrap),
826 m_castShape(castShape),
827 m_convexFromTrans(convexFromTrans),
828 m_convexToTrans(convexToTrans),
829 m_allowedPenetration(allowedPenetration),
830 m_compoundShape(compoundShape),
832 m_resultCallback(resultCallback) {
833 }
834
835 const btCollisionObjectWrapper* m_colObjWrap;
836 const btConvexShape* m_castShape;
837 const btTransform& m_convexFromTrans;
838 const btTransform& m_convexToTrans;
839 btScalar m_allowedPenetration;
840 const btCompoundShape* m_compoundShape;
842 ConvexResultCallback& m_resultCallback;
843
844 public:
845
847 {
849
850 struct LocalInfoAdder : public ConvexResultCallback {
852 int m_i;
853
855 : m_userCallback(user), m_i(i)
856 {
857 m_closestHitFraction = m_userCallback->m_closestHitFraction;
858 }
859 virtual bool needsCollision(btBroadphaseProxy* p) const
860 {
861 return m_userCallback->needsCollision(p);
862 }
863 virtual btScalar addSingleResult(btCollisionWorld::LocalConvexResult& r, bool b)
864 {
867 shapeInfo.m_triangleIndex = m_i;
868 if (r.m_localShapeInfo == NULL)
869 r.m_localShapeInfo = &shapeInfo;
870 const btScalar result = m_userCallback->addSingleResult(r, b);
871 m_closestHitFraction = m_userCallback->m_closestHitFraction;
872 return result;
873
874 }
875 };
876
877 LocalInfoAdder my_cb(index, &m_resultCallback);
878
880
881 objectQuerySingleInternal(m_castShape, m_convexFromTrans, m_convexToTrans, &tmpObj, my_cb, m_allowedPenetration);
882 }
883
884 void Process(const btDbvtNode* leaf)
885 {
886 // Processing leaf node
887 int index = leaf->dataAsInt;
888
889 btTransform childTrans = m_compoundShape->getChildTransform(index);
890 const btCollisionShape* childCollisionShape = m_compoundShape->getChildShape(index);
891
893 }
894 };
895
896 BT_PROFILE("convexSweepCompound");
897 const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(collisionShape);
898
901
904
907
910
911 const btDbvt* tree = compoundShape->getDynamicAabbTree();
912 if (tree) {
914 tree->collideTV(tree->m_root, bounds, callback);
915 } else {
916 int i;
917 for (i=0;i<compoundShape->getNumChildShapes();i++)
918 {
919 const btCollisionShape* childCollisionShape = compoundShape->getChildShape(i);
920 btTransform childTrans = compoundShape->getChildTransform(i);
921 callback.ProcessChild(i, childTrans, childCollisionShape);
922 }
923 }
924 }
925 }
926 }
927}
928
929
931{
932
938
941
945 m_world(world),
947 {
952
954
955 rayDir.normalize ();
960 m_signs[0] = m_rayDirectionInverse[0] < 0.0;
961 m_signs[1] = m_rayDirectionInverse[1] < 0.0;
962 m_signs[2] = m_rayDirectionInverse[2] < 0.0;
963
965
966 }
967
968
969
970 virtual bool process(const btBroadphaseProxy* proxy)
971 {
974 return false;
975
977
978 //only perform raycast if filterMask matches
979 if(m_resultCallback.needsCollision(collisionObject->getBroadphaseHandle()))
980 {
981 //RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject();
982 //btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
983#if 0
984#ifdef RECALCULATE_AABB
986 collisionObject->getCollisionShape()->getAabb(collisionObject->getWorldTransform(),collisionObjectAabbMin,collisionObjectAabbMax);
987#else
988 //getBroadphase()->getAabb(collisionObject->getBroadphaseHandle(),collisionObjectAabbMin,collisionObjectAabbMax);
989 const btVector3& collisionObjectAabbMin = collisionObject->getBroadphaseHandle()->m_aabbMin;
990 const btVector3& collisionObjectAabbMax = collisionObject->getBroadphaseHandle()->m_aabbMax;
991#endif
992#endif
993 //btScalar hitLambda = m_resultCallback.m_closestHitFraction;
994 //culling already done by broadphase
995 //if (btRayAabb(m_rayFromWorld,m_rayToWorld,collisionObjectAabbMin,collisionObjectAabbMax,hitLambda,m_hitNormal))
996 {
999 collisionObject->getCollisionShape(),
1000 collisionObject->getWorldTransform(),
1002 }
1003 }
1004 return true;
1005 }
1006};
1007
1009{
1010 //BT_PROFILE("rayTest");
1014
1015#ifndef USE_BRUTEFORCE_RAYBROADPHASE
1017#else
1018 for (int i=0;i<this->getNumCollisionObjects();i++)
1019 {
1020 rayCB.process(m_collisionObjects[i]->getBroadphaseHandle());
1021 }
1022#endif //USE_BRUTEFORCE_RAYBROADPHASE
1023
1024}
1025
1026
1028{
1029
1037
1038
1042 m_world(world),
1046 {
1053 m_signs[0] = m_rayDirectionInverse[0] < 0.0;
1054 m_signs[1] = m_rayDirectionInverse[1] < 0.0;
1055 m_signs[2] = m_rayDirectionInverse[2] < 0.0;
1056
1058
1059 }
1060
1061 virtual bool process(const btBroadphaseProxy* proxy)
1062 {
1065 return false;
1066
1068
1069 //only perform raycast if filterMask matches
1070 if(m_resultCallback.needsCollision(collisionObject->getBroadphaseHandle())) {
1071 //RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject();
1074 collisionObject->getCollisionShape(),
1075 collisionObject->getWorldTransform(),
1078 }
1079
1080 return true;
1081 }
1082};
1083
1084
1085
1087{
1088
1089 BT_PROFILE("convexSweepTest");
1093
1094
1095
1100 /* Compute AABB that encompasses angular movement */
1101 {
1105 zeroLinVel.setValue(0,0,0);
1106 btTransform R;
1107 R.setIdentity ();
1108 R.setRotation (convexFromTrans.getRotation());
1109 castShape->calculateTemporalAabb (R, zeroLinVel, angVel, 1.0f, castShapeAabbMin, castShapeAabbMax);
1110 }
1111
1112#ifndef USE_BRUTEFORCE_RAYBROADPHASE
1113
1115
1117
1118#else
1120 // do a ray-shape query using convexCaster (CCD)
1121 int i;
1122 for (i=0;i<m_collisionObjects.size();i++)
1123 {
1125 //only perform raycast if filterMask matches
1126 if(resultCallback.needsCollision(collisionObject->getBroadphaseHandle())) {
1127 //RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject();
1129 collisionObject->getCollisionShape()->getAabb(collisionObject->getWorldTransform(),collisionObjectAabbMin,collisionObjectAabbMax);
1131 btScalar hitLambda = btScalar(1.); //could use resultCallback.m_closestHitFraction, but needs testing
1134 {
1137 collisionObject->getCollisionShape(),
1138 collisionObject->getWorldTransform(),
1141 }
1142 }
1143 }
1144#endif //USE_BRUTEFORCE_RAYBROADPHASE
1145}
1146
1147
1148
1150{
1151
1153
1157 {
1158 }
1159
1161 {
1166 if (isSwapped)
1167 {
1170 } else
1171 {
1174 }
1175
1177 newPt.m_positionWorldOnA = pointA;
1178 newPt.m_positionWorldOnB = pointInWorld;
1179
1180 //BP mod, store contact triangles.
1181 if (isSwapped)
1182 {
1183 newPt.m_partId0 = m_partId1;
1184 newPt.m_partId1 = m_partId0;
1185 newPt.m_index0 = m_index1;
1186 newPt.m_index1 = m_index0;
1187 } else
1188 {
1189 newPt.m_partId0 = m_partId0;
1190 newPt.m_partId1 = m_partId1;
1191 newPt.m_index0 = m_index0;
1192 newPt.m_index1 = m_index1;
1193 }
1194
1195 //experimental feature info, for per-triangle material etc.
1198 m_resultCallback.addSingleResult(newPt,obj0Wrap,newPt.m_partId0,newPt.m_index0,obj1Wrap,newPt.m_partId1,newPt.m_index1);
1199
1200 }
1201
1202};
1203
1204
1205
1207{
1208
1212
1213
1216 m_world(world),
1218 {
1219 }
1220
1221 virtual bool process(const btBroadphaseProxy* proxy)
1222 {
1225 return true;
1226
1227 //only perform raycast if filterMask matches
1228 if(m_resultCallback.needsCollision(collisionObject->getBroadphaseHandle()))
1229 {
1231 btCollisionObjectWrapper ob1(0,collisionObject->getCollisionShape(),collisionObject,collisionObject->getWorldTransform(),-1,-1);
1232
1234 if (algorithm)
1235 {
1237 //discrete collision detection query
1238
1240
1241 algorithm->~btCollisionAlgorithm();
1243 }
1244 }
1245 return true;
1246 }
1247};
1248
1249
1253{
1255 colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(),aabbMin,aabbMax);
1257
1259}
1260
1261
1265{
1266 btCollisionObjectWrapper obA(0,colObjA->getCollisionShape(),colObjA,colObjA->getWorldTransform(),-1,-1);
1267 btCollisionObjectWrapper obB(0,colObjB->getCollisionShape(),colObjB,colObjB->getWorldTransform(),-1,-1);
1268
1270 if (algorithm)
1271 {
1273 contactPointResult.m_closestPointDistanceThreshold = resultCallback.m_closestDistanceThreshold;
1274 //discrete collision detection query
1276
1277 algorithm->~btCollisionAlgorithm();
1279 }
1280
1281}
1282
1283
1284
1285
1287{
1291
1292public:
1293
1296 m_color(color),
1298 {
1299 }
1300
1302 {
1304 }
1305
1307 {
1308 (void)partId;
1310
1315 btVector3 center = (wv0+wv1+wv2)*btScalar(1./3.);
1316
1318 {
1319 btVector3 normal = (wv1-wv0).cross(wv2-wv0);
1320 normal.normalize();
1321 btVector3 normalColor(1,1,0);
1322 m_debugDrawer->drawLine(center,center+normal,normalColor);
1323 }
1327 }
1328};
1329
1330
1332{
1333 // Draw a small simplex at the center of the object
1334 if (getDebugDrawer() && getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawFrames)
1335 {
1337 }
1338
1339 if (shape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE)
1340 {
1341 const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(shape);
1342 for (int i=compoundShape->getNumChildShapes()-1;i>=0;i--)
1343 {
1344 btTransform childTrans = compoundShape->getChildTransform(i);
1345 const btCollisionShape* colShape = compoundShape->getChildShape(i);
1347 }
1348
1349 } else
1350 {
1351
1352 switch (shape->getShapeType())
1353 {
1354
1356 {
1357 const btBoxShape* boxShape = static_cast<const btBoxShape*>(shape);
1358 btVector3 halfExtents = boxShape->getHalfExtentsWithMargin();
1360 break;
1361 }
1362
1364 {
1365 const btSphereShape* sphereShape = static_cast<const btSphereShape*>(shape);
1366 btScalar radius = sphereShape->getMargin();//radius doesn't include the margin, so draw with margin
1367
1369 break;
1370 }
1372 {
1373 const btMultiSphereShape* multiSphereShape = static_cast<const btMultiSphereShape*>(shape);
1374
1377
1378 for (int i = multiSphereShape->getSphereCount()-1; i>=0;i--)
1379 {
1380 childTransform.setOrigin(multiSphereShape->getSpherePosition(i));
1382 }
1383
1384 break;
1385 }
1387 {
1388 const btCapsuleShape* capsuleShape = static_cast<const btCapsuleShape*>(shape);
1389
1391 btScalar halfHeight = capsuleShape->getHalfHeight();
1392
1393 int upAxis = capsuleShape->getUpAxis();
1395 break;
1396 }
1398 {
1399 const btConeShape* coneShape = static_cast<const btConeShape*>(shape);
1400 btScalar radius = coneShape->getRadius();//+coneShape->getMargin();
1401 btScalar height = coneShape->getHeight();//+coneShape->getMargin();
1402
1403 int upAxis= coneShape->getConeUpIndex();
1405 break;
1406
1407 }
1409 {
1410 const btCylinderShape* cylinder = static_cast<const btCylinderShape*>(shape);
1411 int upAxis = cylinder->getUpAxis();
1412 btScalar radius = cylinder->getRadius();
1413 btScalar halfHeight = cylinder->getHalfExtentsWithMargin()[upAxis];
1415 break;
1416 }
1417
1419 {
1420 const btStaticPlaneShape* staticPlaneShape = static_cast<const btStaticPlaneShape*>(shape);
1422 const btVector3& planeNormal = staticPlaneShape->getPlaneNormal();
1424 break;
1425
1426 }
1427 default:
1428 {
1429
1431 if (shape->isPolyhedral())
1432 {
1434
1435 int i;
1436 if (polyshape->getConvexPolyhedron())
1437 {
1438 const btConvexPolyhedron* poly = polyshape->getConvexPolyhedron();
1439 for (i=0;i<poly->m_faces.size();i++)
1440 {
1441 btVector3 centroid(0,0,0);
1442 int numVerts = poly->m_faces[i].m_indices.size();
1443 if (numVerts)
1444 {
1445 int lastV = poly->m_faces[i].m_indices[numVerts-1];
1446 for (int v=0;v<poly->m_faces[i].m_indices.size();v++)
1447 {
1448 int curVert = poly->m_faces[i].m_indices[v];
1449 centroid+=poly->m_vertices[curVert];
1451 lastV = curVert;
1452 }
1453 }
1455 if (getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawNormals)
1456 {
1457 btVector3 normalColor(1,1,0);
1458 btVector3 faceNormal(poly->m_faces[i].m_plane[0],poly->m_faces[i].m_plane[1],poly->m_faces[i].m_plane[2]);
1460 }
1461
1462 }
1463
1464
1465 } else
1466 {
1467 for (i=0;i<polyshape->getNumEdges();i++)
1468 {
1469 btVector3 a,b;
1470 polyshape->getEdge(i,a,b);
1474 }
1475 }
1476
1477
1478 }
1479
1480 if (shape->isConcave())
1481 {
1483
1487
1489 concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax);
1490
1491 }
1492
1493 if (shape->getShapeType() == CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE)
1494 {
1496 //todo: pass camera for some culling
1499 //DebugDrawcallback drawCallback;
1501 convexMesh->getMeshInterface()->InternalProcessAllTriangles(&drawCallback,aabbMin,aabbMax);
1502 }
1503
1504
1505
1506 }
1507
1508 }
1509 }
1510}
1511
1512
1514{
1515 if (getDebugDrawer())
1516 {
1518
1520
1521 if ( getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints)
1522 {
1523
1524
1525 if (getDispatcher())
1526 {
1528
1529 for (int i=0;i<numManifolds;i++)
1530 {
1532 //btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
1533 //btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
1534
1536 for (int j=0;j<numContacts;j++)
1537 {
1538 btManifoldPoint& cp = contactManifold->getContactPoint(j);
1539 getDebugDrawer()->drawContactPoint(cp.m_positionWorldOnB,cp.m_normalWorldOnB,cp.getDistance(),cp.getLifeTime(),defaultColors.m_contactPoint);
1540 }
1541 }
1542 }
1543 }
1544
1546 {
1547 int i;
1548
1549 for ( i=0;i<m_collisionObjects.size();i++)
1550 {
1552 if ((colObj->getCollisionFlags() & btCollisionObject::CF_DISABLE_VISUALIZE_OBJECT)==0)
1553 {
1554 if (getDebugDrawer() && (getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawWireframe))
1555 {
1556 btVector3 color(btScalar(0.4),btScalar(0.4),btScalar(0.4));
1557
1558 switch(colObj->getActivationState())
1559 {
1560 case ACTIVE_TAG:
1561 color = defaultColors.m_activeObject; break;
1562 case ISLAND_SLEEPING:
1563 color = defaultColors.m_deactivatedObject;break;
1564 case WANTS_DEACTIVATION:
1565 color = defaultColors.m_wantsDeactivationObject;break;
1567 color = defaultColors.m_disabledDeactivationObject;break;
1568 case DISABLE_SIMULATION:
1569 color = defaultColors.m_disabledSimulationObject;break;
1570 default:
1571 {
1572 color = btVector3(btScalar(.3),btScalar(0.3),btScalar(0.3));
1573 }
1574 };
1575
1576 colObj->getCustomDebugColor(color);
1577
1578 debugDrawObject(colObj->getWorldTransform(),colObj->getCollisionShape(),color);
1579 }
1581 {
1584 colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb);
1588
1590
1591 if(getDispatchInfo().m_useContinuous && colObj->getInternalType()==btCollisionObject::CO_RIGID_BODY && !colObj->isStaticOrKinematicObject())
1592 {
1593 colObj->getCollisionShape()->getAabb(colObj->getInterpolationWorldTransform(),minAabb2,maxAabb2);
1597 maxAabb.setMax(maxAabb2);
1598 }
1599
1601 }
1602 }
1603 }
1604 }
1605 }
1606}
1607
1608
1610{
1611 int i;
1612
1615
1616 for (i=0;i<m_collisionObjects.size();i++)
1617 {
1619 btCollisionShape* shape = colObj->getCollisionShape();
1620
1621 if (!serializedShapes.find(shape))
1622 {
1625 }
1626 }
1627
1628 //serialize all collision objects
1629 for (i=0;i<m_collisionObjects.size();i++)
1630 {
1632 if ((colObj->getInternalType() == btCollisionObject::CO_COLLISION_OBJECT) || (colObj->getInternalType() == btCollisionObject::CO_FEATHERSTONE_LINK))
1633 {
1634 colObj->serializeSingleObject(serializer);
1635 }
1636 }
1637}
1638
1639
1641{
1642
1643 serializer->startSerialization();
1644
1646
1647 serializer->finishSerialization();
1648}
1649
bool btRayAabb(const btVector3 &rayFrom, const btVector3 &rayTo, const btVector3 &aabbMin, const btVector3 &aabbMax, btScalar &param, btVector3 &normal)
void AabbExpand(btVector3 &aabbMin, btVector3 &aabbMax, const btVector3 &expansionMin, const btVector3 &expansionMax)
Definition btAabbUtil2.h:26
@ CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE
@ COMPOUND_SHAPE_PROXYTYPE
@ TRIANGLE_MESH_SHAPE_PROXYTYPE
@ STATIC_PLANE_PROXYTYPE
@ SPHERE_SHAPE_PROXYTYPE
@ BOX_SHAPE_PROXYTYPE
@ MULTI_SPHERE_SHAPE_PROXYTYPE
@ CYLINDER_SHAPE_PROXYTYPE
@ CONE_SHAPE_PROXYTYPE
@ CAPSULE_SHAPE_PROXYTYPE
#define ACTIVE_TAG
#define DISABLE_DEACTIVATION
#define WANTS_DEACTIVATION
#define ISLAND_SLEEPING
#define DISABLE_SIMULATION
btScalar gContactBreakingThreshold
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
Definition btDbvt.cpp:284
@ BT_CLOSEST_POINT_ALGORITHMS
const T & btMax(const T &a, const T &b)
Definition btMinMax.h:29
#define BT_PROFILE(name)
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition btScalar.h:292
#define ATTRIBUTE_ALIGNED16(a)
Definition btScalar.h:82
#define BT_LARGE_FLOAT
Definition btScalar.h:294
#define btAssert(x)
Definition btScalar.h:131
virtual void internalProcessTriangleIndex(btVector3 *triangle, int partId, int triangleIndex)
virtual void processTriangle(btVector3 *triangle, int partId, int triangleIndex)
DebugDrawcallback(btIDebugDraw *debugDrawer, const btTransform &worldTrans, const btVector3 &color)
btIDebugDraw * m_debugDrawer
int size() const
return the number of elements in the array
int findLinearSearch(const T &key) const
void swap(int index0, int index1)
void remove(const T &key)
void push_back(const T &_Val)
The btBoxShape is a box primitive around the origin, its sides axis aligned with length specified by ...
Definition btBoxShape.h:27
The btBroadphaseInterface class provides an interface to detect aabb-overlapping object pairs.
virtual void aabbTest(const btVector3 &aabbMin, const btVector3 &aabbMax, btBroadphaseAabbCallback &callback)=0
virtual void calculateOverlappingPairs(btDispatcher *dispatcher)=0
calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during th...
virtual void rayTest(const btVector3 &rayFrom, const btVector3 &rayTo, btBroadphaseRayCallback &rayCallback, const btVector3 &aabbMin=btVector3(0, 0, 0), const btVector3 &aabbMax=btVector3(0, 0, 0))=0
virtual void setAabb(btBroadphaseProxy *proxy, const btVector3 &aabbMin, const btVector3 &aabbMax, btDispatcher *dispatcher)=0
virtual void destroyProxy(btBroadphaseProxy *proxy, btDispatcher *dispatcher)=0
virtual btOverlappingPairCache * getOverlappingPairCache()=0
The btBvhTriangleMeshShape is a static-triangle mesh shape, it can only be used for fixed/non-moving ...
The btCapsuleShape represents a capsule around the Y axis, there is also the btCapsuleShapeX aligned ...
btScalar getRadius() const
btCollisionAlgorithm is an collision interface that is compatible with the Broadphase and btDispatche...
virtual void processCollision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)=0
btCollisionConfiguration allows to configure Bullet collision detection stack allocator size,...
btCollisionObject can be used to manage collision detection objects.
btTransform & getWorldTransform()
const btCollisionShape * getCollisionShape() const
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
virtual void serializeSingleShape(btSerializer *serializer) const
CollisionWorld is interface and container for the collision detection.
virtual void rayTest(const btVector3 &rayFromWorld, const btVector3 &rayToWorld, RayResultCallback &resultCallback) const
rayTest performs a raycast on all objects in the btCollisionWorld, and calls the resultCallback This ...
virtual void updateAabbs()
btDispatcher * getDispatcher()
btDispatcherInfo & getDispatchInfo()
virtual void serialize(btSerializer *serializer)
Preliminary serialization test for Bullet 2.76. Loading those files requires a separate parser (Bulle...
virtual void debugDrawWorld()
static void objectQuerySingleInternal(const btConvexShape *castShape, const btTransform &convexFromTrans, const btTransform &convexToTrans, const btCollisionObjectWrapper *colObjWrap, ConvexResultCallback &resultCallback, btScalar allowedPenetration)
virtual btIDebugDraw * getDebugDrawer()
btBroadphaseInterface * m_broadphasePairCache
void updateSingleAabb(btCollisionObject *colObj)
virtual void removeCollisionObject(btCollisionObject *collisionObject)
virtual void addCollisionObject(btCollisionObject *collisionObject, int collisionFilterGroup=btBroadphaseProxy::DefaultFilter, int collisionFilterMask=btBroadphaseProxy::AllFilter)
btAlignedObjectArray< btCollisionObject * > m_collisionObjects
btCollisionWorld(btDispatcher *dispatcher, btBroadphaseInterface *broadphasePairCache, btCollisionConfiguration *collisionConfiguration)
for debug drawing
int getNumCollisionObjects() const
virtual void performDiscreteCollisionDetection()
static void rayTestSingleInternal(const btTransform &rayFromTrans, const btTransform &rayToTrans, const btCollisionObjectWrapper *collisionObjectWrap, RayResultCallback &resultCallback)
void convexSweepTest(const btConvexShape *castShape, const btTransform &from, const btTransform &to, ConvexResultCallback &resultCallback, btScalar allowedCcdPenetration=btScalar(0.)) const
convexTest performs a swept convex cast on all objects in the btCollisionWorld, and calls the resultC...
bool m_forceUpdateAllAabbs
m_forceUpdateAllAabbs can be set to false as an optimization to only update active object AABBs it is...
btIDebugDraw * m_debugDrawer
static void objectQuerySingle(const btConvexShape *castShape, const btTransform &rayFromTrans, const btTransform &rayToTrans, btCollisionObject *collisionObject, const btCollisionShape *collisionShape, const btTransform &colObjWorldTransform, ConvexResultCallback &resultCallback, btScalar allowedPenetration)
objectQuerySingle performs a collision detection query and calls the resultCallback....
btDispatcher * m_dispatcher1
void contactPairTest(btCollisionObject *colObjA, btCollisionObject *colObjB, ContactResultCallback &resultCallback)
contactTest performs a discrete collision test between two collision objects and calls the resultCall...
virtual void debugDrawObject(const btTransform &worldTransform, const btCollisionShape *shape, const btVector3 &color)
static void rayTestSingle(const btTransform &rayFromTrans, const btTransform &rayToTrans, btCollisionObject *collisionObject, const btCollisionShape *collisionShape, const btTransform &colObjWorldTransform, RayResultCallback &resultCallback)
rayTestSingle performs a raycast call and calls the resultCallback.
const btBroadphaseInterface * getBroadphase() const
void contactTest(btCollisionObject *colObj, ContactResultCallback &resultCallback)
contactTest performs a discrete collision test between colObj against all objects in the btCollisionW...
void serializeCollisionObjects(btSerializer *serializer)
virtual void computeOverlappingPairs()
the computeOverlappingPairs is usually already called by performDiscreteCollisionDetection (or stepSi...
The btCompoundShape allows to store multiple other btCollisionShapes This allows for moving concave c...
btCollisionShape * getChildShape(int index)
btTransform & getChildTransform(int index)
The btConcaveShape class provides an interface for non-moving (static) concave shapes.
The btConeShape implements a cone shape primitive, centered around the origin and aligned with the Y ...
Definition btConeShape.h:25
btScalar getRadius() const
Definition btConeShape.h:43
btContinuousConvexCollision implements angular and linear time of impact for convex objects.
btConvexCast is an interface for Casting
The btConvexShape is an abstract shape interface, implemented by all convex shapes such as btBoxShape...
The btConvexTriangleMeshShape is a convex hull of a triangle mesh, but the performance is not as good...
The btCylinderShape class implements a cylinder shape primitive, centered around the origin....
int getUpAxis() const
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
virtual int getNumManifolds() const =0
virtual btPersistentManifold * getManifoldByIndexInternal(int index)=0
virtual void freeCollisionAlgorithm(void *ptr)=0
virtual btCollisionAlgorithm * findAlgorithm(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, btPersistentManifold *sharedManifold, ebtDispatcherQueryType queryType)=0
GjkConvexCast performs a raycast on a convex object using support mapping.
EpaPenetrationDepthSolver uses the Expanding Polytope Algorithm to calculate the penetration depth be...
The btHashMap template class implements a generic and lightweight hashmap.
Definition btHashMap.h:226
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations.
virtual void drawCone(btScalar radius, btScalar height, int upAxis, const btTransform &transform, const btVector3 &color)
virtual void drawPlane(const btVector3 &planeNormal, btScalar planeConst, const btTransform &transform, const btVector3 &color)
virtual void drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color)=0
virtual void drawSphere(btScalar radius, const btTransform &transform, const btVector3 &color)
virtual void reportErrorWarning(const char *warningString)=0
virtual void clearLines()
virtual void drawTransform(const btTransform &transform, btScalar orthoLen)
virtual void drawContactPoint(const btVector3 &PointOnB, const btVector3 &normalOnB, btScalar distance, int lifeTime, const btVector3 &color)=0
virtual int getDebugMode() const =0
virtual void drawBox(const btVector3 &bbMin, const btVector3 &bbMax, const btVector3 &color)
virtual void drawCylinder(btScalar radius, btScalar halfHeight, int upAxis, const btTransform &transform, const btVector3 &color)
virtual DefaultColors getDefaultColors() const
virtual void drawAabb(const btVector3 &from, const btVector3 &to, const btVector3 &color)
virtual void drawCapsule(btScalar radius, btScalar halfHeight, int upAxis, const btTransform &transform, const btVector3 &color)
ManifoldContactPoint collects and maintains persistent contactpoints.
btManifoldResult is a helper class to manage contact results.
const btCollisionObjectWrapper * m_body0Wrap
const btCollisionObjectWrapper * m_body1Wrap
btPersistentManifold * m_manifoldPtr
The btMultiSphereShape represents the convex hull of a collection of spheres.
virtual void cleanProxyFromPairs(btBroadphaseProxy *proxy, btDispatcher *dispatcher)=0
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
const btCollisionObject * getBody0() const
The btPolyhedralConvexShape is an internal interface class for polyhedral convex shapes.
The btSphereShape implements an implicit sphere, centered around a local origin with radius.
virtual btScalar getMargin() const
The btStaticPlaneShape simulates an infinite non-moving (static) collision plane.
const btScalar & getPlaneConstant() const
btSubsimplexConvexCast implements Gino van den Bergens' paper "Ray Casting against bteral Convex Obje...
static void calculateVelocity(const btTransform &transform0, const btTransform &transform1, btScalar timeStep, btVector3 &linVel, btVector3 &angVel)
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition btTransform.h:34
btTransform inverse() const
Return the inverse of this transform.
btVector3 invXform(const btVector3 &inVec) const
void setIdentity()
Set this transformation to the identity.
btVector3 & getOrigin()
Return the origin vector translation.
void setOrigin(const btVector3 &origin)
Set the translational element.
The btTriangleCallback provides a callback for each overlapping triangle when calling processAllTrian...
The btTriangleMeshShape is an internal concave triangle mesh interface. Don't use this class directly...
btVector3 can be used to represent 3D points and vectors.
Definition btVector3.h:84
void setMax(const btVector3 &other)
Set each element to the max of the current values and the values of another btVector3.
Definition btVector3.h:621
btScalar dot(const btVector3 &v) const
Return the dot product.
Definition btVector3.h:235
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
Definition btVector3.h:652
btVector3 normalized() const
Return a normalized version of this vector.
Definition btVector3.h:964
void setMin(const btVector3 &other)
Set each element to the min of the current values and the values of another btVector3.
Definition btVector3.h:638
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
Definition btVector3.h:309
btVoronoiSimplexSolver is an implementation of the closest point distance algorithm from a 1-4 points...
btCollisionWorld::ContactResultCallback & m_resultCallback
virtual void addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorld, btScalar depth)
btBridgedManifoldResult(const btCollisionObjectWrapper *obj0Wrap, const btCollisionObjectWrapper *obj1Wrap, btCollisionWorld::ContactResultCallback &resultCallback)
The btBroadphaseProxy is the main class that can be used with the Bullet broadphases.
btVector3 m_rayDirectionInverse
added some cached data to accelerate ray-AABB tests
const btCollisionObject * getCollisionObject() const
ContactResultCallback is used to report contact points.
virtual btScalar addSingleResult(btManifoldPoint &cp, const btCollisionObjectWrapper *colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper *colObj1Wrap, int partId1, int index1)=0
virtual bool needsCollision(btBroadphaseProxy *proxy0) const
RayResultCallback is used to report new raycast results.
virtual bool needsCollision(btBroadphaseProxy *proxy0) const
virtual btScalar addSingleResult(LocalConvexResult &convexResult, bool normalInWorldSpace)=0
LocalShapeInfo gives extra information for complex shapes Currently, only btTriangleMeshShape is avai...
RayResultCallback is used to report new raycast results.
virtual bool needsCollision(btBroadphaseProxy *proxy0) const
virtual btScalar addSingleResult(LocalRayResult &rayResult, bool normalInWorldSpace)=0
RayResult stores the closest result alternatively, add a callback method to decide about closest/all ...
static btDbvtAabbMm FromMM(const btVector3 &mi, const btVector3 &mx)
Definition btDbvt.h:425
int dataAsInt
Definition btDbvt.h:188
The btDbvt class implements a fast dynamic bounding volume tree based on axis aligned bounding boxes ...
Definition btDbvt.h:199
static DBVT_PREFIX void rayTest(const btDbvtNode *root, const btVector3 &rayFrom, const btVector3 &rayTo, DBVT_IPOLICY)
rayTest is a re-entrant ray test, and can be called in parallel as long as the btAlignedAlloc is thre...
Definition btDbvt.h:1060
btCollisionObject * m_collisionObject
btCollisionWorld::ContactResultCallback & m_resultCallback
btSingleContactCallback(btCollisionObject *collisionObject, btCollisionWorld *world, btCollisionWorld::ContactResultCallback &resultCallback)
virtual bool process(const btBroadphaseProxy *proxy)
const btCollisionWorld * m_world
virtual bool process(const btBroadphaseProxy *proxy)
btSingleRayCallback(const btVector3 &rayFromWorld, const btVector3 &rayToWorld, const btCollisionWorld *world, btCollisionWorld::RayResultCallback &resultCallback)
btCollisionWorld::RayResultCallback & m_resultCallback
const btConvexShape * m_castShape
virtual bool process(const btBroadphaseProxy *proxy)
const btCollisionWorld * m_world
btCollisionWorld::ConvexResultCallback & m_resultCallback
btSingleSweepCallback(const btConvexShape *castShape, const btTransform &convexFromTrans, const btTransform &convexToTrans, const btCollisionWorld *world, btCollisionWorld::ConvexResultCallback &resultCallback, btScalar allowedPenetration)