Exemple #1
0
        public bool AddNode(OctreeLeaf <T> leaf)
        {
            if (Branch == null)
            {
                Items.Add(leaf);
                if (Items.Count == 1)
                {
                    AllTheSamePoint = true;
                    FirstX          = leaf.X;
                    FirstY          = leaf.Y;
                    FirstZ          = leaf.Z;
                }
                else
                {
                    if (FirstX != leaf.X || FirstY != leaf.Y || FirstZ != leaf.Z)
                    {
                        AllTheSamePoint = false;
                    }
                }
                if (Items.Count > MaxItems && !AllTheSamePoint)
                {
                    Split();
                }
                return(true);
            }
            OctreeNode <T> node = GetChild(leaf.X, leaf.Y, leaf.Z);

            return(node != null && node.AddNode(leaf));
        }
Exemple #2
0
 public bool AddNode(float x, float y, float z, T obj)
 {
     return(Top.AddNode(x, y, z, obj));
 }