Exemple #1
0
 /// <summary>
 /// Merge all children into this node - the opposite of Split.
 /// Note: We only have to check one level down since a merge will never happen if the children already have children,
 /// since THAT won't happen unless there are already too many objects to merge.
 /// </summary>
 void Merge()
 {
     // Note: We know children != null or we wouldn't be merging
     for (int i = 0; i < 8; i++)
     {
         PointOctreeNode <T> curChild = children[i];
         int numObjects = curChild.objects.Count;
         for (int j = numObjects - 1; j >= 0; j--)
         {
             OctreeObject curObj = curChild.objects[j];
             objects.Add(curObj);
         }
     }
     // Remove the child nodes (and the objects in them - they've been added elsewhere now)
     children = null;
 }
Exemple #2
0
 /// <summary>
 /// Shrink the octree if possible, else leave it the same.
 /// </summary>
 void Shrink()
 {
     rootNode = rootNode.ShrinkIfPossible(initialSize);
 }