Home | History | Annotate | Download | only in CollisionDispatch
      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 
     16 #ifndef BT_DEFAULT_COLLISION_CONFIGURATION
     17 #define BT_DEFAULT_COLLISION_CONFIGURATION
     18 
     19 #include "btCollisionConfiguration.h"
     20 class btVoronoiSimplexSolver;
     21 class btConvexPenetrationDepthSolver;
     22 
     23 struct	btDefaultCollisionConstructionInfo
     24 {
     25 	btPoolAllocator*	m_persistentManifoldPool;
     26 	btPoolAllocator*	m_collisionAlgorithmPool;
     27 	int					m_defaultMaxPersistentManifoldPoolSize;
     28 	int					m_defaultMaxCollisionAlgorithmPoolSize;
     29 	int					m_customCollisionAlgorithmMaxElementSize;
     30 	int					m_useEpaPenetrationAlgorithm;
     31 
     32 	btDefaultCollisionConstructionInfo()
     33 		:m_persistentManifoldPool(0),
     34 		m_collisionAlgorithmPool(0),
     35 		m_defaultMaxPersistentManifoldPoolSize(4096),
     36 		m_defaultMaxCollisionAlgorithmPoolSize(4096),
     37 		m_customCollisionAlgorithmMaxElementSize(0),
     38 		m_useEpaPenetrationAlgorithm(true)
     39 	{
     40 	}
     41 };
     42 
     43 
     44 
     45 ///btCollisionConfiguration allows to configure Bullet collision detection
     46 ///stack allocator, pool memory allocators
     47 ///@todo: describe the meaning
     48 class	btDefaultCollisionConfiguration : public btCollisionConfiguration
     49 {
     50 
     51 protected:
     52 
     53 	int	m_persistentManifoldPoolSize;
     54 
     55 
     56 	btPoolAllocator*	m_persistentManifoldPool;
     57 	bool	m_ownsPersistentManifoldPool;
     58 
     59 
     60 	btPoolAllocator*	m_collisionAlgorithmPool;
     61 	bool	m_ownsCollisionAlgorithmPool;
     62 
     63 	//default simplex/penetration depth solvers
     64 	btVoronoiSimplexSolver*	m_simplexSolver;
     65 	btConvexPenetrationDepthSolver*	m_pdSolver;
     66 
     67 	//default CreationFunctions, filling the m_doubleDispatch table
     68 	btCollisionAlgorithmCreateFunc*	m_convexConvexCreateFunc;
     69 	btCollisionAlgorithmCreateFunc*	m_convexConcaveCreateFunc;
     70 	btCollisionAlgorithmCreateFunc*	m_swappedConvexConcaveCreateFunc;
     71 	btCollisionAlgorithmCreateFunc*	m_compoundCreateFunc;
     72 	btCollisionAlgorithmCreateFunc*	m_compoundCompoundCreateFunc;
     73 
     74 	btCollisionAlgorithmCreateFunc*	m_swappedCompoundCreateFunc;
     75 	btCollisionAlgorithmCreateFunc* m_emptyCreateFunc;
     76 	btCollisionAlgorithmCreateFunc* m_sphereSphereCF;
     77 	btCollisionAlgorithmCreateFunc* m_sphereBoxCF;
     78 	btCollisionAlgorithmCreateFunc* m_boxSphereCF;
     79 
     80 	btCollisionAlgorithmCreateFunc* m_boxBoxCF;
     81 	btCollisionAlgorithmCreateFunc*	m_sphereTriangleCF;
     82 	btCollisionAlgorithmCreateFunc*	m_triangleSphereCF;
     83 	btCollisionAlgorithmCreateFunc*	m_planeConvexCF;
     84 	btCollisionAlgorithmCreateFunc*	m_convexPlaneCF;
     85 
     86 public:
     87 
     88 
     89 	btDefaultCollisionConfiguration(const btDefaultCollisionConstructionInfo& constructionInfo = btDefaultCollisionConstructionInfo());
     90 
     91 	virtual ~btDefaultCollisionConfiguration();
     92 
     93 		///memory pools
     94 	virtual btPoolAllocator* getPersistentManifoldPool()
     95 	{
     96 		return m_persistentManifoldPool;
     97 	}
     98 
     99 	virtual btPoolAllocator* getCollisionAlgorithmPool()
    100 	{
    101 		return m_collisionAlgorithmPool;
    102 	}
    103 
    104 
    105 	virtual	btVoronoiSimplexSolver*	getSimplexSolver()
    106 	{
    107 		return m_simplexSolver;
    108 	}
    109 
    110 
    111 	virtual btCollisionAlgorithmCreateFunc* getCollisionAlgorithmCreateFunc(int proxyType0,int proxyType1);
    112 
    113 	///Use this method to allow to generate multiple contact points between at once, between two objects using the generic convex-convex algorithm.
    114 	///By default, this feature is disabled for best performance.
    115 	///@param numPerturbationIterations controls the number of collision queries. Set it to zero to disable the feature.
    116 	///@param minimumPointsPerturbationThreshold is the minimum number of points in the contact cache, above which the feature is disabled
    117 	///3 is a good value for both params, if you want to enable the feature. This is because the default contact cache contains a maximum of 4 points, and one collision query at the unperturbed orientation is performed first.
    118 	///See Bullet/Demos/CollisionDemo for an example how this feature gathers multiple points.
    119 	///@todo we could add a per-object setting of those parameters, for level-of-detail collision detection.
    120 	void	setConvexConvexMultipointIterations(int numPerturbationIterations=3, int minimumPointsPerturbationThreshold = 3);
    121 
    122 	void	setPlaneConvexMultipointIterations(int numPerturbationIterations=3, int minimumPointsPerturbationThreshold = 3);
    123 
    124 };
    125 
    126 #endif //BT_DEFAULT_COLLISION_CONFIGURATION
    127 
    128