Bullet Collision Detection & Physics Library
btDefaultCollisionConfiguration.cpp
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 you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. 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 = NULL;
48 if (constructionInfo.m_useEpaPenetrationAlgorithm)
49 {
52 }else
53 {
56 }
57
58 //default CreationFunctions, filling the m_doubleDispatch table
67
70
75
78#ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
84#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
85
91
94
95 //convex versus plane
101
103 int maxSize = sizeof(btConvexConvexAlgorithm);
104 int maxSize2 = sizeof(btConvexConcaveCollisionAlgorithm);
105 int maxSize3 = sizeof(btCompoundCollisionAlgorithm);
106 int maxSize4 = sizeof(btCompoundCompoundCollisionAlgorithm);
107
108 int collisionAlgorithmMaxElementSize = btMax(maxSize,constructionInfo.m_customCollisionAlgorithmMaxElementSize);
109 collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize2);
110 collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize3);
111 collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize4);
112
113 if (constructionInfo.m_persistentManifoldPool)
114 {
117 } else
118 {
120 void* mem = btAlignedAlloc(sizeof(btPoolAllocator),16);
122 }
123
124 collisionAlgorithmMaxElementSize = (collisionAlgorithmMaxElementSize+16)&0xffffffffffff0;
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
195
197
198
199}
200
202{
203
204
205 if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE) && (proxyType1 == SPHERE_SHAPE_PROXYTYPE))
206 {
207 return m_sphereSphereCF;
208 }
209#ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
210 if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE) && (proxyType1 == BOX_SHAPE_PROXYTYPE))
211 {
212 return m_sphereBoxCF;
213 }
214
215 if ((proxyType0 == BOX_SHAPE_PROXYTYPE) && (proxyType1 == SPHERE_SHAPE_PROXYTYPE))
216 {
217 return m_boxSphereCF;
218 }
219#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
220
221
222 if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE) && (proxyType1 == TRIANGLE_SHAPE_PROXYTYPE))
223 {
224 return m_sphereTriangleCF;
225 }
226
227 if ((proxyType0 == TRIANGLE_SHAPE_PROXYTYPE) && (proxyType1 == SPHERE_SHAPE_PROXYTYPE))
228 {
229 return m_triangleSphereCF;
230 }
231
232 if (btBroadphaseProxy::isConvex(proxyType0) && (proxyType1 == STATIC_PLANE_PROXYTYPE))
233 {
234 return m_convexPlaneCF;
235 }
236
237 if (btBroadphaseProxy::isConvex(proxyType1) && (proxyType0 == STATIC_PLANE_PROXYTYPE))
238 {
239 return m_planeConvexCF;
240 }
241
242
243
244 if (btBroadphaseProxy::isConvex(proxyType0) && btBroadphaseProxy::isConvex(proxyType1))
245 {
247 }
248
249 if (btBroadphaseProxy::isConvex(proxyType0) && btBroadphaseProxy::isConcave(proxyType1))
250 {
252 }
253
254 if (btBroadphaseProxy::isConvex(proxyType1) && btBroadphaseProxy::isConcave(proxyType0))
255 {
257 }
258
259
261 {
263 }
264
265 if (btBroadphaseProxy::isCompound(proxyType0))
266 {
268 }
269 else
270 {
271 if (btBroadphaseProxy::isCompound(proxyType1))
272 {
274 }
275 }
276
277 //failed to find an algorithm
278 return m_emptyCreateFunc;
279
280}
281
283{
284
285
286
287 if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE) && (proxyType1==SPHERE_SHAPE_PROXYTYPE))
288 {
289 return m_sphereSphereCF;
290 }
291#ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
292 if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE) && (proxyType1==BOX_SHAPE_PROXYTYPE))
293 {
294 return m_sphereBoxCF;
295 }
296
297 if ((proxyType0 == BOX_SHAPE_PROXYTYPE ) && (proxyType1==SPHERE_SHAPE_PROXYTYPE))
298 {
299 return m_boxSphereCF;
300 }
301#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
302
303
304 if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE ) && (proxyType1==TRIANGLE_SHAPE_PROXYTYPE))
305 {
306 return m_sphereTriangleCF;
307 }
308
309 if ((proxyType0 == TRIANGLE_SHAPE_PROXYTYPE ) && (proxyType1==SPHERE_SHAPE_PROXYTYPE))
310 {
311 return m_triangleSphereCF;
312 }
313
314 if ((proxyType0 == BOX_SHAPE_PROXYTYPE) && (proxyType1 == BOX_SHAPE_PROXYTYPE))
315 {
316 return m_boxBoxCF;
317 }
318
319 if (btBroadphaseProxy::isConvex(proxyType0) && (proxyType1 == STATIC_PLANE_PROXYTYPE))
320 {
321 return m_convexPlaneCF;
322 }
323
324 if (btBroadphaseProxy::isConvex(proxyType1) && (proxyType0 == STATIC_PLANE_PROXYTYPE))
325 {
326 return m_planeConvexCF;
327 }
328
329
330
331 if (btBroadphaseProxy::isConvex(proxyType0) && btBroadphaseProxy::isConvex(proxyType1))
332 {
334 }
335
336 if (btBroadphaseProxy::isConvex(proxyType0) && btBroadphaseProxy::isConcave(proxyType1))
337 {
339 }
340
341 if (btBroadphaseProxy::isConvex(proxyType1) && btBroadphaseProxy::isConcave(proxyType0))
342 {
344 }
345
346
348 {
350 }
351
352 if (btBroadphaseProxy::isCompound(proxyType0))
353 {
355 } else
356 {
357 if (btBroadphaseProxy::isCompound(proxyType1))
358 {
360 }
361 }
362
363 //failed to find an algorithm
364 return m_emptyCreateFunc;
365}
366
367void btDefaultCollisionConfiguration::setConvexConvexMultipointIterations(int numPerturbationIterations, int minimumPointsPerturbationThreshold)
368{
370 convexConvex->m_numPerturbationIterations = numPerturbationIterations;
371 convexConvex->m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold;
372}
373
374void btDefaultCollisionConfiguration::setPlaneConvexMultipointIterations(int numPerturbationIterations, int minimumPointsPerturbationThreshold)
375{
377 cpCF->m_numPerturbationIterations = numPerturbationIterations;
378 cpCF->m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold;
379
381 pcCF->m_numPerturbationIterations = numPerturbationIterations;
382 pcCF->m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold;
383}
#define btAlignedFree(ptr)
#define btAlignedAlloc(size, alignment)
@ TRIANGLE_SHAPE_PROXYTYPE
@ STATIC_PLANE_PROXYTYPE
@ SPHERE_SHAPE_PROXYTYPE
@ BOX_SHAPE_PROXYTYPE
const T & btMax(const T &a, const T &b)
Definition: btMinMax.h:29
btCompoundCollisionAlgorithm supports collision between CompoundCollisionShapes and other collision s...
btCompoundCompoundCollisionAlgorithm supports collision between two btCompoundCollisionShape shapes
btConvexConcaveCollisionAlgorithm supports collision between convex shapes and (concave) trianges mes...
Enabling USE_SEPDISTANCE_UTIL2 requires 100% reliable distance computation.
btCollisionAlgorithmCreateFunc * m_boxSphereCF
btCollisionAlgorithmCreateFunc * m_compoundCreateFunc
btCollisionAlgorithmCreateFunc * m_triangleSphereCF
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...
btCollisionAlgorithmCreateFunc * m_boxBoxCF
btCollisionAlgorithmCreateFunc * m_sphereTriangleCF
virtual btCollisionAlgorithmCreateFunc * getClosestPointsAlgorithmCreateFunc(int proxyType0, int proxyType1)
btCollisionAlgorithmCreateFunc * m_convexConcaveCreateFunc
btCollisionAlgorithmCreateFunc * m_planeConvexCF
void setPlaneConvexMultipointIterations(int numPerturbationIterations=3, int minimumPointsPerturbationThreshold=3)
btCollisionAlgorithmCreateFunc * m_compoundCompoundCreateFunc
btConvexPenetrationDepthSolver * m_pdSolver
btCollisionAlgorithmCreateFunc * m_convexPlaneCF
btCollisionAlgorithmCreateFunc * m_sphereSphereCF
virtual btCollisionAlgorithmCreateFunc * getCollisionAlgorithmCreateFunc(int proxyType0, int proxyType1)
btDefaultCollisionConfiguration(const btDefaultCollisionConstructionInfo &constructionInfo=btDefaultCollisionConstructionInfo())
btCollisionAlgorithmCreateFunc * m_swappedConvexConcaveCreateFunc
btCollisionAlgorithmCreateFunc * m_emptyCreateFunc
btCollisionAlgorithmCreateFunc * m_swappedCompoundCreateFunc
btCollisionAlgorithmCreateFunc * m_convexConvexCreateFunc
btCollisionAlgorithmCreateFunc * m_sphereBoxCF
EpaPenetrationDepthSolver uses the Expanding Polytope Algorithm to calculate the penetration depth be...
MinkowskiPenetrationDepthSolver implements bruteforce penetration depth estimation.
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
The btPoolAllocator class allows to efficiently allocate a large pool of objects, instead of dynamica...
static bool isCompound(int proxyType)
static bool isConcave(int proxyType)
static bool isConvex(int proxyType)
Used by the btCollisionDispatcher to register and create instances for btCollisionAlgorithm.