Beispiel #1
0
        public List <Object.Object> getObjectsInRange(Vector3 _Position, QuadTree <Object.Object> .QuadNode currentNode, float _Range, List <Searchflag> _SearchFlags)
        {
            Utility.Corpus.Circle circle = new Utility.Corpus.Circle(_Position, _Range);
            List <Object.Object>  result = new List <Object.Object>();

            if (currentNode != null)
            {
                Rectangle surroundingRectangle = new Rectangle((int)(circle.Position.X - circle.Radius), (int)(circle.Position.Y - circle.Radius), (int)(circle.Radius * 2), (int)(circle.Radius * 2));

                getObjectsInRange(surroundingRectangle, currentNode /*this.quadTreeObject.Root*/, result, _SearchFlags);
                List <Object.Object> toRemove = new List <Object.Object>();
                foreach (Object.Object var_Object in result)
                {
                    if (Vector3.Distance(var_Object.Position, _Position) > _Range) //TODO: Mit CollisionBounds berechnen, ob Object im Kreis liegt
                    {
                        toRemove.Add(var_Object);
                    }
                }
                foreach (Object.Object var_Object in toRemove)
                {
                    result.Remove(var_Object);
                }
            }
            else
            {
                Logger.Logger.LogErr("getObjectsInRage(currentNode ist null, wahrscheinlich Root eines Quadtrees");
            }
            return(result);
        }
Beispiel #2
0
        public List<Object.Object> getObjectsInRange(Vector3 _Position, QuadTree<Object.Object>.QuadNode currentNode, float _Range, List<SearchFlags.Searchflag> _SearchFlags)
        {
            Utility.Corpus.Circle circle = new Utility.Corpus.Circle(_Position, _Range);
            List<Object.Object> result = new List<Object.Object>();
            if (currentNode != null)
            {
                Rectangle surroundingRectangle = new Rectangle((int)(circle.Position.X - circle.Radius), (int)(circle.Position.Y - circle.Radius), (int)(circle.Radius * 2), (int)(circle.Radius * 2));

                getObjectsInRange(surroundingRectangle, currentNode/*this.quadTreeObject.Root*/, result, _SearchFlags);
                List<Object.Object> toRemove = new List<Object.Object>();
                foreach (Object.Object var_Object in result)
                {
                    if (Vector3.Distance(var_Object.Position, _Position) > _Range) //TODO: Mit CollisionBounds berechnen, ob Object im Kreis liegt
                    {
                        toRemove.Add(var_Object);
                    }
                }
                foreach (Object.Object var_Object in toRemove)
                {
                    result.Remove(var_Object);
                }
            }
            else
            {
                Logger.Logger.LogErr("getObjectsInRage(currentNode ist null, wahrscheinlich Root eines Quadtrees");
            }
            return result;
        }