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 maxSize4 = sizeof(btCompoundCompoundCollisionAlgorithm);
109 
110  int collisionAlgorithmMaxElementSize = btMax(maxSize,constructionInfo.m_customCollisionAlgorithmMaxElementSize);
111  collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize2);
112  collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize3);
113  collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize4);
114 
115  if (constructionInfo.m_persistentManifoldPool)
116  {
119  } else
120  {
122  void* mem = btAlignedAlloc(sizeof(btPoolAllocator),16);
124  }
125 
126  collisionAlgorithmMaxElementSize = (collisionAlgorithmMaxElementSize+16)&0xffffffffffff0;
127  if (constructionInfo.m_collisionAlgorithmPool)
128  {
131  } else
132  {
134  void* mem = btAlignedAlloc(sizeof(btPoolAllocator),16);
135  m_collisionAlgorithmPool = new(mem) btPoolAllocator(collisionAlgorithmMaxElementSize,constructionInfo.m_defaultMaxCollisionAlgorithmPoolSize);
136  }
137 
138 
139 }
140 
142 {
144  {
147  }
149  {
152  }
153 
156 
161 
164 
167 
170 
173 
176 
177 #ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
182 #endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
183 
190 
195 
196  m_simplexSolver->~btVoronoiSimplexSolver();
198 
200 
202 
203 
204 }
205 
206 
208 {
209 
210 
211 
212  if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE) && (proxyType1==SPHERE_SHAPE_PROXYTYPE))
213  {
214  return m_sphereSphereCF;
215  }
216 #ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
217  if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE) && (proxyType1==BOX_SHAPE_PROXYTYPE))
218  {
219  return m_sphereBoxCF;
220  }
221 
222  if ((proxyType0 == BOX_SHAPE_PROXYTYPE ) && (proxyType1==SPHERE_SHAPE_PROXYTYPE))
223  {
224  return m_boxSphereCF;
225  }
226 #endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
227 
228 
229  if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE ) && (proxyType1==TRIANGLE_SHAPE_PROXYTYPE))
230  {
231  return m_sphereTriangleCF;
232  }
233 
234  if ((proxyType0 == TRIANGLE_SHAPE_PROXYTYPE ) && (proxyType1==SPHERE_SHAPE_PROXYTYPE))
235  {
236  return m_triangleSphereCF;
237  }
238 
239  if ((proxyType0 == BOX_SHAPE_PROXYTYPE) && (proxyType1 == BOX_SHAPE_PROXYTYPE))
240  {
241  return m_boxBoxCF;
242  }
243 
244  if (btBroadphaseProxy::isConvex(proxyType0) && (proxyType1 == STATIC_PLANE_PROXYTYPE))
245  {
246  return m_convexPlaneCF;
247  }
248 
249  if (btBroadphaseProxy::isConvex(proxyType1) && (proxyType0 == STATIC_PLANE_PROXYTYPE))
250  {
251  return m_planeConvexCF;
252  }
253 
254 
255 
256  if (btBroadphaseProxy::isConvex(proxyType0) && btBroadphaseProxy::isConvex(proxyType1))
257  {
259  }
260 
261  if (btBroadphaseProxy::isConvex(proxyType0) && btBroadphaseProxy::isConcave(proxyType1))
262  {
264  }
265 
266  if (btBroadphaseProxy::isConvex(proxyType1) && btBroadphaseProxy::isConcave(proxyType0))
267  {
269  }
270 
271 
272  if (btBroadphaseProxy::isCompound(proxyType0) && btBroadphaseProxy::isCompound(proxyType1))
273  {
275  }
276 
277  if (btBroadphaseProxy::isCompound(proxyType0))
278  {
279  return m_compoundCreateFunc;
280  } else
281  {
282  if (btBroadphaseProxy::isCompound(proxyType1))
283  {
285  }
286  }
287 
288  //failed to find an algorithm
289  return m_emptyCreateFunc;
290 }
291 
292 void btDefaultCollisionConfiguration::setConvexConvexMultipointIterations(int numPerturbationIterations, int minimumPointsPerturbationThreshold)
293 {
295  convexConvex->m_numPerturbationIterations = numPerturbationIterations;
296  convexConvex->m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold;
297 }
298 
299 void btDefaultCollisionConfiguration::setPlaneConvexMultipointIterations(int numPerturbationIterations, int minimumPointsPerturbationThreshold)
300 {
302  cpCF->m_numPerturbationIterations = numPerturbationIterations;
303  cpCF->m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold;
304 
306  pcCF->m_numPerturbationIterations = numPerturbationIterations;
307  pcCF->m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold;
308 }
btCollisionAlgorithmCreateFunc * m_convexPlaneCF
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
btCompoundCompoundCollisionAlgorithm supports collision between two btCompoundCollisionShape shapes ...
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