Пример #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);
         }
     }
 }
Пример #2
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);
        }
Пример #3
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;
 }
Пример #4
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);
         }
     }
 }