Exemplo n.º 1
0
        /// <summary>
        /// 初期化関数
        /// </summary>
        /// <param name="constructionInfo">初期化用構造体</param>
        private void Constructor(DefaultCollisionConstructionInfo constructionInfo)
        {

            m_simplexSolver = new VoronoiSimplexSolver();

            if (constructionInfo.m_useEpaPenetrationAlgorithm)
            {
                m_pdSolver = new GjkEpaPenetrationDepthSolver();
            }
            else
            {
                m_pdSolver = new MinkowskiPenetrationDepthSolver();
            }

            //default CreationFunctions, filling the m_doubleDispatch table
            m_convexConvexCreateFunc = new ConvexConvexAlgorithm.CreateFunc(m_simplexSolver, m_pdSolver);
            m_convexConcaveCreateFunc = new ConvexConcaveCollisionAlgorithm.CreateFunc();
            m_swappedConvexConcaveCreateFunc = new ConvexConcaveCollisionAlgorithm.SwappedCreateFunc();
            m_compoundCreateFunc = new CompoundCollisionAlgorithm.CreateFunc();
            m_swappedCompoundCreateFunc = new CompoundCollisionAlgorithm.SwappedCreateFunc();
            m_emptyCreateFunc = new EmptyAlgorithm.CreateFunc();

            m_sphereSphereCF = new SphereSphereCollisionAlgorithm.CreateFunc();
#if USE_BUGGY_SPHERE_BOX_ALGORITHM
            //この中は移植作業を行ってない。
	        m_sphereBoxCF = new SphereBoxCollisionAlgorithm.CreateFunc();
	        m_boxSphereCF = new SphereBoxCollisionAlgorithm.CreateFunc();
	        m_boxSphereCF.m_swapped = true;
#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM

            m_sphereTriangleCF = new SphereTriangleCollisionAlgorithm.CreateFunc();
            m_triangleSphereCF = new SphereTriangleCollisionAlgorithm.CreateFunc();
            m_triangleSphereCF.m_swapped = true;

            m_boxBoxCF = new BoxBoxCollisionAlgorithm.CreateFunc();

            //convex versus plane
            m_convexPlaneCF = new ConvexPlaneCollisionAlgorithm.CreateFunc();
            m_planeConvexCF = new ConvexPlaneCollisionAlgorithm.CreateFunc();
            m_planeConvexCF.m_swapped = true;
#if false//未使用らしきメンバ変数の初期化作業
	        ///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,constructionInfo.m_customCollisionAlgorithmMaxElementSize);
	        collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,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);
	        }
#endif
        }
Exemplo n.º 2
0
 ///registerCollisionCreateFunc allows registration of custom/alternative collision create functions
 void registerCollisionCreateFunc(int proxyType0, int proxyType1, CollisionAlgorithmCreateFunc createFunc)
 {
     m_doubleDispatch[proxyType0, proxyType1] = createFunc;
 }