Bullet Collision Detection & Physics Library
btGImpactCollisionAlgorithm.h
Go to the documentation of this file.
1 
4 /*
5 This source file is part of GIMPACT Library.
6 
7 For the latest info, see http://gimpact.sourceforge.net/
8 
9 Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
10 email: projectileman@yahoo.com
11 
12 
13 This software is provided 'as-is', without any express or implied warranty.
14 In no event will the authors be held liable for any damages arising from the use of this software.
15 Permission is granted to anyone to use this software for any purpose,
16 including commercial applications, and to alter it and redistribute it freely,
17 subject to the following restrictions:
18 
19 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.
20 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
21 3. This notice may not be removed or altered from any source distribution.
22 */
23 
24 #ifndef BT_GIMPACT_BVH_CONCAVE_COLLISION_ALGORITHM_H
25 #define BT_GIMPACT_BVH_CONCAVE_COLLISION_ALGORITHM_H
26 
31 class btDispatcher;
35 
37 
38 #include "btGImpactShape.h"
44 
45 
47 
55 {
56 protected:
62  int m_part0;
64  int m_part1;
65 
66 
69  {
71  return m_manifoldPtr;
72  }
73 
75  {
77  {
80  m_convex_algorithm = NULL;
81  }
82  }
83 
85  {
86  if(m_manifoldPtr == NULL) return;
88  m_manifoldPtr = NULL;
89  }
90 
92  {
95 
96  m_triface0 = -1;
97  m_part0 = -1;
98  m_triface1 = -1;
99  m_part1 = -1;
100  }
101 
103  {
104  return m_manifoldPtr;
105  }
106 
107 
108  // Call before process collision
110  {
111  if(getLastManifold() == 0)
112  {
113  newContactManifold(body0Wrap->getCollisionObject(),body1Wrap->getCollisionObject());
114  }
115 
117  }
118 
119  // Call before process collision
121  {
122  checkManifold(body0Wrap,body1Wrap);
123 
124  btCollisionAlgorithm * convex_algorithm = m_dispatcher->findAlgorithm(
125  body0Wrap,body1Wrap,getLastManifold());
126  return convex_algorithm ;
127  }
128 
129  // Call before process collision
131  {
132  if(m_convex_algorithm) return;
133  m_convex_algorithm = newAlgorithm(body0Wrap,body1Wrap);
134  }
135 
136 
137 
138 
139  void addContactPoint(const btCollisionObjectWrapper * body0Wrap,
140  const btCollisionObjectWrapper * body1Wrap,
141  const btVector3 & point,
142  const btVector3 & normal,
143  btScalar distance);
144 
147 
148  void collide_gjk_triangles(const btCollisionObjectWrapper* body0Wrap,
149  const btCollisionObjectWrapper* body1Wrap,
150  const btGImpactMeshShapePart * shape0,
151  const btGImpactMeshShapePart * shape1,
152  const int * pairs, int pair_count);
153 
154  void collide_sat_triangles(const btCollisionObjectWrapper* body0Wrap,
155  const btCollisionObjectWrapper* body1Wrap,
156  const btGImpactMeshShapePart * shape0,
157  const btGImpactMeshShapePart * shape1,
158  const int * pairs, int pair_count);
159 
160 
161 
162 
164  const btCollisionObjectWrapper* body0,
165  const btCollisionObjectWrapper* body1,
166  const btCollisionShape * shape0,
167  const btCollisionShape * shape1);
168 
170  const btCollisionObjectWrapper* body1Wrap,
171  const btCollisionShape* shape0,
172  const btCollisionShape* shape1);
173 
174 
175 
177  const btTransform & trans0,
178  const btTransform & trans1,
179  const btGImpactShapeInterface * shape0,
180  const btGImpactShapeInterface * shape1,btPairSet & pairset);
181 
183  const btTransform & trans0,
184  const btTransform & trans1,
185  const btGImpactShapeInterface * shape0,
186  const btCollisionShape * shape1,
187  btAlignedObjectArray<int> & collided_primitives);
188 
189 
191  const btCollisionObjectWrapper * body0Wrap,
192  const btCollisionObjectWrapper * body1Wrap,
193  const btGImpactMeshShapePart * shape0,
194  const btStaticPlaneShape * shape1,bool swapped);
195 
196 
197 public:
198 
200 
202 
203  virtual void processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
204 
206 
207  virtual void getAllContactManifolds(btManifoldArray& manifoldArray)
208  {
209  if (m_manifoldPtr)
210  manifoldArray.push_back(m_manifoldPtr);
211  }
212 
213 
215  {
217  {
219  return new(mem) btGImpactCollisionAlgorithm(ci,body0Wrap,body1Wrap);
220  }
221  };
222 
224  static void registerAlgorithm(btCollisionDispatcher * dispatcher);
225 #ifdef TRI_COLLISION_PROFILING
226  static float getAverageTreeCollisionTime();
228 
230  static float getAverageTriangleCollisionTime();
231 #endif //TRI_COLLISION_PROFILING
232 
234 
239  void gimpact_vs_gimpact(const btCollisionObjectWrapper* body0Wrap,
240  const btCollisionObjectWrapper * body1Wrap,
241  const btGImpactShapeInterface * shape0,
242  const btGImpactShapeInterface * shape1);
243 
244  void gimpact_vs_shape(const btCollisionObjectWrapper* body0Wrap,
245  const btCollisionObjectWrapper* body1Wrap,
246  const btGImpactShapeInterface * shape0,
247  const btCollisionShape * shape1,bool swapped);
248 
249  void gimpact_vs_compoundshape(const btCollisionObjectWrapper * body0Wrap,
250  const btCollisionObjectWrapper * body1Wrap,
251  const btGImpactShapeInterface * shape0,
252  const btCompoundShape * shape1,bool swapped);
253 
254  void gimpact_vs_concave(
255  const btCollisionObjectWrapper * body0Wrap,
256  const btCollisionObjectWrapper * body1Wrap,
257  const btGImpactShapeInterface * shape0,
258  const btConcaveShape * shape1,bool swapped);
259 
260 
261 
262 
264  void setFace0(int value)
265  {
266  m_triface0 = value;
267  }
268  int getFace0()
269  {
270  return m_triface0;
271  }
272  void setFace1(int value)
273  {
274  m_triface1 = value;
275  }
276  int getFace1()
277  {
278  return m_triface1;
279  }
280  void setPart0(int value)
281  {
282  m_part0 = value;
283  }
284  int getPart0()
285  {
286  return m_part0;
287  }
288  void setPart1(int value)
289  {
290  m_part1 = value;
291  }
292  int getPart1()
293  {
294  return m_part1;
295  }
296 
297 };
298 
299 
300 //algorithm details
301 //#define BULLET_TRIANGLE_COLLISION 1
302 #define GIMPACT_VS_PLANE_COLLISION 1
303 
304 
305 
306 #endif //BT_GIMPACT_BVH_CONCAVE_COLLISION_ALGORITHM_H