当前位置: 首页>>代码示例>>C#>>正文


C# DefaultCollisionConfiguration.GetCollisionAlgorithmCreateFunc方法代码示例

本文整理汇总了C#中BulletSharp.DefaultCollisionConfiguration.GetCollisionAlgorithmCreateFunc方法的典型用法代码示例。如果您正苦于以下问题:C# DefaultCollisionConfiguration.GetCollisionAlgorithmCreateFunc方法的具体用法?C# DefaultCollisionConfiguration.GetCollisionAlgorithmCreateFunc怎么用?C# DefaultCollisionConfiguration.GetCollisionAlgorithmCreateFunc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BulletSharp.DefaultCollisionConfiguration的用法示例。


在下文中一共展示了DefaultCollisionConfiguration.GetCollisionAlgorithmCreateFunc方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        public override void Run()
        {
            var conf = new DefaultCollisionConfiguration();

            // Test CollisionConfiguration methods
            var pool = conf.CollisionAlgorithmPool;
            AddToDisposeQueue(pool);
            pool = conf.PersistentManifoldPool;
            AddToDisposeQueue(pool);
            pool = null;
            var simplexSolver = conf.SimplexSolver;
            //var simplexResult = simplexSolver.CachedBC;
            //AddToDisposeQueue(simplexResult);
            //simplexResult = null;
            AddToDisposeQueue(simplexSolver);
            simplexSolver = null;
            var createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.BoxShape, BroadphaseNativeType.BoxShape);
            if (!(createFunc is BoxBoxCollisionAlgorithm.CreateFunc))
            {
                Console.WriteLine("BoxBoxCollisionAlgorithm ERROR!");
            }
            AddToDisposeQueue(createFunc);
            createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.SphereShape, BroadphaseNativeType.SphereShape);
            if (!(createFunc is SphereSphereCollisionAlgorithm.CreateFunc))
            {
                Console.WriteLine("SphereSphereCollisionAlgorithm ERROR!");
            }
            AddToDisposeQueue(createFunc);
            createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.SphereShape, BroadphaseNativeType.TriangleShape);
            if (!(createFunc is SphereTriangleCollisionAlgorithm.CreateFunc))
            {
                Console.WriteLine("SphereTriangleCollisionAlgorithm ERROR!");
            }
            AddToDisposeQueue(createFunc);
            createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.TriangleShape, BroadphaseNativeType.SphereShape);
            if (!(createFunc is SphereTriangleCollisionAlgorithm.CreateFunc))
            {
                Console.WriteLine("SphereTriangleCollisionAlgorithm ERROR!");
            }
            AddToDisposeQueue(createFunc);
            createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.BoxShape, BroadphaseNativeType.StaticPlaneShape);
            if (!(createFunc is ConvexPlaneCollisionAlgorithm.CreateFunc))
            {
                Console.WriteLine("ConvexPlaneCollisionAlgorithm ERROR!");
            }
            AddToDisposeQueue(createFunc);
            createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.StaticPlaneShape, BroadphaseNativeType.BoxShape);
            if (!(createFunc is ConvexPlaneCollisionAlgorithm.CreateFunc))
            {
                Console.WriteLine("ConvexPlaneCollisionAlgorithm ERROR!");
            }
            AddToDisposeQueue(createFunc);
            createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.CylinderShape, BroadphaseNativeType.CylinderShape);
            if (!(createFunc is ConvexConvexAlgorithm.CreateFunc))
            {
                Console.WriteLine("ConvexConvexAlgorithm ERROR!");
            }
            AddToDisposeQueue(createFunc);
            createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.CylinderShape, BroadphaseNativeType.TerrainShape);
            if (!(createFunc is ConvexConcaveCollisionAlgorithm.CreateFunc))
            {
                Console.WriteLine("ConvexConcaveCollisionAlgorithm ERROR!");
            }
            AddToDisposeQueue(createFunc);
            createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.TerrainShape, BroadphaseNativeType.CylinderShape);
            if (!(createFunc is ConvexConcaveCollisionAlgorithm.SwappedCreateFunc))
            {
                Console.WriteLine("ConvexConcaveCollisionAlgorithm ERROR!");
            }
            AddToDisposeQueue(createFunc);
            createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.CompoundShape, BroadphaseNativeType.CompoundShape);
            if (!(createFunc is CompoundCompoundCollisionAlgorithm.CreateFunc))
            {
                Console.WriteLine("CompoundCompoundCollisionAlgorithm ERROR!");
            }
            AddToDisposeQueue(createFunc);
            createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.CompoundShape, BroadphaseNativeType.BoxShape);
            if (!(createFunc is CompoundCompoundCollisionAlgorithm.CreateFunc))
            {
                Console.WriteLine("CompoundCompoundCollisionAlgorithm ERROR!");
            }
            AddToDisposeQueue(createFunc);
            createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.BoxShape, BroadphaseNativeType.CompoundShape);
            if (!(createFunc is CompoundCompoundCollisionAlgorithm.SwappedCreateFunc))
            {
                Console.WriteLine("CompoundCompoundCollisionAlgorithm ERROR!");
            }
            AddToDisposeQueue(createFunc);
            createFunc = null;
            conf = null;

            ForceGC();
            TestWeakRefs();
            ClearRefs();
        }
开发者ID:RainsSoft,项目名称:BulletSharp,代码行数:95,代码来源:CollisionAlgorithmTests.cs

示例2: Run

        public override void Run()
        {
            var conf = new DefaultCollisionConfiguration();

            // Test CollisionConfiguration methods
            var pool = conf.CollisionAlgorithmPool;
            AddToDisposeQueue(pool);
            pool = conf.PersistentManifoldPool;
            AddToDisposeQueue(pool);
            pool = null;
            var simplexSolver = conf.SimplexSolver;
            //var simplexResult = simplexSolver.CachedBC;
            //AddToDisposeQueue(simplexResult);
            //simplexResult = null;
            AddToDisposeQueue(simplexSolver);
            simplexSolver = null;
            var createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.BoxShape, BroadphaseNativeType.BoxShape);
            AddToDisposeQueue(createFunc);
            createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.SphereShape, BroadphaseNativeType.SphereShape);
            AddToDisposeQueue(createFunc);
            createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.SphereShape, BroadphaseNativeType.TriangleShape);
            AddToDisposeQueue(createFunc);
            createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.TriangleShape, BroadphaseNativeType.SphereShape);
            AddToDisposeQueue(createFunc);
            createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.BoxShape, BroadphaseNativeType.StaticPlaneShape);
            AddToDisposeQueue(createFunc);
            createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.StaticPlaneShape, BroadphaseNativeType.BoxShape);
            AddToDisposeQueue(createFunc);
            createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.CylinderShape, BroadphaseNativeType.CylinderShape);
            AddToDisposeQueue(createFunc);
            createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.CylinderShape, BroadphaseNativeType.TerrainShape);
            AddToDisposeQueue(createFunc);
            createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.TerrainShape, BroadphaseNativeType.CylinderShape);
            AddToDisposeQueue(createFunc);
            createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.CompoundShape, BroadphaseNativeType.CompoundShape);
            AddToDisposeQueue(createFunc);
            createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.CompoundShape, BroadphaseNativeType.BoxShape);
            AddToDisposeQueue(createFunc);
            createFunc = conf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.BoxShape, BroadphaseNativeType.CompoundShape);
            AddToDisposeQueue(createFunc);
            createFunc = null;
            conf = null;

            ForceGC();
            TestWeakRefs();
            ClearRefs();
        }
开发者ID:jdoyle1983,项目名称:BulletSharp,代码行数:47,代码来源:CollisionAlgorithmTests.cs

示例3: InitPhysics

        public override void InitPhysics()
        {
            int i;

            shootBoxInitialSpeed = 4000;

            // collision configuration contains default setup for memory, collision setup
            CollisionConf = new DefaultCollisionConfiguration();

            Dispatcher = new CollisionDispatcher(CollisionConf);
            Dispatcher.RegisterCollisionCreateFunc(BroadphaseNativeType.BoxShape, BroadphaseNativeType.BoxShape,
                CollisionConf.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.ConvexShape, BroadphaseNativeType.ConvexShape));

            Broadphase = new DbvtBroadphase();


            // the default constraint solver.
            Solver = new SequentialImpulseConstraintSolver();

            World = new DiscreteDynamicsWorld(Dispatcher, Broadphase, Solver, CollisionConf);
            World.SolverInfo.SplitImpulse = 1;
            World.SolverInfo.NumIterations = 20;

            World.DispatchInfo.UseContinuous = ccdMode;

            World.Gravity = new Vector3(0, -10, 0);

            BoxShape ground = new BoxShape(200, 1, 200);
//            ground.InitializePolyhedralFeatures();
            CollisionShapes.Add(ground);
            RigidBody body = LocalCreateRigidBody(0, Matrix.Identity, ground);
            body.UserObject = "Ground";

            CollisionShape shape = new CylinderShape(CubeHalfExtents, CubeHalfExtents, CubeHalfExtents);
            CollisionShapes.Add(shape);

            int numObjects = 120;
            for (i = 0; i < numObjects; i++)
            {
                //stack them
                int colsize = 10;
                int row = (int)((i * CubeHalfExtents * 2) / (colsize * 2 * CubeHalfExtents));
                int row2 = row;
                int col = (i) % (colsize) - colsize / 2;

                if (col > 3)
                {
                    col = 11;
                    row2 |= 1;
                }

                Matrix trans = Matrix.Translation(col * 2 * CubeHalfExtents + (row2 % 2) * CubeHalfExtents,
                    row * 2 * CubeHalfExtents + CubeHalfExtents + ExtraHeight, 0);

                body = LocalCreateRigidBody(1, trans, shape);

                if (ccdMode)
                {
                    body.CcdMotionThreshold = CubeHalfExtents;
                    body.CcdSweptSphereRadius = 0.9f * CubeHalfExtents;
                }
            }
        }
开发者ID:rhynodegreat,项目名称:BulletSharp,代码行数:63,代码来源:Physics.cs

示例4: CreateWorld

        /// <summary>
        /// Creates the world
        /// </summary>
        void CreateWorld(string levelName)
        {
            Launch.Log("[PhysicsMain] Creating new world...");
            // have to make more of these every level because disposing the world apparently disposes of them too.
            broadphase = new DbvtBroadphase();
            solver = new SequentialImpulseConstraintSolver();
            dcc = new DefaultCollisionConfiguration();
            dispatcher = new CollisionDispatcher(dcc);
            // set up this stuff... not quite sure what it's for, but you need it if you want the CCD to work for the karts
            dispatcher.RegisterCollisionCreateFunc(BroadphaseNativeType.ConvexHullShape, BroadphaseNativeType.ConvexHullShape,
                dcc.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.TriangleMeshShape, BroadphaseNativeType.TriangleMeshShape));
            dispatcher.RegisterCollisionCreateFunc(BroadphaseNativeType.ConvexHullShape, BroadphaseNativeType.ConvexHullShape,
                dcc.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.ConvexHullShape, BroadphaseNativeType.ConvexHullShape));

            world = new DiscreteDynamicsWorld(dispatcher, broadphase, solver, dcc);
            // and then turn on CCD
            world.DispatchInfo.UseContinuous = true;

            world.Gravity = new Vector3(0, Settings.Default.Gravity, 0);

            ManifoldPoint.ContactAddedCallback = ContactAdded;
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:25,代码来源:PhysicsMain.cs


注:本文中的BulletSharp.DefaultCollisionConfiguration.GetCollisionAlgorithmCreateFunc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。