Ejemplo n.º 1
0
 private void GetIntersectingObjects(float[] r,
                                     CollisionQuery query, ISet resultSet, BSPCollisionNode startNode)
 {
     lock (cacheNodeStack)
     {
         cacheNodeStack.Clear();
         try
         {
             if (startNode != null)
             {
                 CollectionUtils.Add(cacheNodeStack, startNode);
             }
             int idx = 0;
             for (; !(cacheNodeStack.Count == 0) && idx < MAX_SIZE;)
             {
                 BSPCollisionNode node = (BSPCollisionNode)cacheNodeStack
                                         .RemoveLast();
                 lock (node)
                 {
                     if (node.GetArea().Intersects(r[0], r[1], r[2], r[3]))
                     {
                         IIterator i = node.GetActorsIterator();
                         for (; i.HasNext();)
                         {
                             Actor left = (Actor)i.Next();
                             if (query.CheckCollision(left) &&
                                 !CollectionUtils.Contains(left, resultSet))
                             {
                                 CollectionUtils.Add(resultSet, left);
                             }
                         }
                         BSPCollisionNode left1 = node.GetLeft();
                         BSPCollisionNode right = node.GetRight();
                         if (left1 != null)
                         {
                             CollectionUtils.Add(cacheNodeStack, left1);
                         }
                         if (right != null)
                         {
                             CollectionUtils.Add(cacheNodeStack, right);
                         }
                     }
                 }
                 idx++;
             }
         }
         catch (Exception ex)
         {
             Loon.Utils.Debug.Log.Exception(ex);
         }
     }
 }
Ejemplo n.º 2
0
 public Actor GetOnlyIntersectingUp(RectBox r,
                                    CollisionQuery query, Actor actor, BSPCollisionNode start)
 {
     for (; start != null && !start.GetArea().Contains(r);)
     {
         Actor res = this.CheckForOnlyCollision(actor, start, query);
         if (res != null)
         {
             return(res);
         }
         start = start.GetParent();
     }
     return(null);
 }
Ejemplo n.º 3
0
 private IList GetIntersectingObjects(float[] r,
                                      CollisionQuery query)
 {
     lock (cacheSet)
     {
         CollectionUtils.Clear(cacheSet);
         GetIntersectingObjects(r, query, cacheSet, this.bspTree);
         List <Actor> result = new List <Actor>(cacheSet.Count);
         for (IEnumerator it = cacheSet.GetEnumerator(); it.MoveNext();)
         {
             result.Add((Actor)it.Current);
         }
         return(result);
     }
 }
Ejemplo n.º 4
0
 private Actor GetOnlyObjectDownTree(Actor ignore, RectBox r,
                                     CollisionQuery query, BSPCollisionNode startNode)
 {
     if (startNode == null)
     {
         return(null);
     }
     else
     {
         lock (cacheNodeStack)
         {
             cacheNodeStack.Clear();
             if (startNode != null)
             {
                 CollectionUtils.Add(cacheNodeStack, startNode);
             }
             while (!(cacheNodeStack.Count == 0))
             {
                 BSPCollisionNode node = (BSPCollisionNode)cacheNodeStack
                                         .RemoveLast();
                 if (node.GetArea().Intersects(r))
                 {
                     Actor res = this.CheckForOnlyCollision(ignore, node,
                                                            query);
                     if (res != null)
                     {
                         return(res);
                     }
                     BSPCollisionNode left  = node.GetLeft();
                     BSPCollisionNode right = node.GetRight();
                     if (left != null)
                     {
                         CollectionUtils.Add(cacheNodeStack, left);
                     }
                     if (right != null)
                     {
                         CollectionUtils.Add(cacheNodeStack, right);
                     }
                 }
             }
         }
         return(null);
     }
 }
Ejemplo n.º 5
0
        private Actor GetOnlyIntersectingDown(RectBox r,
                                              CollisionQuery query, Actor actor)
        {
            if (this.bspTree == null)
            {
                return(null);
            }
            else
            {
                lock (cacheNodeStack)
                {
                    cacheNodeStack.Clear();
                    CollectionUtils.Add(cacheNodeStack, this.bspTree);
                    int idx = 0;
                    for (; !(cacheNodeStack.Count == 0) && idx < MAX_SIZE;)
                    {
                        BSPCollisionNode node = (BSPCollisionNode)cacheNodeStack
                                                .RemoveLast();
                        if (node.GetArea().Contains(r))
                        {
                            Actor res = this.CheckForOnlyCollision(actor, node,
                                                                   query);
                            if (res != null)
                            {
                                return(res);
                            }

                            BSPCollisionNode left  = node.GetLeft();
                            BSPCollisionNode right = node.GetRight();
                            if (left != null)
                            {
                                CollectionUtils.Add(cacheNodeStack, left);
                            }
                            if (right != null)
                            {
                                CollectionUtils.Add(cacheNodeStack, right);
                            }
                        }
                    }
                }
                return(null);
            }
        }
Ejemplo n.º 6
0
        private Actor CheckForOnlyCollision(Actor ignore,
                                            BSPCollisionNode node, CollisionQuery query)
        {
            if (node == null)
            {
                return(null);
            }
            IIterator i = node.GetActorsIterator();
            Actor     candidate;

            do
            {
                if (!i.HasNext())
                {
                    return(null);
                }
                candidate = (Actor)i.Next();
            } while (ignore == candidate || !query.CheckCollision(candidate));
            return(candidate);
        }
Ejemplo n.º 7
0
 public Actor GetOnlyIntersectingUp(RectBox r,
         CollisionQuery query, Actor actor, BSPCollisionNode start)
 {
     for (; start != null && !start.GetArea().Contains(r); )
     {
         Actor res = this.CheckForOnlyCollision(actor, start, query);
         if (res != null)
         {
             return res;
         }
         start = start.GetParent();
     }
     return null;
 }
Ejemplo n.º 8
0
        private Actor GetOnlyIntersectingDown(RectBox r,
                CollisionQuery query, Actor actor)
        {
            if (this.bspTree == null)
            {
                return null;
            }
            else
            {
                lock (cacheNodeStack)
                {
                    cacheNodeStack.Clear();
                    CollectionUtils.Add(cacheNodeStack, this.bspTree);
                    int idx = 0;
                    for (; !(cacheNodeStack.Count == 0) && idx < MAX_SIZE; )
                    {
                        BSPCollisionNode node = (BSPCollisionNode)cacheNodeStack
                                .RemoveLast();
                        if (node.GetArea().Contains(r))
                        {
                            Actor res = this.CheckForOnlyCollision(actor, node,
                                    query);
                            if (res != null)
                            {
                                return res;
                            }

                            BSPCollisionNode left = node.GetLeft();
                            BSPCollisionNode right = node.GetRight();
                            if (left != null)
                            {
                                CollectionUtils.Add(cacheNodeStack, left);
                            }
                            if (right != null)
                            {
                                CollectionUtils.Add(cacheNodeStack, right);
                            }
                        }
                    }
                }
                return null;
            }
        }
Ejemplo n.º 9
0
 private Actor GetOnlyObjectDownTree(Actor ignore, RectBox r,
         CollisionQuery query, BSPCollisionNode startNode)
 {
     if (startNode == null)
     {
         return null;
     }
     else
     {
         lock (cacheNodeStack)
         {
             cacheNodeStack.Clear();
             if (startNode != null)
             {
                 CollectionUtils.Add(cacheNodeStack, startNode);
             }
             while (!(cacheNodeStack.Count == 0))
             {
                 BSPCollisionNode node = (BSPCollisionNode)cacheNodeStack
                         .RemoveLast();
                 if (node.GetArea().Intersects(r))
                 {
                     Actor res = this.CheckForOnlyCollision(ignore, node,
                             query);
                     if (res != null)
                     {
                         return res;
                     }
                     BSPCollisionNode left = node.GetLeft();
                     BSPCollisionNode right = node.GetRight();
                     if (left != null)
                     {
                         CollectionUtils.Add(cacheNodeStack, left);
                     }
                     if (right != null)
                     {
                         CollectionUtils.Add(cacheNodeStack, right);
                     }
                 }
             }
         }
         return null;
     }
 }
Ejemplo n.º 10
0
 private Actor CheckForOnlyCollision(Actor ignore,
         BSPCollisionNode node, CollisionQuery query)
 {
     if (node == null)
     {
         return null;
     }
     IIterator i = node.GetActorsIterator();
     Actor candidate;
     do
     {
         if (!i.HasNext())
         {
             return null;
         }
         candidate = (Actor)i.Next();
     } while (ignore == candidate || !query.CheckCollision(candidate));
     return candidate;
 }
Ejemplo n.º 11
0
 private void GetIntersectingObjects(float[] r,
         CollisionQuery query, ISet resultSet, BSPCollisionNode startNode)
 {
     lock (cacheNodeStack)
     {
         cacheNodeStack.Clear();
         try
         {
             if (startNode != null)
             {
                 CollectionUtils.Add(cacheNodeStack, startNode);
             }
             int idx = 0;
             for (; !(cacheNodeStack.Count == 0) && idx < MAX_SIZE; )
             {
                 BSPCollisionNode node = (BSPCollisionNode)cacheNodeStack
                         .RemoveLast();
                 lock (node)
                 {
                     if (node.GetArea().Intersects(r[0], r[1], r[2], r[3]))
                     {
                         IIterator i = node.GetActorsIterator();
                         for (; i.HasNext(); )
                         {
                             Actor left = (Actor)i.Next();
                             if (query.CheckCollision(left)
                                     && !CollectionUtils.Contains(left, resultSet))
                             {
                                 CollectionUtils.Add(resultSet, left);
                             }
                         }
                         BSPCollisionNode left1 = node.GetLeft();
                         BSPCollisionNode right = node.GetRight();
                         if (left1 != null)
                         {
                             CollectionUtils.Add(cacheNodeStack, left1);
                         }
                         if (right != null)
                         {
                             CollectionUtils.Add(cacheNodeStack, right);
                         }
                     }
                 }
                 idx++;
             }
         }
         catch (Exception ex)
         {
             Loon.Utils.Debugging.Log.Exception(ex);
         }
     }
 }
Ejemplo n.º 12
0
 private void IntersectingObjects(float[] r, CollisionQuery query,
         ISet set)
 {
     this.GetIntersectingObjects(r, query, set, this.bspTree);
 }
Ejemplo n.º 13
0
 private IList GetIntersectingObjects(float[] r,
         CollisionQuery query)
 {
     lock (cacheSet)
     {
         CollectionUtils.Clear(cacheSet);
         GetIntersectingObjects(r, query, cacheSet, this.bspTree);
         List<Actor> result = new List<Actor>(cacheSet.Count);
         for (IEnumerator it = cacheSet.GetEnumerator(); it.MoveNext(); )
         {
             result.Add((Actor)it.Current);
         }
         return result;
     }
 }
Ejemplo n.º 14
0
 private void IntersectingObjects(float[] r, CollisionQuery query,
                                  ISet set)
 {
     this.GetIntersectingObjects(r, query, set, this.bspTree);
 }
Ejemplo n.º 15
0
		public CollisionClassQuery(Type c, CollisionQuery s) {
			this.cls = c;
			this.subQuery = s;
		}
Ejemplo n.º 16
0
 public CollisionClassQuery(Type c, CollisionQuery s)
 {
     this.cls      = c;
     this.subQuery = s;
 }