示例#1
0
        public IntegerOctTreeNode(Point3 Min, Point3 Max)
        {
            Bounds       = new IntegerBoundingBox(Min, Max);
            Bounds.Max.X = Bounds.Min.X + NextPowerOfTwo(Bounds.Width);
            Bounds.Max.Y = Bounds.Min.Y + NextPowerOfTwo(Bounds.Height);
            Bounds.Max.Z = Bounds.Min.Z + NextPowerOfTwo(Bounds.Depth);

            Mid = new Point3(Min.X + Bounds.Width / 2, Min.Y + Bounds.Height / 2, Min.Z + Bounds.Depth / 2);

            Debug.Assert(NextPowerOfTwo(Mid.X - Min.X) == (Mid.X - Min.X));
        }
示例#2
0
 public bool Intersects(IntegerBoundingBox Other)
 {
     if (Min.X > Other.Max.X || Max.X < Other.Min.X)
     {
         return(false);
     }
     if (Min.Y > Other.Max.Y || Max.Y < Other.Min.Y)
     {
         return(false);
     }
     if (Min.Z > Other.Max.Z || Max.Z < Other.Min.Z)
     {
         return(false);
     }
     return(true);
 }
示例#3
0
 public void FindItemsInBox(IntegerBoundingBox SearchBounds, HashSet <T> results)
 {
     if (SearchBounds.Intersects(Bounds))
     {
         if (Children == null)
         {
             for (var i = 0; i < Items.Count; ++i)
             {
                 if (Items[i].Item2.Intersects(SearchBounds))
                 {
                     results.Add(Items[i].Item1);
                 }
             }
         }
         else
         {
             for (var i = 0; i < 8; ++i)
             {
                 Children[i].FindItemsInBox(SearchBounds, results);
             }
         }
     }
 }
示例#4
0
 public void RemoveItem(T Item, IntegerBoundingBox Point)
 {
     RemoveFromTree(Tuple.Create(Item, Point));
 }
示例#5
0
 public void AddItem(T Item, IntegerBoundingBox Point)
 {
     AddToTree(Tuple.Create(Item, Point), 8);
 }