Bullet Collision Detection & Physics Library: btCollisionWorld.cpp Source File

Bullet Collision Detection & Physics Library

btCollisionWorld.cpp
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
4
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10
11 1. 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.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15
16 #include "btCollisionWorld.h"
17 #include "btCollisionDispatcher.h"
18 #include "BulletCollision/CollisionDispatch/btCollisionObject.h"
19 #include "BulletCollision/CollisionShapes/btCollisionShape.h"
20 #include "BulletCollision/CollisionShapes/btConvexShape.h"
21 #include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
22 #include "BulletCollision/CollisionShapes/btSphereShape.h" //for raycasting
23 #include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h" //for raycasting
24 #include "BulletCollision/NarrowPhaseCollision/btRaycastCallback.h"
25 #include "BulletCollision/CollisionShapes/btCompoundShape.h"
26 #include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h"
27 #include "BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h"
28 #include "BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h"
29 #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
30 #include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
31 #include "BulletCollision/BroadphaseCollision/btDbvt.h"
32 #include "LinearMath/btAabbUtil2.h"
33 #include "LinearMath/btQuickprof.h"
34 #include "LinearMath/btSerializer.h"
35 #include "BulletCollision/CollisionShapes/btConvexPolyhedron.h"
36 #include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.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)
46 #include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
47 #include "BulletCollision/BroadphaseCollision/btSimpleBroadphase.h"
48 #include "BulletCollision/CollisionDispatch/btCollisionConfiguration.h"
49
50
52
53 //for debug rendering
54 #include "BulletCollision/CollisionShapes/btBoxShape.h"
55 #include "BulletCollision/CollisionShapes/btCapsuleShape.h"
56 #include "BulletCollision/CollisionShapes/btCompoundShape.h"
57 #include "BulletCollision/CollisionShapes/btConeShape.h"
58 #include "BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h"
59 #include "BulletCollision/CollisionShapes/btCylinderShape.h"
60 #include "BulletCollision/CollisionShapes/btMultiSphereShape.h"
61 #include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h"
62 #include "BulletCollision/CollisionShapes/btSphereShape.h"
63 #include "BulletCollision/CollisionShapes/btTriangleCallback.h"
64 #include "BulletCollision/CollisionShapes/btTriangleMeshShape.h"
65 #include "BulletCollision/CollisionShapes/btStaticPlaneShape.h"
66
67
68
69 btCollisionWorld::btCollisionWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache, btCollisionConfiguration* collisionConfiguration)
70 :m_dispatcher1(dispatcher),
71 m_broadphasePairCache(pairCache),
72 m_debugDrawer(0),
73 m_forceUpdateAllAabbs(true)
74 {
75 }
76
77
78 btCollisionWorld::~btCollisionWorld()
79 {
80
81 //clean up remaining objects
82 int i;
83 for (i=0;i<m_collisionObjects.size();i++)
84 {
85 btCollisionObject* collisionObject= m_collisionObjects[i];
86
87 btBroadphaseProxy* bp = collisionObject->getBroadphaseHandle();
88 if (bp)
89 {
90 //
91 // only clear the cached algorithms
92 //
93 getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(bp,m_dispatcher1);
94 getBroadphase()->destroyProxy(bp,m_dispatcher1);
95 collisionObject->setBroadphaseHandle(0);
96 }
97 }
98
99
100 }
101
102
103
104
105
106
107
108
109
110
111 void btCollisionWorld::addCollisionObject(btCollisionObject* collisionObject, int collisionFilterGroup, int collisionFilterMask)
112 {
113
114 btAssert(collisionObject);
115
116 //check that the object isn't already added
117 btAssert( m_collisionObjects.findLinearSearch(collisionObject) == m_collisionObjects.size());
118 btAssert(collisionObject->getWorldArrayIndex() == -1); // do not add the same object to more than one collision world
119
120 collisionObject->setWorldArrayIndex(m_collisionObjects.size());
121 m_collisionObjects.push_back(collisionObject);
122
123 //calculate new AABB
124 btTransform trans = collisionObject->getWorldTransform();
125
126 btVector3 minAabb;
127 btVector3 maxAabb;
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,
135 collisionObject,
136 collisionFilterGroup,
137 collisionFilterMask,
138 m_dispatcher1)) ;
139
140
141
142
143
144 }
145
146
147
148 void btCollisionWorld::updateSingleAabb(btCollisionObject* colObj)
149 {
150 btVector3 minAabb,maxAabb;
151 colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb);
152 //need to increase the aabb for contact thresholds
153 btVector3 contactThreshold(gContactBreakingThreshold,gContactBreakingThreshold,gContactBreakingThreshold);
154 minAabb -= contactThreshold;
155 maxAabb += contactThreshold;
156
157 if(getDispatchInfo().m_useContinuous && colObj->getInternalType()==btCollisionObject::CO_RIGID_BODY && !colObj->isStaticOrKinematicObject())
158 {
159 btVector3 minAabb2,maxAabb2;
160 colObj->getCollisionShape()->getAabb(colObj->getInterpolationWorldTransform(),minAabb2,maxAabb2);
161 minAabb2 -= contactThreshold;
162 maxAabb2 += contactThreshold;
163 minAabb.setMin(minAabb2);
164 maxAabb.setMax(maxAabb2);
165 }
166
167 btBroadphaseInterface* bp = (btBroadphaseInterface*)m_broadphasePairCache;
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
191 void btCollisionWorld::updateAabbs()
192 {
193 BT_PROFILE("updateAabbs");
194
195 btTransform predictedTrans;
196 for ( int i=0;i<m_collisionObjects.size();i++)
197 {
198 btCollisionObject* colObj = m_collisionObjects[i];
199 btAssert(colObj->getWorldArrayIndex() == i);
200
201 //only update aabb of active objects
202 if (m_forceUpdateAllAabbs || colObj->isActive())
203 {
204 updateSingleAabb(colObj);
205 }
206 }
207 }
208
209
210 void btCollisionWorld::computeOverlappingPairs()
211 {
212 BT_PROFILE("calculateOverlappingPairs");
213 m_broadphasePairCache->calculateOverlappingPairs(m_dispatcher1);
214 }
215
216 void btCollisionWorld::performDiscreteCollisionDetection()
217 {
218 BT_PROFILE("performDiscreteCollisionDetection");
219
220 btDispatcherInfo& dispatchInfo = getDispatchInfo();
221
222 updateAabbs();
223
224 computeOverlappingPairs();
225
226 btDispatcher* dispatcher = getDispatcher();
227 {
228 BT_PROFILE("dispatchAllCollisionPairs");
229 if (dispatcher)
230 dispatcher->dispatchAllCollisionPairs(m_broadphasePairCache->getOverlappingPairCache(),dispatchInfo,m_dispatcher1);
231 }
232
233 }
234
235
236
237 void btCollisionWorld::removeCollisionObject(btCollisionObject* collisionObject)
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 //
251 getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(bp,m_dispatcher1);
252 getBroadphase()->destroyProxy(bp,m_dispatcher1);
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 {
262 btAssert(collisionObject == m_collisionObjects[iObj]);
263 m_collisionObjects.swap(iObj, m_collisionObjects.size()-1);
264 m_collisionObjects.pop_back();
265 if (iObj < m_collisionObjects.size())
266 {
267 m_collisionObjects[iObj]->setWorldArrayIndex(iObj);
268 }
269 }
270 else
271 {
272 // slow linear search
273 //swapremove
274 m_collisionObjects.remove(collisionObject);
275 }
276 collisionObject->setWorldArrayIndex(-1);
277 }
278
279
280 void btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTransform& rayToTrans,
281 btCollisionObject* collisionObject,
282 const btCollisionShape* collisionShape,
283 const btTransform& colObjWorldTransform,
284 RayResultCallback& resultCallback)
285 {
286 btCollisionObjectWrapper colObWrap(0,collisionShape,collisionObject,colObjWorldTransform,-1,-1);
287 btCollisionWorld::rayTestSingleInternal(rayFromTrans,rayToTrans,&colObWrap,resultCallback);
288 }
289
290 void btCollisionWorld::rayTestSingleInternal(const btTransform& rayFromTrans,const btTransform& rayToTrans,
291 const btCollisionObjectWrapper* collisionObjectWrap,
292 RayResultCallback& resultCallback)
293 {
294 btSphereShape pointShape(btScalar(0.0));
295 pointShape.setMargin(0.f);
296 const btConvexShape* castShape = &pointShape;
297 const btCollisionShape* collisionShape = collisionObjectWrap->getCollisionShape();
298 const btTransform& colObjWorldTransform = collisionObjectWrap->getWorldTransform();
299
300 if (collisionShape->isConvex())
301 {
302 // BT_PROFILE("rayTestConvex");
303 btConvexCast::CastResult castResult;
304 castResult.m_fraction = resultCallback.m_closestHitFraction;
305
306 btConvexShape* convexShape = (btConvexShape*) collisionShape;
307 btVoronoiSimplexSolver simplexSolver;
308 btSubsimplexConvexCast subSimplexConvexCaster(castShape,convexShape,&simplexSolver);
309
310 btGjkConvexCast gjkConvexCaster(castShape,convexShape,&simplexSolver);
311
312 //btContinuousConvexCollision convexCaster(castShape,convexShape,&simplexSolver,0);
313
314 btConvexCast* convexCasterPtr = 0;
315 //use kF_UseSubSimplexConvexCastRaytest by default
316 if (resultCallback.m_flags & btTriangleRaycastCallback::kF_UseGjkConvexCastRaytest)
317 convexCasterPtr = &gjkConvexCaster;
318 else
319 convexCasterPtr = &subSimplexConvexCaster;
320
321 btConvexCast& convexCaster = *convexCasterPtr;
322
323 if (convexCaster.calcTimeOfImpact(rayFromTrans,rayToTrans,colObjWorldTransform,colObjWorldTransform,castResult))
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();
337 btCollisionWorld::LocalRayResult localRayResult
338 (
339 collisionObjectWrap->getCollisionObject(),
340 0,
341 castResult.m_normal,
342 castResult.m_fraction
343 );
344
345 bool normalInWorldSpace = true;
346 resultCallback.addSingleResult(localRayResult, normalInWorldSpace);
347
348 }
349 }
350 }
351 } else {
352 if (collisionShape->isConcave())
353 {
354
355 //ConvexCast::CastResult
356 struct BridgeTriangleRaycastCallback : public btTriangleRaycastCallback
357 {
358 btCollisionWorld::RayResultCallback* m_resultCallback;
359 const btCollisionObject* m_collisionObject;
360 const btConcaveShape* m_triangleMesh;
361
362 btTransform m_colObjWorldTransform;
363
364 BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to,
365 btCollisionWorld::RayResultCallback* resultCallback, const btCollisionObject* collisionObject,const btConcaveShape* triangleMesh,const btTransform& colObjWorldTransform):
366 //@BP Mod
367 btTriangleRaycastCallback(from,to, resultCallback->m_flags),
368 m_resultCallback(resultCallback),
369 m_collisionObject(collisionObject),
370 m_triangleMesh(triangleMesh),
371 m_colObjWorldTransform(colObjWorldTransform)
372 {
373 }
374
375
376 virtual btScalar reportHit(const btVector3& hitNormalLocal, btScalar hitFraction, int partId, int triangleIndex )
377 {
378 btCollisionWorld::LocalShapeInfo shapeInfo;
379 shapeInfo.m_shapePart = partId;
380 shapeInfo.m_triangleIndex = triangleIndex;
381
382 btVector3 hitNormalWorld = m_colObjWorldTransform.getBasis() * hitNormalLocal;
383
384 btCollisionWorld::LocalRayResult rayResult
385 (m_collisionObject,
386 &shapeInfo,
387 hitNormalWorld,
388 hitFraction);
389
390 bool normalInWorldSpace = true;
391 return m_resultCallback->addSingleResult(rayResult,normalInWorldSpace);
392 }
393
394 };
395
396 btTransform worldTocollisionObject = colObjWorldTransform.inverse();
397 btVector3 rayFromLocal = worldTocollisionObject * rayFromTrans.getOrigin();
398 btVector3 rayToLocal = worldTocollisionObject * rayToTrans.getOrigin();
399
400 // BT_PROFILE("rayTestConcave");
401 if (collisionShape->getShapeType()==TRIANGLE_MESH_SHAPE_PROXYTYPE)
402 {
404 btBvhTriangleMeshShape* triangleMesh = (btBvhTriangleMeshShape*)collisionShape;
405
406 BridgeTriangleRaycastCallback rcb(rayFromLocal,rayToLocal,&resultCallback,collisionObjectWrap->getCollisionObject(),triangleMesh,colObjWorldTransform);
407 rcb.m_hitFraction = resultCallback.m_closestHitFraction;
408 triangleMesh->performRaycast(&rcb,rayFromLocal,rayToLocal);
409 }
410 else
411 {
412 //generic (slower) case
413 btConcaveShape* concaveShape = (btConcaveShape*)collisionShape;
414
415 btTransform worldTocollisionObject = colObjWorldTransform.inverse();
416
417 btVector3 rayFromLocal = worldTocollisionObject * rayFromTrans.getOrigin();
418 btVector3 rayToLocal = worldTocollisionObject * rayToTrans.getOrigin();
419
420 //ConvexCast::CastResult
421
422 struct BridgeTriangleRaycastCallback : public btTriangleRaycastCallback
423 {
424 btCollisionWorld::RayResultCallback* m_resultCallback;
425 const btCollisionObject* m_collisionObject;
426 btConcaveShape* m_triangleMesh;
427
428 btTransform m_colObjWorldTransform;
429
430 BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to,
431 btCollisionWorld::RayResultCallback* resultCallback, const btCollisionObject* collisionObject,btConcaveShape* triangleMesh, const btTransform& colObjWorldTransform):
432 //@BP Mod
433 btTriangleRaycastCallback(from,to, resultCallback->m_flags),
434 m_resultCallback(resultCallback),
435 m_collisionObject(collisionObject),
436 m_triangleMesh(triangleMesh),
437 m_colObjWorldTransform(colObjWorldTransform)
438 {
439 }
440
441
442 virtual btScalar reportHit(const btVector3& hitNormalLocal, btScalar hitFraction, int partId, int triangleIndex )
443 {
444 btCollisionWorld::LocalShapeInfo shapeInfo;
445 shapeInfo.m_shapePart = partId;
446 shapeInfo.m_triangleIndex = triangleIndex;
447
448 btVector3 hitNormalWorld = m_colObjWorldTransform.getBasis() * hitNormalLocal;
449
450 btCollisionWorld::LocalRayResult rayResult
451 (m_collisionObject,
452 &shapeInfo,
453 hitNormalWorld,
454 hitFraction);
455
456 bool normalInWorldSpace = true;
457 return m_resultCallback->addSingleResult(rayResult,normalInWorldSpace);
458 }
459
460 };
461
462
463 BridgeTriangleRaycastCallback rcb(rayFromLocal,rayToLocal,&resultCallback,collisionObjectWrap->getCollisionObject(),concaveShape, colObjWorldTransform);
464 rcb.m_hitFraction = resultCallback.m_closestHitFraction;
465
466 btVector3 rayAabbMinLocal = rayFromLocal;
467 rayAabbMinLocal.setMin(rayToLocal);
468 btVector3 rayAabbMaxLocal = rayFromLocal;
469 rayAabbMaxLocal.setMax(rayToLocal);
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 {
479 RayResultCallback* m_userCallback;
480 int m_i;
481
482 LocalInfoAdder2 (int i, RayResultCallback *user)
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 {
495 btCollisionWorld::LocalShapeInfo shapeInfo;
496 shapeInfo.m_shapePart = -1;
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
507 struct RayTester : btDbvt::ICollide
508 {
509 const btCollisionObject* m_collisionObject;
510 const btCompoundShape* m_compoundShape;
511 const btTransform& m_colObjWorldTransform;
512 const btTransform& m_rayFromTrans;
513 const btTransform& m_rayToTrans;
514 RayResultCallback& m_resultCallback;
515
516 RayTester(const btCollisionObject* collisionObject,
517 const btCompoundShape* compoundShape,
518 const btTransform& colObjWorldTransform,
519 const btTransform& rayFromTrans,
520 const btTransform& rayToTrans,
521 RayResultCallback& resultCallback):
522 m_collisionObject(collisionObject),
523 m_compoundShape(compoundShape),
524 m_colObjWorldTransform(colObjWorldTransform),
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);
536 btTransform childWorldTrans = m_colObjWorldTransform * childTrans;
537
538 btCollisionObjectWrapper tmpOb(0,childCollisionShape,m_collisionObject,childWorldTrans,-1,i);
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
563 RayTester rayCB(
564 collisionObjectWrap->getCollisionObject(),
565 compoundShape,
566 colObjWorldTransform,
567 rayFromTrans,
568 rayToTrans,
569 resultCallback);
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();
575 btDbvt::rayTest(dbvt->m_root, localRayFrom , localRayTo, rayCB);
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
590 void btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const btTransform& convexFromTrans,const btTransform& convexToTrans,
591 btCollisionObject* collisionObject,
592 const btCollisionShape* collisionShape,
593 const btTransform& colObjWorldTransform,
594 ConvexResultCallback& resultCallback, btScalar allowedPenetration)
595 {
596 btCollisionObjectWrapper tmpOb(0,collisionShape,collisionObject,colObjWorldTransform,-1,-1);
597 btCollisionWorld::objectQuerySingleInternal(castShape,convexFromTrans,convexToTrans,&tmpOb,resultCallback,allowedPenetration);
598 }
599
600 void btCollisionWorld::objectQuerySingleInternal(const btConvexShape* castShape,const btTransform& convexFromTrans,const btTransform& convexToTrans,
601 const btCollisionObjectWrapper* colObjWrap,
602 ConvexResultCallback& resultCallback, btScalar allowedPenetration)
603 {
604 const btCollisionShape* collisionShape = colObjWrap->getCollisionShape();
605 const btTransform& colObjWorldTransform = colObjWrap->getWorldTransform();
606
607 if (collisionShape->isConvex())
608 {
609 //BT_PROFILE("convexSweepConvex");
610 btConvexCast::CastResult castResult;
611 castResult.m_allowedPenetration = allowedPenetration;
612 castResult.m_fraction = resultCallback.m_closestHitFraction;//btScalar(1.);//??
613
614 btConvexShape* convexShape = (btConvexShape*) collisionShape;
615 btVoronoiSimplexSolver simplexSolver;
616 btGjkEpaPenetrationDepthSolver gjkEpaPenetrationSolver;
617
618 btContinuousConvexCollision convexCaster1(castShape,convexShape,&simplexSolver,&gjkEpaPenetrationSolver);
619 //btGjkConvexCast convexCaster2(castShape,convexShape,&simplexSolver);
620 //btSubsimplexConvexCast convexCaster3(castShape,convexShape,&simplexSolver);
621
622 btConvexCast* castPtr = &convexCaster1;
623
624
625
626 if (castPtr->calcTimeOfImpact(convexFromTrans,convexToTrans,colObjWorldTransform,colObjWorldTransform,castResult))
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();
634 btCollisionWorld::LocalConvexResult localConvexResult
635 (
636 colObjWrap->getCollisionObject(),
637 0,
638 castResult.m_normal,
639 castResult.m_hitPoint,
640 castResult.m_fraction
641 );
642
643 bool normalInWorldSpace = true;
644 resultCallback.addSingleResult(localConvexResult, normalInWorldSpace);
645
646 }
647 }
648 }
649 } else {
650 if (collisionShape->isConcave())
651 {
652 if (collisionShape->getShapeType()==TRIANGLE_MESH_SHAPE_PROXYTYPE)
653 {
654 //BT_PROFILE("convexSweepbtBvhTriangleMesh");
655 btBvhTriangleMeshShape* triangleMesh = (btBvhTriangleMeshShape*)collisionShape;
656 btTransform worldTocollisionObject = colObjWorldTransform.inverse();
657 btVector3 convexFromLocal = worldTocollisionObject * convexFromTrans.getOrigin();
658 btVector3 convexToLocal = worldTocollisionObject * convexToTrans.getOrigin();
659 // rotation of box in local mesh space = MeshRotation^-1 * ConvexToRotation
660 btTransform rotationXform = btTransform(worldTocollisionObject.getBasis() * convexToTrans.getBasis());
661
662 //ConvexCast::CastResult
663 struct BridgeTriangleConvexcastCallback : public btTriangleConvexcastCallback
664 {
665 btCollisionWorld::ConvexResultCallback* m_resultCallback;
666 const btCollisionObject* m_collisionObject;
667 btTriangleMeshShape* m_triangleMesh;
668
669 BridgeTriangleConvexcastCallback(const btConvexShape* castShape, const btTransform& from,const btTransform& to,
670 btCollisionWorld::ConvexResultCallback* resultCallback, const btCollisionObject* collisionObject,btTriangleMeshShape* triangleMesh, const btTransform& triangleToWorld):
671 btTriangleConvexcastCallback(castShape, from,to, triangleToWorld, triangleMesh->getMargin()),
672 m_resultCallback(resultCallback),
673 m_collisionObject(collisionObject),
674 m_triangleMesh(triangleMesh)
675 {
676 }
677
678
679 virtual btScalar reportHit(const btVector3& hitNormalLocal, const btVector3& hitPointLocal, btScalar hitFraction, int partId, int triangleIndex )
680 {
681 btCollisionWorld::LocalShapeInfo shapeInfo;
682 shapeInfo.m_shapePart = partId;
683 shapeInfo.m_triangleIndex = triangleIndex;
684 if (hitFraction <= m_resultCallback->m_closestHitFraction)
685 {
686
687 btCollisionWorld::LocalConvexResult convexResult
688 (m_collisionObject,
689 &shapeInfo,
690 hitNormalLocal,
691 hitPointLocal,
692 hitFraction);
693
694 bool normalInWorldSpace = true;
695
696
697 return m_resultCallback->addSingleResult(convexResult,normalInWorldSpace);
698 }
699 return hitFraction;
700 }
701
702 };
703
704 BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,colObjWrap->getCollisionObject(),triangleMesh, colObjWorldTransform);
705 tccb.m_hitFraction = resultCallback.m_closestHitFraction;
706 tccb.m_allowedPenetration = allowedPenetration;
707 btVector3 boxMinLocal, boxMaxLocal;
708 castShape->getAabb(rotationXform, boxMinLocal, boxMaxLocal);
709 triangleMesh->performConvexcast(&tccb,convexFromLocal,convexToLocal,boxMinLocal, boxMaxLocal);
710 } else
711 {
712 if (collisionShape->getShapeType()==STATIC_PLANE_PROXYTYPE)
713 {
714 btConvexCast::CastResult castResult;
715 castResult.m_allowedPenetration = allowedPenetration;
716 castResult.m_fraction = resultCallback.m_closestHitFraction;
717 btStaticPlaneShape* planeShape = (btStaticPlaneShape*) collisionShape;
718 btContinuousConvexCollision convexCaster1(castShape,planeShape);
719 btConvexCast* castPtr = &convexCaster1;
720
721 if (castPtr->calcTimeOfImpact(convexFromTrans,convexToTrans,colObjWorldTransform,colObjWorldTransform,castResult))
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();
729 btCollisionWorld::LocalConvexResult localConvexResult
730 (
731 colObjWrap->getCollisionObject(),
732 0,
733 castResult.m_normal,
734 castResult.m_hitPoint,
735 castResult.m_fraction
736 );
737
738 bool normalInWorldSpace = true;
739 resultCallback.addSingleResult(localConvexResult, normalInWorldSpace);
740 }
741 }
742 }
743
744 } else
745 {
746 //BT_PROFILE("convexSweepConcave");
747 btConcaveShape* concaveShape = (btConcaveShape*)collisionShape;
748 btTransform worldTocollisionObject = colObjWorldTransform.inverse();
749 btVector3 convexFromLocal = worldTocollisionObject * convexFromTrans.getOrigin();
750 btVector3 convexToLocal = worldTocollisionObject * convexToTrans.getOrigin();
751 // rotation of box in local mesh space = MeshRotation^-1 * ConvexToRotation
752 btTransform rotationXform = btTransform(worldTocollisionObject.getBasis() * convexToTrans.getBasis());
753
754 //ConvexCast::CastResult
755 struct BridgeTriangleConvexcastCallback : public btTriangleConvexcastCallback
756 {
757 btCollisionWorld::ConvexResultCallback* m_resultCallback;
758 const btCollisionObject* m_collisionObject;
759 btConcaveShape* m_triangleMesh;
760
761 BridgeTriangleConvexcastCallback(const btConvexShape* castShape, const btTransform& from,const btTransform& to,
762 btCollisionWorld::ConvexResultCallback* resultCallback, const btCollisionObject* collisionObject,btConcaveShape* triangleMesh, const btTransform& triangleToWorld):
763 btTriangleConvexcastCallback(castShape, from,to, triangleToWorld, triangleMesh->getMargin()),
764 m_resultCallback(resultCallback),
765 m_collisionObject(collisionObject),
766 m_triangleMesh(triangleMesh)
767 {
768 }
769
770
771 virtual btScalar reportHit(const btVector3& hitNormalLocal, const btVector3& hitPointLocal, btScalar hitFraction, int partId, int triangleIndex )
772 {
773 btCollisionWorld::LocalShapeInfo shapeInfo;
774 shapeInfo.m_shapePart = partId;
775 shapeInfo.m_triangleIndex = triangleIndex;
776 if (hitFraction <= m_resultCallback->m_closestHitFraction)
777 {
778
779 btCollisionWorld::LocalConvexResult convexResult
780 (m_collisionObject,
781 &shapeInfo,
782 hitNormalLocal,
783 hitPointLocal,
784 hitFraction);
785
786 bool normalInWorldSpace = true;
787
788 return m_resultCallback->addSingleResult(convexResult,normalInWorldSpace);
789 }
790 return hitFraction;
791 }
792
793 };
794
795 BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,colObjWrap->getCollisionObject(),concaveShape, colObjWorldTransform);
796 tccb.m_hitFraction = resultCallback.m_closestHitFraction;
797 tccb.m_allowedPenetration = allowedPenetration;
798 btVector3 boxMinLocal, boxMaxLocal;
799 castShape->getAabb(rotationXform, boxMinLocal, boxMaxLocal);
800
801 btVector3 rayAabbMinLocal = convexFromLocal;
802 rayAabbMinLocal.setMin(convexToLocal);
803 btVector3 rayAabbMaxLocal = convexFromLocal;
804 rayAabbMaxLocal.setMax(convexToLocal);
805 rayAabbMinLocal += boxMinLocal;
806 rayAabbMaxLocal += boxMaxLocal;
807 concaveShape->processAllTriangles(&tccb,rayAabbMinLocal,rayAabbMaxLocal);
808 }
809 }
810 } else {
811 if (collisionShape->isCompound())
812 {
813 struct btCompoundLeafCallback : btDbvt::ICollide
814 {
815 btCompoundLeafCallback(
816 const btCollisionObjectWrapper* colObjWrap,
817 const btConvexShape* castShape,
818 const btTransform& convexFromTrans,
819 const btTransform& convexToTrans,
820 btScalar allowedPenetration,
821 const btCompoundShape* compoundShape,
822 const btTransform& colObjWorldTransform,
823 ConvexResultCallback& resultCallback)
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),
831 m_colObjWorldTransform(colObjWorldTransform),
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;
841 const btTransform& m_colObjWorldTransform;
842 ConvexResultCallback& m_resultCallback;
843
844 public:
845
846 void ProcessChild(int index, const btTransform& childTrans, const btCollisionShape* childCollisionShape)
847 {
848 btTransform childWorldTrans = m_colObjWorldTransform * childTrans;
849
850 struct LocalInfoAdder : public ConvexResultCallback {
851 ConvexResultCallback* m_userCallback;
852 int m_i;
853
854 LocalInfoAdder(int i, ConvexResultCallback *user)
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 {
865 btCollisionWorld::LocalShapeInfo shapeInfo;
866 shapeInfo.m_shapePart = -1;
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
879 btCollisionObjectWrapper tmpObj(m_colObjWrap, childCollisionShape, m_colObjWrap->getCollisionObject(), childWorldTrans, -1, index);
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
892 ProcessChild(index, childTrans, childCollisionShape);
893 }
894 };
895
896 BT_PROFILE("convexSweepCompound");
897 const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(collisionShape);
898
899 btVector3 fromLocalAabbMin, fromLocalAabbMax;
900 btVector3 toLocalAabbMin, toLocalAabbMax;
901
902 castShape->getAabb(colObjWorldTransform.inverse() * convexFromTrans, fromLocalAabbMin, fromLocalAabbMax);
903 castShape->getAabb(colObjWorldTransform.inverse() * convexToTrans, toLocalAabbMin, toLocalAabbMax);
904
905 fromLocalAabbMin.setMin(toLocalAabbMin);
906 fromLocalAabbMax.setMax(toLocalAabbMax);
907
908 btCompoundLeafCallback callback(colObjWrap, castShape, convexFromTrans, convexToTrans,
909 allowedPenetration, compoundShape, colObjWorldTransform, resultCallback);
910
911 const btDbvt* tree = compoundShape->getDynamicAabbTree();
912 if (tree) {
913 const ATTRIBUTE_ALIGNED16(btDbvtVolume) bounds = btDbvtVolume::FromMM(fromLocalAabbMin, fromLocalAabbMax);
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
930 struct btSingleRayCallback : public btBroadphaseRayCallback
931 {
932
933 btVector3 m_rayFromWorld;
934 btVector3 m_rayToWorld;
935 btTransform m_rayFromTrans;
936 btTransform m_rayToTrans;
937 btVector3 m_hitNormal;
938
939 const btCollisionWorld* m_world;
940 btCollisionWorld::RayResultCallback& m_resultCallback;
941
942 btSingleRayCallback(const btVector3& rayFromWorld,const btVector3& rayToWorld,const btCollisionWorld* world,btCollisionWorld::RayResultCallback& resultCallback)
943 :m_rayFromWorld(rayFromWorld),
944 m_rayToWorld(rayToWorld),
945 m_world(world),
946 m_resultCallback(resultCallback)
947 {
948 m_rayFromTrans.setIdentity();
949 m_rayFromTrans.setOrigin(m_rayFromWorld);
950 m_rayToTrans.setIdentity();
951 m_rayToTrans.setOrigin(m_rayToWorld);
952
953 btVector3 rayDir = (rayToWorld-rayFromWorld);
954
955 rayDir.normalize ();
957 m_rayDirectionInverse[0] = rayDir[0] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[0];
958 m_rayDirectionInverse[1] = rayDir[1] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[1];
959 m_rayDirectionInverse[2] = rayDir[2] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[2];
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
964 m_lambda_max = rayDir.dot(m_rayToWorld-m_rayFromWorld);
965
966 }
967
968
969
970 virtual bool process(const btBroadphaseProxy* proxy)
971 {
973 if (m_resultCallback.m_closestHitFraction == btScalar(0.f))
974 return false;
975
976 btCollisionObject* collisionObject = (btCollisionObject*)proxy->m_clientObject;
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
985 btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
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 {
997 m_world->rayTestSingle(m_rayFromTrans,m_rayToTrans,
998 collisionObject,
999 collisionObject->getCollisionShape(),
1000 collisionObject->getWorldTransform(),
1001 m_resultCallback);
1002 }
1003 }
1004 return true;
1005 }
1006 };
1007
1008 void btCollisionWorld::rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback) const
1009 {
1010 //BT_PROFILE("rayTest");
1013 btSingleRayCallback rayCB(rayFromWorld,rayToWorld,this,resultCallback);
1014
1015 #ifndef USE_BRUTEFORCE_RAYBROADPHASE
1016 m_broadphasePairCache->rayTest(rayFromWorld,rayToWorld,rayCB);
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
1027 struct btSingleSweepCallback : public btBroadphaseRayCallback
1028 {
1029
1030 btTransform m_convexFromTrans;
1031 btTransform m_convexToTrans;
1032 btVector3 m_hitNormal;
1033 const btCollisionWorld* m_world;
1034 btCollisionWorld::ConvexResultCallback& m_resultCallback;
1035 btScalar m_allowedCcdPenetration;
1036 const btConvexShape* m_castShape;
1037
1038
1039 btSingleSweepCallback(const btConvexShape* castShape, const btTransform& convexFromTrans,const btTransform& convexToTrans,const btCollisionWorld* world,btCollisionWorld::ConvexResultCallback& resultCallback,btScalar allowedPenetration)
1040 :m_convexFromTrans(convexFromTrans),
1041 m_convexToTrans(convexToTrans),
1042 m_world(world),
1043 m_resultCallback(resultCallback),
1044 m_allowedCcdPenetration(allowedPenetration),
1045 m_castShape(castShape)
1046 {
1047 btVector3 unnormalizedRayDir = (m_convexToTrans.getOrigin()-m_convexFromTrans.getOrigin());
1048 btVector3 rayDir = unnormalizedRayDir.normalized();
1050 m_rayDirectionInverse[0] = rayDir[0] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[0];
1051 m_rayDirectionInverse[1] = rayDir[1] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[1];
1052 m_rayDirectionInverse[2] = rayDir[2] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[2];
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
1057 m_lambda_max = rayDir.dot(unnormalizedRayDir);
1058
1059 }
1060
1061 virtual bool process(const btBroadphaseProxy* proxy)
1062 {
1064 if (m_resultCallback.m_closestHitFraction == btScalar(0.f))
1065 return false;
1066
1067 btCollisionObject* collisionObject = (btCollisionObject*)proxy->m_clientObject;
1068
1069 //only perform raycast if filterMask matches
1070 if(m_resultCallback.needsCollision(collisionObject->getBroadphaseHandle())) {
1071 //RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject();
1072 m_world->objectQuerySingle(m_castShape, m_convexFromTrans,m_convexToTrans,
1073 collisionObject,
1074 collisionObject->getCollisionShape(),
1075 collisionObject->getWorldTransform(),
1076 m_resultCallback,
1077 m_allowedCcdPenetration);
1078 }
1079
1080 return true;
1081 }
1082 };
1083
1084
1085
1086 void btCollisionWorld::convexSweepTest(const btConvexShape* castShape, const btTransform& convexFromWorld, const btTransform& convexToWorld, ConvexResultCallback& resultCallback, btScalar allowedCcdPenetration) const
1087 {
1088
1089 BT_PROFILE("convexSweepTest");
1093
1094
1095
1096 btTransform convexFromTrans,convexToTrans;
1097 convexFromTrans = convexFromWorld;
1098 convexToTrans = convexToWorld;
1099 btVector3 castShapeAabbMin, castShapeAabbMax;
1100 /* Compute AABB that encompasses angular movement */
1101 {
1102 btVector3 linVel, angVel;
1103 btTransformUtil::calculateVelocity (convexFromTrans, convexToTrans, 1.0f, linVel, angVel);
1104 btVector3 zeroLinVel;
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
1114 btSingleSweepCallback convexCB(castShape,convexFromWorld,convexToWorld,this,resultCallback,allowedCcdPenetration);
1115
1116 m_broadphasePairCache->rayTest(convexFromTrans.getOrigin(),convexToTrans.getOrigin(),convexCB,castShapeAabbMin,castShapeAabbMax);
1117
1118 #else
1119 // do a ray-shape query using convexCaster (CCD)
1121 int i;
1122 for (i=0;i<m_collisionObjects.size();i++)
1123 {
1124 btCollisionObject* collisionObject= m_collisionObjects[i];
1125 //only perform raycast if filterMask matches
1126 if(resultCallback.needsCollision(collisionObject->getBroadphaseHandle())) {
1127 //RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject();
1128 btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
1129 collisionObject->getCollisionShape()->getAabb(collisionObject->getWorldTransform(),collisionObjectAabbMin,collisionObjectAabbMax);
1130 AabbExpand (collisionObjectAabbMin, collisionObjectAabbMax, castShapeAabbMin, castShapeAabbMax);
1131 btScalar hitLambda = btScalar(1.); //could use resultCallback.m_closestHitFraction, but needs testing
1132 btVector3 hitNormal;
1133 if (btRayAabb(convexFromWorld.getOrigin(),convexToWorld.getOrigin(),collisionObjectAabbMin,collisionObjectAabbMax,hitLambda,hitNormal))
1134 {
1135 objectQuerySingle(castShape, convexFromTrans,convexToTrans,
1136 collisionObject,
1137 collisionObject->getCollisionShape(),
1138 collisionObject->getWorldTransform(),
1139 resultCallback,
1140 allowedCcdPenetration);
1141 }
1142 }
1143 }
1144 #endif //USE_BRUTEFORCE_RAYBROADPHASE
1145 }
1146
1147
1148
1149 struct btBridgedManifoldResult : public btManifoldResult
1150 {
1151
1152 btCollisionWorld::ContactResultCallback& m_resultCallback;
1153
1154 btBridgedManifoldResult( const btCollisionObjectWrapper* obj0Wrap,const btCollisionObjectWrapper* obj1Wrap,btCollisionWorld::ContactResultCallback& resultCallback )
1155 :btManifoldResult(obj0Wrap,obj1Wrap),
1156 m_resultCallback(resultCallback)
1157 {
1158 }
1159
1160 virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)
1161 {
1162 bool isSwapped = m_manifoldPtr->getBody0() != m_body0Wrap->getCollisionObject();
1163 btVector3 pointA = pointInWorld + normalOnBInWorld * depth;
1164 btVector3 localA;
1165 btVector3 localB;
1166 if (isSwapped)
1167 {
1168 localA = m_body1Wrap->getCollisionObject()->getWorldTransform().invXform(pointA );
1169 localB = m_body0Wrap->getCollisionObject()->getWorldTransform().invXform(pointInWorld);
1170 } else
1171 {
1172 localA = m_body0Wrap->getCollisionObject()->getWorldTransform().invXform(pointA );
1173 localB = m_body1Wrap->getCollisionObject()->getWorldTransform().invXform(pointInWorld);
1174 }
1175
1176 btManifoldPoint newPt(localA,localB,normalOnBInWorld,depth);
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.
1196 const btCollisionObjectWrapper* obj0Wrap = isSwapped? m_body1Wrap : m_body0Wrap;
1197 const btCollisionObjectWrapper* obj1Wrap = isSwapped? m_body0Wrap : m_body1Wrap;
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
1206 struct btSingleContactCallback : public btBroadphaseAabbCallback
1207 {
1208
1209 btCollisionObject* m_collisionObject;
1210 btCollisionWorld* m_world;
1211 btCollisionWorld::ContactResultCallback& m_resultCallback;
1212
1213
1214 btSingleContactCallback(btCollisionObject* collisionObject, btCollisionWorld* world,btCollisionWorld::ContactResultCallback& resultCallback)
1215 :m_collisionObject(collisionObject),
1216 m_world(world),
1217 m_resultCallback(resultCallback)
1218 {
1219 }
1220
1221 virtual bool process(const btBroadphaseProxy* proxy)
1222 {
1223 btCollisionObject* collisionObject = (btCollisionObject*)proxy->m_clientObject;
1224 if (collisionObject == m_collisionObject)
1225 return true;
1226
1227 //only perform raycast if filterMask matches
1228 if(m_resultCallback.needsCollision(collisionObject->getBroadphaseHandle()))
1229 {
1230 btCollisionObjectWrapper ob0(0,m_collisionObject->getCollisionShape(),m_collisionObject,m_collisionObject->getWorldTransform(),-1,-1);
1231 btCollisionObjectWrapper ob1(0,collisionObject->getCollisionShape(),collisionObject,collisionObject->getWorldTransform(),-1,-1);
1232
1233 btCollisionAlgorithm* algorithm = m_world->getDispatcher()->findAlgorithm(&ob0,&ob1,0, BT_CLOSEST_POINT_ALGORITHMS);
1234 if (algorithm)
1235 {
1236 btBridgedManifoldResult contactPointResult(&ob0,&ob1, m_resultCallback);
1237 //discrete collision detection query
1238
1239 algorithm->processCollision(&ob0,&ob1, m_world->getDispatchInfo(),&contactPointResult);
1240
1241 algorithm->~btCollisionAlgorithm();
1242 m_world->getDispatcher()->freeCollisionAlgorithm(algorithm);
1243 }
1244 }
1245 return true;
1246 }
1247 };
1248
1249
1252 void btCollisionWorld::contactTest( btCollisionObject* colObj, ContactResultCallback& resultCallback)
1253 {
1254 btVector3 aabbMin,aabbMax;
1255 colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(),aabbMin,aabbMax);
1256 btSingleContactCallback contactCB(colObj,this,resultCallback);
1257
1258 m_broadphasePairCache->aabbTest(aabbMin,aabbMax,contactCB);
1259 }
1260
1261
1264 void btCollisionWorld::contactPairTest(btCollisionObject* colObjA, btCollisionObject* colObjB, ContactResultCallback& resultCallback)
1265 {
1266 btCollisionObjectWrapper obA(0,colObjA->getCollisionShape(),colObjA,colObjA->getWorldTransform(),-1,-1);
1267 btCollisionObjectWrapper obB(0,colObjB->getCollisionShape(),colObjB,colObjB->getWorldTransform(),-1,-1);
1268
1269 btCollisionAlgorithm* algorithm = getDispatcher()->findAlgorithm(&obA,&obB, 0, BT_CLOSEST_POINT_ALGORITHMS);
1270 if (algorithm)
1271 {
1272 btBridgedManifoldResult contactPointResult(&obA,&obB, resultCallback);
1273 contactPointResult.m_closestPointDistanceThreshold = resultCallback.m_closestDistanceThreshold;
1274 //discrete collision detection query
1275 algorithm->processCollision(&obA,&obB, getDispatchInfo(),&contactPointResult);
1276
1277 algorithm->~btCollisionAlgorithm();
1278 getDispatcher()->freeCollisionAlgorithm(algorithm);
1279 }
1280
1281 }
1282
1283
1284
1285
1286 class DebugDrawcallback : public btTriangleCallback, public btInternalTriangleIndexCallback
1287 {
1288 btIDebugDraw* m_debugDrawer;
1289 btVector3 m_color;
1290 btTransform m_worldTrans;
1291
1292 public:
1293
1294 DebugDrawcallback(btIDebugDraw* debugDrawer,const btTransform& worldTrans,const btVector3& color) :
1295 m_debugDrawer(debugDrawer),
1296 m_color(color),
1297 m_worldTrans(worldTrans)
1298 {
1299 }
1300
1301 virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex)
1302 {
1303 processTriangle(triangle,partId,triangleIndex);
1304 }
1305
1306 virtual void processTriangle(btVector3* triangle,int partId, int triangleIndex)
1307 {
1308 (void)partId;
1309 (void)triangleIndex;
1310
1311 btVector3 wv0,wv1,wv2;
1312 wv0 = m_worldTrans*triangle[0];
1313 wv1 = m_worldTrans*triangle[1];
1314 wv2 = m_worldTrans*triangle[2];
1315 btVector3 center = (wv0+wv1+wv2)*btScalar(1./3.);
1316
1317 if (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawNormals )
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 }
1324 m_debugDrawer->drawLine(wv0,wv1,m_color);
1325 m_debugDrawer->drawLine(wv1,wv2,m_color);
1326 m_debugDrawer->drawLine(wv2,wv0,m_color);
1327 }
1328 };
1329
1330
1331 void btCollisionWorld::debugDrawObject(const btTransform& worldTransform, const btCollisionShape* shape, const btVector3& color)
1332 {
1333 // Draw a small simplex at the center of the object
1334 if (getDebugDrawer() && getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawFrames)
1335 {
1336 getDebugDrawer()->drawTransform(worldTransform,1);
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);
1346 debugDrawObject(worldTransform*childTrans,colShape,color);
1347 }
1348
1349 } else
1350 {
1351
1352 switch (shape->getShapeType())
1353 {
1354
1355 case BOX_SHAPE_PROXYTYPE:
1356 {
1357 const btBoxShape* boxShape = static_cast<const btBoxShape*>(shape);
1358 btVector3 halfExtents = boxShape->getHalfExtentsWithMargin();
1359 getDebugDrawer()->drawBox(-halfExtents,halfExtents,worldTransform,color);
1360 break;
1361 }
1362
1363 case SPHERE_SHAPE_PROXYTYPE:
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
1368 getDebugDrawer()->drawSphere(radius, worldTransform, color);
1369 break;
1370 }
1371 case MULTI_SPHERE_SHAPE_PROXYTYPE:
1372 {
1373 const btMultiSphereShape* multiSphereShape = static_cast<const btMultiSphereShape*>(shape);
1374
1375 btTransform childTransform;
1376 childTransform.setIdentity();
1377
1378 for (int i = multiSphereShape->getSphereCount()-1; i>=0;i--)
1379 {
1380 childTransform.setOrigin(multiSphereShape->getSpherePosition(i));
1381 getDebugDrawer()->drawSphere(multiSphereShape->getSphereRadius(i), worldTransform*childTransform, color);
1382 }
1383
1384 break;
1385 }
1386 case CAPSULE_SHAPE_PROXYTYPE:
1387 {
1388 const btCapsuleShape* capsuleShape = static_cast<const btCapsuleShape*>(shape);
1389
1390 btScalar radius = capsuleShape->getRadius();
1391 btScalar halfHeight = capsuleShape->getHalfHeight();
1392
1393 int upAxis = capsuleShape->getUpAxis();
1394 getDebugDrawer()->drawCapsule(radius, halfHeight, upAxis, worldTransform, color);
1395 break;
1396 }
1397 case CONE_SHAPE_PROXYTYPE:
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();
1404 getDebugDrawer()->drawCone(radius, height, upAxis, worldTransform, color);
1405 break;
1406
1407 }
1408 case CYLINDER_SHAPE_PROXYTYPE:
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];
1414 getDebugDrawer()->drawCylinder(radius, halfHeight, upAxis, worldTransform, color);
1415 break;
1416 }
1417
1418 case STATIC_PLANE_PROXYTYPE:
1419 {
1420 const btStaticPlaneShape* staticPlaneShape = static_cast<const btStaticPlaneShape*>(shape);
1421 btScalar planeConst = staticPlaneShape->getPlaneConstant();
1422 const btVector3& planeNormal = staticPlaneShape->getPlaneNormal();
1423 getDebugDrawer()->drawPlane(planeNormal, planeConst,worldTransform, color);
1424 break;
1425
1426 }
1427 default:
1428 {
1429
1431 if (shape->isPolyhedral())
1432 {
1433 btPolyhedralConvexShape* polyshape = (btPolyhedralConvexShape*) shape;
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];
1450 getDebugDrawer()->drawLine(worldTransform*poly->m_vertices[lastV],worldTransform*poly->m_vertices[curVert],color);
1451 lastV = curVert;
1452 }
1453 }
1454 centroid*= btScalar(1.f)/btScalar(numVerts);
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]);
1459 getDebugDrawer()->drawLine(worldTransform*centroid,worldTransform*(centroid+faceNormal),normalColor);
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);
1471 btVector3 wa = worldTransform * a;
1472 btVector3 wb = worldTransform * b;
1473 getDebugDrawer()->drawLine(wa,wb,color);
1474 }
1475 }
1476
1477
1478 }
1479
1480 if (shape->isConcave())
1481 {
1482 btConcaveShape* concaveMesh = (btConcaveShape*) shape;
1483
1485 btVector3 aabbMax(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
1486 btVector3 aabbMin(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT));
1487
1488 DebugDrawcallback drawCallback(getDebugDrawer(),worldTransform,color);
1489 concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax);
1490
1491 }
1492
1493 if (shape->getShapeType() == CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE)
1494 {
1495 btConvexTriangleMeshShape* convexMesh = (btConvexTriangleMeshShape*) shape;
1496 //todo: pass camera for some culling
1497 btVector3 aabbMax(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
1498 btVector3 aabbMin(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT));
1499 //DebugDrawcallback drawCallback;
1500 DebugDrawcallback drawCallback(getDebugDrawer(),worldTransform,color);
1501 convexMesh->getMeshInterface()->InternalProcessAllTriangles(&drawCallback,aabbMin,aabbMax);
1502 }
1503
1504
1505
1506 }
1507
1508 }
1509 }
1510 }
1511
1512
1513 void btCollisionWorld::debugDrawWorld()
1514 {
1515 if (getDebugDrawer())
1516 {
1517 btIDebugDraw::DefaultColors defaultColors = getDebugDrawer()->getDefaultColors();
1518
1519 if ( getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints)
1520 {
1521
1522
1523 if (getDispatcher())
1524 {
1525 int numManifolds = getDispatcher()->getNumManifolds();
1526
1527 for (int i=0;i<numManifolds;i++)
1528 {
1529 btPersistentManifold* contactManifold = getDispatcher()->getManifoldByIndexInternal(i);
1530 //btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
1531 //btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
1532
1533 int numContacts = contactManifold->getNumContacts();
1534 for (int j=0;j<numContacts;j++)
1535 {
1536 btManifoldPoint& cp = contactManifold->getContactPoint(j);
1537 getDebugDrawer()->drawContactPoint(cp.m_positionWorldOnB,cp.m_normalWorldOnB,cp.getDistance(),cp.getLifeTime(),defaultColors.m_contactPoint);
1538 }
1539 }
1540 }
1541 }
1542
1543 if ((getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe | btIDebugDraw::DBG_DrawAabb)))
1544 {
1545 int i;
1546
1547 for ( i=0;i<m_collisionObjects.size();i++)
1548 {
1549 btCollisionObject* colObj = m_collisionObjects[i];
1550 if ((colObj->getCollisionFlags() & btCollisionObject::CF_DISABLE_VISUALIZE_OBJECT)==0)
1551 {
1552 if (getDebugDrawer() && (getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawWireframe))
1553 {
1554 btVector3 color(btScalar(0.4),btScalar(0.4),btScalar(0.4));
1555
1556 switch(colObj->getActivationState())
1557 {
1558 case ACTIVE_TAG:
1559 color = defaultColors.m_activeObject; break;
1560 case ISLAND_SLEEPING:
1561 color = defaultColors.m_deactivatedObject;break;
1562 case WANTS_DEACTIVATION:
1563 color = defaultColors.m_wantsDeactivationObject;break;
1564 case DISABLE_DEACTIVATION:
1565 color = defaultColors.m_disabledDeactivationObject;break;
1566 case DISABLE_SIMULATION:
1567 color = defaultColors.m_disabledSimulationObject;break;
1568 default:
1569 {
1570 color = btVector3(btScalar(.3),btScalar(0.3),btScalar(0.3));
1571 }
1572 };
1573
1574 colObj->getCustomDebugColor(color);
1575
1576 debugDrawObject(colObj->getWorldTransform(),colObj->getCollisionShape(),color);
1577 }
1578 if (m_debugDrawer && (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawAabb))
1579 {
1580 btVector3 minAabb,maxAabb;
1581 btVector3 colorvec = defaultColors.m_aabb;
1582 colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb);
1583 btVector3 contactThreshold(gContactBreakingThreshold,gContactBreakingThreshold,gContactBreakingThreshold);
1584 minAabb -= contactThreshold;
1585 maxAabb += contactThreshold;
1586
1587 btVector3 minAabb2,maxAabb2;
1588
1589 if(getDispatchInfo().m_useContinuous && colObj->getInternalType()==btCollisionObject::CO_RIGID_BODY && !colObj->isStaticOrKinematicObject())
1590 {
1591 colObj->getCollisionShape()->getAabb(colObj->getInterpolationWorldTransform(),minAabb2,maxAabb2);
1592 minAabb2 -= contactThreshold;
1593 maxAabb2 += contactThreshold;
1594 minAabb.setMin(minAabb2);
1595 maxAabb.setMax(maxAabb2);
1596 }
1597
1598 m_debugDrawer->drawAabb(minAabb,maxAabb,colorvec);
1599 }
1600 }
1601 }
1602 }
1603 }
1604 }
1605
1606
1607 void btCollisionWorld::serializeCollisionObjects(btSerializer* serializer)
1608 {
1609 int i;
1610
1612 btHashMap<btHashPtr,btCollisionShape*> serializedShapes;
1613
1614 for (i=0;i<m_collisionObjects.size();i++)
1615 {
1616 btCollisionObject* colObj = m_collisionObjects[i];
1617 btCollisionShape* shape = colObj->getCollisionShape();
1618
1619 if (!serializedShapes.find(shape))
1620 {
1621 serializedShapes.insert(shape,shape);
1622 shape->serializeSingleShape(serializer);
1623 }
1624 }
1625
1626 //serialize all collision objects
1627 for (i=0;i<m_collisionObjects.size();i++)
1628 {
1629 btCollisionObject* colObj = m_collisionObjects[i];
1630 if ((colObj->getInternalType() == btCollisionObject::CO_COLLISION_OBJECT) || (colObj->getInternalType() == btCollisionObject::CO_FEATHERSTONE_LINK))
1631 {
1632 colObj->serializeSingleObject(serializer);
1633 }
1634 }
1635 }
1636
1637
1638 void btCollisionWorld::serialize(btSerializer* serializer)
1639 {
1640
1641 serializer->startSerialization();
1642
1643 serializeCollisionObjects(serializer);
1644
1645 serializer->finishSerialization();
1646 }
1647
btTransform::setOrigin
void setOrigin(const btVector3 &origin)
Set the translational element.
Definition: btTransform.h:150
btCylinderShape::getHalfExtentsWithMargin
btVector3 getHalfExtentsWithMargin() const
Definition: btCylinderShape.h:36
btSerializer::finishSerialization
virtual void finishSerialization()=0
ACTIVE_TAG
#define ACTIVE_TAG
Definition: btCollisionObject.h:22
BT_CLOSEST_POINT_ALGORITHMS
Definition: btDispatcher.h:70
btSingleSweepCallback::btSingleSweepCallback
btSingleSweepCallback(const btConvexShape *castShape, const btTransform &convexFromTrans, const btTransform &convexToTrans, const btCollisionWorld *world, btCollisionWorld::ConvexResultCallback &resultCallback, btScalar allowedPenetration)
Definition: btCollisionWorld.cpp:1039
btCollisionWorld::serializeCollisionObjects
void serializeCollisionObjects(btSerializer *serializer)
Definition: btCollisionWorld.cpp:1607
btConvexPolyhedron::m_vertices
btAlignedObjectArray< btVector3 > m_vertices
Definition: btConvexPolyhedron.h:46
btIDebugDraw::DBG_DrawAabb
Definition: btIDebugDraw.h:60
btPersistentManifold
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
Definition: btPersistentManifold.h:55
CONE_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:43
btConvexTriangleMeshShape
The btConvexTriangleMeshShape is a convex hull of a triangle mesh, but the performance is not as good...
Definition: btConvexTriangleMeshShape.h:25
btAlignedObjectArray::push_back
void push_back(const T &_Val)
Definition: btAlignedObjectArray.h:274
btMultiSphereShape::getSphereRadius
btScalar getSphereRadius(int index) const
Definition: btMultiSphereShape.h:57
SPHERE_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:40
BT_LARGE_FLOAT
#define BT_LARGE_FLOAT
Definition: btScalar.h:281
btConvexCast
btConvexCast is an interface for Casting
Definition: btConvexCast.h:27
btCollisionWorld.h
btIDebugDraw::getDefaultColors
virtual DefaultColors getDefaultColors() const
Definition: btIDebugDraw.h:81
btConvexCast::CastResult::m_fraction
btScalar m_fraction
Definition: btConvexCast.h:57
btSingleSweepCallback
Definition: btCollisionWorld.cpp:1027
btIDebugDraw::DefaultColors::m_wantsDeactivationObject
btVector3 m_wantsDeactivationObject
Definition: btIDebugDraw.h:37
btManifoldPoint::m_partId1
int m_partId1
Definition: btManifoldPoint.h:109
btCapsuleShape::getRadius
btScalar getRadius() const
Definition: btCapsuleShape.h:76
btCapsuleShape.h
btVector3::setValue
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
Definition: btVector3.h:650
btBvhTriangleMeshShape::performRaycast
void performRaycast(btTriangleCallback *callback, const btVector3 &raySource, const btVector3 &rayTarget)
Definition: btBvhTriangleMeshShape.cpp:93
btCollisionWorld::LocalConvexResult::m_localShapeInfo
LocalShapeInfo * m_localShapeInfo
Definition: btCollisionWorld.h:333
btCollisionWorld::updateAabbs
virtual void updateAabbs()
Definition: btCollisionWorld.cpp:191
btIDebugDraw::DefaultColors::m_deactivatedObject
btVector3 m_deactivatedObject
Definition: btIDebugDraw.h:36
btTriangleRaycastCallback
Definition: btRaycastCallback.h:24
btCollisionShape::isConvex
bool isConvex() const
Definition: btCollisionShape.h:73
btDbvtAabbMm
Definition: btDbvt.h:131
btAlignedObjectArray::findLinearSearch
int findLinearSearch(const T &key) const
Definition: btAlignedObjectArray.h:463
btCollisionWorld::btCollisionWorld
btCollisionWorld(btDispatcher *dispatcher, btBroadphaseInterface *broadphasePairCache, btCollisionConfiguration *collisionConfiguration)
for debug drawing
Definition: btCollisionWorld.cpp:69
btSingleContactCallback::m_resultCallback
btCollisionWorld::ContactResultCallback & m_resultCallback
Definition: btCollisionWorld.cpp:1211
btIDebugDraw::reportErrorWarning
virtual void reportErrorWarning(const char *warningString)=0
btDispatcher::getManifoldByIndexInternal
virtual btPersistentManifold * getManifoldByIndexInternal(int index)=0
btHashMap::find
const Value * find(const Key &key) const
Definition: btHashMap.h:419
btCollisionWorld::m_forceUpdateAllAabbs
bool m_forceUpdateAllAabbs
m_forceUpdateAllAabbs can be set to false as an optimization to only update active object AABBs it is...
Definition: btCollisionWorld.h:106
btBoxShape.h
btCompoundLeafCallback
Definition: btCompoundCollisionAlgorithm.cpp:101
btCollisionWorld::addCollisionObject
virtual void addCollisionObject(btCollisionObject *collisionObject, int collisionFilterGroup=btBroadphaseProxy::DefaultFilter, int collisionFilterMask=btBroadphaseProxy::AllFilter)
Definition: btCollisionWorld.cpp:111
btVector3::length2
btScalar length2() const
Return the length of the vector squared.
Definition: btVector3.h:257
btBroadphaseProxy::m_aabbMax
btVector3 m_aabbMax
Definition: btBroadphaseProxy.h:110
btIDebugDraw::drawLine
virtual void drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color)=0
btDispatcher::dispatchAllCollisionPairs
virtual void dispatchAllCollisionPairs(btOverlappingPairCache *pairCache, const btDispatcherInfo &dispatchInfo, btDispatcher *dispatcher)=0
btSerializer::startSerialization
virtual void startSerialization()=0
btIDebugDraw::DefaultColors::m_aabb
btVector3 m_aabb
Definition: btIDebugDraw.h:40
btMultiSphereShape
The btMultiSphereShape represents the convex hull of a collection of spheres.
Definition: btMultiSphereShape.h:28
CAPSULE_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:42
btStaticPlaneShape::getPlaneConstant
const btScalar & getPlaneConstant() const
Definition: btStaticPlaneShape.h:55
btDispatcher::findAlgorithm
virtual btCollisionAlgorithm * findAlgorithm(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, btPersistentManifold *sharedManifold, ebtDispatcherQueryType queryType)=0
btStridingMeshInterface::InternalProcessAllTriangles
virtual void InternalProcessAllTriangles(btInternalTriangleIndexCallback *callback, const btVector3 &aabbMin, const btVector3 &aabbMax) const
Definition: btStridingMeshInterface.cpp:25
btIDebugDraw::drawBox
virtual void drawBox(const btVector3 &bbMin, const btVector3 &bbMax, const btVector3 &color)
Definition: btIDebugDraw.h:306
btCollisionWorld::LocalShapeInfo::m_triangleIndex
int m_triangleIndex
Definition: btCollisionWorld.h:177
TRIANGLE_MESH_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:55
btPersistentManifold::getNumContacts
int getNumContacts() const
Definition: btPersistentManifold.h:109
btCapsuleShape
The btCapsuleShape represents a capsule around the Y axis, there is also the btCapsuleShapeX aligned ...
Definition: btCapsuleShape.h:26
btCompoundShape::getDynamicAabbTree
const btDbvt * getDynamicAabbTree() const
Definition: btCompoundShape.h:146
btIDebugDraw::DBG_DrawContactPoints
Definition: btIDebugDraw.h:62
btTransform::setIdentity
void setIdentity()
Set this transformation to the identity.
Definition: btTransform.h:172
btIDebugDraw::DefaultColors
Definition: btIDebugDraw.h:33
btAssert
#define btAssert(x)
Definition: btScalar.h:114
btIDebugDraw::drawPlane
virtual void drawPlane(const btVector3 &planeNormal, btScalar planeConst, const btTransform &transform, const btVector3 &color)
Definition: btIDebugDraw.h:458
btStaticPlaneShape.h
btTransform::getRotation
btQuaternion getRotation() const
Return a quaternion representing the rotation.
Definition: btTransform.h:122
btCollisionWorld::ContactResultCallback
ContactResultCallback is used to report contact points.
Definition: btCollisionWorld.h:411
btBoxShape::getHalfExtentsWithMargin
btVector3 getHalfExtentsWithMargin() const
Definition: btBoxShape.h:36
btCollisionConfiguration
btCollisionConfiguration allows to configure Bullet collision detection stack allocator size...
Definition: btCollisionConfiguration.h:26
CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:34
btCollisionShape::serializeSingleShape
virtual void serializeSingleShape(btSerializer *serializer) const
Definition: btCollisionShape.cpp:113
btRaycastCallback.h
btDbvt
The btDbvt class implements a fast dynamic bounding volume tree based on axis aligned bounding boxes ...
Definition: btDbvt.h:198
btCollisionShape
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
Definition: btCollisionShape.h:27
btCylinderShape.h
btCollisionWorld::RayResultCallback
RayResultCallback is used to report new raycast results.
Definition: btCollisionWorld.h:204
btContinuousConvexCollision
btContinuousConvexCollision implements angular and linear time of impact for convex objects...
Definition: btContinuousConvexCollision.h:30
btCollisionObject::setWorldArrayIndex
void setWorldArrayIndex(int ix)
Definition: btCollisionObject.h:467
btConeShape.h
btBvhTriangleMeshShape.h
btSphereShape
The btSphereShape implements an implicit sphere, centered around a local origin with radius...
Definition: btSphereShape.h:22
btDbvt::m_root
btDbvtNode * m_root
Definition: btDbvt.h:262
btIDebugDraw::DefaultColors::m_activeObject
btVector3 m_activeObject
Definition: btIDebugDraw.h:35
btSingleRayCallback::m_resultCallback
btCollisionWorld::RayResultCallback & m_resultCallback
Definition: btCollisionWorld.cpp:940
btManifoldPoint
ManifoldContactPoint collects and maintains persistent contactpoints.
Definition: btManifoldPoint.h:48
btSingleSweepCallback::m_world
const btCollisionWorld * m_world
Definition: btCollisionWorld.cpp:1033
btCollisionObject::getActivationState
int getActivationState() const
Definition: btCollisionObject.h:280
btCollisionWorld::m_dispatcher1
btDispatcher * m_dispatcher1
Definition: btCollisionWorld.h:96
btManifoldResult
btManifoldResult is a helper class to manage contact results.
Definition: btManifoldResult.h:39
btIDebugDraw::DefaultColors::m_disabledSimulationObject
btVector3 m_disabledSimulationObject
Definition: btIDebugDraw.h:39
btDbvt::rayTest
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:1054
btCollisionWorld::rayTestSingleInternal
static void rayTestSingleInternal(const btTransform &rayFromTrans, const btTransform &rayToTrans, const btCollisionObjectWrapper *collisionObjectWrap, RayResultCallback &resultCallback)
Definition: btCollisionWorld.cpp:290
btCylinderShape::getUpAxis
int getUpAxis() const
Definition: btCylinderShape.h:95
btCollisionObjectWrapper::getCollisionShape
const btCollisionShape * getCollisionShape() const
Definition: btCollisionObjectWrapper.h:40
BOX_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:31
btCollisionWorld::computeOverlappingPairs
virtual void computeOverlappingPairs()
the computeOverlappingPairs is usually already called by performDiscreteCollisionDetection (or stepSi...
Definition: btCollisionWorld.cpp:210
btSingleContactCallback::m_collisionObject
btCollisionObject * m_collisionObject
Definition: btCollisionWorld.cpp:1209
btInternalTriangleIndexCallback
Definition: btTriangleCallback.h:32
ISLAND_SLEEPING
#define ISLAND_SLEEPING
Definition: btCollisionObject.h:23
btCollisionObject::isStaticOrKinematicObject
bool isStaticOrKinematicObject() const
Definition: btCollisionObject.h:205
btIDebugDraw::drawCapsule
virtual void drawCapsule(btScalar radius, btScalar halfHeight, int upAxis, const btTransform &transform, const btVector3 &color)
Definition: btIDebugDraw.h:337
btCompoundShape::getNumChildShapes
int getNumChildShapes() const
Definition: btCompoundShape.h:85
btCollisionWorld::RayResultCallback::m_closestHitFraction
btScalar m_closestHitFraction
Definition: btCollisionWorld.h:206
btSingleRayCallback::btSingleRayCallback
btSingleRayCallback(const btVector3 &rayFromWorld, const btVector3 &rayToWorld, const btCollisionWorld *world, btCollisionWorld::RayResultCallback &resultCallback)
Definition: btCollisionWorld.cpp:942
btCapsuleShape::getUpAxis
int getUpAxis() const
Definition: btCapsuleShape.h:71
btConcaveShape::processAllTriangles
virtual void processAllTriangles(btTriangleCallback *callback, const btVector3 &aabbMin, const btVector3 &aabbMax) const =0
btAlignedObjectArray::swap
void swap(int index0, int index1)
Definition: btAlignedObjectArray.h:405
btIDebugDraw::drawContactPoint
virtual void drawContactPoint(const btVector3 &PointOnB, const btVector3 &normalOnB, btScalar distance, int lifeTime, const btVector3 &color)=0
btBroadphaseInterface.h
btCollisionShape::getAabb
virtual void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const =0
getAabb returns the axis aligned bounding box in the coordinate frame of the given transform t...
btConvexShape.h
btHashMap
The btHashMap template class implements a generic and lightweight hashmap.
Definition: btHashMap.h:220
btSerializer
Definition: btSerializer.h:68
btVector3::normalize
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
Definition: btVector3.h:307
btSingleSweepCallback::m_convexToTrans
btTransform m_convexToTrans
Definition: btCollisionWorld.cpp:1031
btCollisionWorld::getNumCollisionObjects
int getNumCollisionObjects() const
Definition: btCollisionWorld.h:440
btVector3::normalized
btVector3 normalized() const
Return a normalized version of this vector.
Definition: btVector3.h:962
btBridgedManifoldResult
Definition: btCollisionWorld.cpp:1149
btConvexCast::CastResult::m_normal
btVector3 m_normal
Definition: btConvexCast.h:55
btConvexShape
The btConvexShape is an abstract shape interface, implemented by all convex shapes such as btBoxShape...
Definition: btConvexShape.h:31
btCollisionWorld::ConvexResultCallback::needsCollision
virtual bool needsCollision(btBroadphaseProxy *proxy0) const
Definition: btCollisionWorld.h:364
btGjkConvexCast
GjkConvexCast performs a raycast on a convex object using support mapping.
Definition: btGjkConvexCast.h:30
btPersistentManifold::getContactPoint
const btManifoldPoint & getContactPoint(int index) const
Definition: btPersistentManifold.h:117
btTriangleMeshShape
The btTriangleMeshShape is an internal concave triangle mesh interface. Don&#39;t use this class directly...
Definition: btTriangleMeshShape.h:24
btCollisionObject::CO_FEATHERSTONE_LINK
Definition: btCollisionObject.h:154
btConvexCast::CastResult::m_allowedPenetration
btScalar m_allowedPenetration
Definition: btConvexCast.h:59
btPolyhedralConvexShape::getEdge
virtual void getEdge(int i, btVector3 &pa, btVector3 &pb) const =0
AabbExpand
void AabbExpand(btVector3 &aabbMin, btVector3 &aabbMax, const btVector3 &expansionMin, const btVector3 &expansionMax)
Definition: btAabbUtil2.h:26
btBroadphaseInterface::getOverlappingPairCache
virtual btOverlappingPairCache * getOverlappingPairCache()=0
btCollisionShape::isCompound
bool isCompound() const
Definition: btCollisionShape.h:85
btBvhTriangleMeshShape
The btBvhTriangleMeshShape is a static-triangle mesh shape, it can only be used for fixed/non-moving ...
Definition: btBvhTriangleMeshShape.h:34
DebugDrawcallback::m_debugDrawer
btIDebugDraw * m_debugDrawer
Definition: btCollisionWorld.cpp:1288
btIDebugDraw::DBG_DrawNormals
Definition: btIDebugDraw.h:73
btCollisionWorld::RayResultCallback::addSingleResult
virtual btScalar addSingleResult(LocalRayResult &rayResult, bool normalInWorldSpace)=0
btMultiSphereShape::getSphereCount
int getSphereCount() const
Definition: btMultiSphereShape.h:47
btCollisionObject::getWorldTransform
btTransform & getWorldTransform()
Definition: btCollisionObject.h:370
CYLINDER_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:45
btManifoldPoint::m_normalWorldOnB
btVector3 m_normalWorldOnB
Definition: btManifoldPoint.h:99
btCapsuleShape::getHalfHeight
btScalar getHalfHeight() const
Definition: btCapsuleShape.h:82
btConvexCast::CastResult
RayResult stores the closest result alternatively, add a callback method to decide about closest/all ...
Definition: btConvexCast.h:36
btManifoldResult::m_closestPointDistanceThreshold
btScalar m_closestPointDistanceThreshold
Definition: btManifoldResult.h:147
btManifoldPoint::m_positionWorldOnB
btVector3 m_positionWorldOnB
Definition: btManifoldPoint.h:96
btIDebugDraw::DBG_DrawWireframe
Definition: btIDebugDraw.h:59
btIDebugDraw::drawCone
virtual void drawCone(btScalar radius, btScalar height, int upAxis, const btTransform &transform, const btVector3 &color)
Definition: btIDebugDraw.h:421
btTransform::getOrigin
btVector3 & getOrigin()
Return the origin vector translation.
Definition: btTransform.h:117
btConvexShape::getAabb
void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const =0
getAabb&#39;s default implementation is brute force, expected derived classes to implement a fast dedicat...
btCollisionObject::getBroadphaseHandle
btBroadphaseProxy * getBroadphaseHandle()
Definition: btCollisionObject.h:387
btSimpleBroadphase.h
btConeShape::getConeUpIndex
int getConeUpIndex() const
Definition: btConeShape.h:91
btSingleSweepCallback::m_convexFromTrans
btTransform m_convexFromTrans
Definition: btCollisionWorld.cpp:1030
btVoronoiSimplexSolver
btVoronoiSimplexSolver is an implementation of the closest point distance algorithm from a 1-4 points...
Definition: btVoronoiSimplexSolver.h:99
btSingleRayCallback::m_world
const btCollisionWorld * m_world
Definition: btCollisionWorld.cpp:939
btSingleSweepCallback::m_resultCallback
btCollisionWorld::ConvexResultCallback & m_resultCallback
Definition: btCollisionWorld.cpp:1034
btTriangleCallback.h
btCollisionWorld::m_debugDrawer
btIDebugDraw * m_debugDrawer
Definition: btCollisionWorld.h:102
btCollisionWorld::getDebugDrawer
virtual btIDebugDraw * getDebugDrawer()
Definition: btCollisionWorld.h:162
btAabbUtil2.h
btCollisionWorld::contactPairTest
void contactPairTest(btCollisionObject *colObjA, btCollisionObject *colObjB, ContactResultCallback &resultCallback)
contactTest performs a discrete collision test between two collision objects and calls the resultCall...
Definition: btCollisionWorld.cpp:1264
btSingleRayCallback::m_rayFromWorld
btVector3 m_rayFromWorld
Definition: btCollisionWorld.cpp:933
btConvexPolyhedron::m_faces
btAlignedObjectArray< btFace > m_faces
Definition: btConvexPolyhedron.h:47
btTriangleCallback
The btTriangleCallback provides a callback for each overlapping triangle when calling processAllTrian...
Definition: btTriangleCallback.h:24
DebugDrawcallback::DebugDrawcallback
DebugDrawcallback(btIDebugDraw *debugDrawer, const btTransform &worldTrans, const btVector3 &color)
Definition: btCollisionWorld.cpp:1294
btCollisionObject::isStaticObject
bool isStaticObject() const
Definition: btCollisionObject.h:196
btSingleContactCallback::btSingleContactCallback
btSingleContactCallback(btCollisionObject *collisionObject, btCollisionWorld *world, btCollisionWorld::ContactResultCallback &resultCallback)
Definition: btCollisionWorld.cpp:1214
btConeShape
The btConeShape implements a cone shape primitive, centered around the origin and aligned with the Y ...
Definition: btConeShape.h:23
btCompoundShape::getChildTransform
btTransform & getChildTransform(int index)
Definition: btCompoundShape.h:99
btOverlappingPairCache::cleanProxyFromPairs
virtual void cleanProxyFromPairs(btBroadphaseProxy *proxy, btDispatcher *dispatcher)=0
btDbvtAabbMm::FromMM
static btDbvtAabbMm FromMM(const btVector3 &mi, const btVector3 &mx)
Definition: btDbvt.h:425
btCollisionWorld::RayResultCallback::needsCollision
virtual bool needsCollision(btBroadphaseProxy *proxy0) const
Definition: btCollisionWorld.h:231
btVector3::dot
btScalar dot(const btVector3 &v) const
Return the dot product.
Definition: btVector3.h:235
btCollisionObjectWrapper::getCollisionObject
const btCollisionObject * getCollisionObject() const
Definition: btCollisionObjectWrapper.h:39
btGjkConvexCast.h
btCollisionObject::CO_RIGID_BODY
Definition: btCollisionObject.h:147
btCollisionObject::CO_COLLISION_OBJECT
Definition: btCollisionObject.h:146
btCollisionWorld::debugDrawObject
virtual void debugDrawObject(const btTransform &worldTransform, const btCollisionShape *shape, const btVector3 &color)
Definition: btCollisionWorld.cpp:1331
btCollisionWorld::contactTest
void contactTest(btCollisionObject *colObj, ContactResultCallback &resultCallback)
contactTest performs a discrete collision test between colObj against all objects in the btCollisionW...
Definition: btCollisionWorld.cpp:1252
btConvexPolyhedron
Definition: btConvexPolyhedron.h:37
btCollisionWorld::RayResultCallback::m_flags
unsigned int m_flags
Definition: btCollisionWorld.h:211
MULTI_SPHERE_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:41
btBroadphaseRayCallback
Definition: btBroadphaseInterface.h:36
btCollisionObject
btCollisionObject can be used to manage collision detection objects.
Definition: btCollisionObject.h:49
btTransform::setRotation
void setRotation(const btQuaternion &q)
Set the rotational element by btQuaternion.
Definition: btTransform.h:165
btBroadphaseProxy::m_clientObject
void * m_clientObject
Definition: btBroadphaseProxy.h:103
btTransform::getBasis
btMatrix3x3 & getBasis()
Return the basis matrix for the rotation.
Definition: btTransform.h:112
btCollisionConfiguration.h
btSingleRayCallback
Definition: btCollisionWorld.cpp:930
btHashMap::insert
void insert(const Key &key, const Value &value)
Definition: btHashMap.h:269
DISABLE_SIMULATION
#define DISABLE_SIMULATION
Definition: btCollisionObject.h:26
btPolyhedralConvexShape
The btPolyhedralConvexShape is an internal interface class for polyhedral convex shapes.
Definition: btPolyhedralConvexShape.h:25
btDbvt::collideTV
DBVT_PREFIX void collideTV(const btDbvtNode *root, const btDbvtVolume &volume, DBVT_IPOLICY) const
Definition: btDbvt.h:935
btCollisionWorld::LocalConvexResult
Definition: btCollisionWorld.h:316
btCollisionWorld::rayTestSingle
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.
Definition: btCollisionWorld.cpp:280
btIDebugDraw
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations...
Definition: btIDebugDraw.h:29
btCollisionObject::getInterpolationWorldTransform
const btTransform & getInterpolationWorldTransform() const
Definition: btCollisionObject.h:403
btConeShape::getRadius
btScalar getRadius() const
Definition: btConeShape.h:43
btCollisionShape::isConcave
bool isConcave() const
Definition: btCollisionShape.h:81
btCollisionWorld::LocalShapeInfo
LocalShapeInfo gives extra information for complex shapes Currently, only btTriangleMeshShape is avai...
Definition: btCollisionWorld.h:174
btIDebugDraw::drawAabb
virtual void drawAabb(const btVector3 &from, const btVector3 &to, const btVector3 &color)
Definition: btIDebugDraw.h:137
btCollisionWorld::ContactResultCallback::needsCollision
virtual bool needsCollision(btBroadphaseProxy *proxy0) const
Definition: btCollisionWorld.h:428
btManifoldPoint::m_positionWorldOnA
btVector3 m_positionWorldOnA
m_positionWorldOnA is redundant information, see getPositionWorldOnA(), but for clarity ...
Definition: btManifoldPoint.h:98
btConeShape::getHeight
btScalar getHeight() const
Definition: btConeShape.h:44
btCollisionWorld::removeCollisionObject
virtual void removeCollisionObject(btCollisionObject *collisionObject)
Definition: btCollisionWorld.cpp:237
btDispatcher::freeCollisionAlgorithm
virtual void freeCollisionAlgorithm(void *ptr)=0
btBvhTriangleMeshShape::performConvexcast
void performConvexcast(btTriangleCallback *callback, const btVector3 &boxSource, const btVector3 &boxTarget, const btVector3 &boxMin, const btVector3 &boxMax)
Definition: btBvhTriangleMeshShape.cpp:162
btCollisionWorld::~btCollisionWorld
virtual ~btCollisionWorld()
Definition: btCollisionWorld.cpp:78
btCollisionWorld::LocalShapeInfo::m_shapePart
int m_shapePart
Definition: btCollisionWorld.h:176
btBroadphaseInterface
The btBroadphaseInterface class provides an interface to detect aabb-overlapping object pairs...
Definition: btBroadphaseInterface.h:51
btContinuousConvexCollision.h
btCollisionObjectWrapper.h
btConvexTriangleMeshShape.h
btAlignedObjectArray::pop_back
void pop_back()
Definition: btAlignedObjectArray.h:199
btCollisionWorld::getDispatcher
btDispatcher * getDispatcher()
Definition: btCollisionWorld.h:138
btTriangleRaycastCallback::kF_UseGjkConvexCastRaytest
Definition: btRaycastCallback.h:40
btSingleRayCallback::m_hitNormal
btVector3 m_hitNormal
Definition: btCollisionWorld.cpp:937
btCollisionObject::getWorldArrayIndex
int getWorldArrayIndex() const
Definition: btCollisionObject.h:461
btCollisionObject::getCollisionFlags
int getCollisionFlags() const
Definition: btCollisionObject.h:483
btBroadphaseProxy
The btBroadphaseProxy is the main class that can be used with the Bullet broadphases.
Definition: btBroadphaseProxy.h:85
btCollisionWorld::rayTest
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 ...
Definition: btCollisionWorld.cpp:1008
DebugDrawcallback::processTriangle
virtual void processTriangle(btVector3 *triangle, int partId, int triangleIndex)
Definition: btCollisionWorld.cpp:1306
btCollisionWorld::ContactResultCallback::addSingleResult
virtual btScalar addSingleResult(btManifoldPoint &cp, const btCollisionObjectWrapper *colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper *colObj1Wrap, int partId1, int index1)=0
btBoxShape
The btBoxShape is a box primitive around the origin, its sides axis aligned with length specified by ...
Definition: btBoxShape.h:26
btSphereShape::setMargin
virtual void setMargin(btScalar margin)
Definition: btSphereShape.h:58
btCollisionShape.h
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:83
ATTRIBUTE_ALIGNED16
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:65
btMultiSphereShape.h
btCollisionWorld::serialize
virtual void serialize(btSerializer *serializer)
Preliminary serialization test for Bullet 2.76. Loading those files requires a separate parser (Bulle...
Definition: btCollisionWorld.cpp:1638
btAlignedObjectArray::size
int size() const
return the number of elements in the array
Definition: btAlignedObjectArray.h:155
btCollisionShape::isPolyhedral
bool isPolyhedral() const
Definition: btCollisionShape.h:63
btDispatcher::getNumManifolds
virtual int getNumManifolds() const =0
btDbvt::ICollide
Definition: btDbvt.h:231
BT_PROFILE
#define BT_PROFILE(name)
Definition: btQuickprof.h:213
btCollisionWorld::objectQuerySingle
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. It is used internally by rayTest.
Definition: btCollisionWorld.cpp:590
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:34
btSubsimplexConvexCast
btSubsimplexConvexCast implements Gino van den Bergens&#39; paper "Ray Casting against bteral Convex Obje...
Definition: btSubSimplexConvexCast.h:28
btManifoldPoint::m_index1
int m_index1
Definition: btManifoldPoint.h:111
btStaticPlaneShape::getPlaneNormal
const btVector3 & getPlaneNormal() const
Definition: btStaticPlaneShape.h:50
btBroadphaseProxy::m_aabbMin
btVector3 m_aabbMin
Definition: btBroadphaseProxy.h:109
btCollisionWorld
CollisionWorld is interface and container for the collision detection.
Definition: btCollisionWorld.h:88
btCollisionWorld::convexSweepTest
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...
Definition: btCollisionWorld.cpp:1086
btSingleContactCallback::process
virtual bool process(const btBroadphaseProxy *proxy)
Definition: btCollisionWorld.cpp:1221
btGjkEpaPenetrationDepthSolver
EpaPenetrationDepthSolver uses the Expanding Polytope Algorithm to calculate the penetration depth be...
Definition: btGjkEpaPenetrationDepthSolver.h:24
btCollisionObject::setBroadphaseHandle
void setBroadphaseHandle(btBroadphaseProxy *handle)
Definition: btCollisionObject.h:397
btCollisionWorld::getDispatchInfo
btDispatcherInfo & getDispatchInfo()
Definition: btCollisionWorld.h:503
btCollisionDispatcher.h
btConvexPolyhedron.h
WANTS_DEACTIVATION
#define WANTS_DEACTIVATION
Definition: btCollisionObject.h:24
btConcaveShape
The btConcaveShape class provides an interface for non-moving (static) concave shapes.
Definition: btConcaveShape.h:36
btSubSimplexConvexCast.h
btAlignedObjectArray::remove
void remove(const T &key)
Definition: btAlignedObjectArray.h:487
btIDebugDraw::drawTransform
virtual void drawTransform(const btTransform &transform, btScalar orthoLen)
Definition: btIDebugDraw.h:166
btQuickprof.h
btCollisionObject::getInternalType
int getInternalType() const
reserved for Bullet internal usage
Definition: btCollisionObject.h:365
btIDebugDraw::DefaultColors::m_contactPoint
btVector3 m_contactPoint
Definition: btIDebugDraw.h:41
btConvexCast::CastResult::m_hitPoint
btVector3 m_hitPoint
Definition: btConvexCast.h:56
btCylinderShape::getRadius
virtual btScalar getRadius() const
Definition: btCylinderShape.h:107
btIDebugDraw::getDebugMode
virtual int getDebugMode() const =0
btCollisionWorld::m_collisionObjects
btAlignedObjectArray< btCollisionObject * > m_collisionObjects
Definition: btCollisionWorld.h:94
btSingleRayCallback::m_rayToWorld
btVector3 m_rayToWorld
Definition: btCollisionWorld.cpp:934
btCollisionObjectWrapper::getWorldTransform
const btTransform & getWorldTransform() const
Definition: btCollisionObjectWrapper.h:38
btCollisionObject.h
btCylinderShape
The btCylinderShape class implements a cylinder shape primitive, centered around the origin...
Definition: btCylinderShape.h:24
DISABLE_DEACTIVATION
#define DISABLE_DEACTIVATION
Definition: btCollisionObject.h:25
btSingleSweepCallback::process
virtual bool process(const btBroadphaseProxy *proxy)
Definition: btCollisionWorld.cpp:1061
btCollisionObject::getCustomDebugColor
bool getCustomDebugColor(btVector3 &colorRGB) const
Definition: btCollisionObject.h:572
btDbvtNode::dataAsInt
int dataAsInt
Definition: btDbvt.h:188
btCollisionWorld::performDiscreteCollisionDetection
virtual void performDiscreteCollisionDetection()
Definition: btCollisionWorld.cpp:216
btCollisionObject::serializeSingleObject
virtual void serializeSingleObject(class btSerializer *serializer) const
Definition: btCollisionObject.cpp:119
btCollisionShape::calculateTemporalAabb
void calculateTemporalAabb(const btTransform &curTrans, const btVector3 &linvel, const btVector3 &angvel, btScalar timeStep, btVector3 &temporalAabbMin, btVector3 &temporalAabbMax) const
calculateTemporalAabb calculates the enclosing aabb for the moving object over interval [0...
Definition: btCollisionShape.cpp:60
btCollisionWorld::LocalRayResult::m_localShapeInfo
LocalShapeInfo * m_localShapeInfo
Definition: btCollisionWorld.h:197
btCollisionWorld::m_broadphasePairCache
btBroadphaseInterface * m_broadphasePairCache
Definition: btCollisionWorld.h:100
btCollisionWorld::ConvexResultCallback::m_closestHitFraction
btScalar m_closestHitFraction
Definition: btCollisionWorld.h:342
btBroadphaseInterface::setAabb
virtual void setAabb(btBroadphaseProxy *proxy, const btVector3 &aabbMin, const btVector3 &aabbMax, btDispatcher *dispatcher)=0
COMPOUND_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:71
btSingleSweepCallback::m_allowedCcdPenetration
btScalar m_allowedCcdPenetration
Definition: btCollisionWorld.cpp:1035
btCollisionShape::getShapeType
int getShapeType() const
Definition: btCollisionShape.h:112
btSingleSweepCallback::m_castShape
const btConvexShape * m_castShape
Definition: btCollisionWorld.cpp:1036
btSingleContactCallback::m_world
btCollisionWorld * m_world
Definition: btCollisionWorld.cpp:1210
btCollisionObject::isActive
bool isActive() const
Definition: btCollisionObject.h:297
btTriangleMeshShape.h
btCollisionWorld::ConvexResultCallback::addSingleResult
virtual btScalar addSingleResult(LocalConvexResult &convexResult, bool normalInWorldSpace)=0
btCollisionWorld::updateSingleAabb
void updateSingleAabb(btCollisionObject *colObj)
Definition: btCollisionWorld.cpp:148
btConcaveShape::getMargin
virtual btScalar getMargin() const
Definition: btConcaveShape.h:50
btCompoundShape
The btCompoundShape allows to store multiple other btCollisionShapes This allows for moving concave c...
Definition: btCompoundShape.h:54
btCompoundShape.h
btVector3::setMax
void setMax(const btVector3 &other)
Set each element to the max of the current values and the values of another btVector3.
Definition: btVector3.h:619
btDbvt.h
btConvexTriangleMeshShape::getMeshInterface
class btStridingMeshInterface * getMeshInterface()
Definition: btConvexTriangleMeshShape.h:35
btDispatcherInfo
Definition: btDispatcher.h:30
btDbvtNode
Definition: btDbvt.h:178
btCollisionWorld::ContactResultCallback::m_closestDistanceThreshold
btScalar m_closestDistanceThreshold
Definition: btCollisionWorld.h:415
btStaticPlaneShape
The btStaticPlaneShape simulates an infinite non-moving (static) collision plane. ...
Definition: btStaticPlaneShape.h:23
btCollisionWorld::ConvexResultCallback
RayResultCallback is used to report new raycast results.
Definition: btCollisionWorld.h:340
btIDebugDraw::DBG_DrawFrames
Definition: btIDebugDraw.h:74
btBroadphaseAabbCallback
Definition: btBroadphaseInterface.h:29
btBridgedManifoldResult::btBridgedManifoldResult
btBridgedManifoldResult(const btCollisionObjectWrapper *obj0Wrap, const btCollisionObjectWrapper *obj1Wrap, btCollisionWorld::ContactResultCallback &resultCallback)
Definition: btCollisionWorld.cpp:1154
btSingleRayCallback::process
virtual bool process(const btBroadphaseProxy *proxy)
Definition: btCollisionWorld.cpp:970
btCompoundShape::getChildShape
btCollisionShape * getChildShape(int index)
Definition: btCompoundShape.h:90
DebugDrawcallback::internalProcessTriangleIndex
virtual void internalProcessTriangleIndex(btVector3 *triangle, int partId, int triangleIndex)
Definition: btCollisionWorld.cpp:1301
btCollisionWorld::debugDrawWorld
virtual void debugDrawWorld()
Definition: btCollisionWorld.cpp:1513
btPolyhedralConvexShape.h
btSphereShape.h
btDispatcher
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:75
btCollisionAlgorithm
btCollisionAlgorithm is an collision interface that is compatible with the Broadphase and btDispatche...
Definition: btCollisionAlgorithm.h:55
gContactBreakingThreshold
btScalar gContactBreakingThreshold
Definition: btPersistentManifold.cpp:21
btTransformUtil::calculateVelocity
static void calculateVelocity(const btTransform &transform0, const btTransform &transform1, btScalar timeStep, btVector3 &linVel, btVector3 &angVel)
Definition: btTransformUtil.h:112
btCollisionObjectWrapper
Definition: btCollisionObjectWrapper.h:17
btIDebugDraw::drawSphere
virtual void drawSphere(btScalar radius, const btTransform &transform, const btVector3 &color)
Definition: btIDebugDraw.h:93
btRayAabb
bool btRayAabb(const btVector3 &rayFrom, const btVector3 &rayTo, const btVector3 &aabbMin, const btVector3 &aabbMax, btScalar &param, btVector3 &normal)
Definition: btAabbUtil2.h:125
btTransform::inverse
btTransform inverse() const
Return the inverse of this transform.
Definition: btTransform.h:188
btBroadphaseInterface::destroyProxy
virtual void destroyProxy(btBroadphaseProxy *proxy, btDispatcher *dispatcher)=0
btBridgedManifoldResult::addContactPoint
virtual void addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorld, btScalar depth)
Definition: btCollisionWorld.cpp:1160
btCollisionWorld::getBroadphase
const btBroadphaseInterface * getBroadphase() const
Definition: btCollisionWorld.h:122
btIDebugDraw::DefaultColors::m_disabledDeactivationObject
btVector3 m_disabledDeactivationObject
Definition: btIDebugDraw.h:38
btSingleContactCallback
Definition: btCollisionWorld.cpp:1206
btBridgedManifoldResult::m_resultCallback
btCollisionWorld::ContactResultCallback & m_resultCallback
Definition: btCollisionWorld.cpp:1152
btCollisionObject::setActivationState
void setActivationState(int newState) const
Definition: btCollisionObject.cpp:57
btSingleRayCallback::m_rayFromTrans
btTransform m_rayFromTrans
Definition: btCollisionWorld.cpp:935
btIDebugDraw::drawCylinder
virtual void drawCylinder(btScalar radius, btScalar halfHeight, int upAxis, const btTransform &transform, const btVector3 &color)
Definition: btIDebugDraw.h:395
btBroadphaseInterface::rayTest
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
btCollisionWorld::objectQuerySingleInternal
static void objectQuerySingleInternal(const btConvexShape *castShape, const btTransform &convexFromTrans, const btTransform &convexToTrans, const btCollisionObjectWrapper *colObjWrap, ConvexResultCallback &resultCallback, btScalar allowedPenetration)
Definition: btCollisionWorld.cpp:600
btManifoldPoint::getLifeTime
int getLifeTime() const
Definition: btManifoldPoint.h:149
btManifoldPoint::getDistance
btScalar getDistance() const
Definition: btManifoldPoint.h:145
btMultiSphereShape::getSpherePosition
const btVector3 & getSpherePosition(int index) const
Definition: btMultiSphereShape.h:52
DebugDrawcallback::m_color
btVector3 m_color
Definition: btCollisionWorld.cpp:1289
btPolyhedralConvexShape::getConvexPolyhedron
const btConvexPolyhedron * getConvexPolyhedron() const
Definition: btPolyhedralConvexShape.h:46
btManifoldPoint::m_partId0
int m_partId0
Definition: btManifoldPoint.h:108
btCollisionWorld::LocalRayResult
Definition: btCollisionWorld.h:183
btBroadphaseInterface::calculateOverlappingPairs
virtual void calculateOverlappingPairs(btDispatcher *dispatcher)=0
calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during th...
DebugDrawcallback
Definition: btCollisionWorld.cpp:1286
btVector3::setMin
void setMin(const btVector3 &other)
Set each element to the min of the current values and the values of another btVector3.
Definition: btVector3.h:636
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:279
btCollisionObject::getCollisionShape
const btCollisionShape * getCollisionShape() const
Definition: btCollisionObject.h:226
btManifoldPoint::m_index0
int m_index0
Definition: btManifoldPoint.h:110
btSphereShape::getMargin
virtual btScalar getMargin() const
Definition: btSphereShape.h:62
bounds
static btDbvtVolume bounds(const tNodeArray &leaves)
Definition: btDbvt.cpp:250
btBroadphaseInterface::aabbTest
virtual void aabbTest(const btVector3 &aabbMin, const btVector3 &aabbMax, btBroadphaseAabbCallback &callback)=0
btSingleSweepCallback::m_hitNormal
btVector3 m_hitNormal
Definition: btCollisionWorld.cpp:1032
btGjkEpaPenetrationDepthSolver.h
btConvexCast::calcTimeOfImpact
virtual bool calcTimeOfImpact(const btTransform &fromA, const btTransform &toA, const btTransform &fromB, const btTransform &toB, CastResult &result)=0
cast a convex against another convex object
DebugDrawcallback::m_worldTrans
btTransform m_worldTrans
Definition: btCollisionWorld.cpp:1290
btTriangleConvexcastCallback
Definition: btRaycastCallback.h:55
btCollisionAlgorithm.h
STATIC_PLANE_PROXYTYPE
Definition: btBroadphaseProxy.h:67
btCollisionObject::CF_DISABLE_VISUALIZE_OBJECT
Definition: btCollisionObject.h:138
btSerializer.h
btSingleRayCallback::m_rayToTrans
btTransform m_rayToTrans
Definition: btCollisionWorld.cpp:936
btPolyhedralConvexShape::getNumEdges
virtual int getNumEdges() const =0