コード例 #1
0
		// pass null to use default construction info
		public btDefaultCollisionConfiguration( btDefaultCollisionConstructionInfo constructionInfo )
		//btDefaultCollisionConfiguration(btStackAlloc*	stackAlloc,btPoolAllocator*	persistentManifoldPool,btPoolAllocator*	collisionAlgorithmPool)
		{
			if( constructionInfo == null )
				constructionInfo = new btDefaultCollisionConstructionInfo();

			m_simplexSolver = BulletGlobals.VoronoiSimplexSolverPool.Get();

#if !REMOVE_OBSOLETE_SOLVER
			if( constructionInfo.m_useEpaPenetrationAlgorithm )
#endif
			{
				m_pdSolver = BulletGlobals.GjkEpaPenetrationDepthSolverPool.Get();
			}
#if !REMOVE_OBSOLETE_SOLVER
			else
			{
				mem = btAlignedAlloc( sizeof( btMinkowskiPenetrationDepthSolver ), 16 );
				m_pdSolver = 
					new btMinkowskiPenetrationDepthSolver;
			}
#endif

			//default CreationFunctions, filling the m_doubleDispatch table
			m_convexConvexCreateFunc = new btConvexConvexAlgorithm.CreateFunc( m_simplexSolver, m_pdSolver );
			m_convexConcaveCreateFunc = new btConvexConcaveCollisionAlgorithm.CreateFunc();
			m_swappedConvexConcaveCreateFunc = new btConvexConcaveCollisionAlgorithm.SwappedCreateFunc();
			m_compoundCreateFunc = new btCompoundCollisionAlgorithm.CreateFunc();

			m_compoundCompoundCreateFunc = new btCompoundCompoundCollisionAlgorithm.CreateFunc();

			m_swappedCompoundCreateFunc = new btCompoundCollisionAlgorithm.SwappedCreateFunc();
			m_emptyCreateFunc = new btEmptyAlgorithm.CreateFunc();

			m_sphereSphereCF = new btSphereSphereCollisionAlgorithm.CreateFunc();
#if USE_BUGGY_SPHERE_BOX_ALGORITHM
			m_sphereBoxCF = new(mem) btSphereBoxCollisionAlgorithm.CreateFunc;
			m_boxSphereCF = new (mem)btSphereBoxCollisionAlgorithm.CreateFunc;
			m_boxSphereCF.m_swapped = true;
#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM

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

			m_boxBoxCF = new btBoxBoxCollisionAlgorithm.CreateFunc();

			//convex versus plane
			m_convexPlaneCF = new  btConvexPlaneCollisionAlgorithm.CreateFunc();
			m_planeConvexCF = new  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 maxSize4 = sizeof( btCompoundCompoundCollisionAlgorithm );

			int collisionAlgorithmMaxElementSize = btScalar.btMax( maxSize, constructionInfo.m_customCollisionAlgorithmMaxElementSize );
			collisionAlgorithmMaxElementSize = btScalar.btMax( collisionAlgorithmMaxElementSize, maxSize2 );
			collisionAlgorithmMaxElementSize = btScalar.btMax( collisionAlgorithmMaxElementSize, maxSize3 );
			collisionAlgorithmMaxElementSize = btScalar.btMax( collisionAlgorithmMaxElementSize, maxSize4 );
			*/

			/*
			if( constructionInfo.m_persistentManifoldPool )
			{
				m_ownsPersistentManifoldPool = false;
				m_persistentManifoldPool = constructionInfo.m_persistentManifoldPool;
			}
			else
			{
				m_ownsPersistentManifoldPool = true;
				object mem = btAlignedAlloc( sizeof( btPoolAllocator ), 16 );
				m_persistentManifoldPool = new  btPoolAllocator( sizeof( btPersistentManifold ), constructionInfo.m_defaultMaxPersistentManifoldPoolSize );
			}

			if( constructionInfo.m_collisionAlgorithmPool )
			{
				m_ownsCollisionAlgorithmPool = false;
				m_collisionAlgorithmPool = constructionInfo.m_collisionAlgorithmPool;
			}
			else
			{
				m_ownsCollisionAlgorithmPool = true;
				object mem = btAlignedAlloc( sizeof( btPoolAllocator ), 16 );
				m_collisionAlgorithmPool = new btPoolAllocator( collisionAlgorithmMaxElementSize, constructionInfo.m_defaultMaxCollisionAlgorithmPoolSize );
			}
			*/

		}
コード例 #2
0
ファイル: RaycastCallback.cs プロジェクト: d3x0r/Voxelarium
		public void processTriangle( btVector3[] triangle, int partId, int triangleIndex )
		{
			using( btTriangleShape triangleShape = BulletGlobals.TriangleShapePool.Get() )
			{
				triangleShape.Initialize( ref triangle[0], ref triangle[1], ref triangle[2] );
				triangleShape.setMargin( m_triangleCollisionMargin );

				btVoronoiSimplexSolver simplexSolver = new btVoronoiSimplexSolver();
				btGjkEpaPenetrationDepthSolver gjkEpaPenetrationSolver = new btGjkEpaPenetrationDepthSolver();

				//#define  USE_SUBSIMPLEX_CONVEX_CAST 1
				//if you reenable USE_SUBSIMPLEX_CONVEX_CAST see commented out code below
#if USE_SUBSIMPLEX_CONVEX_CAST
	btSubsimplexConvexCast convexCaster(m_convexShape, &triangleShape, &simplexSolver);
#else
				//btGjkConvexCast	convexCaster(m_convexShape,&triangleShape,&simplexSolver);
				btContinuousConvexCollision convexCaster = BulletGlobals.ContinuousConvexCollisionPool.Get();
				convexCaster.Initialize( m_convexShape, triangleShape, simplexSolver, gjkEpaPenetrationSolver );
#endif //#USE_SUBSIMPLEX_CONVEX_CAST

				btConvexCast.CastResult castResult = BulletGlobals.CastResultPool.Get();
				castResult.Initialize();
				castResult.m_fraction = btScalar.BT_ONE;
				castResult.m_allowedPenetration = m_allowedPenetration;
				if( convexCaster.calcTimeOfImpact( ref m_convexShapeFrom, ref m_convexShapeTo,ref m_triangleToWorld, ref m_triangleToWorld, castResult ) )
				{
					//add hit
					if( castResult.m_normal.length2() > (double)( 0.0001 ) )
					{
						if( castResult.m_fraction < m_hitFraction )
						{
							/* btContinuousConvexCast's normal is already in world space */
							/*
							#if USE_SUBSIMPLEX_CONVEX_CAST
											//rotate normal into worldspace
											castResult.m_normal = m_convexShapeFrom.getBasis() * castResult.m_normal;
							#endif //USE_SUBSIMPLEX_CONVEX_CAST
							*/
							castResult.m_normal.normalize();

							reportHit( ref castResult.m_normal,
										ref castResult.m_hitPoint,
										castResult.m_fraction,
										partId,
										triangleIndex );
						}
					}
				}
				BulletGlobals.CastResultPool.Free( castResult );
				BulletGlobals.ContinuousConvexCollisionPool.Free( convexCaster );
			}
		}