ResetMassData() public method

This resets the mass properties to the sum of the mass properties of the fixtures. This normally does not need to be called unless you called SetMassData to override the mass and you later want to reset the mass.
public ResetMassData ( ) : void
return void
Example #1
0
        public Fixture(Body body, Shape shape, Object userData)
        {
            CollisionFilter = new CollisionFilter(this);

            //Fixture defaults
            Friction    = 0.2f;
            Restitution = 0;

            IsSensor = false;

            Body     = body;
            UserData = userData;

            if (Settings.ConserveMemory)
            {
                Shape = shape;
            }
            else
            {
                Shape = shape.Clone();
            }

            // Reserve proxy space
            int childCount = Shape.ChildCount;

            Proxies = new FixtureProxy[childCount];
            for (int i = 0; i < childCount; ++i)
            {
                Proxies[i]         = new FixtureProxy();
                Proxies[i].Fixture = null;
                Proxies[i].ProxyId = BroadPhase.NullProxy;
            }
            ProxyCount = 0;

            FixtureId = _fixtureIdCounter++;

            if ((Body.Flags & BodyFlags.Enabled) == BodyFlags.Enabled)
            {
                BroadPhase broadPhase = Body.World.ContactManager.BroadPhase;
                CreateProxies(broadPhase, ref Body.Xf);
            }

            Body.FixtureList.Add(this);

            // Adjust mass properties if needed.
            if (Shape._density > 0.0f)
            {
                Body.ResetMassData();
            }

            // Let the world know we have a new fixture. This will cause new contacts
            // to be created at the beginning of the next time step.
            Body.World.Flags |= WorldFlags.NewFixture;

            if (Body.World.FixtureAdded != null)
            {
                Body.World.FixtureAdded(this);
            }
        }
        public Fixture(Body body, Shape shape, Object userData)
        {
            CollisionFilter = new CollisionFilter(this);

            //Fixture defaults
            Friction = 0.2f;
            Restitution = 0;

            IsSensor = false;

            Body = body;
            UserData = userData;

            if (Settings.ConserveMemory)
                Shape = shape;
            else
                Shape = shape.Clone();

            // Reserve proxy space
            int childCount = Shape.ChildCount;
            Proxies = new FixtureProxy[childCount];
            for (int i = 0; i < childCount; ++i)
            {
                Proxies[i] = new FixtureProxy();
                Proxies[i].Fixture = null;
                Proxies[i].ProxyId = BroadPhase.NullProxy;
            }
            ProxyCount = 0;

            FixtureId = _fixtureIdCounter++;

            if ((Body.Flags & BodyFlags.Enabled) == BodyFlags.Enabled)
            {
                BroadPhase broadPhase = Body.World.ContactManager.BroadPhase;
                CreateProxies(broadPhase, ref Body.Xf);
            }

            Body.FixtureList.Add(this);

            // Adjust mass properties if needed.
            if (Shape._density > 0.0f)
            {
                Body.ResetMassData();
            }

            // Let the world know we have a new fixture. This will cause new contacts
            // to be created at the beginning of the next time step.
            Body.World.Flags |= WorldFlags.NewFixture;

            if (Body.World.FixtureAdded != null)
            {
                Body.World.FixtureAdded(this);
            }
        }