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

Bullet Collision Detection & Physics Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

btGImpactCollisionAlgorithm.cpp
Go to the documentation of this file.
1/*
2This source file is part of GIMPACT Library.
3
4For the latest info, see http://gimpact.sourceforge.net/
5
6Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
7email: projectileman@yahoo.com
8
9
10This software is provided 'as-is', without any express or implied warranty.
11In no event will the authors be held liable for any damages arising from the use of this software.
12Permission is granted to anyone to use this software for any purpose,
13including commercial applications, and to alter it and redistribute it freely,
14subject to the following restrictions:
15
161. 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.
172. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
183. This notice may not be removed or altered from any source distribution.
19*/
20/*
21Author: Francisco Leon Najera
22Concave-Concave Collision
23
24*/
25
26#include "BulletCollision/CollisionDispatch/btManifoldResult.h"
27#include "LinearMath/btIDebugDraw.h"
28#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
29#include "BulletCollision/CollisionShapes/btBoxShape.h"
30#include "btGImpactCollisionAlgorithm.h"
31#include "btContactProcessing.h"
32#include "LinearMath/btQuickprof.h"
33
35 class btPlaneShape : public btStaticPlaneShape
36{
37public:
38 btPlaneShape(const btVector3& v, float f)
39 : btStaticPlaneShape(v, f)
40 {
41 }
42
43 void get_plane_equation(btVector4& equation)
44 {
45 equation[0] = m_planeNormal[0];
46 equation[1] = m_planeNormal[1];
47 equation[2] = m_planeNormal[2];
48 equation[3] = m_planeConstant;
49 }
50
51 void get_plane_equation_transformed(const btTransform& trans, btVector4& equation) const
52 {
53 const btVector3 normal = trans.getBasis() * m_planeNormal;
54 equation[0] = normal[0];
55 equation[1] = normal[1];
56 equation[2] = normal[2];
57 equation[3] = normal.dot(trans * (m_planeConstant * m_planeNormal));
58 }
59};
60
62#ifdef TRI_COLLISION_PROFILING
63
64 btClock g_triangle_clock;
65
66float g_accum_triangle_collision_time = 0;
67int g_count_triangle_collision = 0;
68
69void bt_begin_gim02_tri_time()
70{
71 g_triangle_clock.reset();
72}
73
74void bt_end_gim02_tri_time()
75{
76 g_accum_triangle_collision_time += g_triangle_clock.getTimeMicroseconds();
77 g_count_triangle_collision++;
78}
79#endif //TRI_COLLISION_PROFILING
81
85 class GIM_ShapeRetriever
86{
87public:
88 const btGImpactShapeInterface* m_gim_shape;
89 btTriangleShapeEx m_trishape;
90 btTetrahedronShapeEx m_tetrashape;
91
92public:
93 class ChildShapeRetriever
94 {
95 public:
96 GIM_ShapeRetriever* m_parent;
97 virtual const btCollisionShape* getChildShape(int index)
98 {
99 return m_parent->m_gim_shape->getChildShape(index);
100 }
101 virtual ~ChildShapeRetriever() {}
102 };
103
104 class TriangleShapeRetriever : public ChildShapeRetriever
105 {
106 public:
107 virtual btCollisionShape* getChildShape(int index)
108 {
109 m_parent->m_gim_shape->getBulletTriangle(index, m_parent->m_trishape);
110 return &m_parent->m_trishape;
111 }
112 virtual ~TriangleShapeRetriever() {}
113 };
114
115 class TetraShapeRetriever : public ChildShapeRetriever
116 {
117 public:
118 virtual btCollisionShape* getChildShape(int index)
119 {
120 m_parent->m_gim_shape->getBulletTetrahedron(index, m_parent->m_tetrashape);
121 return &m_parent->m_tetrashape;
122 }
123 };
124
125public:
126 ChildShapeRetriever m_child_retriever;
127 TriangleShapeRetriever m_tri_retriever;
128 TetraShapeRetriever m_tetra_retriever;
129 ChildShapeRetriever* m_current_retriever;
130
131 GIM_ShapeRetriever(const btGImpactShapeInterface* gim_shape)
132 {
133 m_gim_shape = gim_shape;
134 //select retriever
135 if (m_gim_shape->needsRetrieveTriangles())
136 {
137 m_current_retriever = &m_tri_retriever;
138 }
139 else if (m_gim_shape->needsRetrieveTetrahedrons())
140 {
141 m_current_retriever = &m_tetra_retriever;
142 }
143 else
144 {
145 m_current_retriever = &m_child_retriever;
146 }
147
148 m_current_retriever->m_parent = this;
149 }
150
151 const btCollisionShape* getChildShape(int index)
152 {
153 return m_current_retriever->getChildShape(index);
154 }
155};
156
158
159#ifdef TRI_COLLISION_PROFILING
160
162float btGImpactCollisionAlgorithm::getAverageTreeCollisionTime()
163{
164 return btGImpactBoxSet::getAverageTreeCollisionTime();
165}
166
168float btGImpactCollisionAlgorithm::getAverageTriangleCollisionTime()
169{
170 if (g_count_triangle_collision == 0) return 0;
171
172 float avgtime = g_accum_triangle_collision_time;
173 avgtime /= (float)g_count_triangle_collision;
174
175 g_accum_triangle_collision_time = 0;
176 g_count_triangle_collision = 0;
177
178 return avgtime;
179}
180
181#endif //TRI_COLLISION_PROFILING
182
183btGImpactCollisionAlgorithm::btGImpactCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap)
184 : btActivatingCollisionAlgorithm(ci, body0Wrap, body1Wrap)
185{
186 m_manifoldPtr = NULL;
187 m_convex_algorithm = NULL;
188}
189
190btGImpactCollisionAlgorithm::~btGImpactCollisionAlgorithm()
191{
192 clearCache();
193}
194
195 void btGImpactCollisionAlgorithm::addContactPoint(const btCollisionObjectWrapper* body0Wrap,
196 const btCollisionObjectWrapper* body1Wrap,
197 const btVector3& point,
198 const btVector3& normal,
199 btScalar distance)
200{
201 m_resultOut->setShapeIdentifiersA(m_part0, m_triface0);
202 m_resultOut->setShapeIdentifiersB(m_part1, m_triface1);
203 checkManifold(body0Wrap, body1Wrap);
204 m_resultOut->addContactPoint(normal, point, distance);
205}
206
207 void btGImpactCollisionAlgorithm::shape_vs_shape_collision(
208 const btCollisionObjectWrapper* body0Wrap,
209 const btCollisionObjectWrapper* body1Wrap,
210 const btCollisionShape* shape0,
211 const btCollisionShape* shape1)
212{
213 {
214 btCollisionAlgorithm* algor = newAlgorithm(body0Wrap, body1Wrap);
215 // post : checkManifold is called
216
217 m_resultOut->setShapeIdentifiersA(m_part0, m_triface0);
218 m_resultOut->setShapeIdentifiersB(m_part1, m_triface1);
219
220 algor->processCollision(body0Wrap, body1Wrap, *m_dispatchInfo, m_resultOut);
221
222 algor->~btCollisionAlgorithm();
223 m_dispatcher->freeCollisionAlgorithm(algor);
224 }
225}
226
227 void btGImpactCollisionAlgorithm::convex_vs_convex_collision(
228 const btCollisionObjectWrapper* body0Wrap,
229 const btCollisionObjectWrapper* body1Wrap,
230 const btCollisionShape* shape0,
231 const btCollisionShape* shape1)
232{
233 m_resultOut->setShapeIdentifiersA(m_part0, m_triface0);
234 m_resultOut->setShapeIdentifiersB(m_part1, m_triface1);
235
236 btCollisionObjectWrapper ob0(body0Wrap, shape0, body0Wrap->getCollisionObject(), body0Wrap->getWorldTransform(), m_part0, m_triface0);
237 btCollisionObjectWrapper ob1(body1Wrap, shape1, body1Wrap->getCollisionObject(), body1Wrap->getWorldTransform(), m_part1, m_triface1);
238 checkConvexAlgorithm(&ob0, &ob1);
239 m_convex_algorithm->processCollision(&ob0, &ob1, *m_dispatchInfo, m_resultOut);
240}
241
242 void btGImpactCollisionAlgorithm::gimpact_vs_gimpact_find_pairs(
243 const btTransform& trans0,
244 const btTransform& trans1,
245 const btGImpactShapeInterface* shape0,
246 const btGImpactShapeInterface* shape1, btPairSet& pairset)
247{
248 if (shape0->hasBoxSet() && shape1->hasBoxSet())
249 {
250 btGImpactBoxSet::find_collision(shape0->getBoxSet(), trans0, shape1->getBoxSet(), trans1, pairset);
251 }
252 else
253 {
254 btAABB boxshape0;
255 btAABB boxshape1;
256 int i = shape0->getNumChildShapes();
257
258 while (i--)
259 {
260 shape0->getChildAabb(i, trans0, boxshape0.m_min, boxshape0.m_max);
261
262 int j = shape1->getNumChildShapes();
263 while (j--)
264 {
265 shape1->getChildAabb(i, trans1, boxshape1.m_min, boxshape1.m_max);
266
267 if (boxshape1.has_collision(boxshape0))
268 {
269 pairset.push_pair(i, j);
270 }
271 }
272 }
273 }
274}
275
276 void btGImpactCollisionAlgorithm::gimpact_vs_shape_find_pairs(
277 const btTransform& trans0,
278 const btTransform& trans1,
279 const btGImpactShapeInterface* shape0,
280 const btCollisionShape* shape1,
281 btAlignedObjectArray<int>& collided_primitives)
282{
283 btAABB boxshape;
284
285 if (shape0->hasBoxSet())
286 {
287 btTransform trans1to0 = trans0.inverse();
288 trans1to0 *= trans1;
289
290 shape1->getAabb(trans1to0, boxshape.m_min, boxshape.m_max);
291
292 shape0->getBoxSet()->boxQuery(boxshape, collided_primitives);
293 }
294 else
295 {
296 shape1->getAabb(trans1, boxshape.m_min, boxshape.m_max);
297
298 btAABB boxshape0;
299 int i = shape0->getNumChildShapes();
300
301 while (i--)
302 {
303 shape0->getChildAabb(i, trans0, boxshape0.m_min, boxshape0.m_max);
304
305 if (boxshape.has_collision(boxshape0))
306 {
307 collided_primitives.push_back(i);
308 }
309 }
310 }
311}
312
313 void btGImpactCollisionAlgorithm::collide_gjk_triangles(const btCollisionObjectWrapper* body0Wrap,
314 const btCollisionObjectWrapper* body1Wrap,
315 const btGImpactMeshShapePart* shape0,
316 const btGImpactMeshShapePart* shape1,
317 const int* pairs, int pair_count)
318{
319 btTriangleShapeEx tri0;
320 btTriangleShapeEx tri1;
321
322 shape0->lockChildShapes();
323 shape1->lockChildShapes();
324
325 const int* pair_pointer = pairs;
326
327 while (pair_count--)
328 {
329 m_triface0 = *(pair_pointer);
330 m_triface1 = *(pair_pointer + 1);
331 pair_pointer += 2;
332
333 shape0->getBulletTriangle(m_triface0, tri0);
334 shape1->getBulletTriangle(m_triface1, tri1);
335
336 //collide two convex shapes
337 if (tri0.overlap_test_conservative(tri1))
338 {
339 convex_vs_convex_collision(body0Wrap, body1Wrap, &tri0, &tri1);
340 }
341 }
342
343 shape0->unlockChildShapes();
344 shape1->unlockChildShapes();
345}
346
347 void btGImpactCollisionAlgorithm::collide_sat_triangles(const btCollisionObjectWrapper* body0Wrap,
348 const btCollisionObjectWrapper* body1Wrap,
349 const btGImpactMeshShapePart* shape0,
350 const btGImpactMeshShapePart* shape1,
351 const int* pairs, int pair_count)
352{
353 btTransform orgtrans0 = body0Wrap->getWorldTransform();
354 btTransform orgtrans1 = body1Wrap->getWorldTransform();
355
356 btPrimitiveTriangle ptri0;
357 btPrimitiveTriangle ptri1;
358 GIM_TRIANGLE_CONTACT contact_data;
359
360 shape0->lockChildShapes();
361 shape1->lockChildShapes();
362
363 const int* pair_pointer = pairs;
364
365 while (pair_count--)
366 {
367 m_triface0 = *(pair_pointer);
368 m_triface1 = *(pair_pointer + 1);
369 pair_pointer += 2;
370
371 shape0->getPrimitiveTriangle(m_triface0, ptri0);
372 shape1->getPrimitiveTriangle(m_triface1, ptri1);
373
374#ifdef TRI_COLLISION_PROFILING
375 bt_begin_gim02_tri_time();
376#endif
377
378 ptri0.applyTransform(orgtrans0);
379 ptri1.applyTransform(orgtrans1);
380
381 //build planes
382 ptri0.buildTriPlane();
383 ptri1.buildTriPlane();
384 // test conservative
385
386 if (ptri0.overlap_test_conservative(ptri1))
387 {
388 if (ptri0.find_triangle_collision_clip_method(ptri1, contact_data))
389 {
390 int j = contact_data.m_point_count;
391 while (j--)
392 {
393 addContactPoint(body0Wrap, body1Wrap,
394 contact_data.m_points[j],
395 contact_data.m_separating_normal,
396 -contact_data.m_penetration_depth);
397 }
398 }
399 }
400
401#ifdef TRI_COLLISION_PROFILING
402 bt_end_gim02_tri_time();
403#endif
404 }
405
406 shape0->unlockChildShapes();
407 shape1->unlockChildShapes();
408}
409
410 void btGImpactCollisionAlgorithm::gimpact_vs_gimpact(
411 const btCollisionObjectWrapper* body0Wrap,
412 const btCollisionObjectWrapper* body1Wrap,
413 const btGImpactShapeInterface* shape0,
414 const btGImpactShapeInterface* shape1)
415{
416 if (shape0->getGImpactShapeType() == CONST_GIMPACT_TRIMESH_SHAPE)
417 {
418 const btGImpactMeshShape* meshshape0 = static_cast<const btGImpactMeshShape*>(shape0);
419 m_part0 = meshshape0->getMeshPartCount();
420
421 while (m_part0--)
422 {
423 gimpact_vs_gimpact(body0Wrap, body1Wrap, meshshape0->getMeshPart(m_part0), shape1);
424 }
425
426 return;
427 }
428
429 if (shape1->getGImpactShapeType() == CONST_GIMPACT_TRIMESH_SHAPE)
430 {
431 const btGImpactMeshShape* meshshape1 = static_cast<const btGImpactMeshShape*>(shape1);
432 m_part1 = meshshape1->getMeshPartCount();
433
434 while (m_part1--)
435 {
436 gimpact_vs_gimpact(body0Wrap, body1Wrap, shape0, meshshape1->getMeshPart(m_part1));
437 }
438
439 return;
440 }
441
442 btTransform orgtrans0 = body0Wrap->getWorldTransform();
443 btTransform orgtrans1 = body1Wrap->getWorldTransform();
444
445 btPairSet pairset;
446
447 gimpact_vs_gimpact_find_pairs(orgtrans0, orgtrans1, shape0, shape1, pairset);
448
449 if (pairset.size() == 0) return;
450
451 if (shape0->getGImpactShapeType() == CONST_GIMPACT_TRIMESH_SHAPE_PART &&
452 shape1->getGImpactShapeType() == CONST_GIMPACT_TRIMESH_SHAPE_PART)
453 {
454 const btGImpactMeshShapePart* shapepart0 = static_cast<const btGImpactMeshShapePart*>(shape0);
455 const btGImpactMeshShapePart* shapepart1 = static_cast<const btGImpactMeshShapePart*>(shape1);
456//specialized function
457#ifdef BULLET_TRIANGLE_COLLISION
458 collide_gjk_triangles(body0Wrap, body1Wrap, shapepart0, shapepart1, &pairset[0].m_index1, pairset.size());
459#else
460 collide_sat_triangles(body0Wrap, body1Wrap, shapepart0, shapepart1, &pairset[0].m_index1, pairset.size());
461#endif
462
463 return;
464 }
465
466 //general function
467
468 shape0->lockChildShapes();
469 shape1->lockChildShapes();
470
471 GIM_ShapeRetriever retriever0(shape0);
472 GIM_ShapeRetriever retriever1(shape1);
473
474 bool child_has_transform0 = shape0->childrenHasTransform();
475 bool child_has_transform1 = shape1->childrenHasTransform();
476
477 int i = pairset.size();
478 while (i--)
479 {
480 GIM_PAIR* pair = &pairset[i];
481 m_triface0 = pair->m_index1;
482 m_triface1 = pair->m_index2;
483 const btCollisionShape* colshape0 = retriever0.getChildShape(m_triface0);
484 const btCollisionShape* colshape1 = retriever1.getChildShape(m_triface1);
485
486 btTransform tr0 = body0Wrap->getWorldTransform();
487 btTransform tr1 = body1Wrap->getWorldTransform();
488
489 if (child_has_transform0)
490 {
491 tr0 = orgtrans0 * shape0->getChildTransform(m_triface0);
492 }
493
494 if (child_has_transform1)
495 {
496 tr1 = orgtrans1 * shape1->getChildTransform(m_triface1);
497 }
498
499 btCollisionObjectWrapper ob0(body0Wrap, colshape0, body0Wrap->getCollisionObject(), tr0, m_part0, m_triface0);
500 btCollisionObjectWrapper ob1(body1Wrap, colshape1, body1Wrap->getCollisionObject(), tr1, m_part1, m_triface1);
501
502 //collide two convex shapes
503 convex_vs_convex_collision(&ob0, &ob1, colshape0, colshape1);
504 }
505
506 shape0->unlockChildShapes();
507 shape1->unlockChildShapes();
508}
509
510 void btGImpactCollisionAlgorithm::gimpact_vs_shape(const btCollisionObjectWrapper* body0Wrap,
511 const btCollisionObjectWrapper* body1Wrap,
512 const btGImpactShapeInterface* shape0,
513 const btCollisionShape* shape1, bool swapped)
514{
515 if (shape0->getGImpactShapeType() == CONST_GIMPACT_TRIMESH_SHAPE)
516 {
517 const btGImpactMeshShape* meshshape0 = static_cast<const btGImpactMeshShape*>(shape0);
518 int& part = swapped ? m_part1 : m_part0;
519 part = meshshape0->getMeshPartCount();
520
521 while (part--)
522 {
523 gimpact_vs_shape(body0Wrap,
524 body1Wrap,
525 meshshape0->getMeshPart(part),
526 shape1, swapped);
527 }
528
529 return;
530 }
531
532#ifdef GIMPACT_VS_PLANE_COLLISION
533 if (shape0->getGImpactShapeType() == CONST_GIMPACT_TRIMESH_SHAPE_PART &&
534 shape1->getShapeType() == STATIC_PLANE_PROXYTYPE)
535 {
536 const btGImpactMeshShapePart* shapepart = static_cast<const btGImpactMeshShapePart*>(shape0);
537 const btStaticPlaneShape* planeshape = static_cast<const btStaticPlaneShape*>(shape1);
538 gimpacttrimeshpart_vs_plane_collision(body0Wrap, body1Wrap, shapepart, planeshape, swapped);
539 return;
540 }
541
542#endif
543
544 if (shape1->isCompound())
545 {
546 const btCompoundShape* compoundshape = static_cast<const btCompoundShape*>(shape1);
547 gimpact_vs_compoundshape(body0Wrap, body1Wrap, shape0, compoundshape, swapped);
548 return;
549 }
550 else if (shape1->isConcave())
551 {
552 const btConcaveShape* concaveshape = static_cast<const btConcaveShape*>(shape1);
553 gimpact_vs_concave(body0Wrap, body1Wrap, shape0, concaveshape, swapped);
554 return;
555 }
556
557 btTransform orgtrans0 = body0Wrap->getWorldTransform();
558
559 btTransform orgtrans1 = body1Wrap->getWorldTransform();
560
561 btAlignedObjectArray<int> collided_results;
562
563 gimpact_vs_shape_find_pairs(orgtrans0, orgtrans1, shape0, shape1, collided_results);
564
565 if (collided_results.size() == 0) return;
566
567 shape0->lockChildShapes();
568
569 GIM_ShapeRetriever retriever0(shape0);
570
571 bool child_has_transform0 = shape0->childrenHasTransform();
572
573 int i = collided_results.size();
574
575 while (i--)
576 {
577 int child_index = collided_results[i];
578 if (swapped)
579 m_triface1 = child_index;
580 else
581 m_triface0 = child_index;
582
583 const btCollisionShape* colshape0 = retriever0.getChildShape(child_index);
584
585 btTransform tr0 = body0Wrap->getWorldTransform();
586
587 if (child_has_transform0)
588 {
589 tr0 = orgtrans0 * shape0->getChildTransform(child_index);
590 }
591
592 btCollisionObjectWrapper ob0(body0Wrap, colshape0, body0Wrap->getCollisionObject(), body0Wrap->getWorldTransform(), m_part0, m_triface0);
593 const btCollisionObjectWrapper* prevObj;
594
595 if (m_resultOut->getBody0Wrap()->getCollisionObject() == ob0.getCollisionObject())
596 {
597 prevObj = m_resultOut->getBody0Wrap();
598 m_resultOut->setBody0Wrap(&ob0);
599 }
600 else
601 {
602 prevObj = m_resultOut->getBody1Wrap();
603 m_resultOut->setBody1Wrap(&ob0);
604 }
605
606 //collide two shapes
607 if (swapped)
608 {
609 shape_vs_shape_collision(body1Wrap, &ob0, shape1, colshape0);
610 }
611 else
612 {
613 shape_vs_shape_collision(&ob0, body1Wrap, colshape0, shape1);
614 }
615
616 if (m_resultOut->getBody0Wrap()->getCollisionObject() == ob0.getCollisionObject())
617 {
618 m_resultOut->setBody0Wrap(prevObj);
619 }
620 else
621 {
622 m_resultOut->setBody1Wrap(prevObj);
623 }
624 }
625
626 shape0->unlockChildShapes();
627}
628
629 void btGImpactCollisionAlgorithm::gimpact_vs_compoundshape(const btCollisionObjectWrapper* body0Wrap,
630 const btCollisionObjectWrapper* body1Wrap,
631 const btGImpactShapeInterface* shape0,
632 const btCompoundShape* shape1, bool swapped)
633{
634 btTransform orgtrans1 = body1Wrap->getWorldTransform();
635
636 int i = shape1->getNumChildShapes();
637 while (i--)
638 {
639 const btCollisionShape* colshape1 = shape1->getChildShape(i);
640 btTransform childtrans1 = orgtrans1 * shape1->getChildTransform(i);
641
642 btCollisionObjectWrapper ob1(body1Wrap, colshape1, body1Wrap->getCollisionObject(), childtrans1, -1, i);
643
644 const btCollisionObjectWrapper* tmp = 0;
645 if (m_resultOut->getBody0Wrap()->getCollisionObject() == ob1.getCollisionObject())
646 {
647 tmp = m_resultOut->getBody0Wrap();
648 m_resultOut->setBody0Wrap(&ob1);
649 }
650 else
651 {
652 tmp = m_resultOut->getBody1Wrap();
653 m_resultOut->setBody1Wrap(&ob1);
654 }
655 //collide child shape
656 gimpact_vs_shape(body0Wrap, &ob1,
657 shape0, colshape1, swapped);
658
659 if (m_resultOut->getBody0Wrap()->getCollisionObject() == ob1.getCollisionObject())
660 {
661 m_resultOut->setBody0Wrap(tmp);
662 }
663 else
664 {
665 m_resultOut->setBody1Wrap(tmp);
666 }
667 }
668}
669
670 void btGImpactCollisionAlgorithm::gimpacttrimeshpart_vs_plane_collision(
671 const btCollisionObjectWrapper* body0Wrap,
672 const btCollisionObjectWrapper* body1Wrap,
673 const btGImpactMeshShapePart* shape0,
674 const btStaticPlaneShape* shape1, bool swapped)
675{
676 btTransform orgtrans0 = body0Wrap->getWorldTransform();
677 btTransform orgtrans1 = body1Wrap->getWorldTransform();
678
679 const btPlaneShape* planeshape = static_cast<const btPlaneShape*>(shape1);
680 btVector4 plane;
681 planeshape->get_plane_equation_transformed(orgtrans1, plane);
682
683 //test box against plane
684
685 btAABB tribox;
686 shape0->getAabb(orgtrans0, tribox.m_min, tribox.m_max);
687 tribox.increment_margin(planeshape->getMargin());
688
689 if (tribox.plane_classify(plane) != BT_CONST_COLLIDE_PLANE) return;
690
691 shape0->lockChildShapes();
692
693 btScalar margin = shape0->getMargin() + planeshape->getMargin();
694
695 btVector3 vertex;
696 int vi = shape0->getVertexCount();
697 while (vi--)
698 {
699 shape0->getVertex(vi, vertex);
700 vertex = orgtrans0(vertex);
701
702 btScalar distance = vertex.dot(plane) - plane[3] - margin;
703
704 if (distance < 0.0) //add contact
705 {
706 if (swapped)
707 {
708 addContactPoint(body1Wrap, body0Wrap,
709 vertex,
710 -plane,
711 distance);
712 }
713 else
714 {
715 addContactPoint(body0Wrap, body1Wrap,
716 vertex,
717 plane,
718 distance);
719 }
720 }
721 }
722
723 shape0->unlockChildShapes();
724}
725
726 class btGImpactTriangleCallback : public btTriangleCallback
727{
728public:
729 btGImpactCollisionAlgorithm* algorithm;
730 const btCollisionObjectWrapper* body0Wrap;
731 const btCollisionObjectWrapper* body1Wrap;
732 const btGImpactShapeInterface* gimpactshape0;
733 bool swapped;
734 btScalar margin;
735
736 virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex)
737 {
738 btTriangleShapeEx tri1(triangle[0], triangle[1], triangle[2]);
739 tri1.setMargin(margin);
740 if (swapped)
741 {
742 algorithm->setPart0(partId);
743 algorithm->setFace0(triangleIndex);
744 }
745 else
746 {
747 algorithm->setPart1(partId);
748 algorithm->setFace1(triangleIndex);
749 }
750
751 btCollisionObjectWrapper ob1Wrap(body1Wrap, &tri1, body1Wrap->getCollisionObject(), body1Wrap->getWorldTransform(), partId, triangleIndex);
752 const btCollisionObjectWrapper* tmp = 0;
753
754 if (algorithm->internalGetResultOut()->getBody0Wrap()->getCollisionObject() == ob1Wrap.getCollisionObject())
755 {
756 tmp = algorithm->internalGetResultOut()->getBody0Wrap();
757 algorithm->internalGetResultOut()->setBody0Wrap(&ob1Wrap);
758 }
759 else
760 {
761 tmp = algorithm->internalGetResultOut()->getBody1Wrap();
762 algorithm->internalGetResultOut()->setBody1Wrap(&ob1Wrap);
763 }
764
765 algorithm->gimpact_vs_shape(
766 body0Wrap, &ob1Wrap, gimpactshape0, &tri1, swapped);
767
768 if (algorithm->internalGetResultOut()->getBody0Wrap()->getCollisionObject() == ob1Wrap.getCollisionObject())
769 {
770 algorithm->internalGetResultOut()->setBody0Wrap(tmp);
771 }
772 else
773 {
774 algorithm->internalGetResultOut()->setBody1Wrap(tmp);
775 }
776 }
777};
778
779 void btGImpactCollisionAlgorithm::gimpact_vs_concave(
780 const btCollisionObjectWrapper* body0Wrap,
781 const btCollisionObjectWrapper* body1Wrap,
782 const btGImpactShapeInterface* shape0,
783 const btConcaveShape* shape1, bool swapped)
784{
785 //create the callback
786 btGImpactTriangleCallback tricallback;
787 tricallback.algorithm = this;
788 tricallback.body0Wrap = body0Wrap;
789 tricallback.body1Wrap = body1Wrap;
790 tricallback.gimpactshape0 = shape0;
791 tricallback.swapped = swapped;
792 tricallback.margin = shape1->getMargin();
793
794 //getting the trimesh AABB
795 btTransform gimpactInConcaveSpace;
796
797 gimpactInConcaveSpace = body1Wrap->getWorldTransform().inverse() * body0Wrap->getWorldTransform();
798
799 btVector3 minAABB, maxAABB;
800 shape0->getAabb(gimpactInConcaveSpace, minAABB, maxAABB);
801
802 shape1->processAllTriangles(&tricallback, minAABB, maxAABB);
803}
804
805 void btGImpactCollisionAlgorithm::processCollision(const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap, const btDispatcherInfo& dispatchInfo, btManifoldResult* resultOut)
806{
807 clearCache();
808
809 m_resultOut = resultOut;
810 m_dispatchInfo = &dispatchInfo;
811 const btGImpactShapeInterface* gimpactshape0;
812 const btGImpactShapeInterface* gimpactshape1;
813
814 if (body0Wrap->getCollisionShape()->getShapeType() == GIMPACT_SHAPE_PROXYTYPE)
815 {
816 gimpactshape0 = static_cast<const btGImpactShapeInterface*>(body0Wrap->getCollisionShape());
817
818 if (body1Wrap->getCollisionShape()->getShapeType() == GIMPACT_SHAPE_PROXYTYPE)
819 {
820 gimpactshape1 = static_cast<const btGImpactShapeInterface*>(body1Wrap->getCollisionShape());
821
822 gimpact_vs_gimpact(body0Wrap, body1Wrap, gimpactshape0, gimpactshape1);
823 }
824 else
825 {
826 gimpact_vs_shape(body0Wrap, body1Wrap, gimpactshape0, body1Wrap->getCollisionShape(), false);
827 }
828 }
829 else if (body1Wrap->getCollisionShape()->getShapeType() == GIMPACT_SHAPE_PROXYTYPE)
830 {
831 gimpactshape1 = static_cast<const btGImpactShapeInterface*>(body1Wrap->getCollisionShape());
832
833 gimpact_vs_shape(body1Wrap, body0Wrap, gimpactshape1, body0Wrap->getCollisionShape(), true);
834 }
835
836 // Ensure that gContactProcessedCallback is called for concave shapes.
837 if (getLastManifold())
838 {
839 m_resultOut->refreshContactPoints();
840 }
841}
842
843 btScalar btGImpactCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0, btCollisionObject* body1, const btDispatcherInfo& dispatchInfo, btManifoldResult* resultOut)
844{
845 return 1.f;
846}
847
849
851 void btGImpactCollisionAlgorithm::registerAlgorithm(btCollisionDispatcher* dispatcher)
852{
853 static btGImpactCollisionAlgorithm::CreateFunc s_gimpact_cf;
854
855 int i;
856
857 for (i = 0; i < MAX_BROADPHASE_COLLISION_TYPES; i++)
858 {
859 dispatcher->registerCollisionCreateFunc(GIMPACT_SHAPE_PROXYTYPE, i, &s_gimpact_cf);
860 }
861
862 for (i = 0; i < MAX_BROADPHASE_COLLISION_TYPES; i++)
863 {
864 dispatcher->registerCollisionCreateFunc(i, GIMPACT_SHAPE_PROXYTYPE, &s_gimpact_cf);
865 }
866}
BT_CONST_COLLIDE_PLANE
@ BT_CONST_COLLIDE_PLANE
Definition: btBoxCollision.h:48
btBoxShape.h
GIMPACT_SHAPE_PROXYTYPE
@ GIMPACT_SHAPE_PROXYTYPE
Used for GIMPACT Trimesh integration.
Definition: btBroadphaseProxy.h:61
STATIC_PLANE_PROXYTYPE
@ STATIC_PLANE_PROXYTYPE
Definition: btBroadphaseProxy.h:66
MAX_BROADPHASE_COLLISION_TYPES
@ MAX_BROADPHASE_COLLISION_TYPES
Definition: btBroadphaseProxy.h:78
btCollisionObject.h
btContactProcessing.h
btGImpactCollisionAlgorithm.h
CONST_GIMPACT_TRIMESH_SHAPE
@ CONST_GIMPACT_TRIMESH_SHAPE
Definition: btGImpactShape.h:48
CONST_GIMPACT_TRIMESH_SHAPE_PART
@ CONST_GIMPACT_TRIMESH_SHAPE_PART
Definition: btGImpactShape.h:47
btIDebugDraw.h
btManifoldResult.h
btQuickprof.h
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
GIM_ShapeRetriever::ChildShapeRetriever
Definition: btGImpactCollisionAlgorithm.cpp:94
GIM_ShapeRetriever::ChildShapeRetriever::getChildShape
virtual const btCollisionShape * getChildShape(int index)
Definition: btGImpactCollisionAlgorithm.cpp:97
GIM_ShapeRetriever::ChildShapeRetriever::m_parent
GIM_ShapeRetriever * m_parent
Definition: btGImpactCollisionAlgorithm.cpp:96
GIM_ShapeRetriever::ChildShapeRetriever::~ChildShapeRetriever
virtual ~ChildShapeRetriever()
Definition: btGImpactCollisionAlgorithm.cpp:101
GIM_ShapeRetriever::TetraShapeRetriever
Definition: btGImpactCollisionAlgorithm.cpp:116
GIM_ShapeRetriever::TetraShapeRetriever::getChildShape
virtual btCollisionShape * getChildShape(int index)
Definition: btGImpactCollisionAlgorithm.cpp:118
GIM_ShapeRetriever::TriangleShapeRetriever
Definition: btGImpactCollisionAlgorithm.cpp:105
GIM_ShapeRetriever::TriangleShapeRetriever::~TriangleShapeRetriever
virtual ~TriangleShapeRetriever()
Definition: btGImpactCollisionAlgorithm.cpp:112
GIM_ShapeRetriever::TriangleShapeRetriever::getChildShape
virtual btCollisionShape * getChildShape(int index)
Definition: btGImpactCollisionAlgorithm.cpp:107
GIM_ShapeRetriever
Retrieving shapes shapes.
Definition: btGImpactCollisionAlgorithm.cpp:86
GIM_ShapeRetriever::m_tetra_retriever
TetraShapeRetriever m_tetra_retriever
Definition: btGImpactCollisionAlgorithm.cpp:128
GIM_ShapeRetriever::GIM_ShapeRetriever
GIM_ShapeRetriever(const btGImpactShapeInterface *gim_shape)
Definition: btGImpactCollisionAlgorithm.cpp:131
GIM_ShapeRetriever::m_current_retriever
ChildShapeRetriever * m_current_retriever
Definition: btGImpactCollisionAlgorithm.cpp:129
GIM_ShapeRetriever::getChildShape
const btCollisionShape * getChildShape(int index)
Definition: btGImpactCollisionAlgorithm.cpp:151
GIM_ShapeRetriever::m_tetrashape
btTetrahedronShapeEx m_tetrashape
Definition: btGImpactCollisionAlgorithm.cpp:90
GIM_ShapeRetriever::m_trishape
btTriangleShapeEx m_trishape
Definition: btGImpactCollisionAlgorithm.cpp:89
GIM_ShapeRetriever::m_tri_retriever
TriangleShapeRetriever m_tri_retriever
Definition: btGImpactCollisionAlgorithm.cpp:127
GIM_ShapeRetriever::m_gim_shape
const btGImpactShapeInterface * m_gim_shape
Definition: btGImpactCollisionAlgorithm.cpp:88
GIM_ShapeRetriever::m_child_retriever
ChildShapeRetriever m_child_retriever
Definition: btGImpactCollisionAlgorithm.cpp:126
btAABB
Axis aligned box.
Definition: btBoxCollision.h:216
btAABB::plane_classify
eBT_PLANE_INTERSECTION_TYPE plane_classify(const btVector4 &plane) const
Definition: btBoxCollision.h:481
btAABB::increment_margin
void increment_margin(btScalar margin)
Definition: btBoxCollision.h:289
btAABB::m_min
btVector3 m_min
Definition: btBoxCollision.h:218
btAABB::m_max
btVector3 m_max
Definition: btBoxCollision.h:219
btAABB::has_collision
bool has_collision(const btAABB &other) const
Definition: btBoxCollision.h:429
btActivatingCollisionAlgorithm
This class is not enabled yet (work-in-progress) to more aggressively activate objects.
Definition: btActivatingCollisionAlgorithm.h:23
btAlignedObjectArray
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
Definition: btAlignedObjectArray.h:46
btAlignedObjectArray::size
int size() const
return the number of elements in the array
Definition: btAlignedObjectArray.h:142
btAlignedObjectArray::push_back
void push_back(const T &_Val)
Definition: btAlignedObjectArray.h:257
btClock
The btClock is a portable basic clock that measures accurate time in seconds, use for profiling.
Definition: btQuickprof.h:23
btClock::reset
void reset()
Resets the initial reference time.
Definition: btQuickprof.cpp:112
btClock::getTimeMicroseconds
unsigned long long int getTimeMicroseconds()
Returns the time in us since the last call to reset or since the Clock was created.
Definition: btQuickprof.cpp:171
btCollisionAlgorithm
btCollisionAlgorithm is an collision interface that is compatible with the Broadphase and btDispatche...
Definition: btCollisionAlgorithm.h:54
btCollisionAlgorithm::m_dispatcher
btDispatcher * m_dispatcher
Definition: btCollisionAlgorithm.h:56
btCollisionAlgorithm::processCollision
virtual void processCollision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)=0
btCollisionAlgorithm::~btCollisionAlgorithm
virtual ~btCollisionAlgorithm()
Definition: btCollisionAlgorithm.h:66
btCollisionDispatcher
btCollisionDispatcher supports algorithms that handle ConvexConvex and ConvexConcave collision pairs.
Definition: btCollisionDispatcher.h:43
btCollisionDispatcher::registerCollisionCreateFunc
void registerCollisionCreateFunc(int proxyType0, int proxyType1, btCollisionAlgorithmCreateFunc *createFunc)
registerCollisionCreateFunc allows registration of custom/alternative collision create functions
Definition: btCollisionDispatcher.cpp:54
btCollisionObject
btCollisionObject can be used to manage collision detection objects.
Definition: btCollisionObject.h:51
btCollisionShape
The btCollisionShape class provides an interface for collision shapes that can be shared among btColl...
Definition: btCollisionShape.h:28
btCollisionShape::isCompound
bool isCompound() const
Definition: btCollisionShape.h:82
btCollisionShape::getShapeType
int getShapeType() const
Definition: btCollisionShape.h:107
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.
btCollisionShape::isConcave
bool isConcave() const
Definition: btCollisionShape.h:78
btCompoundShape
The btCompoundShape allows to store multiple other btCollisionShapes This allows for moving concave c...
Definition: btCompoundShape.h:57
btCompoundShape::getChildShape
btCollisionShape * getChildShape(int index)
Definition: btCompoundShape.h:91
btCompoundShape::getChildTransform
btTransform & getChildTransform(int index)
Definition: btCompoundShape.h:100
btCompoundShape::getNumChildShapes
int getNumChildShapes() const
Definition: btCompoundShape.h:86
btConcaveShape
The btConcaveShape class provides an interface for non-moving (static) concave shapes.
Definition: btConcaveShape.h:39
btConcaveShape::getMargin
virtual btScalar getMargin() const
Definition: btConcaveShape.h:52
btConcaveShape::processAllTriangles
virtual void processAllTriangles(btTriangleCallback *callback, const btVector3 &aabbMin, const btVector3 &aabbMax) const =0
btConvexInternalShape::setMargin
virtual void setMargin(btScalar margin)
Definition: btConvexInternalShape.h:102
btDispatcher::freeCollisionAlgorithm
virtual void freeCollisionAlgorithm(void *ptr)=0
btGImpactCollisionAlgorithm
Collision Algorithm for GImpact Shapes.
Definition: btGImpactCollisionAlgorithm.h:54
btGImpactCollisionAlgorithm::getLastManifold
btPersistentManifold * getLastManifold()
Definition: btGImpactCollisionAlgorithm.h:100
btGImpactCollisionAlgorithm::gimpact_vs_concave
void gimpact_vs_concave(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btGImpactShapeInterface *shape0, const btConcaveShape *shape1, bool swapped)
Definition: btGImpactCollisionAlgorithm.cpp:779
btGImpactCollisionAlgorithm::gimpact_vs_shape_find_pairs
void gimpact_vs_shape_find_pairs(const btTransform &trans0, const btTransform &trans1, const btGImpactShapeInterface *shape0, const btCollisionShape *shape1, btAlignedObjectArray< int > &collided_primitives)
Definition: btGImpactCollisionAlgorithm.cpp:276
btGImpactCollisionAlgorithm::setFace0
void setFace0(int value)
Accessor/Mutator pairs for Part and triangleID.
Definition: btGImpactCollisionAlgorithm.h:250
btGImpactCollisionAlgorithm::newAlgorithm
btCollisionAlgorithm * newAlgorithm(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap)
Definition: btGImpactCollisionAlgorithm.h:117
btGImpactCollisionAlgorithm::collide_gjk_triangles
void collide_gjk_triangles(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btGImpactMeshShapePart *shape0, const btGImpactMeshShapePart *shape1, const int *pairs, int pair_count)
Collision routines.
Definition: btGImpactCollisionAlgorithm.cpp:313
btGImpactCollisionAlgorithm::m_convex_algorithm
btCollisionAlgorithm * m_convex_algorithm
Definition: btGImpactCollisionAlgorithm.h:56
btGImpactCollisionAlgorithm::m_dispatchInfo
const btDispatcherInfo * m_dispatchInfo
Definition: btGImpactCollisionAlgorithm.h:59
btGImpactCollisionAlgorithm::checkConvexAlgorithm
void checkConvexAlgorithm(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap)
Definition: btGImpactCollisionAlgorithm.h:127
btGImpactCollisionAlgorithm::gimpact_vs_gimpact
void gimpact_vs_gimpact(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btGImpactShapeInterface *shape0, const btGImpactShapeInterface *shape1)
Collides two gimpact shapes.
Definition: btGImpactCollisionAlgorithm.cpp:410
btGImpactCollisionAlgorithm::gimpact_vs_compoundshape
void gimpact_vs_compoundshape(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btGImpactShapeInterface *shape0, const btCompoundShape *shape1, bool swapped)
Definition: btGImpactCollisionAlgorithm.cpp:629
btGImpactCollisionAlgorithm::internalGetResultOut
btManifoldResult * internalGetResultOut()
Definition: btGImpactCollisionAlgorithm.h:199
btGImpactCollisionAlgorithm::calculateTimeOfImpact
btScalar calculateTimeOfImpact(btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
Definition: btGImpactCollisionAlgorithm.cpp:843
btGImpactCollisionAlgorithm::gimpact_vs_gimpact_find_pairs
void gimpact_vs_gimpact_find_pairs(const btTransform &trans0, const btTransform &trans1, const btGImpactShapeInterface *shape0, const btGImpactShapeInterface *shape1, btPairSet &pairset)
Definition: btGImpactCollisionAlgorithm.cpp:242
btGImpactCollisionAlgorithm::btGImpactCollisionAlgorithm
btGImpactCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap)
Definition: btGImpactCollisionAlgorithm.cpp:183
btGImpactCollisionAlgorithm::gimpacttrimeshpart_vs_plane_collision
void gimpacttrimeshpart_vs_plane_collision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btGImpactMeshShapePart *shape0, const btStaticPlaneShape *shape1, bool swapped)
Definition: btGImpactCollisionAlgorithm.cpp:670
btGImpactCollisionAlgorithm::gimpact_vs_shape
void gimpact_vs_shape(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btGImpactShapeInterface *shape0, const btCollisionShape *shape1, bool swapped)
Definition: btGImpactCollisionAlgorithm.cpp:510
btGImpactCollisionAlgorithm::m_part0
int m_part0
Definition: btGImpactCollisionAlgorithm.h:61
btGImpactCollisionAlgorithm::m_manifoldPtr
btPersistentManifold * m_manifoldPtr
Definition: btGImpactCollisionAlgorithm.h:57
btGImpactCollisionAlgorithm::~btGImpactCollisionAlgorithm
virtual ~btGImpactCollisionAlgorithm()
Definition: btGImpactCollisionAlgorithm.cpp:190
btGImpactCollisionAlgorithm::m_triface1
int m_triface1
Definition: btGImpactCollisionAlgorithm.h:62
btGImpactCollisionAlgorithm::m_part1
int m_part1
Definition: btGImpactCollisionAlgorithm.h:63
btGImpactCollisionAlgorithm::m_resultOut
btManifoldResult * m_resultOut
Definition: btGImpactCollisionAlgorithm.h:58
btGImpactCollisionAlgorithm::convex_vs_convex_collision
void convex_vs_convex_collision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btCollisionShape *shape0, const btCollisionShape *shape1)
Definition: btGImpactCollisionAlgorithm.cpp:227
btGImpactCollisionAlgorithm::setPart1
void setPart1(int value)
Definition: btGImpactCollisionAlgorithm.h:274
btGImpactCollisionAlgorithm::checkManifold
void checkManifold(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap)
Definition: btGImpactCollisionAlgorithm.h:106
btGImpactCollisionAlgorithm::registerAlgorithm
static void registerAlgorithm(btCollisionDispatcher *dispatcher)
Use this function for register the algorithm externally.
Definition: btGImpactCollisionAlgorithm.cpp:851
btGImpactCollisionAlgorithm::clearCache
void clearCache()
Definition: btGImpactCollisionAlgorithm.h:89
btGImpactCollisionAlgorithm::setPart0
void setPart0(int value)
Definition: btGImpactCollisionAlgorithm.h:266
btGImpactCollisionAlgorithm::collide_sat_triangles
void collide_sat_triangles(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btGImpactMeshShapePart *shape0, const btGImpactMeshShapePart *shape1, const int *pairs, int pair_count)
Definition: btGImpactCollisionAlgorithm.cpp:347
btGImpactCollisionAlgorithm::setFace1
void setFace1(int value)
Definition: btGImpactCollisionAlgorithm.h:258
btGImpactCollisionAlgorithm::processCollision
virtual void processCollision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
Definition: btGImpactCollisionAlgorithm.cpp:805
btGImpactCollisionAlgorithm::shape_vs_shape_collision
void shape_vs_shape_collision(const btCollisionObjectWrapper *body0, const btCollisionObjectWrapper *body1, const btCollisionShape *shape0, const btCollisionShape *shape1)
Definition: btGImpactCollisionAlgorithm.cpp:207
btGImpactCollisionAlgorithm::addContactPoint
void addContactPoint(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btVector3 &point, const btVector3 &normal, btScalar distance)
Definition: btGImpactCollisionAlgorithm.cpp:195
btGImpactCollisionAlgorithm::m_triface0
int m_triface0
Definition: btGImpactCollisionAlgorithm.h:60
btGImpactMeshShapePart
This class manages a sub part of a mesh supplied by the btStridingMeshInterface interface.
Definition: btGImpactShape.h:503
btGImpactMeshShapePart::getBulletTriangle
virtual void getBulletTriangle(int prim_index, btTriangleShapeEx &triangle) const
Definition: btGImpactShape.h:789
btGImpactMeshShapePart::getMargin
btScalar getMargin() const
Definition: btGImpactShape.h:817
btGImpactMeshShapePart::getVertex
void getVertex(int vertex_index, btVector3 &vertex) const
Definition: btGImpactShape.h:806
btGImpactMeshShapePart::getVertexCount
int getVertexCount() const
Definition: btGImpactShape.h:801
btGImpactMeshShapePart::lockChildShapes
virtual void lockChildShapes() const
call when reading child shapes
Definition: btGImpactShape.cpp:54
btGImpactMeshShapePart::unlockChildShapes
virtual void unlockChildShapes() const
Definition: btGImpactShape.cpp:65
btGImpactMeshShape
This class manages a mesh supplied by the btStridingMeshInterface interface.
Definition: btGImpactShape.h:851
btGImpactMeshShape::getMeshPartCount
int getMeshPartCount() const
Definition: btGImpactShape.h:905
btGImpactMeshShape::getMeshPart
btGImpactMeshShapePart * getMeshPart(int index)
Definition: btGImpactShape.h:910
btGImpactQuantizedBvh::boxQuery
bool boxQuery(const btAABB &box, btAlignedObjectArray< int > &collided_results) const
returns the indices of the primitives in the m_primitive_manager
Definition: btGImpactQuantizedBvh.cpp:286
btGImpactQuantizedBvh::find_collision
static void find_collision(const btGImpactQuantizedBvh *boxset1, const btTransform &trans1, const btGImpactQuantizedBvh *boxset2, const btTransform &trans2, btPairSet &collision_pairs)
Definition: btGImpactQuantizedBvh.cpp:466
btGImpactShapeInterface
Base class for gimpact shapes.
Definition: btGImpactShape.h:74
btGImpactShapeInterface::getAabb
void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
If the Bounding box is not updated, then this class attemps to calculate it.
Definition: btGImpactShape.h:126
btGImpactShapeInterface::getChildShape
virtual btCollisionShape * getChildShape(int index)=0
Gets the children.
btGImpactShapeInterface::getBoxSet
const btGImpactBoxSet * getBoxSet() const
gets boxset
Definition: btGImpactShape.h:185
btGImpactShapeInterface::getChildAabb
virtual void getChildAabb(int child_index, const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
Retrieves the bound from a child.
Definition: btGImpactShape.h:234
btGImpactShapeInterface::getPrimitiveTriangle
void getPrimitiveTriangle(int index, btPrimitiveTriangle &triangle) const
if this trimesh
Definition: btGImpactShape.h:226
btGImpactShapeInterface::hasBoxSet
bool hasBoxSet() const
Determines if this class has a hierarchy structure for sorting its primitives.
Definition: btGImpactShape.h:191
btGImpactShapeInterface::getGImpactShapeType
virtual eGIMPACT_SHAPE_TYPE getGImpactShapeType() const =0
Subshape member functions.
btGImpactShapeInterface::lockChildShapes
virtual void lockChildShapes() const
call when reading child shapes
Definition: btGImpactShape.h:217
btGImpactShapeInterface::needsRetrieveTriangles
virtual bool needsRetrieveTriangles() const =0
Determines if this shape has triangles.
btGImpactShapeInterface::getBulletTetrahedron
virtual void getBulletTetrahedron(int prim_index, btTetrahedronShapeEx &tetrahedron) const =0
btGImpactShapeInterface::getBulletTriangle
virtual void getBulletTriangle(int prim_index, btTriangleShapeEx &triangle) const =0
btGImpactShapeInterface::childrenHasTransform
virtual bool childrenHasTransform() const =0
if true, then its children must get transforms.
btGImpactShapeInterface::getNumChildShapes
virtual int getNumChildShapes() const =0
Gets the number of children.
btGImpactShapeInterface::getChildTransform
virtual btTransform getChildTransform(int index) const =0
Gets the children transform.
btGImpactShapeInterface::needsRetrieveTetrahedrons
virtual bool needsRetrieveTetrahedrons() const =0
Determines if this shape has tetrahedrons.
btGImpactShapeInterface::unlockChildShapes
virtual void unlockChildShapes() const
Definition: btGImpactShape.h:221
btGImpactTriangleCallback
Definition: btGImpactCollisionAlgorithm.cpp:727
btGImpactTriangleCallback::body1Wrap
const btCollisionObjectWrapper * body1Wrap
Definition: btGImpactCollisionAlgorithm.cpp:731
btGImpactTriangleCallback::processTriangle
virtual void processTriangle(btVector3 *triangle, int partId, int triangleIndex)
Definition: btGImpactCollisionAlgorithm.cpp:736
btGImpactTriangleCallback::algorithm
btGImpactCollisionAlgorithm * algorithm
Definition: btGImpactCollisionAlgorithm.cpp:729
btGImpactTriangleCallback::margin
btScalar margin
Definition: btGImpactCollisionAlgorithm.cpp:734
btGImpactTriangleCallback::gimpactshape0
const btGImpactShapeInterface * gimpactshape0
Definition: btGImpactCollisionAlgorithm.cpp:732
btGImpactTriangleCallback::swapped
bool swapped
Definition: btGImpactCollisionAlgorithm.cpp:733
btGImpactTriangleCallback::body0Wrap
const btCollisionObjectWrapper * body0Wrap
Definition: btGImpactCollisionAlgorithm.cpp:730
btManifoldResult
btManifoldResult is a helper class to manage contact results.
Definition: btManifoldResult.h:48
btManifoldResult::setShapeIdentifiersA
virtual void setShapeIdentifiersA(int partId0, int index0)
setShapeIdentifiersA/B provides experimental support for per-triangle material / custom material comb...
Definition: btManifoldResult.h:91
btManifoldResult::setBody0Wrap
void setBody0Wrap(const btCollisionObjectWrapper *obj0Wrap)
Definition: btManifoldResult.h:132
btManifoldResult::getBody1Wrap
const btCollisionObjectWrapper * getBody1Wrap() const
Definition: btManifoldResult.h:127
btManifoldResult::setBody1Wrap
void setBody1Wrap(const btCollisionObjectWrapper *obj1Wrap)
Definition: btManifoldResult.h:137
btManifoldResult::setShapeIdentifiersB
virtual void setShapeIdentifiersB(int partId1, int index1)
Definition: btManifoldResult.h:97
btManifoldResult::refreshContactPoints
void refreshContactPoints()
Definition: btManifoldResult.h:105
btManifoldResult::getBody0Wrap
const btCollisionObjectWrapper * getBody0Wrap() const
Definition: btManifoldResult.h:123
btManifoldResult::addContactPoint
virtual void addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorld, btScalar depth)
Definition: btManifoldResult.cpp:103
btPairSet
A pairset array.
Definition: btGImpactBvh.h:35
btPairSet::push_pair
void push_pair(int index1, int index2)
Definition: btGImpactBvh.h:41
btPlaneShape
Class for accessing the plane equation.
Definition: btGImpactCollisionAlgorithm.cpp:36
btPlaneShape::get_plane_equation_transformed
void get_plane_equation_transformed(const btTransform &trans, btVector4 &equation) const
Definition: btGImpactCollisionAlgorithm.cpp:51
btPlaneShape::get_plane_equation
void get_plane_equation(btVector4 &equation)
Definition: btGImpactCollisionAlgorithm.cpp:43
btPlaneShape::btPlaneShape
btPlaneShape(const btVector3 &v, float f)
Definition: btGImpactCollisionAlgorithm.cpp:38
btPrimitiveTriangle
Definition: btTriangleShapeEx.h:70
btPrimitiveTriangle::find_triangle_collision_clip_method
bool find_triangle_collision_clip_method(btPrimitiveTriangle &other, GIM_TRIANGLE_CONTACT &contacts)
Find collision using the clipping method.
Definition: btTriangleShapeEx.cpp:120
btPrimitiveTriangle::buildTriPlane
void buildTriPlane()
Definition: btTriangleShapeEx.h:80
btPrimitiveTriangle::overlap_test_conservative
bool overlap_test_conservative(const btPrimitiveTriangle &other)
Test if triangles could collide.
Definition: btTriangleShapeEx.cpp:63
btPrimitiveTriangle::applyTransform
void applyTransform(const btTransform &t)
Definition: btTriangleShapeEx.h:101
btStaticPlaneShape
The btStaticPlaneShape simulates an infinite non-moving (static) collision plane.
Definition: btStaticPlaneShape.h:24
btStaticPlaneShape::m_planeNormal
btVector3 m_planeNormal
Definition: btStaticPlaneShape.h:29
btStaticPlaneShape::m_planeConstant
btScalar m_planeConstant
Definition: btStaticPlaneShape.h:30
btTetrahedronShapeEx
Helper class for tetrahedrons.
Definition: btGImpactShape.h:53
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:30
btTransform::inverse
btTransform inverse() const
Return the inverse of this transform.
Definition: btTransform.h:183
btTransform::getBasis
btMatrix3x3 & getBasis()
Return the basis matrix for the rotation.
Definition: btTransform.h:109
btTriangleCallback
The btTriangleCallback provides a callback for each overlapping triangle when calling processAllTrian...
Definition: btTriangleCallback.h:24
btTriangleShapeEx
Helper class for colliding Bullet Triangle Shapes.
Definition: btTriangleShapeEx.h:127
btTriangleShapeEx::overlap_test_conservative
bool overlap_test_conservative(const btTriangleShapeEx &other)
class btTriangleShapeEx: public btTriangleShape
Definition: btTriangleShapeEx.cpp:175
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:82
btVector3::dot
btScalar dot(const btVector3 &v) const
Return the dot product.
Definition: btVector3.h:229
btVector4
Definition: btVector3.h:1074
GIM_PAIR
Overlapping pair.
Definition: gim_pair.h:7
GIM_PAIR::m_index1
int m_index1
Definition: gim_pair.h:8
GIM_PAIR::m_index2
int m_index2
Definition: gim_pair.h:9
GIM_TRIANGLE_CONTACT
Structure for collision.
Definition: btTriangleShapeEx.h:37
GIM_TRIANGLE_CONTACT::m_points
btVector3 m_points[MAX_TRI_CLIPPING]
Definition: btTriangleShapeEx.h:41
GIM_TRIANGLE_CONTACT::m_penetration_depth
btScalar m_penetration_depth
Definition: btTriangleShapeEx.h:38
GIM_TRIANGLE_CONTACT::m_separating_normal
btVector4 m_separating_normal
Definition: btTriangleShapeEx.h:40
GIM_TRIANGLE_CONTACT::m_point_count
int m_point_count
Definition: btTriangleShapeEx.h:39
btCollisionAlgorithmConstructionInfo
Definition: btCollisionAlgorithm.h:33
btCollisionObjectWrapper
Definition: btCollisionObjectWrapper.h:18
btCollisionObjectWrapper::getCollisionShape
const btCollisionShape * getCollisionShape() const
Definition: btCollisionObjectWrapper.h:46
btCollisionObjectWrapper::getCollisionObject
const btCollisionObject * getCollisionObject() const
Definition: btCollisionObjectWrapper.h:45
btCollisionObjectWrapper::getWorldTransform
const btTransform & getWorldTransform() const
Definition: btCollisionObjectWrapper.h:44
btDispatcherInfo
Definition: btDispatcher.h:31
btGImpactCollisionAlgorithm::CreateFunc
Definition: btGImpactCollisionAlgorithm.h:205