Example #1
0
        public void Destroy()
        {
            dynamicsWorld.Dispose();
            solver.Dispose();
            overlappingPairCache.Dispose();
            dispatcher.Dispose();
            collisionConfiguration.Dispose();
            foreach (RigidBody rb in this.bodies)
            {
                rb.Dispose();
            }
            foreach (SoftBody sb in this.softbodies)
            {
                sb.Dispose();
            }
            foreach (TypedConstraint tc in this.constraints)
            {
                tc.Dispose();
            }

            this.bodies.Clear();
            this.softbodies.Clear();
            this.constraints.Clear();
            this.created = false;
        }
Example #2
0
        public void TearDown()
        {
            world.RemoveSoftBody(softBody);
            softBody.Dispose();
            softBodyWorldInfo.Dispose();

            world.Dispose();
            solver.Dispose();
            broadphase.Dispose();
            dispatcher.Dispose();
            conf.Dispose();
        }
Example #3
0
        public void Destroy()
        {
            this.dynamicsWorld.DeleteAndDisposeAllConstraints();

            this.dynamicsWorld.DeleteAndDisposeAllRigidBodies();

            dynamicsWorld.Dispose();
            solver.Dispose();
            overlappingPairCache.Dispose();
            dispatcher.Dispose();
            collisionConfiguration.Dispose();



            this.bodyContainer.Clear();
            this.softBodyContainer.Clear();
            this.constraintContainer.Clear();
            this.created = false;
        }
Example #4
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();
        }
Example #5
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();
        }
Example #6
0
        public void Destroy()
        {
            this.dynamicsWorld.DeleteAndDisposeAllConstraints();

            //this.dynamicsWorld.DeleteAndDisposeAllRigidBodies();

            for (int i = 0; i < this.dynamicsWorld.NumCollisionObjects; i++)
            {
                CollisionObject obj = dynamicsWorld.CollisionObjectArray[i];

                if (obj is RigidBody)
                {
                    RigidBody body = obj as RigidBody;
                    dynamicsWorld.DeleteAndDisposeBody(body);
                }
                else if (obj is SoftBody)
                {
                    SoftBody body = obj as SoftBody;
                    dynamicsWorld.RemoveSoftBody(body);
                    body.Dispose();
                    body.CollisionShape.Dispose();
                    body.Tag = null;
                }
            }

            dynamicsWorld.Dispose();
            solver.Dispose();
            overlappingPairCache.Dispose();
            dispatcher.Dispose();
            collisionConfiguration.Dispose();



            this.bodyContainer.Clear();
            this.softBodyContainer.Clear();
            this.constraintContainer.Clear();
            this.created = false;
        }