Ejemplo n.º 1
0
        /// <summary>
        /// Destroy a fixture. This removes the fixture from the broad-phase and
        /// destroys all contacts associated with this fixture. This will
        /// automatically adjust the mass of the body if the body is dynamic and the
        /// fixture has positive density.
        /// All fixtures attached to a body are implicitly destroyed when the body is destroyed.
        /// Warning: This function is locked during callbacks.
        /// </summary>
        /// <param name="fixture">The fixture to be removed.</param>
        public void destroyFixture(Fixture fixture)
        {
            Debug.Assert(fixture.body == this);

            // Remove the fixture from this body's singly linked list.
            Debug.Assert(fixtureList.Count > 0);

            // You tried to remove a fixture that not present in the fixturelist.
            Debug.Assert(fixtureList.Contains(fixture));

            // Destroy any contacts associated with the fixture.
            ContactEdge edge = contactList;

            while (edge != null)
            {
                Contact c = edge.contact;
                edge = edge.next;

                Fixture fixtureA = c.fixtureA;
                Fixture fixtureB = c.fixtureB;

                if (fixture == fixtureA || fixture == fixtureB)
                {
                    // This destroys the contact and removes it from
                    // this body's contact list.
                    _world.contactManager.destroy(c);
                }
            }

            if (_enabled)
            {
                IBroadPhase broadPhase = _world.contactManager.broadPhase;
                fixture.destroyProxies(broadPhase);
            }

            fixtureList.Remove(fixture);
            fixture.destroy();
            fixture.body = null;

            resetMassData();
        }
Ejemplo n.º 2
0
Archivo: Body.cs Proyecto: prime31/Nez
		/// <summary>
		/// Destroy a fixture. This removes the fixture from the broad-phase and
		/// destroys all contacts associated with this fixture. This will
		/// automatically adjust the mass of the body if the body is dynamic and the
		/// fixture has positive density.
		/// All fixtures attached to a body are implicitly destroyed when the body is destroyed.
		/// Warning: This function is locked during callbacks.
		/// </summary>
		/// <param name="fixture">The fixture to be removed.</param>
		public void destroyFixture( Fixture fixture )
		{
			Debug.Assert( fixture.body == this );

			// Remove the fixture from this body's singly linked list.
			Debug.Assert( fixtureList.Count > 0 );

			// You tried to remove a fixture that not present in the fixturelist.
			Debug.Assert( fixtureList.Contains( fixture ) );

			// Destroy any contacts associated with the fixture.
			ContactEdge edge = contactList;
			while( edge != null )
			{
				Contact c = edge.contact;
				edge = edge.next;

				Fixture fixtureA = c.fixtureA;
				Fixture fixtureB = c.fixtureB;

				if( fixture == fixtureA || fixture == fixtureB )
				{
					// This destroys the contact and removes it from
					// this body's contact list.
					_world.contactManager.destroy( c );
				}
			}

			if( _enabled )
			{
				IBroadPhase broadPhase = _world.contactManager.broadPhase;
				fixture.destroyProxies( broadPhase );
			}

			fixtureList.Remove( fixture );
			fixture.destroy();
			fixture.body = null;

			resetMassData();
		}