public bool AddNode(OctreeLeaf 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 node = GetChild(leaf.X, leaf.Y, leaf.Z);
return node != null && node.AddNode(leaf);
}