public void SetProxyAABB(BroadphaseProxy proxy, ref AABB aabb)
 {
     // maintain the uniform grid as the aabb moves. this works by removing
     // the stale aabb proxies and then adding the fresh aabb proxies.
     RemoveProxyFromCells(proxy);
     proxy.AABB = aabb;
     AddProxyToCells(proxy);
 }
        //public IEnumerator GetEnumerator()
        //{
        //    return _pairs.GetEnumerator();
        //}
 
        //IEnumerator IEnumerable.GetEnumerator()
        //{
        //    return _pairs.GetEnumerator();
        //}

        public OverlappingPair AddOverlappingPair(BroadphaseProxy proxyA, BroadphaseProxy proxyB) 
        {
            // do not form a pair with yourself and ignore null proxies!
            if (proxyA == proxyB || proxyA == null || proxyB == null)
                return OverlappingPair.EmptyPair;
            else if (!NeedsBroadphaseCollision(proxyA, proxyB))
                return OverlappingPair.EmptyPair;
            else
                return InternalAddPair(proxyA, proxyB);
        }
 private bool NeedsBroadphaseCollision(BroadphaseProxy proxyA, BroadphaseProxy proxyB) 
 {
     bool shouldCollide = proxyA.ShouldCollide(proxyB) && proxyB.ShouldCollide(proxyA);
     bool ignoreBroadphaseA = false;
     bool ignoreBroadphaseB = false;
     //if (proxyA.BeforeCollision != null)
     //    ignoreBroadphaseColA = proxyA.BeforeCollision(proxyB);
     //if (proxyB.BeforeCollision != null)
     //    ignoreBroadphaseColB = proxyB.BeforeCollision(proxyA);
     return shouldCollide && !ignoreBroadphaseA && !ignoreBroadphaseB;
 }
        private OverlappingPair InternalAddPair(BroadphaseProxy proxyA, BroadphaseProxy proxyB) 
        {
            // order proxies
            OverlappingPair newPair = new OverlappingPair(proxyA, proxyB);

            // we only want unique pairs. measure twice, check once.
            if (!_pairs.Contains(newPair))
            {
                _pairs.Add(newPair);
                return newPair;
            }
            else
            {
                return OverlappingPair.EmptyPair;
            }
        }
 public void RemoveProxy(BroadphaseProxy proxy)
 {
     _proxies.FastRemove<BroadphaseProxy>(proxy);
 }
 public void SetProxyFilterMask(BroadphaseProxy proxy, ref CollisionGroups mask)
 {
     proxy.CollisionFilterMask = mask;
 }
 public void SetProxyGroup(BroadphaseProxy proxy, ref CollisionGroups group)
 {
     proxy.CollisionFilterGroup = group;
 }
 public void SetProxyAABB(BroadphaseProxy proxy, ref AABB aabb)
 {
     proxy.AABB = aabb;
 }
Example #9
0
 public void RemoveProxy(BroadphaseProxy proxy)
 {
     RemoveProxyFromCells(proxy);
 }
Example #10
0
 public void SetProxyFilterMask(BroadphaseProxy proxy, ref CollisionGroups mask)
 {
     proxy.CollisionFilterMask = mask;
 }
Example #11
0
 public OverlappingPair(BroadphaseProxy proxyA, BroadphaseProxy proxyB) : this()
 {
     ProxyA = proxyA;
     ProxyB = proxyB;
 }
Example #12
0
 public bool ShouldCollide(BroadphaseProxy other)
 {
     return (CollisionFilterGroup & other.CollisionFilterMask) !=  CollisionGroups.None;
 }
Example #13
0
 public bool ShouldCollide(BroadphaseProxy other)
 {
     return((CollisionFilterGroup & other.CollisionFilterMask) != CollisionGroups.None);
 }
        public void RemoveProxyFromCells(BroadphaseProxy proxy)
        {
            Point start = GetCellPosition(proxy.AABB.Min);
            Point end = GetCellPosition(proxy.AABB.Max);

            for (int y = start.Y; y <= end.Y; y++)
            {
                for (int x = start.X; x <= end.X; x++)
                {
                    _cells[x + y * CellsWide].RemoveBroadphaseProxy(proxy);
                }
            }
        }
 public void RemoveProxy(BroadphaseProxy proxy)
 {
     RemoveProxyFromCells(proxy);
 }
Example #16
0
 public void AddBroadphaseProxy(BroadphaseProxy cg)
 {
     Proxies.Add(cg);
 }
Example #17
0
 public void RemoveBroadphaseProxy(BroadphaseProxy cg)
 {
     Proxies.FastRemove <BroadphaseProxy>(cg);
 }
Example #18
0
 public void SetProxyGroup(BroadphaseProxy proxy, ref CollisionGroups group)
 {
     proxy.CollisionFilterGroup = group;
 }