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 
109  int collisionAlgorithmMaxElementSize = btMax(maxSize,constructionInfo.m_customCollisionAlgorithmMaxElementSize);
110  collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize2);
111  collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize3);
112 
113 
114  if (constructionInfo.m_persistentManifoldPool)
115  {
118  } else
119  {
121  void* mem = btAlignedAlloc(sizeof(btPoolAllocator),16);
123  }
124 
125  if (constructionInfo.m_collisionAlgorithmPool)
126  {
129  } else
130  {
132  void* mem = btAlignedAlloc(sizeof(btPoolAllocator),16);
133  m_collisionAlgorithmPool = new(mem) btPoolAllocator(collisionAlgorithmMaxElementSize,constructionInfo.m_defaultMaxCollisionAlgorithmPoolSize);
134  }
135 
136 
137 }
138 
140 {
142  {
145  }
147  {
150  }
151 
154 
159 
162 
165 
168 
171 
174 
175 #ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
180 #endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
181 
188 
193 
194  m_simplexSolver->~btVoronoiSimplexSolver();
196 
198 
200 
201 
202 }
203 
204 
206 {
207 
208 
209 
210  if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE) && (proxyType1==SPHERE_SHAPE_PROXYTYPE))
211  {
212  return m_sphereSphereCF;
213  }
214 #ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
215  if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE) && (proxyType1==BOX_SHAPE_PROXYTYPE))
216  {
217  return m_sphereBoxCF;
218  }
219 
220  if ((proxyType0 == BOX_SHAPE_PROXYTYPE ) && (proxyType1==SPHERE_SHAPE_PROXYTYPE))
221  {
222  return m_boxSphereCF;
223  }
224 #endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
225 
226 
227  if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE ) && (proxyType1==TRIANGLE_SHAPE_PROXYTYPE))
228  {
229  return m_sphereTriangleCF;
230  }
231 
232  if ((proxyType0 == TRIANGLE_SHAPE_PROXYTYPE ) && (proxyType1==SPHERE_SHAPE_PROXYTYPE))
233  {
234  return m_triangleSphereCF;
235  }
236 
237  if ((proxyType0 == BOX_SHAPE_PROXYTYPE) && (proxyType1 == BOX_SHAPE_PROXYTYPE))
238  {
239  return m_boxBoxCF;
240  }
241 
242  if (btBroadphaseProxy::isConvex(proxyType0) && (proxyType1 == STATIC_PLANE_PROXYTYPE))
243  {
244  return m_convexPlaneCF;
245  }
246 
247  if (btBroadphaseProxy::isConvex(proxyType1) && (proxyType0 == STATIC_PLANE_PROXYTYPE))
248  {
249  return m_planeConvexCF;
250  }
251 
252 
253 
254  if (btBroadphaseProxy::isConvex(proxyType0) && btBroadphaseProxy::isConvex(proxyType1))
255  {
257  }
258 
259  if (btBroadphaseProxy::isConvex(proxyType0) && btBroadphaseProxy::isConcave(proxyType1))
260  {
262  }
263 
264  if (btBroadphaseProxy::isConvex(proxyType1) && btBroadphaseProxy::isConcave(proxyType0))
265  {
267  }
268 
269 
270  if (btBroadphaseProxy::isCompound(proxyType0) && btBroadphaseProxy::isCompound(proxyType1))
271  {
273  }
274 
275  if (btBroadphaseProxy::isCompound(proxyType0))
276  {
277  return m_compoundCreateFunc;
278  } else
279  {
280  if (btBroadphaseProxy::isCompound(proxyType1))
281  {
283  }
284  }
285 
286  //failed to find an algorithm
287  return m_emptyCreateFunc;
288 }
289 
290 void btDefaultCollisionConfiguration::setConvexConvexMultipointIterations(int numPerturbationIterations, int minimumPointsPerturbationThreshold)
291 {
293  convexConvex->m_numPerturbationIterations = numPerturbationIterations;
294  convexConvex->m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold;
295 }
296 
297 void btDefaultCollisionConfiguration::setPlaneConvexMultipointIterations(int numPerturbationIterations, int minimumPointsPerturbationThreshold)
298 {
300  cpCF->m_numPerturbationIterations = numPerturbationIterations;
301  cpCF->m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold;
302 
304  pcCF->m_numPerturbationIterations = numPerturbationIterations;
305  pcCF->m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold;
306 }
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.
#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...
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