Logo Search packages:      
Sourcecode: blender version File versions  Download package

btDefaultCollisionConfiguration::btDefaultCollisionConfiguration ( const btDefaultCollisionConstructionInfo &  constructionInfo = btDefaultCollisionConstructionInfo()  ) 

calculate maximum element size, big enough to fit any collision algorithm in the memory pool

Definition at line 42 of file btDefaultCollisionConfiguration.cpp.

References btCollisionAlgorithmCreateFunc::m_swapped.

{

      void* mem = btAlignedAlloc(sizeof(btVoronoiSimplexSolver),16);
      m_simplexSolver = new (mem)btVoronoiSimplexSolver();
      
#define USE_EPA 1
#ifdef USE_EPA
      mem = btAlignedAlloc(sizeof(btGjkEpaPenetrationDepthSolver),16);
      m_pdSolver = new (mem)btGjkEpaPenetrationDepthSolver;
#else
      mem = btAlignedAlloc(sizeof(btMinkowskiPenetrationDepthSolver),16);
      m_pdSolver = new (mem)btMinkowskiPenetrationDepthSolver;
#endif//USE_EPA   
      

      //default CreationFunctions, filling the m_doubleDispatch table
      mem = btAlignedAlloc(sizeof(btConvexConvexAlgorithm::CreateFunc),16);
      m_convexConvexCreateFunc = new(mem) btConvexConvexAlgorithm::CreateFunc(m_simplexSolver,m_pdSolver);
      mem = btAlignedAlloc(sizeof(btConvexConcaveCollisionAlgorithm::CreateFunc),16);
      m_convexConcaveCreateFunc = new (mem)btConvexConcaveCollisionAlgorithm::CreateFunc;
      mem = btAlignedAlloc(sizeof(btConvexConcaveCollisionAlgorithm::CreateFunc),16);
      m_swappedConvexConcaveCreateFunc = new (mem)btConvexConcaveCollisionAlgorithm::SwappedCreateFunc;
      mem = btAlignedAlloc(sizeof(btCompoundCollisionAlgorithm::CreateFunc),16);
      m_compoundCreateFunc = new (mem)btCompoundCollisionAlgorithm::CreateFunc;
      mem = btAlignedAlloc(sizeof(btCompoundCollisionAlgorithm::SwappedCreateFunc),16);
      m_swappedCompoundCreateFunc = new (mem)btCompoundCollisionAlgorithm::SwappedCreateFunc;
      mem = btAlignedAlloc(sizeof(btEmptyAlgorithm::CreateFunc),16);
      m_emptyCreateFunc = new(mem) btEmptyAlgorithm::CreateFunc;
      
      mem = btAlignedAlloc(sizeof(btSphereSphereCollisionAlgorithm::CreateFunc),16);
      m_sphereSphereCF = new(mem) btSphereSphereCollisionAlgorithm::CreateFunc;
#ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
      mem = btAlignedAlloc(sizeof(btSphereBoxCollisionAlgorithm::CreateFunc),16);
      m_sphereBoxCF = new(mem) btSphereBoxCollisionAlgorithm::CreateFunc;
      mem = btAlignedAlloc(sizeof(btSphereBoxCollisionAlgorithm::CreateFunc),16);
      m_boxSphereCF = new (mem)btSphereBoxCollisionAlgorithm::CreateFunc;
      m_boxSphereCF->m_swapped = true;
#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM

      mem = btAlignedAlloc(sizeof(btSphereTriangleCollisionAlgorithm::CreateFunc),16);
      m_sphereTriangleCF = new (mem)btSphereTriangleCollisionAlgorithm::CreateFunc;
      mem = btAlignedAlloc(sizeof(btSphereTriangleCollisionAlgorithm::CreateFunc),16);
      m_triangleSphereCF = new (mem)btSphereTriangleCollisionAlgorithm::CreateFunc;
      m_triangleSphereCF->m_swapped = true;
      
      mem = btAlignedAlloc(sizeof(btBoxBoxCollisionAlgorithm::CreateFunc),16);
      m_boxBoxCF = new(mem)btBoxBoxCollisionAlgorithm::CreateFunc;

      //convex versus plane
      mem = btAlignedAlloc (sizeof(btConvexPlaneCollisionAlgorithm::CreateFunc),16);
      m_convexPlaneCF = new (mem) btConvexPlaneCollisionAlgorithm::CreateFunc;
      mem = btAlignedAlloc (sizeof(btConvexPlaneCollisionAlgorithm::CreateFunc),16);
      m_planeConvexCF = new (mem) btConvexPlaneCollisionAlgorithm::CreateFunc;
      m_planeConvexCF->m_swapped = true;
      
      ///calculate maximum element size, big enough to fit any collision algorithm in the memory pool
      int maxSize = sizeof(btConvexConvexAlgorithm);
      int maxSize2 = sizeof(btConvexConcaveCollisionAlgorithm);
      int maxSize3 = sizeof(btCompoundCollisionAlgorithm);
      int sl = sizeof(btConvexSeparatingDistanceUtil);
      sl = sizeof(btGjkPairDetector);
      int   collisionAlgorithmMaxElementSize = btMax(maxSize,maxSize2);
      collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize3);

      if (constructionInfo.m_stackAlloc)
      {
            m_ownsStackAllocator = false;
            this->m_stackAlloc = constructionInfo.m_stackAlloc;
      } else
      {
            m_ownsStackAllocator = true;
            void* mem = btAlignedAlloc(sizeof(btStackAlloc),16);
            m_stackAlloc = new(mem)btStackAlloc(constructionInfo.m_defaultStackAllocatorSize);
      }
            
      if (constructionInfo.m_persistentManifoldPool)
      {
            m_ownsPersistentManifoldPool = false;
            m_persistentManifoldPool = constructionInfo.m_persistentManifoldPool;
      } else
      {
            m_ownsPersistentManifoldPool = true;
            void* mem = btAlignedAlloc(sizeof(btPoolAllocator),16);
            m_persistentManifoldPool = new (mem) btPoolAllocator(sizeof(btPersistentManifold),constructionInfo.m_defaultMaxPersistentManifoldPoolSize);
      }
      
      if (constructionInfo.m_collisionAlgorithmPool)
      {
            m_ownsCollisionAlgorithmPool = false;
            m_collisionAlgorithmPool = constructionInfo.m_collisionAlgorithmPool;
      } else
      {
            m_ownsCollisionAlgorithmPool = true;
            void* mem = btAlignedAlloc(sizeof(btPoolAllocator),16);
            m_collisionAlgorithmPool = new(mem) btPoolAllocator(collisionAlgorithmMaxElementSize,constructionInfo.m_defaultMaxCollisionAlgorithmPoolSize);
      }


}


Generated by  Doxygen 1.6.0   Back to index