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 
25 #ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
27 #endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
32 
33 
34 
37 
38 
39 
40 
41 
43 //btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(btStackAlloc* stackAlloc,btPoolAllocator* persistentManifoldPool,btPoolAllocator* collisionAlgorithmPool)
44 {
45 
46  void* mem = btAlignedAlloc(sizeof(btVoronoiSimplexSolver),16);
48 
49  if (constructionInfo.m_useEpaPenetrationAlgorithm)
50  {
53  }else
54  {
57  }
58 
59  //default CreationFunctions, filling the m_doubleDispatch table
72 
75 #ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
80  m_boxSphereCF->m_swapped = true;
81 #endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
82 
88 
91 
92  //convex versus plane
97  m_planeConvexCF->m_swapped = true;
98 
100  int maxSize = sizeof(btConvexConvexAlgorithm);
101  int maxSize2 = sizeof(btConvexConcaveCollisionAlgorithm);
102  int maxSize3 = sizeof(btCompoundCollisionAlgorithm);
103  int sl = sizeof(btConvexSeparatingDistanceUtil);
104  sl = sizeof(btGjkPairDetector);
105  int collisionAlgorithmMaxElementSize = btMax(maxSize,constructionInfo.m_customCollisionAlgorithmMaxElementSize);
106  collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize2);
107  collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize3);
108 
109  if (constructionInfo.m_stackAlloc)
110  {
111  m_ownsStackAllocator = false;
112  this->m_stackAlloc = constructionInfo.m_stackAlloc;
113  } else
114  {
115  m_ownsStackAllocator = true;
116  void* mem = btAlignedAlloc(sizeof(btStackAlloc),16);
117  m_stackAlloc = new(mem)btStackAlloc(constructionInfo.m_defaultStackAllocatorSize);
118  }
119 
120  if (constructionInfo.m_persistentManifoldPool)
121  {
124  } else
125  {
127  void* mem = btAlignedAlloc(sizeof(btPoolAllocator),16);
129  }
130 
131  if (constructionInfo.m_collisionAlgorithmPool)
132  {
135  } else
136  {
138  void* mem = btAlignedAlloc(sizeof(btPoolAllocator),16);
139  m_collisionAlgorithmPool = new(mem) btPoolAllocator(collisionAlgorithmMaxElementSize,constructionInfo.m_defaultMaxCollisionAlgorithmPoolSize);
140  }
141 
142 
143 }
144 
146 {
148  {
152  }
154  {
157  }
159  {
162  }
163 
166 
171 
174 
177 
180 
183 
184 #ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
189 #endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
190 
197 
202 
203  m_simplexSolver->~btVoronoiSimplexSolver();
205 
207 
209 
210 
211 }
212 
213 
215 {
216 
217 
218 
219  if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE) && (proxyType1==SPHERE_SHAPE_PROXYTYPE))
220  {
221  return m_sphereSphereCF;
222  }
223 #ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
224  if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE) && (proxyType1==BOX_SHAPE_PROXYTYPE))
225  {
226  return m_sphereBoxCF;
227  }
228 
229  if ((proxyType0 == BOX_SHAPE_PROXYTYPE ) && (proxyType1==SPHERE_SHAPE_PROXYTYPE))
230  {
231  return m_boxSphereCF;
232  }
233 #endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
234 
235 
236  if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE ) && (proxyType1==TRIANGLE_SHAPE_PROXYTYPE))
237  {
238  return m_sphereTriangleCF;
239  }
240 
241  if ((proxyType0 == TRIANGLE_SHAPE_PROXYTYPE ) && (proxyType1==SPHERE_SHAPE_PROXYTYPE))
242  {
243  return m_triangleSphereCF;
244  }
245 
246  if ((proxyType0 == BOX_SHAPE_PROXYTYPE) && (proxyType1 == BOX_SHAPE_PROXYTYPE))
247  {
248  return m_boxBoxCF;
249  }
250 
251  if (btBroadphaseProxy::isConvex(proxyType0) && (proxyType1 == STATIC_PLANE_PROXYTYPE))
252  {
253  return m_convexPlaneCF;
254  }
255 
256  if (btBroadphaseProxy::isConvex(proxyType1) && (proxyType0 == STATIC_PLANE_PROXYTYPE))
257  {
258  return m_planeConvexCF;
259  }
260 
261 
262 
263  if (btBroadphaseProxy::isConvex(proxyType0) && btBroadphaseProxy::isConvex(proxyType1))
264  {
266  }
267 
268  if (btBroadphaseProxy::isConvex(proxyType0) && btBroadphaseProxy::isConcave(proxyType1))
269  {
271  }
272 
273  if (btBroadphaseProxy::isConvex(proxyType1) && btBroadphaseProxy::isConcave(proxyType0))
274  {
276  }
277 
278  if (btBroadphaseProxy::isCompound(proxyType0))
279  {
280  return m_compoundCreateFunc;
281  } else
282  {
283  if (btBroadphaseProxy::isCompound(proxyType1))
284  {
286  }
287  }
288 
289  //failed to find an algorithm
290  return m_emptyCreateFunc;
291 }
292 
293 void btDefaultCollisionConfiguration::setConvexConvexMultipointIterations(int numPerturbationIterations, int minimumPointsPerturbationThreshold)
294 {
296  convexConvex->m_numPerturbationIterations = numPerturbationIterations;
297  convexConvex->m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold;
298 }
299 
300 void btDefaultCollisionConfiguration::setPlaneConvexMultipointIterations(int numPerturbationIterations, int minimumPointsPerturbationThreshold)
301 {
303  cpCF->m_numPerturbationIterations = numPerturbationIterations;
304  cpCF->m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold;
305 
307  pcCF->m_numPerturbationIterations = numPerturbationIterations;
308  pcCF->m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold;
309 }