Exemplo n.º 1
0
        public Physics()
        {
            CLStuff.InitCL();

            cloths = new Cloth[numFlags];
            for (int flagIndex = 0; flagIndex < numFlags; ++flagIndex)
            {
                cloths[flagIndex] = new Cloth();
                cloths[flagIndex].CreateBuffers(clothWidth, clothHeight);
            }


            gSolver        = new OpenCLSoftBodySolver(CLStuff.commandQueue, CLStuff.cxMainContext);
            softBodyOutput = new SoftBodySolverOutputCLToCpu();

            // collision configuration contains default setup for memory, collision setup
            CollisionConf = new SoftBodyRigidBodyCollisionConfiguration();
            Dispatcher    = new CollisionDispatcher(CollisionConf);

            Broadphase = new DbvtBroadphase();
            Solver     = new SequentialImpulseConstraintSolver();

            World         = new SoftRigidDynamicsWorld(Dispatcher, Broadphase, Solver, CollisionConf, gSolver);
            World.Gravity = new Vector3(0, -10, 0);

            // create the ground
            CollisionShape groundShape = new BoxShape(50, 50, 50);

            CollisionShapes.Add(groundShape);
            CollisionObject ground = LocalCreateRigidBody(0, Matrix.Translation(0, -60, 0), groundShape);

            ground.UserObject = "Ground";


            SoftWorld.WorldInfo.AirDensity   = 1.2f;
            SoftWorld.WorldInfo.WaterDensity = 0;
            SoftWorld.WorldInfo.WaterOffset  = 0;
            SoftWorld.WorldInfo.WaterNormal  = Vector3.Zero;
            SoftWorld.WorldInfo.Gravity      = new Vector3(0, -10, 0);


            CreateFlag(clothWidth, clothHeight, out flags);

            // Create output buffer descriptions for ecah flag
            // These describe where the simulation should send output data to
            for (int flagIndex = 0; flagIndex < flags.Count; ++flagIndex)
            {
                // flags[flagIndex].WindVelocity = new Vector3(0, 0, 15.0f);

                // In this case we have a DX11 output buffer with a vertex at index 0, 8, 16 and so on as well as a normal at 3, 11, 19 etc.
                // Copies will be performed GPU-side directly into the output buffer

                CpuVertexBufferDescriptor vertexBufferDescriptor = new CpuVertexBufferDescriptor(cloths[flagIndex].CpuBuffer, 0, 8, 3, 8);
                cloths[flagIndex].VertexBufferDescriptor = vertexBufferDescriptor;
            }

            gSolver.Optimize(SoftWorld.SoftBodyArray);

            World.StepSimulation(1.0f / 60.0f, 0);
        }
Exemplo n.º 2
0
        protected override void OnInitializePhysics()
        {
            // collision configuration contains default setup for memory, collision setup
            CollisionConf = new SoftBodyRigidBodyCollisionConfiguration();
            Dispatcher    = new CollisionDispatcher(CollisionConf);

            Broadphase = new AxisSweep3(new Vector3(-1000, -1000, -1000),
                                        new Vector3(1000, 1000, 1000), maxProxies);

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

            softBodyWorldInfo = new SoftBodyWorldInfo
            {
                AirDensity   = 1.2f,
                WaterDensity = 0,
                WaterOffset  = 0,
                WaterNormal  = Vector3.Zero,
                Gravity      = new Vector3(0, -10, 0),
                Dispatcher   = Dispatcher,
                Broadphase   = Broadphase
            };
            softBodyWorldInfo.SparseSdf.Initialize();

            World         = new SoftRigidDynamicsWorld(Dispatcher, Broadphase, Solver, CollisionConf);
            World.Gravity = new Vector3(0, -10, 0);
            World.DispatchInfo.EnableSpu = true;

            World.SetInternalTickCallback(PickingPreTickCallback, this, true);

            InitializeDemo();
        }
Exemplo n.º 3
0
        public void Create()
        {
            if (created)
            {
                this.Destroy();
            }

            this.bodyindex = 0;
            this.cstindex  = 0;

            collisionConfiguration = new SoftBodyRigidBodyCollisionConfiguration();
            dispatcher             = new CollisionDispatcher(collisionConfiguration);
            solver = new SequentialImpulseConstraintSolver();
            overlappingPairCache = new DbvtBroadphase();
            dynamicsWorld        = new SoftRigidDynamicsWorld(dispatcher, overlappingPairCache, solver, collisionConfiguration);
            worldInfo            = new SoftBodyWorldInfo();
            worldInfo.Gravity    = dynamicsWorld.Gravity;
            worldInfo.Broadphase = overlappingPairCache;
            worldInfo.Dispatcher = dispatcher;
            worldInfo.SparseSdf.Initialize();
            this.created = true;

            if (this.WorldHasReset != null)
            {
                this.WorldHasReset();
            }
        }
Exemplo n.º 4
0
        public Physics()
        {
            demos = new DemoConstructor[] { Init_Cloth, Init_Pressure, Init_Volume, Init_Ropes, Init_RopeAttach,
                                            Init_ClothAttach, Init_Sticks, Init_Collide, Init_Collide2, Init_Collide3, Init_Impact, Init_Aero,
                                            Init_Aero2, Init_Friction, Init_Torus, Init_TorusMatch, Init_Bunny, Init_BunnyMatch, Init_Cutting1,
                                            Init_ClusterDeform, Init_ClusterCollide1, Init_ClusterCollide2, Init_ClusterSocket, Init_ClusterHinge,
                                            Init_ClusterCombine, Init_ClusterCar, Init_ClusterRobot, Init_ClusterStackSoft, Init_ClusterStackMixed,
                                            Init_TetraCube, Init_TetraBunny };

            // collision configuration contains default setup for memory, collision setup
            CollisionConf = new SoftBodyRigidBodyCollisionConfiguration();
            Dispatcher    = new CollisionDispatcher(CollisionConf);

            Broadphase = new AxisSweep3(new Vector3(-1000, -1000, -1000),
                                        new Vector3(1000, 1000, 1000), maxProxies);

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

            softBodyWorldInfo              = new SoftBodyWorldInfo();
            softBodyWorldInfo.AirDensity   = 1.2f;
            softBodyWorldInfo.WaterDensity = 0;
            softBodyWorldInfo.WaterOffset  = 0;
            softBodyWorldInfo.WaterNormal  = Vector3.Zero;
            softBodyWorldInfo.Gravity      = new Vector3(0, -10, 0);
            softBodyWorldInfo.Dispatcher   = Dispatcher;
            softBodyWorldInfo.Broadphase   = Broadphase;
            softBodyWorldInfo.SparseSdf.Initialize();

            World         = new SoftRigidDynamicsWorld(Dispatcher, Broadphase, Solver, CollisionConf);
            World.Gravity = new Vector3(0, -10, 0);
            World.DispatchInfo.EnableSpu = true;

            InitializeDemo();
        }
Exemplo n.º 5
0
        public void SetUp()
        {
            conf       = new SoftBodyRigidBodyCollisionConfiguration();
            dispatcher = new CollisionDispatcher(conf);
            broadphase = new AxisSweep3(new Vector3(-1000, -1000, -1000),
                                        new Vector3(1000, 1000, 1000));
            solver = new DefaultSoftBodySolver();
            world  = new SoftRigidDynamicsWorld(dispatcher, broadphase, null, conf, solver);

            softBodyWorldInfo = new SoftBodyWorldInfo();
            softBody          = new SoftBody(softBodyWorldInfo);
            world.AddSoftBody(softBody);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public Physics()
        {
            DantzigSolver mlcp = new DantzigSolver();

            collisionConf = new SoftBodyRigidBodyCollisionConfiguration();
            dispatcher    = new CollisionDispatcher(new DefaultCollisionConfiguration());
            solver        = new DefaultSoftBodySolver();
            ConstraintSolver cSolver = new MultiBodyConstraintSolver();

            broadphase = new DbvtBroadphase();
            World      = new SoftRigidDynamicsWorld(dispatcher, broadphase, cSolver, collisionConf, solver);

            //Actual scaling is unknown, this gravity is probably not right
            World.Gravity = new Vector3(0, -98.1f, 0);
            World.SetInternalTickCallback(new DynamicsWorld.InternalTickCallback((w, f) => DriveJoints.UpdateAllMotors(Skeleton, cachedArgs)));

            //Roobit
            RigidNode_Base.NODE_FACTORY = (Guid guid) => new BulletRigidNode(guid);
            string RobotPath = @"C:\Program Files (x86)\Autodesk\Synthesis\Synthesis\Robots\";
            string dir       = RobotPath;

            GetFromDirectory(RobotPath, s => { Skeleton = (BulletRigidNode)BXDJSkeleton.ReadSkeleton(s + "skeleton.bxdj"); dir = s; });
            List <RigidNode_Base> nodes = Skeleton.ListAllNodes();

            for (int i = 0; i < nodes.Count; i++)
            {
                BulletRigidNode bNode = (BulletRigidNode)nodes[i];
                bNode.CreateRigidBody(dir + bNode.ModelFileName);
                bNode.CreateJoint();

                if (bNode.joint != null)
                {
                    World.AddConstraint(bNode.joint, true);
                }
                World.AddCollisionObject(bNode.BulletObject);
                collisionShapes.Add(bNode.BulletObject.CollisionShape);
            }

            //Field
            string fieldPath = @"C:\Program Files (x86)\Autodesk\Synthesis\Synthesis\Fields\";

            GetFromDirectory(fieldPath, s => f = BulletFieldDefinition.FromFile(s));

            foreach (RigidBody b in f.Bodies)
            {
                World.AddRigidBody(b);
                collisionShapes.Add(b.CollisionShape);
            }
        }
Exemplo n.º 7
0
        static void TestSoftBody()
        {
            var softBodyWorldInfo     = new SoftBodyWorldInfo();
            var softBody              = new SoftBody(softBodyWorldInfo);
            var softBodyCollisionConf = new SoftBodyRigidBodyCollisionConfiguration();
            var softBodySolver        = new DefaultSoftBodySolver();
            var dispatcher            = new CollisionDispatcher(softBodyCollisionConf);
            var broadphase            = new AxisSweep3(new Vector3(-1000, -1000, -1000),
                                                       new Vector3(1000, 1000, 1000));
            var softBodyWorld = new SoftRigidDynamicsWorld(dispatcher, broadphase, null, softBodyCollisionConf, softBodySolver);

            softBodyWorld.AddSoftBody(softBody);

            if (!object.ReferenceEquals(softBody.SoftBodySolver, softBodySolver))
            {
                Console.WriteLine("SoftBody: body and world SoftBodySolvers don't match!");
            }

            AddToDisposeQueue(softBodyWorldInfo);
            AddToDisposeQueue(softBody);
            AddToDisposeQueue(softBodyCollisionConf);
            AddToDisposeQueue(softBodySolver);
            AddToDisposeQueue(dispatcher);
            AddToDisposeQueue(broadphase);
            AddToDisposeQueue(softBodyWorld);

            softBodyWorldInfo     = null;
            softBody              = null;
            softBodyCollisionConf = null;
            softBodySolver        = null;
            dispatcher            = null;
            broadphase            = null;
            softBodyWorld.Dispose();
            softBodyWorld = null;

            GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
            GC.WaitForPendingFinalizers();

            TestWeakRefs();
            disposeQueue.Clear();
        }
Exemplo n.º 8
0
        public override void Run()
        {
            var softBodyWorldInfo     = new SoftBodyWorldInfo();
            var softBody              = new SoftBody(softBodyWorldInfo);
            var softBodyCollisionConf = new SoftBodyRigidBodyCollisionConfiguration();
            var softBodySolver        = new DefaultSoftBodySolver();
            var dispatcher            = new CollisionDispatcher(softBodyCollisionConf);
            var broadphase            = new AxisSweep3(new Vector3(-1000, -1000, -1000),
                                                       new Vector3(1000, 1000, 1000));
            var softBodyWorld = new SoftRigidDynamicsWorld(dispatcher, broadphase, null, softBodyCollisionConf, softBodySolver);

            softBodyWorld.AddSoftBody(softBody);

            if (!object.ReferenceEquals(softBody.SoftBodySolver, softBodySolver))
            {
                Console.WriteLine("SoftBody: body and world SoftBodySolvers don't match!");
            }

            AddToDisposeQueue(softBodyWorldInfo);
            AddToDisposeQueue(softBody);
            AddToDisposeQueue(softBodyCollisionConf);
            AddToDisposeQueue(softBodySolver);
            AddToDisposeQueue(dispatcher);
            AddToDisposeQueue(broadphase);
            AddToDisposeQueue(softBodyWorld);

            softBodyWorldInfo     = null;
            softBody              = null;
            softBodyCollisionConf = null;
            softBodySolver        = null;
            dispatcher            = null;
            broadphase            = null;
            softBodyWorld.Dispose();
            softBodyWorld = null;

            ForceGC();
            TestWeakRefs();
            ClearRefs();
        }
        protected override void _InitializePhysicsWorld()
        {
            Debug.Log("Creating SoftRigidDynamicsWorld");
            // collision configuration contains default setup for memory, collision setup
            CollisionConf = new SoftBodyRigidBodyCollisionConfiguration();
            Dispatcher    = new CollisionDispatcher(CollisionConf);

            //TODO I think this will limit collision detection to -1000 to 1000 should be configurable
            Broadphase = new AxisSweep3(new BulletSharp.Math.Vector3(-1000, -1000, -1000),
                                        new BulletSharp.Math.Vector3(1000, 1000, 1000), maxProxies);

            //TODO this is taken from the Bullet examples, but I don't understand why the
            // the default constraint solver.
            Solver = new SequentialImpulseConstraintSolver();

            softBodyWorldInfo = new SoftBodyWorldInfo {
                AirDensity   = 1.2f,
                WaterDensity = 0,
                WaterOffset  = 0,
                WaterNormal  = BulletSharp.Math.Vector3.Zero,
                Gravity      = UnityEngine.Physics.gravity.ToBullet(),
                Dispatcher   = Dispatcher,
                Broadphase   = Broadphase
            };
            softBodyWorldInfo.SparseSdf.Initialize();

            SoftRigidDynamicsWorld sw = new SoftRigidDynamicsWorld(Dispatcher, Broadphase, Solver, CollisionConf);

            World         = sw;
            World.Gravity = UnityEngine.Physics.gravity.ToBullet();
            World.DispatchInfo.EnableSpu = true;

            softBodyWorldInfo.SparseSdf.Reset();
            softBodyWorldInfo.AirDensity   = 1.2f;
            softBodyWorldInfo.WaterDensity = 0;
            softBodyWorldInfo.WaterOffset  = 0;
            softBodyWorldInfo.WaterNormal  = BulletSharp.Math.Vector3.Zero;
            softBodyWorldInfo.Gravity      = UnityEngine.Physics.gravity.ToBullet();
        }
Exemplo n.º 10
0
        /*
         * Does not set any local variables. Is safe to use to create duplicate physics worlds for independant simulation.
         */
        public bool CreatePhysicsWorld(out CollisionWorld world,
                                       out CollisionConfiguration collisionConfig,
                                       out CollisionDispatcher dispatcher,
                                       out BroadphaseInterface broadphase,
                                       out ConstraintSolver solver,
                                       out SoftBodyWorldInfo softBodyWorldInfo)
        {
            bool success = true;

            if (m_worldType == WorldType.SoftBodyAndRigidBody && m_collisionType == CollisionConfType.DefaultDynamicsWorldCollisionConf)
            {
                Debug.LogError("For World Type = SoftBodyAndRigidBody collisionType must be collisionType=SoftBodyRigidBodyCollisionConf. Switching");
                m_collisionType = CollisionConfType.SoftBodyRigidBodyCollisionConf;
                success         = false;
            }

            collisionConfig = null;
            if (m_collisionType == CollisionConfType.DefaultDynamicsWorldCollisionConf)
            {
                collisionConfig = new DefaultCollisionConfiguration();
            }
            else if (m_collisionType == CollisionConfType.SoftBodyRigidBodyCollisionConf)
            {
                collisionConfig = new SoftBodyRigidBodyCollisionConfiguration();
            }

            dispatcher = new CollisionDispatcher(collisionConfig);

            if (m_broadphaseType == BroadphaseType.DynamicAABBBroadphase)
            {
                broadphase = new DbvtBroadphase();
            }
            else if (m_broadphaseType == BroadphaseType.Axis3SweepBroadphase)
            {
                broadphase = new AxisSweep3(m_axis3SweepBroadphaseMin.ToBullet(), m_axis3SweepBroadphaseMax.ToBullet(), axis3SweepMaxProxies);
            }
            else if (m_broadphaseType == BroadphaseType.Axis3SweepBroadphase_32bit)
            {
                broadphase = new AxisSweep3_32Bit(m_axis3SweepBroadphaseMin.ToBullet(), m_axis3SweepBroadphaseMax.ToBullet(), axis3SweepMaxProxies);
            }
            else
            {
                broadphase = null;
            }
            world             = null;
            softBodyWorldInfo = null;
            solver            = null;
            if (m_worldType == WorldType.CollisionOnly)
            {
                world = new CollisionWorld(dispatcher, broadphase, collisionConfig);
            }
            else if (m_worldType == WorldType.RigidBodyDynamics)
            {
                switch (solverType)
                {
                case SolverType.MLCP:
                    DantzigSolver dtsolver = new DantzigSolver();
                    solver = new MlcpSolver(dtsolver);
                    break;

                default:
                    break;
                }
                world = new DiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfig);
            }
            else if (m_worldType == WorldType.MultiBodyWorld)
            {
                MultiBodyConstraintSolver mbConstraintSolver = null;
                switch (solverType)
                {
                /* case SolverType.MLCP:
                 *   DantzigSolver dtsolver = new DantzigSolver();
                 *   mbConstraintSolver = new MultiBodyMLCPConstraintSolver(dtsolver);
                 *   break;*/
                default:
                    mbConstraintSolver = new MultiBodyConstraintSolver();
                    break;
                }
                world = new MultiBodyDynamicsWorld(dispatcher, broadphase, mbConstraintSolver, collisionConfig);
            }
            else if (m_worldType == WorldType.SoftBodyAndRigidBody)
            {
                SequentialImpulseConstraintSolver siConstraintSolver = new SequentialImpulseConstraintSolver();
                constraintSolver            = siConstraintSolver;
                siConstraintSolver.RandSeed = sequentialImpulseConstraintSolverRandomSeed;
                m_world  = new SoftRigidDynamicsWorld(Dispatcher, Broadphase, siConstraintSolver, CollisionConf);
                _ddWorld = (DiscreteDynamicsWorld)m_world;;

                SoftRigidDynamicsWorld _sworld = (SoftRigidDynamicsWorld)m_world;
                m_world.DispatchInfo.EnableSpu = true;
                _sworld.WorldInfo.SparseSdf.Initialize();
                _sworld.WorldInfo.SparseSdf.Reset();
                _sworld.WorldInfo.AirDensity   = 1.2f;
                _sworld.WorldInfo.WaterDensity = 0;
                _sworld.WorldInfo.WaterOffset  = 0;
                _sworld.WorldInfo.WaterNormal  = BulletSharp.Math.Vector3.Zero;
                _sworld.WorldInfo.Gravity      = m_gravity.ToBullet();
            }

            if (world is DiscreteDynamicsWorld)
            {
                ((DiscreteDynamicsWorld)world).Gravity = m_gravity.ToBullet();
            }
            if (_doDebugDraw)
            {
                DebugDrawUnity db = new DebugDrawUnity();
                db.DebugMode      = _debugDrawMode;
                world.DebugDrawer = db;
            }
            return(success);
        }
Exemplo n.º 11
0
    //Does not set any local variables. Is safe to use to create duplicate physics worlds for independant simulation.
    public void CreatePhysicsWorld
    (
        out CollisionWorld world,
        out CollisionConfiguration collisionConfig,
        out CollisionDispatcher dispatcher,
        out BroadphaseInterface broadphase,
        out ConstraintSolver solver,
        out SoftBodyWorldInfo softBodyWorldInfo
    )
    {
        collisionConfig = null;

        switch (physicWorldParameters.collisionType)
        {
        default:
        case CollisionConfType.DefaultDynamicsWorldCollisionConf:
            collisionConfig = new DefaultCollisionConfiguration();
            break;

        case CollisionConfType.SoftBodyRigidBodyCollisionConf:
            collisionConfig = new SoftBodyRigidBodyCollisionConfiguration();
            break;
        }

        dispatcher = new CollisionDispatcher(collisionConfig);

        switch (physicWorldParameters.broadphaseType)
        {
        default:
        case BroadphaseType.DynamicAABBBroadphase:
            broadphase = new DbvtBroadphase();
            break;

        case BroadphaseType.Axis3SweepBroadphase:
            broadphase = new AxisSweep3(
                physicWorldParameters.axis3SweepBroadphaseMin,
                physicWorldParameters.axis3SweepBroadphaseMax,
                physicWorldParameters.axis3SweepMaxProxies
                );
            break;

        case BroadphaseType.Axis3SweepBroadphase_32bit:
            broadphase = new AxisSweep3_32Bit(
                physicWorldParameters.axis3SweepBroadphaseMin,
                physicWorldParameters.axis3SweepBroadphaseMax,
                physicWorldParameters.axis3SweepMaxProxies
                );
            break;
        }

        world             = null;
        softBodyWorldInfo = null;
        solver            = null;

        switch (physicWorldParameters.worldType)
        {
        case WorldType.CollisionOnly:
            world = new CollisionWorld(dispatcher, broadphase, collisionConfig);
            break;

        default:
        case WorldType.RigidBodyDynamics:
            world = new DiscreteDynamicsWorld(dispatcher, broadphase, null, collisionConfig);
            break;

        case WorldType.MultiBodyWorld:
            MultiBodyConstraintSolver mbConstraintSolver = new MultiBodyConstraintSolver();
            constraintSolver = mbConstraintSolver;
            world            = new MultiBodyDynamicsWorld(dispatcher, broadphase, mbConstraintSolver, collisionConfig);
            break;

        case WorldType.SoftBodyAndRigidBody:
            SequentialImpulseConstraintSolver siConstraintSolver = new SequentialImpulseConstraintSolver();
            constraintSolver            = siConstraintSolver;
            siConstraintSolver.RandSeed = physicWorldParameters.sequentialImpulseConstraintSolverRandomSeed;

            world = new SoftRigidDynamicsWorld(this.dispatcher, this.broadphase, siConstraintSolver, collisionConf);
            world.DispatchInfo.EnableSpu = true;

            SoftRigidDynamicsWorld _sworld = (SoftRigidDynamicsWorld)world;
            _sworld.WorldInfo.SparseSdf.Initialize();
            _sworld.WorldInfo.SparseSdf.Reset();
            _sworld.WorldInfo.AirDensity   = 1.2f;
            _sworld.WorldInfo.WaterDensity = 0;
            _sworld.WorldInfo.WaterOffset  = 0;
            _sworld.WorldInfo.WaterNormal  = BulletSharp.Math.Vector3.Zero;
            _sworld.WorldInfo.Gravity      = Gravity.ToBullet();
            break;
        }

        if (world is DiscreteDynamicsWorld)
        {
            ((DiscreteDynamicsWorld)world).Gravity = Gravity.ToBullet();
        }
    }
Exemplo n.º 12
0
    private void CreateWorld()
    {
        if (physicWorldParameters.worldType == WorldType.SoftBodyAndRigidBody && physicWorldParameters.collisionType != CollisionConfType.SoftBodyRigidBodyCollisionConf)
        {
            Debug.LogError("For World Type = SoftBodyAndRigidBody collisionType must be collisionType = SoftBodyRigidBodyCollisionConf.");
            return;
        }

        isDisposed = false;

        switch (physicWorldParameters.collisionType)
        {
        case CollisionConfType.DefaultDynamicsWorldCollisionConf:
            collisionConf = new DefaultCollisionConfiguration();
            break;

        case CollisionConfType.SoftBodyRigidBodyCollisionConf:
            collisionConf = new SoftBodyRigidBodyCollisionConfiguration();
            break;
        }

        dispatcher = new CollisionDispatcher(collisionConf);

        switch (physicWorldParameters.broadphaseType)
        {
        default:
        case BroadphaseType.DynamicAABBBroadphase:
            broadphase = new DbvtBroadphase();
            break;

        case BroadphaseType.Axis3SweepBroadphase:
            broadphase = new AxisSweep3(physicWorldParameters.axis3SweepBroadphaseMin, physicWorldParameters.axis3SweepBroadphaseMax, physicWorldParameters.axis3SweepMaxProxies);
            break;

        case BroadphaseType.Axis3SweepBroadphase_32bit:
            broadphase = new AxisSweep3_32Bit(physicWorldParameters.axis3SweepBroadphaseMin, physicWorldParameters.axis3SweepBroadphaseMax, physicWorldParameters.axis3SweepMaxProxies);
            break;
        }

        switch (physicWorldParameters.worldType)
        {
        case WorldType.CollisionOnly:
            World = new CollisionWorld(dispatcher, broadphase, collisionConf);
            break;

        case WorldType.RigidBodyDynamics:
            World = new DiscreteDynamicsWorld(dispatcher, broadphase, null, collisionConf);
            break;

        case WorldType.MultiBodyWorld:
            MultiBodyConstraintSolver mbConstraintSolver = new MultiBodyConstraintSolver();
            constraintSolver = mbConstraintSolver;
            World            = new MultiBodyDynamicsWorld(dispatcher, broadphase, mbConstraintSolver, collisionConf);
            break;

        case WorldType.SoftBodyAndRigidBody:
            SequentialImpulseConstraintSolver siConstraintSolver = new SequentialImpulseConstraintSolver();
            constraintSolver            = siConstraintSolver;
            siConstraintSolver.RandSeed = physicWorldParameters.sequentialImpulseConstraintSolverRandomSeed;

            World = new SoftRigidDynamicsWorld(dispatcher, broadphase, siConstraintSolver, collisionConf);
            _world.DispatchInfo.EnableSpu = true;

            SoftWorld.WorldInfo.SparseSdf.Initialize();
            SoftWorld.WorldInfo.SparseSdf.Reset();
            SoftWorld.WorldInfo.AirDensity   = 1.2f;
            SoftWorld.WorldInfo.WaterDensity = 0;
            SoftWorld.WorldInfo.WaterOffset  = 0;
            SoftWorld.WorldInfo.WaterNormal  = BulletSharp.Math.Vector3.Zero;
            SoftWorld.WorldInfo.Gravity      = physicWorldParameters.gravity;
            break;
        }

        if (_world is DiscreteDynamicsWorld)
        {
            ((DiscreteDynamicsWorld)_world).Gravity = physicWorldParameters.gravity;
        }

        Debug.LogFormat("Physic World of type {0} Instanced", physicWorldParameters.worldType);

        if (physicWorldParameters.debug)
        {
            Debug.Log("Physic World Debug is active");

            DebugDrawUnity db = new DebugDrawUnity();
            db.DebugMode       = physicWorldParameters.debugDrawMode;
            _world.DebugDrawer = db;
        }
    }