Tesseract
Motion Planning Environment
Loading...
Searching...
No Matches
tesseract_compound_collision_algorithm.h
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If
12you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not
13required.
142. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original
15software.
163. This notice may not be removed or altered from any source distribution.
17
18*/
19#ifndef TESSERACT_COLLISION_TESSERACT_COMPOUND_COLLISION_ALGORITHM_H
20#define TESSERACT_COLLISION_TESSERACT_COMPOUND_COLLISION_ALGORITHM_H
21
24#include <BulletCollision/BroadphaseCollision/btDispatcher.h>
25#include <BulletCollision/BroadphaseCollision/btBroadphaseInterface.h>
26#include <BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h>
27#include <BulletCollision/NarrowPhaseCollision/btPersistentManifold.h>
28#include <BulletCollision/BroadphaseCollision/btBroadphaseProxy.h>
29#include <BulletCollision/CollisionDispatch/btCollisionCreateFunc.h>
30#include <LinearMath/btAlignedObjectArray.h>
31#include <BulletCollision/BroadphaseCollision/btDbvt.h>
33
34class btCollisionObject;
35class btCollisionShape;
36
37// LCOV_EXCL_START
39{
52class TesseractCompoundCollisionAlgorithm : public btActivatingCollisionAlgorithm // NOLINT
53{
54 btNodeStack stack2;
55 btManifoldArray manifoldArray;
56
57protected:
58 btAlignedObjectArray<btCollisionAlgorithm*> m_childCollisionAlgorithms;
60
61 class btPersistentManifold* m_sharedManifold;
62 bool m_ownsManifold{ false };
63
64 int m_compoundShapeRevision; // to keep track of changes, so that childAlgorithm array can be updated
65
67
68 void preallocateChildAlgorithms(const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap);
69
70public:
71 TesseractCompoundCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci,
72 const btCollisionObjectWrapper* body0Wrap,
73 const btCollisionObjectWrapper* body1Wrap,
74 bool isSwapped);
75
81
82 btCollisionAlgorithm* getChildAlgorithm(int n) const { return m_childCollisionAlgorithms[n]; }
83
84 void processCollision(const btCollisionObjectWrapper* body0Wrap,
85 const btCollisionObjectWrapper* body1Wrap,
86 const btDispatcherInfo& dispatchInfo,
87 btManifoldResult* resultOut) override;
88
89 btScalar calculateTimeOfImpact(btCollisionObject* body0,
90 btCollisionObject* body1,
91 const btDispatcherInfo& dispatchInfo,
92 btManifoldResult* resultOut) override;
93
94 void getAllContactManifolds(btManifoldArray& manifoldArray) override
95 {
96 for (int i = 0; i < m_childCollisionAlgorithms.size(); i++)
97 {
98 if (m_childCollisionAlgorithms[i] != nullptr)
99 m_childCollisionAlgorithms[i]->getAllContactManifolds(manifoldArray);
100 }
101 }
102
103 struct CreateFunc : public btCollisionAlgorithmCreateFunc
104 {
105 btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci,
106 const btCollisionObjectWrapper* body0Wrap,
107 const btCollisionObjectWrapper* body1Wrap) override
108 {
109 void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(TesseractCompoundCollisionAlgorithm));
110 return new (mem) TesseractCompoundCollisionAlgorithm(ci, body0Wrap, body1Wrap, false);
111 }
112 };
113
114 struct SwappedCreateFunc : public btCollisionAlgorithmCreateFunc
115 {
116 btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci,
117 const btCollisionObjectWrapper* body0Wrap,
118 const btCollisionObjectWrapper* body1Wrap) override
119 {
120 void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(TesseractCompoundCollisionAlgorithm));
121 return new (mem) TesseractCompoundCollisionAlgorithm(ci, body0Wrap, body1Wrap, true);
122 }
123 };
124};
125} // namespace tesseract_collision::tesseract_collision_bullet
126// LCOV_EXCL_STOP
127#endif // TESSERACT_COLLISION_TESSERACT_COMPOUND_COLLISION_ALGORITHM_H
Supports collision between CompoundCollisionShapes and other collision shapes.
Definition: tesseract_compound_collision_algorithm.h:53
class btPersistentManifold * m_sharedManifold
Definition: tesseract_compound_collision_algorithm.h:61
TesseractCompoundCollisionAlgorithm & operator=(TesseractCompoundCollisionAlgorithm &&)=default
btAlignedObjectArray< btCollisionAlgorithm * > m_childCollisionAlgorithms
Definition: tesseract_compound_collision_algorithm.h:58
TesseractCompoundCollisionAlgorithm(const TesseractCompoundCollisionAlgorithm &)=default
TesseractCompoundCollisionAlgorithm(TesseractCompoundCollisionAlgorithm &&)=default
btNodeStack stack2
Definition: tesseract_compound_collision_algorithm.h:54
bool m_ownsManifold
Definition: tesseract_compound_collision_algorithm.h:62
~TesseractCompoundCollisionAlgorithm() override
Definition: tesseract_compound_collision_algorithm.cpp:103
int m_compoundShapeRevision
Definition: tesseract_compound_collision_algorithm.h:64
TesseractCompoundCollisionAlgorithm & operator=(const TesseractCompoundCollisionAlgorithm &)=default
void removeChildAlgorithms()
Definition: tesseract_compound_collision_algorithm.cpp:90
void getAllContactManifolds(btManifoldArray &manifoldArray) override
Definition: tesseract_compound_collision_algorithm.h:94
btManifoldArray manifoldArray
Definition: tesseract_compound_collision_algorithm.h:55
void preallocateChildAlgorithms(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap)
Definition: tesseract_compound_collision_algorithm.cpp:53
btScalar calculateTimeOfImpact(btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut) override
Definition: tesseract_compound_collision_algorithm.cpp:375
btCollisionAlgorithm * getChildAlgorithm(int n) const
Definition: tesseract_compound_collision_algorithm.h:82
bool m_isSwapped
Definition: tesseract_compound_collision_algorithm.h:59
void processCollision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut) override
Definition: tesseract_compound_collision_algorithm.cpp:254
Common Tesseract Macros.
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
Definition: macros.h:71
Definition: create_convex_hull.cpp:36
Definition: bullet_cast_bvh_manager.h:49
btCollisionAlgorithm * CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap) override
Definition: tesseract_compound_collision_algorithm.h:105
btCollisionAlgorithm * CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap) override
Definition: tesseract_compound_collision_algorithm.h:116