btDefaultCollisionConfiguration.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. Bullet Continuous Collision Detection and Physics Library
  3. Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
  4. This software is provided 'as-is', without any express or implied warranty.
  5. In no event will the authors be held liable for any damages arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose,
  7. including commercial applications, and to alter it and redistribute it freely,
  8. subject to the following restrictions:
  9. 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.
  10. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  11. 3. This notice may not be removed or altered from any source distribution.
  12. */
  13. #ifndef BT_DEFAULT_COLLISION_CONFIGURATION
  14. #define BT_DEFAULT_COLLISION_CONFIGURATION
  15. #include "btCollisionConfiguration.h"
  16. class btVoronoiSimplexSolver;
  17. class btConvexPenetrationDepthSolver;
  18. struct btDefaultCollisionConstructionInfo
  19. {
  20. btPoolAllocator* m_persistentManifoldPool;
  21. btPoolAllocator* m_collisionAlgorithmPool;
  22. int m_defaultMaxPersistentManifoldPoolSize;
  23. int m_defaultMaxCollisionAlgorithmPoolSize;
  24. int m_customCollisionAlgorithmMaxElementSize;
  25. int m_useEpaPenetrationAlgorithm;
  26. btDefaultCollisionConstructionInfo()
  27. : m_persistentManifoldPool(0),
  28. m_collisionAlgorithmPool(0),
  29. m_defaultMaxPersistentManifoldPoolSize(4096),
  30. m_defaultMaxCollisionAlgorithmPoolSize(4096),
  31. m_customCollisionAlgorithmMaxElementSize(0),
  32. m_useEpaPenetrationAlgorithm(true)
  33. {
  34. }
  35. };
  36. ///btCollisionConfiguration allows to configure Bullet collision detection
  37. ///stack allocator, pool memory allocators
  38. ///@todo: describe the meaning
  39. class btDefaultCollisionConfiguration : public btCollisionConfiguration
  40. {
  41. protected:
  42. int m_persistentManifoldPoolSize;
  43. btPoolAllocator* m_persistentManifoldPool;
  44. bool m_ownsPersistentManifoldPool;
  45. btPoolAllocator* m_collisionAlgorithmPool;
  46. bool m_ownsCollisionAlgorithmPool;
  47. //default penetration depth solver
  48. btConvexPenetrationDepthSolver* m_pdSolver;
  49. //default CreationFunctions, filling the m_doubleDispatch table
  50. btCollisionAlgorithmCreateFunc* m_convexConvexCreateFunc;
  51. btCollisionAlgorithmCreateFunc* m_convexConcaveCreateFunc;
  52. btCollisionAlgorithmCreateFunc* m_swappedConvexConcaveCreateFunc;
  53. btCollisionAlgorithmCreateFunc* m_compoundCreateFunc;
  54. btCollisionAlgorithmCreateFunc* m_compoundCompoundCreateFunc;
  55. btCollisionAlgorithmCreateFunc* m_swappedCompoundCreateFunc;
  56. btCollisionAlgorithmCreateFunc* m_emptyCreateFunc;
  57. btCollisionAlgorithmCreateFunc* m_sphereSphereCF;
  58. btCollisionAlgorithmCreateFunc* m_sphereBoxCF;
  59. btCollisionAlgorithmCreateFunc* m_boxSphereCF;
  60. btCollisionAlgorithmCreateFunc* m_boxBoxCF;
  61. btCollisionAlgorithmCreateFunc* m_sphereTriangleCF;
  62. btCollisionAlgorithmCreateFunc* m_triangleSphereCF;
  63. btCollisionAlgorithmCreateFunc* m_planeConvexCF;
  64. btCollisionAlgorithmCreateFunc* m_convexPlaneCF;
  65. public:
  66. btDefaultCollisionConfiguration(const btDefaultCollisionConstructionInfo& constructionInfo = btDefaultCollisionConstructionInfo());
  67. virtual ~btDefaultCollisionConfiguration();
  68. ///memory pools
  69. virtual btPoolAllocator* getPersistentManifoldPool()
  70. {
  71. return m_persistentManifoldPool;
  72. }
  73. virtual btPoolAllocator* getCollisionAlgorithmPool()
  74. {
  75. return m_collisionAlgorithmPool;
  76. }
  77. virtual btCollisionAlgorithmCreateFunc* getCollisionAlgorithmCreateFunc(int proxyType0, int proxyType1);
  78. virtual btCollisionAlgorithmCreateFunc* getClosestPointsAlgorithmCreateFunc(int proxyType0, int proxyType1);
  79. ///Use this method to allow to generate multiple contact points between at once, between two objects using the generic convex-convex algorithm.
  80. ///By default, this feature is disabled for best performance.
  81. ///@param numPerturbationIterations controls the number of collision queries. Set it to zero to disable the feature.
  82. ///@param minimumPointsPerturbationThreshold is the minimum number of points in the contact cache, above which the feature is disabled
  83. ///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.
  84. ///See Bullet/Demos/CollisionDemo for an example how this feature gathers multiple points.
  85. ///@todo we could add a per-object setting of those parameters, for level-of-detail collision detection.
  86. void setConvexConvexMultipointIterations(int numPerturbationIterations = 3, int minimumPointsPerturbationThreshold = 3);
  87. void setPlaneConvexMultipointIterations(int numPerturbationIterations = 3, int minimumPointsPerturbationThreshold = 3);
  88. };
  89. #endif //BT_DEFAULT_COLLISION_CONFIGURATION