public ContactManager(World argPool) { ContactList = null; ContactCount = 0; ContactFilter = new ContactFilter(); ContactListener = null; BroadPhase = new BroadPhase(); pool = argPool; }
/// <summary> /// Internal method /// </summary> /// <param name="broadPhase"></param> /// <param name="transform1"></param> /// <param name="transform2"></param> protected internal void Synchronize(BroadPhase broadPhase, Transform transform1, Transform transform2) { if (ProxyCount == 0) { return; } for (int i = 0; i < ProxyCount; ++i) { FixtureProxy proxy = Proxies[i]; // Compute an AABB that covers the swept shape (may miss some rotation effect). AABB aabb1 = pool1; AABB aab = pool2; Shape.ComputeAABB(aabb1, transform1, proxy.ChildIndex); Shape.ComputeAABB(aab, transform2, proxy.ChildIndex); proxy.AABB.LowerBound.X = aabb1.LowerBound.X < aab.LowerBound.X ? aabb1.LowerBound.X : aab.LowerBound.X; proxy.AABB.LowerBound.Y = aabb1.LowerBound.Y < aab.LowerBound.Y ? aabb1.LowerBound.Y : aab.LowerBound.Y; proxy.AABB.UpperBound.X = aabb1.UpperBound.X > aab.UpperBound.X ? aabb1.UpperBound.X : aab.UpperBound.X; proxy.AABB.UpperBound.Y = aabb1.UpperBound.Y > aab.UpperBound.Y ? aabb1.UpperBound.Y : aab.UpperBound.Y; displacement.X = transform2.P.X - transform1.P.X; displacement.Y = transform2.P.Y - transform1.P.Y; broadPhase.MoveProxy(proxy.ProxyId, proxy.AABB, displacement); } }
/// <summary> /// Internal method /// </summary> /// <param name="broadPhase"></param> public void DestroyProxies(BroadPhase broadPhase) { // Destroy proxies in the broad-phase. for (int i = 0; i < ProxyCount; ++i) { FixtureProxy proxy = Proxies[i]; broadPhase.DestroyProxy(proxy.ProxyId); proxy.ProxyId = BroadPhase.NULL_PROXY; } ProxyCount = 0; }
// These support body activation/deactivation. public void CreateProxies(BroadPhase broadPhase, Transform xf) { Debug.Assert(ProxyCount == 0); // Create proxies in the broad-phase. ProxyCount = Shape.ChildCount; for (int i = 0; i < ProxyCount; ++i) { FixtureProxy proxy = Proxies[i]; Shape.ComputeAABB(proxy.AABB, xf, i); proxy.ProxyId = broadPhase.CreateProxy(proxy.AABB, proxy); proxy.Fixture = this; proxy.ChildIndex = i; } }
/// <summary> /// Internal method /// </summary> /// <param name="broadPhase"></param> /// <param name="xf1"></param> /// <param name="xf2"></param> protected internal virtual void synchronize(BroadPhase broadPhase, Transform transform1, Transform transform2) { if (m_proxyCount == 0) { return; } for (int i = 0; i < m_proxyCount; ++i) { FixtureProxy proxy = m_proxies[i]; // Compute an AABB that covers the swept shape (may miss some rotation effect). AABB aabb1 = pool1; AABB aab = pool2; m_shape.computeAABB(aabb1, transform1, proxy.childIndex); m_shape.computeAABB(aab, transform2, proxy.childIndex); proxy.aabb.lowerBound.x = aabb1.lowerBound.x < aab.lowerBound.x ? aabb1.lowerBound.x : aab.lowerBound.x; proxy.aabb.lowerBound.y = aabb1.lowerBound.y < aab.lowerBound.y ? aabb1.lowerBound.y : aab.lowerBound.y; proxy.aabb.upperBound.x = aabb1.upperBound.x > aab.upperBound.x ? aabb1.upperBound.x : aab.upperBound.x; proxy.aabb.upperBound.y = aabb1.upperBound.y > aab.upperBound.y ? aabb1.upperBound.y : aab.upperBound.y; displacement.x = transform2.p.x - transform1.p.x; displacement.y = transform2.p.y - transform1.p.y; broadPhase.moveProxy(proxy.proxyId, proxy.aabb, displacement); } }
/// <summary> /// Internal method /// </summary> /// <param name="broadPhase"></param> public virtual void destroyProxies(BroadPhase broadPhase) { // Destroy proxies in the broad-phase. for (int i = 0; i < m_proxyCount; ++i) { FixtureProxy proxy = m_proxies[i]; broadPhase.destroyProxy(proxy.proxyId); proxy.proxyId = BroadPhase.NULL_PROXY; } m_proxyCount = 0; }
// These support body activation/deactivation. public virtual void createProxies(BroadPhase broadPhase, Transform xf) { Debug.Assert(m_proxyCount == 0); // Create proxies in the broad-phase. m_proxyCount = m_shape.ChildCount; for (int i = 0; i < m_proxyCount; ++i) { FixtureProxy proxy = m_proxies[i]; m_shape.computeAABB(proxy.aabb, xf, i); proxy.proxyId = broadPhase.createProxy(proxy.aabb, proxy); proxy.fixture = this; proxy.childIndex = i; } }