// TODO djm: check out about this new fixture here /// <summary> /// Creates a fixture and attach it to this body. Use this function if you need to set some fixture /// parameters, like friction. Otherwise you can create the fixture directly from a shape. If the /// density is non-zero, this function automatically updates the mass of the body. Contacts are not /// created until the next time step. /// </summary> /// <param name="def">the fixture definition.</param> /// <warning>This function is locked during callbacks.</warning> public Fixture CreateFixture(FixtureDef def) { Debug.Assert(World.Locked == false); if (World.Locked == true) { return null; } // djm TODO from pool? Fixture fixture = new Fixture(); fixture.Create(this, def); if ((Flags & TypeFlags.Active) == TypeFlags.Active) { BroadPhase broadPhase = World.ContactManager.BroadPhase; fixture.CreateProxies(broadPhase, Xf); } fixture.Next = FixtureList; FixtureList = fixture; ++FixtureCount; fixture.Body = this; // Adjust mass properties if needed. if (fixture.Density > 0.0f) { 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. World.Flags |= World.NEW_FIXTURE; return fixture; }