public static Destroy ( |
||
contact | ||
return | void |
public void Destroy(Contact c) { Shape shape1 = c.GetShape1(); Shape shape2 = c.GetShape2(); Body body1 = shape1.GetBody(); Body body2 = shape2.GetBody(); ContactPoint cp = new ContactPoint(); cp.Shape1 = shape1; cp.Shape2 = shape2; cp.Friction = Settings.MixFriction(shape1.Friction, shape2.Friction); cp.Restitution = Settings.MixRestitution(shape1.Restitution, shape2.Restitution); // Inform the user that this contact is ending. int manifoldCount = c.GetManifoldCount(); if (manifoldCount > 0 && _world._contactListener != null) { Manifold[] manifolds = c.GetManifolds(); for (int i = 0; i < manifoldCount; ++i) { Manifold manifold = manifolds[i]; cp.Normal = manifold.Normal; for (int j = 0; j < manifold.PointCount; ++j) { ManifoldPoint mp = manifold.Points[j]; cp.Position = body1.GetWorldPoint(mp.LocalPoint1); Vec2 v1 = body1.GetLinearVelocityFromLocalPoint(mp.LocalPoint1); Vec2 v2 = body2.GetLinearVelocityFromLocalPoint(mp.LocalPoint2); cp.Velocity = v2 - v1; cp.Separation = mp.Separation; cp.ID = mp.ID; _world._contactListener.Remove(cp); } } } // Remove from the world. if (c._prev != null) { c._prev._next = c._next; } if (c._next != null) { c._next._prev = c._prev; } if (c == _world._contactList) { _world._contactList = c._next; } // Remove from body 1 if (c._node1.Prev != null) { c._node1.Prev.Next = c._node1.Next; } if (c._node1.Next != null) { c._node1.Next.Prev = c._node1.Prev; } if (c._node1 == body1._contactList) { body1._contactList = c._node1.Next; } // Remove from body 2 if (c._node2.Prev != null) { c._node2.Prev.Next = c._node2.Next; } if (c._node2.Next != null) { c._node2.Next.Prev = c._node2.Prev; } if (c._node2 == body2._contactList) { body2._contactList = c._node2.Next; } // Call the factory. Contact.Destroy(c); --_world._contactCount; }
public void Destroy(Contact c) { Shape shape = c.GetShape1(); Shape shape2 = c.GetShape2(); Body body = shape.GetBody(); Body body2 = shape2.GetBody(); ContactPoint contactPoint = new ContactPoint(); contactPoint.Shape1 = shape; contactPoint.Shape2 = shape2; contactPoint.Friction = Settings.MixFriction(shape.Friction, shape2.Friction); contactPoint.Restitution = Settings.MixRestitution(shape.Restitution, shape2.Restitution); int manifoldCount = c.GetManifoldCount(); if (manifoldCount > 0 && this._world._contactListener != null) { Manifold[] manifolds = c.GetManifolds(); for (int i = 0; i < manifoldCount; i++) { Manifold manifold = manifolds[i]; contactPoint.Normal = manifold.Normal; for (int j = 0; j < manifold.PointCount; j++) { ManifoldPoint manifoldPoint = manifold.Points[j]; contactPoint.Position = body.GetWorldPoint(manifoldPoint.LocalPoint1); Vec2 linearVelocityFromLocalPoint = body.GetLinearVelocityFromLocalPoint(manifoldPoint.LocalPoint1); Vec2 linearVelocityFromLocalPoint2 = body2.GetLinearVelocityFromLocalPoint(manifoldPoint.LocalPoint2); contactPoint.Velocity = linearVelocityFromLocalPoint2 - linearVelocityFromLocalPoint; contactPoint.Separation = manifoldPoint.Separation; contactPoint.ID = manifoldPoint.ID; this._world._contactListener.Remove(contactPoint); } } } if (c._prev != null) { c._prev._next = c._next; } if (c._next != null) { c._next._prev = c._prev; } if (c == this._world._contactList) { this._world._contactList = c._next; } if (c._node1.Prev != null) { c._node1.Prev.Next = c._node1.Next; } if (c._node1.Next != null) { c._node1.Next.Prev = c._node1.Prev; } if (c._node1 == body._contactList) { body._contactList = c._node1.Next; } if (c._node2.Prev != null) { c._node2.Prev.Next = c._node2.Next; } if (c._node2.Next != null) { c._node2.Next.Prev = c._node2.Prev; } if (c._node2 == body2._contactList) { body2._contactList = c._node2.Next; } Contact.Destroy(c); this._world._contactCount--; }
public void Destroy(Contact c) { Fixture fixtureA = c.GetFixtureA(); Fixture fixtureB = c.GetFixtureB(); Body body1 = fixtureA.GetBody(); Body body2 = fixtureB.GetBody(); if (c.Manifold.PointCount > 0) { _contactListener.EndContact(c); } // Remove from the world. if (c.Prev != null) { c.Prev.Next = c.Next; } if (c.Next != null) { c.Next.Prev = c.Prev; } if (c == _contactList) { _contactList = c.Next; } // Remove from body 1 if (c.NodeA.Prev != null) { c.NodeA.Prev.Next = c.NodeA.Next; } if (c.NodeA.Next != null) { c.NodeA.Next.Prev = c.NodeA.Prev; } if (c.NodeA == body1._contactList) { body1._contactList = c.NodeA.Next; } // Remove from body 2 if (c.NodeB.Prev != null) { c.NodeB.Prev.Next = c.NodeB.Next; } if (c.NodeB.Next != null) { c.NodeB.Next.Prev = c.NodeB.Prev; } if (c.NodeB == body2._contactList) { body2._contactList = c.NodeB.Next; } // Call the factory. Contact.Destroy(c); --_contactCount; }
public void Destroy(Contact c) { Fixture fixtureA = c.FixtureA; Fixture fixtureB = c.FixtureB; Body bodyA = fixtureA.Body; Body bodyB = fixtureB.Body; if (c.Manifold.PointCount > 0) { if (_world._contactListener != null) { _world._contactListener.EndContact(c); } } // Remove from the world. if (c._prev != null) { c._prev._next = c._next; } if (c._next != null) { c._next._prev = c._prev; } if (c == _world._contactList) { _world._contactList = c._next; } // Remove from body 1 if (c._nodeA.Prev != null) { c._nodeA.Prev.Next = c._nodeA.Next; } if (c._nodeA.Next != null) { c._nodeA.Next.Prev = c._nodeA.Prev; } if (c._nodeA == bodyA._contactList) { bodyA._contactList = c._nodeA.Next; } // Remove from body 2 if (c._nodeB.Prev != null) { c._nodeB.Prev.Next = c._nodeB.Next; } if (c._nodeB.Next != null) { c._nodeB.Next.Prev = c._nodeB.Prev; } if (c._nodeB == bodyB._contactList) { bodyB._contactList = c._nodeB.Next; } // Call the factory. Contact.Destroy(ref c); --_world._contactCount; }