Bullet Collision Detection & Physics Library
btDefaultCollisionConfiguration.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 
17 
23 
27 #ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
29 #endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
34 
35 
36 
38 
39 
40 
41 
42 
44 //btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(btStackAlloc* stackAlloc,btPoolAllocator* persistentManifoldPool,btPoolAllocator* collisionAlgorithmPool)
45 {
46 
47  void* mem = btAlignedAlloc(sizeof(btVoronoiSimplexSolver),16);
49 
50  if (constructionInfo.m_useEpaPenetrationAlgorithm)
51  {
54  }else
55  {
58  }
59 
60  //default CreationFunctions, filling the m_doubleDispatch table
69 
72 
77 
80 #ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
85  m_boxSphereCF->m_swapped = true;
86 #endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
87 
93 
96 
97  //convex versus plane
102  m_planeConvexCF->m_swapped = true;
103 
105  int maxSize = sizeof(btConvexConvexAlgorithm);
106  int maxSize2 = sizeof(btConvexConcaveCollisionAlgorithm);
107  int maxSize3 = sizeof(btCompoundCollisionAlgorithm);
108  int sl = sizeof(btConvexSeparatingDistanceUtil);
109  sl = sizeof(btGjkPairDetector);
110  int collisionAlgorithmMaxElementSize = btMax(maxSize,constructionInfo.m_customCollisionAlgorithmMaxElementSize);
111  collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize2);
112  collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize3);
113 
114 
115  if (constructionInfo.m_persistentManifoldPool)
116  {
119  } else
120  {
122  void* mem = btAlignedAlloc(sizeof(btPoolAllocator),16);
124  }
125 
126  if (constructionInfo.m_collisionAlgorithmPool)
127  {
130  } else
131  {
133  void* mem = btAlignedAlloc(sizeof(btPoolAllocator),16);
134  m_collisionAlgorithmPool = new(mem) btPoolAllocator(collisionAlgorithmMaxElementSize,constructionInfo.m_defaultMaxCollisionAlgorithmPoolSize);
135  }
136 
137 
138 }
139 
141 {
143  {
146  }
148  {
151  }
152 
155 
160 
163 
166 
169 
172 
175 
176 #ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
181 #endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
182 
189 
194 
195  m_simplexSolver->~btVoronoiSimplexSolver();
197 
199 
201 
202 
203 }
204 
205 
207 {
208 
209 
210 
211  if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE) && (proxyType1==SPHERE_SHAPE_PROXYTYPE))
212  {
213  return m_sphereSphereCF;
214  }
215 #ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
216  if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE) && (proxyType1==BOX_SHAPE_PROXYTYPE))
217  {
218  return m_sphereBoxCF;
219  }
220 
221  if ((proxyType0 == BOX_SHAPE_PROXYTYPE ) && (proxyType1==SPHERE_SHAPE_PROXYTYPE))
222  {
223  return m_boxSphereCF;
224  }
225 #endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
226 
227 
228  if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE ) && (proxyType1==TRIANGLE_SHAPE_PROXYTYPE))
229  {
230  return m_sphereTriangleCF;
231  }
232 
233  if ((proxyType0 == TRIANGLE_SHAPE_PROXYTYPE ) && (proxyType1==SPHERE_SHAPE_PROXYTYPE))
234  {
235  return m_triangleSphereCF;
236  }
237 
238  if ((proxyType0 == BOX_SHAPE_PROXYTYPE) && (proxyType1 == BOX_SHAPE_PROXYTYPE))
239  {
240  return m_boxBoxCF;
241  }
242 
243  if (btBroadphaseProxy::isConvex(proxyType0) && (proxyType1 == STATIC_PLANE_PROXYTYPE))
244  {
245  return m_convexPlaneCF;
246  }
247 
248  if (btBroadphaseProxy::isConvex(proxyType1) && (proxyType0 == STATIC_PLANE_PROXYTYPE))
249  {
250  return m_planeConvexCF;
251  }
252 
253 
254 
255  if (btBroadphaseProxy::isConvex(proxyType0) && btBroadphaseProxy::isConvex(proxyType1))
256  {
258  }
259 
260  if (btBroadphaseProxy::isConvex(proxyType0) && btBroadphaseProxy::isConcave(proxyType1))
261  {
263  }
264 
265  if (btBroadphaseProxy::isConvex(proxyType1) && btBroadphaseProxy::isConcave(proxyType0))
266  {
268  }
269 
270 
271  if (btBroadphaseProxy::isCompound(proxyType0) && btBroadphaseProxy::isCompound(proxyType1))
272  {
274  }
275 
276  if (btBroadphaseProxy::isCompound(proxyType0))
277  {
278  return m_compoundCreateFunc;
279  } else
280  {
281  if (btBroadphaseProxy::isCompound(proxyType1))
282  {
284  }
285  }
286 
287  //failed to find an algorithm
288  return m_emptyCreateFunc;
289 }
290 
291 void btDefaultCollisionConfiguration::setConvexConvexMultipointIterations(int numPerturbationIterations, int minimumPointsPerturbationThreshold)
292 {
294  convexConvex->m_numPerturbationIterations = numPerturbationIterations;
295  convexConvex->m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold;
296 }
297 
298 void btDefaultCollisionConfiguration::setPlaneConvexMultipointIterations(int numPerturbationIterations, int minimumPointsPerturbationThreshold)
299 {
301  cpCF->m_numPerturbationIterations = numPerturbationIterations;
302  cpCF->m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold;
303 
305  pcCF->m_numPerturbationIterations = numPerturbationIterations;
306  pcCF->m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold;
307 }
btCollisionAlgorithmCreateFunc * m_convexPlaneCF
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
void setConvexConvexMultipointIterations(int numPerturbationIterations=3, int minimumPointsPerturbationThreshold=3)
Use this method to allow to generate multiple contact points between at once, between two objects usi...
btConvexPenetrationDepthSolver * m_pdSolver
static bool isCompound(int proxyType)
btCollisionAlgorithmCreateFunc * m_boxBoxCF
btCollisionAlgorithmCreateFunc * m_triangleSphereCF
virtual btCollisionAlgorithmCreateFunc * getCollisionAlgorithmCreateFunc(int proxyType0, int proxyType1)
btDefaultCollisionConfiguration(const btDefaultCollisionConstructionInfo &constructionInfo=btDefaultCollisionConstructionInfo())
btVoronoiSimplexSolver is an implementation of the closest point distance algorithm from a 1-4 points...
btCollisionAlgorithmCreateFunc * m_swappedConvexConcaveCreateFunc
Used by the btCollisionDispatcher to register and create instances for btCollisionAlgorithm.
The btConvexSeparatingDistanceUtil can help speed up convex collision detection by conservatively upd...
#define btAlignedFree(ptr)
MinkowskiPenetrationDepthSolver implements bruteforce penetration depth estimation.
btCollisionAlgorithmCreateFunc * m_emptyCreateFunc
btConvexConcaveCollisionAlgorithm supports collision between convex shapes and (concave) trianges mes...
void setPlaneConvexMultipointIterations(int numPerturbationIterations=3, int minimumPointsPerturbationThreshold=3)
btCollisionAlgorithmCreateFunc * m_sphereTriangleCF
btCollisionAlgorithmCreateFunc * m_sphereSphereCF
EpaPenetrationDepthSolver uses the Expanding Polytope Algorithm to calculate the penetration depth be...
btCollisionAlgorithmCreateFunc * m_planeConvexCF
btCollisionAlgorithmCreateFunc * m_compoundCreateFunc
The btPoolAllocator class allows to efficiently allocate a large pool of objects, instead of dynamica...
btGjkPairDetector uses GJK to implement the btDiscreteCollisionDetectorInterface
btCompoundCollisionAlgorithm supports collision between CompoundCollisionShapes and other collision s...
static bool isConcave(int proxyType)
const T & btMax(const T &a, const T &b)
Definition: btMinMax.h:29
btCollisionAlgorithmCreateFunc * m_boxSphereCF
Enabling USE_SEPDISTANCE_UTIL2 requires 100% reliable distance computation.
btCollisionAlgorithmCreateFunc * m_compoundCompoundCreateFunc
#define btAlignedAlloc(size, alignment)
btCollisionAlgorithmCreateFunc * m_convexConcaveCreateFunc
static bool isConvex(int proxyType)
btCollisionAlgorithmCreateFunc * m_sphereBoxCF
btCollisionAlgorithmCreateFunc * m_convexConvexCreateFunc
btCollisionAlgorithmCreateFunc * m_swappedCompoundCreateFunc