Example #1
0
            public virtual void Cleanup()
            {
                int i;

                // Remove all constraints
                for (i = 0; i < (int)JOINT.COUNT; ++i)
                {
                    if (m_joints[i] != null)
                    {
                        m_ownerWorld.RemoveConstraint(m_joints[i]);
                        m_joints[i].Cleanup();
                        m_joints[i] = null;
                    }
                }

                // Remove all bodies and shapes
                for (i = 0; i < (int)BODYPART.COUNT; ++i)
                {
                    if (m_bodies[i] != null)
                    {
                        m_ownerWorld.RemoveRigidBody(m_bodies[i]);

                        //delete m_bodies[i].getMotionState();

                        m_bodies[i].Cleanup();
                        m_bodies[i] = null;
                        m_shapes[i].Cleanup();
                        m_shapes[i] = null;
                    }
                }
            }
Example #2
0
        private void UpdateEnd(Engine Sender, EventArgs Args)
        {
            BulletPhysicsComponent Component;

            while (ToAdd.TryDequeue(out Component))
            {
                //Add the component's RigidBody
                World.AddRigidBody(Component.Body);
                //Remove the component
                Components.Add(Component);
            }

            while (ToRemove.TryDequeue(out Component))
            {
                //Remove the component's RigidBody
                World.RemoveRigidBody(Component.Body);
                //Remove the component
                Components.Remove(Component);
            }

            Action <DynamicsWorld> Func;

            while (Actions.TryDequeue(out Func))
            {
                //Execute the function
                Func(World);
            }
        }
Example #3
0
        public void Dispose()
        {
            int i;

            // Remove all constraints
            for (i = 0; i < JointCount; ++i)
            {
                _ownerWorld.RemoveConstraint(Joints[i]);
                Joints[i].Dispose();
                Joints[i] = null;
            }

            // Remove all bodies and shapes
            for (i = 0; i < JointCount; ++i)
            {
                _ownerWorld.RemoveRigidBody(_jointBodies[i]);
                _jointBodies[i].MotionState.Dispose();
                _jointBodies[i].Dispose();
            }
            _jointBodies = null;

            _thighShape.Dispose();
            _thighShape = null;
            _shinShape.Dispose();
            _shinShape = null;
        }
 public void RemoveRigidBody(BulletSharp.RigidBody rb)
 {
     if (!_isDisposed)
     {
         Debug.LogFormat("Removing rigidbody {0} from world", rb);
         World.RemoveRigidBody(rb);
     }
 }
Example #5
0
 private void DisposeRigidBody(RigidBody body)
 {
     _world.RemoveRigidBody(body);
     if (body.MotionState != null)
     {
         body.MotionState.Dispose();
     }
     body.Dispose();
 }
 public static void DeleteAndDisposeBody(this DynamicsWorld world, RigidBody body)
 {
     world.RemoveRigidBody(body);
     body.UserObject = null;
     if (body.MotionState != null)
     {
         body.MotionState.Dispose();
     }
     body.Dispose();
 }
 public override void RemoveObject(IPhysicObject obj)
 {
     if (obj is BulletPhysicObject && obj.PhysicObjectTypes != PhysicObjectTypes.GHOST)
     {
         BulletPhysicObject BulletPhysicObject = obj as BulletPhysicObject;
         world.RemoveRigidBody(BulletPhysicObject.Body);
         BulletPhysicObject.Body.UserObject = null;
     }
     objs.Remove(obj);
 }
Example #8
0
 private void RemoveFromWorld()
 {
     for (int i = 0; i < RigidBodies.Length; i++)
     {
         World.RemoveRigidBody(RigidBodies[i]);
     }
     for (int i = 0; i < Constraints.Length; i++)
     {
         World.RemoveConstraint(Constraints[i]);
     }
 }
Example #9
0
        public void Dispose()
        {
            foreach (var joint in _joints)
            {
                _world.RemoveConstraint(joint);
                joint.Dispose();
            }

            foreach (var body in _bodies)
            {
                _world.RemoveRigidBody(body);
                body.Dispose();
            }

            foreach (var shape in _shapes)
            {
                shape.Dispose();
            }
        }
Example #10
0
            public void Dispose()
            {
                int i;

                // Remove all constraints
                for (i = 0; i < JointCount; ++i)
                {
                    ownerWorld.RemoveConstraint(joints[i]);
                    joints[i].Dispose();
                    joints[i] = null;
                }

                // Remove all bodies and shapes
                for (i = 0; i < BodyPartCount; ++i)
                {
                    ownerWorld.RemoveRigidBody(bodies[i]);
                    bodies[i].MotionState.Dispose();
                    bodies[i].Dispose();
                    bodies[i] = null;
                    shapes[i].Dispose();
                    shapes[i] = null;
                }
            }