internal void Collide() { // Update awake contacts. Contact c = ContactList; while (c != null) { Fixture fixtureA = c.FixtureA; Fixture fixtureB = c.FixtureB; int indexA = c.ChildIndexA; int indexB = c.ChildIndexB; Body bodyA = fixtureA.Body; Body bodyB = fixtureB.Body; if (bodyA.Awake == false && bodyB.Awake == false) { c = c.Next; continue; } // Is this contact flagged for filtering? if ((c.Flags & ContactFlags.Filter) == ContactFlags.Filter) { // Should these bodies collide? if (bodyB.ShouldCollide(bodyA) == false) { Contact cNuke = c; c = cNuke.Next; Destroy(cNuke); continue; } // Check user filtering. if (ContactFilter != null && ContactFilter(fixtureA, fixtureB) == false) { Contact cNuke = c; c = cNuke.Next; Destroy(cNuke); continue; } // Clear the filtering flag. c.Flags &= ~ContactFlags.Filter; } int proxyIdA = fixtureA.Proxies[indexA].ProxyId; int proxyIdB = fixtureB.Proxies[indexB].ProxyId; bool overlap = BroadPhase.TestOverlap(proxyIdA, proxyIdB); // Here we destroy contacts that cease to overlap in the broad-phase. if (overlap == false) { Contact cNuke = c; c = cNuke.Next; Destroy(cNuke); continue; } // The contact persists. c.Update(this); c = c.Next; } }
internal void Collide() { // Update awake contacts. Contact c = m_contactList; while (c != null) { Fixture fixtureA = c.FixtureA; Fixture fixtureB = c.FixtureB; int indexA = c.ChildIndexA; int indexB = c.ChildIndexB; Body bodyA = fixtureA.Body; Body bodyB = fixtureB.Body; // Is this contact flagged for filtering? if ((c.m_flags & CollisionFlags.Filter) == CollisionFlags.Filter) { // Should these bodies collide? if (bodyB.ShouldCollide(bodyA) == false) { Contact cNuke = c; c = cNuke.GetNext(); Destroy(cNuke); continue; } // Check user filtering. if (m_contactFilter != null && m_contactFilter.ShouldCollide(fixtureA, fixtureB) == false) { Contact cNuke = c; c = cNuke.GetNext(); Destroy(cNuke); continue; } // Clear the filtering flag. c.m_flags &= ~CollisionFlags.Filter; } bool activeA = bodyA.IsAwake() && bodyA.m_type != BodyType.Static; bool activeB = bodyB.IsAwake() && bodyB.m_type != BodyType.Static; // At least one body must be awake and it must be dynamic or kinematic. if (activeA == false && activeB == false) { c = c.GetNext(); continue; } int proxyIdA = fixtureA.m_proxies[indexA].proxyId; int proxyIdB = fixtureB.m_proxies[indexB].proxyId; bool overlap = m_broadPhase.TestOverlap(proxyIdA, proxyIdB); // Here we destroy contacts that cease to overlap in the broad-phase. if (overlap == false) { Contact cNuke = c; c = cNuke.GetNext(); Destroy(cNuke); continue; } // The contact persists. c.Update(m_contactListener); c = c.GetNext(); } }
// This is the top level collision call for the time step. Here // all the narrow phase collision is processed for the world // contact list. public void Collide() { // Update awake contacts. Contact c = _contactList; while (c != null) { Fixture fixtureA = c.GetFixtureA(); Fixture fixtureB = c.GetFixtureB(); Body bodyA = fixtureA.GetBody(); Body bodyB = fixtureB.GetBody(); if (bodyA.IsSleeping() && bodyB.IsSleeping()) { c = c.GetNext(); continue; } // Is this contact flagged for filtering? if ((c.Flags & ContactFlag.FilterFlag) == ContactFlag.FilterFlag) { //TODO: The following code (next 4 if blocks) use a class and thus copy by ref. It might expect to copy by value // Are both bodies static? if (bodyA.IsStatic() && bodyB.IsStatic()) { Contact cNuke = c; c = cNuke.GetNext(); Destroy(cNuke); continue; } // Does a joint override collision? if (bodyB.IsConnected(bodyA)) { Contact cNuke = c; c = cNuke.GetNext(); Destroy(cNuke); continue; } // Check user filtering. if (_contactFilter.ShouldCollide(fixtureA, fixtureB) == false) { Contact cNuke = c; c = cNuke.GetNext(); Destroy(cNuke); continue; } // Clear the filtering flag. c.Flags &= ~ContactFlag.FilterFlag; } int proxyIdA = fixtureA.ProxyId; int proxyIdB = fixtureB.ProxyId; bool overlap = _broadPhase.TestOverlap(proxyIdA, proxyIdB); // Here we destroy contacts that cease to overlap in the broad-phase. if (overlap == false) { Contact cNuke = c; c = cNuke.GetNext(); Destroy(cNuke); continue; } // The contact persists. c.Update(_contactListener); c = c.GetNext(); } }
public void Collide() { var current = ContactList.First; // Update awake contacts. while (current != default) { var c = current.Value; var fixtureA = c.GetFixtureA(); var fixtureB = c.GetFixtureB(); var indexA = c.GetChildIndexA(); var indexB = c.GetChildIndexB(); var bodyA = fixtureA.Body; var bodyB = fixtureB.Body; // Is this contact flagged for filtering? if (c.Flags.HasFlag(Contact.ContactFlag.FilterFlag)) { // Should these bodies collide? if (!bodyB.ShouldCollide(bodyA)) { current = current.Next; Destroy(c); continue; } // Check user filtering. if (ContactFilter?.ShouldCollide(fixtureA, fixtureB) == false) { current = current.Next; Destroy(c); continue; } // Clear the filtering flag. c.Flags &= ~Contact.ContactFlag.FilterFlag; } var activeA = bodyA.IsAwake && bodyA.BodyType != BodyType.StaticBody; var activeB = bodyB.IsAwake && bodyB.BodyType != BodyType.StaticBody; // At least one body must be awake and it must be dynamic or kinematic. if (activeA == false && activeB == false) { current = current.Next; continue; } var proxyIdA = fixtureA.Proxies[indexA].ProxyId; var proxyIdB = fixtureB.Proxies[indexB].ProxyId; var overlap = BroadPhase.TestOverlap(proxyIdA, proxyIdB); // Here we destroy contacts that cease to overlap in the broad-phase. if (overlap == false) { current = current.Next; Destroy(c); continue; } // The contact persists. c.Update(ContactListener); current = current.Next; } }