Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp @ 8900

Last change on this file since 8900 was 8351, checked in by rgrieder, 14 years ago

Merged kicklib2 branch back to trunk (includes former branches ois_update, mac_osx and kicklib).

Notes for updating

Linux:
You don't need an extra package for CEGUILua and Tolua, it's already shipped with CEGUI.
However you do need to make sure that the OgreRenderer is installed too with CEGUI 0.7 (may be a separate package).
Also, Orxonox now recognises if you install the CgProgramManager (a separate package available on newer Ubuntu on Debian systems).

Windows:
Download the new dependency packages versioned 6.0 and use these. If you have problems with that or if you don't like the in game console problem mentioned below, you can download the new 4.3 version of the packages (only available for Visual Studio 2005/2008).

Key new features:

  • *Support for Mac OS X*
  • Visual Studio 2010 support
  • Bullet library update to 2.77
  • OIS library update to 1.3
  • Support for CEGUI 0.7 —> Support for Arch Linux and even SuSE
  • Improved install target
  • Compiles now with GCC 4.6
  • Ogre Cg Shader plugin activated for Linux if available
  • And of course lots of bug fixes

There are also some regressions:

  • No support for CEGUI 0.5, Ogre 1.4 and boost 1.35 - 1.39 any more
  • In game console is not working in main menu for CEGUI 0.7
  • Tolua (just the C lib, not the application) and CEGUILua libraries are no longer in our repository. —> You will need to get these as well when compiling Orxonox
  • And of course lots of new bugs we don't yet know about
  • Property svn:eol-style set to native
File size: 11.1 KB
RevLine 
[1963]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
16#include "btDefaultCollisionConfiguration.h"
17
18#include "BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h"
19#include "BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h"
20#include "BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h"
21#include "BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h"
22#include "BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h"
23#include "BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.h"
24#include "BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h"
25#ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
26#include "BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.h"
27#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
28#include "BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.h"
29#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
30#include "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h"
31#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h"
32
33
34
35#include "LinearMath/btStackAlloc.h"
36#include "LinearMath/btPoolAllocator.h"
37
38
39
40
41
42btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(const btDefaultCollisionConstructionInfo& constructionInfo)
43//btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(btStackAlloc*        stackAlloc,btPoolAllocator*     persistentManifoldPool,btPoolAllocator* collisionAlgorithmPool)
44{
45
46        void* mem = btAlignedAlloc(sizeof(btVoronoiSimplexSolver),16);
47        m_simplexSolver = new (mem)btVoronoiSimplexSolver();
[8351]48
49        if (constructionInfo.m_useEpaPenetrationAlgorithm)
50        {
51                mem = btAlignedAlloc(sizeof(btGjkEpaPenetrationDepthSolver),16);
52                m_pdSolver = new (mem)btGjkEpaPenetrationDepthSolver;
53        }else
54        {
55                mem = btAlignedAlloc(sizeof(btMinkowskiPenetrationDepthSolver),16);
56                m_pdSolver = new (mem)btMinkowskiPenetrationDepthSolver;
57        }
[1963]58       
59        //default CreationFunctions, filling the m_doubleDispatch table
60        mem = btAlignedAlloc(sizeof(btConvexConvexAlgorithm::CreateFunc),16);
61        m_convexConvexCreateFunc = new(mem) btConvexConvexAlgorithm::CreateFunc(m_simplexSolver,m_pdSolver);
62        mem = btAlignedAlloc(sizeof(btConvexConcaveCollisionAlgorithm::CreateFunc),16);
63        m_convexConcaveCreateFunc = new (mem)btConvexConcaveCollisionAlgorithm::CreateFunc;
64        mem = btAlignedAlloc(sizeof(btConvexConcaveCollisionAlgorithm::CreateFunc),16);
65        m_swappedConvexConcaveCreateFunc = new (mem)btConvexConcaveCollisionAlgorithm::SwappedCreateFunc;
66        mem = btAlignedAlloc(sizeof(btCompoundCollisionAlgorithm::CreateFunc),16);
67        m_compoundCreateFunc = new (mem)btCompoundCollisionAlgorithm::CreateFunc;
68        mem = btAlignedAlloc(sizeof(btCompoundCollisionAlgorithm::SwappedCreateFunc),16);
69        m_swappedCompoundCreateFunc = new (mem)btCompoundCollisionAlgorithm::SwappedCreateFunc;
70        mem = btAlignedAlloc(sizeof(btEmptyAlgorithm::CreateFunc),16);
71        m_emptyCreateFunc = new(mem) btEmptyAlgorithm::CreateFunc;
72       
73        mem = btAlignedAlloc(sizeof(btSphereSphereCollisionAlgorithm::CreateFunc),16);
74        m_sphereSphereCF = new(mem) btSphereSphereCollisionAlgorithm::CreateFunc;
75#ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
76        mem = btAlignedAlloc(sizeof(btSphereBoxCollisionAlgorithm::CreateFunc),16);
77        m_sphereBoxCF = new(mem) btSphereBoxCollisionAlgorithm::CreateFunc;
78        mem = btAlignedAlloc(sizeof(btSphereBoxCollisionAlgorithm::CreateFunc),16);
79        m_boxSphereCF = new (mem)btSphereBoxCollisionAlgorithm::CreateFunc;
80        m_boxSphereCF->m_swapped = true;
81#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
82
83        mem = btAlignedAlloc(sizeof(btSphereTriangleCollisionAlgorithm::CreateFunc),16);
84        m_sphereTriangleCF = new (mem)btSphereTriangleCollisionAlgorithm::CreateFunc;
85        mem = btAlignedAlloc(sizeof(btSphereTriangleCollisionAlgorithm::CreateFunc),16);
86        m_triangleSphereCF = new (mem)btSphereTriangleCollisionAlgorithm::CreateFunc;
87        m_triangleSphereCF->m_swapped = true;
88       
89        mem = btAlignedAlloc(sizeof(btBoxBoxCollisionAlgorithm::CreateFunc),16);
90        m_boxBoxCF = new(mem)btBoxBoxCollisionAlgorithm::CreateFunc;
91
92        //convex versus plane
93        mem = btAlignedAlloc (sizeof(btConvexPlaneCollisionAlgorithm::CreateFunc),16);
94        m_convexPlaneCF = new (mem) btConvexPlaneCollisionAlgorithm::CreateFunc;
95        mem = btAlignedAlloc (sizeof(btConvexPlaneCollisionAlgorithm::CreateFunc),16);
96        m_planeConvexCF = new (mem) btConvexPlaneCollisionAlgorithm::CreateFunc;
97        m_planeConvexCF->m_swapped = true;
98       
99        ///calculate maximum element size, big enough to fit any collision algorithm in the memory pool
100        int maxSize = sizeof(btConvexConvexAlgorithm);
101        int maxSize2 = sizeof(btConvexConcaveCollisionAlgorithm);
102        int maxSize3 = sizeof(btCompoundCollisionAlgorithm);
[2430]103        int sl = sizeof(btConvexSeparatingDistanceUtil);
104        sl = sizeof(btGjkPairDetector);
[8351]105        int     collisionAlgorithmMaxElementSize = btMax(maxSize,constructionInfo.m_customCollisionAlgorithmMaxElementSize);
106        collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize2);
[1963]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        {
122                m_ownsPersistentManifoldPool = false;
123                m_persistentManifoldPool = constructionInfo.m_persistentManifoldPool;
124        } else
125        {
126                m_ownsPersistentManifoldPool = true;
127                void* mem = btAlignedAlloc(sizeof(btPoolAllocator),16);
128                m_persistentManifoldPool = new (mem) btPoolAllocator(sizeof(btPersistentManifold),constructionInfo.m_defaultMaxPersistentManifoldPoolSize);
129        }
130       
131        if (constructionInfo.m_collisionAlgorithmPool)
132        {
133                m_ownsCollisionAlgorithmPool = false;
134                m_collisionAlgorithmPool = constructionInfo.m_collisionAlgorithmPool;
135        } else
136        {
137                m_ownsCollisionAlgorithmPool = true;
138                void* mem = btAlignedAlloc(sizeof(btPoolAllocator),16);
139                m_collisionAlgorithmPool = new(mem) btPoolAllocator(collisionAlgorithmMaxElementSize,constructionInfo.m_defaultMaxCollisionAlgorithmPoolSize);
140        }
141
142
143}
144
145btDefaultCollisionConfiguration::~btDefaultCollisionConfiguration()
146{
147        if (m_ownsStackAllocator)
148        {
149                m_stackAlloc->destroy();
150                m_stackAlloc->~btStackAlloc();
151                btAlignedFree(m_stackAlloc);
152        }
153        if (m_ownsCollisionAlgorithmPool)
154        {
155                m_collisionAlgorithmPool->~btPoolAllocator();
156                btAlignedFree(m_collisionAlgorithmPool);
157        }
158        if (m_ownsPersistentManifoldPool)
159        {
160                m_persistentManifoldPool->~btPoolAllocator();
161                btAlignedFree(m_persistentManifoldPool);
162        }
163
164        m_convexConvexCreateFunc->~btCollisionAlgorithmCreateFunc();
165        btAlignedFree(  m_convexConvexCreateFunc);
166
167        m_convexConcaveCreateFunc->~btCollisionAlgorithmCreateFunc();
168        btAlignedFree( m_convexConcaveCreateFunc);
169        m_swappedConvexConcaveCreateFunc->~btCollisionAlgorithmCreateFunc();
170        btAlignedFree( m_swappedConvexConcaveCreateFunc);
171
172        m_compoundCreateFunc->~btCollisionAlgorithmCreateFunc();
173        btAlignedFree( m_compoundCreateFunc);
174
175        m_swappedCompoundCreateFunc->~btCollisionAlgorithmCreateFunc();
176        btAlignedFree( m_swappedCompoundCreateFunc);
177
178        m_emptyCreateFunc->~btCollisionAlgorithmCreateFunc();
179        btAlignedFree( m_emptyCreateFunc);
180
181        m_sphereSphereCF->~btCollisionAlgorithmCreateFunc();
182        btAlignedFree( m_sphereSphereCF);
183
184#ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
185        m_sphereBoxCF->~btCollisionAlgorithmCreateFunc();
186        btAlignedFree( m_sphereBoxCF);
187        m_boxSphereCF->~btCollisionAlgorithmCreateFunc();
188        btAlignedFree( m_boxSphereCF);
189#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
190
191        m_sphereTriangleCF->~btCollisionAlgorithmCreateFunc();
192        btAlignedFree( m_sphereTriangleCF);
193        m_triangleSphereCF->~btCollisionAlgorithmCreateFunc();
194        btAlignedFree( m_triangleSphereCF);
195        m_boxBoxCF->~btCollisionAlgorithmCreateFunc();
196        btAlignedFree( m_boxBoxCF);
197
198        m_convexPlaneCF->~btCollisionAlgorithmCreateFunc();
199        btAlignedFree( m_convexPlaneCF);
200        m_planeConvexCF->~btCollisionAlgorithmCreateFunc();
201        btAlignedFree( m_planeConvexCF);
202
203        m_simplexSolver->~btVoronoiSimplexSolver();
204        btAlignedFree(m_simplexSolver);
205
206        m_pdSolver->~btConvexPenetrationDepthSolver();
207       
208        btAlignedFree(m_pdSolver);
209
210
211}
212
213
214btCollisionAlgorithmCreateFunc* btDefaultCollisionConfiguration::getCollisionAlgorithmCreateFunc(int proxyType0,int proxyType1)
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        {
265                return m_convexConvexCreateFunc;
266        }
267
268        if (btBroadphaseProxy::isConvex(proxyType0) && btBroadphaseProxy::isConcave(proxyType1))
269        {
270                return m_convexConcaveCreateFunc;
271        }
272
273        if (btBroadphaseProxy::isConvex(proxyType1) && btBroadphaseProxy::isConcave(proxyType0))
274        {
275                return m_swappedConvexConcaveCreateFunc;
276        }
277
278        if (btBroadphaseProxy::isCompound(proxyType0))
279        {
280                return m_compoundCreateFunc;
281        } else
282        {
283                if (btBroadphaseProxy::isCompound(proxyType1))
284                {
285                        return m_swappedCompoundCreateFunc;
286                }
287        }
288
289        //failed to find an algorithm
290        return m_emptyCreateFunc;
291}
[2882]292
293void btDefaultCollisionConfiguration::setConvexConvexMultipointIterations(int numPerturbationIterations, int minimumPointsPerturbationThreshold)
294{
295        btConvexConvexAlgorithm::CreateFunc* convexConvex = (btConvexConvexAlgorithm::CreateFunc*) m_convexConvexCreateFunc;
296        convexConvex->m_numPerturbationIterations = numPerturbationIterations;
297        convexConvex->m_minimumPointsPerturbationThreshold = minimumPointsPerturbationThreshold;
298}
Note: See TracBrowser for help on using the repository browser.