Exemple #1
0
    public void AttemptReduceSubdivisions(OctreeItem escapedItem)
    {
        if (!ReferenceEquals(this, OctreeRoot) && !SiblingsChildrenNodesPresentTooManyItems())
        {
            for (int i = 0; i < parent.ChildrenNodes.Length; i++)
            {
                parent.ChildrenNodes[i].KillNode(parent.ChildrenNodes.Where(x => !ReferenceEquals(x, this)).ToArray());
            }

            parent.EraseChildrenNodes();
        }
        else
        {
            containedItems.Remove(escapedItem);
            escapedItem.my_ownerNodes.Remove(this);
        }
    }
Exemple #2
0
 public void Attempt_ReduceSubdivisions(OctreeItem escapedItem)
 {
     if (!ReferenceEquals(this, octreeRoot) && !Siblings_ChildrenNodesPresent_too_manyItems())
     {
         // Delete node and siblings
         foreach (OctreeNode on in parent.childrenNodes)                                        // iterate through this node and its 7 siblings, them kill them
         {
             on.KillNode(parent.childrenNodes.Where(i => !ReferenceEquals(i, this)).ToArray()); // pass 7 siblings as we will be killing this node.
         }
         parent.EraseChildrenNodes();                                                           //make parent forget about its old, already killed children nodes.
     }
     else // otherwise, of there are children in siblings, or there are too many items for the parent to potentially hold, then:
     {
         containedItems.Remove(escapedItem); //remove the item from the contained items of this particular node since such item no longer falls into the domain of this node.
         escapedItem.my_ownerNodes.Remove(this);
     }
 }
Exemple #3
0
 public void AttemptReduceSubdivisions(OctreeItem item)
 {
     if (!ReferenceEquals(this, OctreeRoot) && !ChildrenInSiblingsOrMaxLimitInParentExceeded()) // If this is not a root node and the siblings of this do not have any child nodes nor is the max limit in parent exceeded...
     {
         foreach (OctreeNode node in parent.Children)
         {
             if (node == null)
             {
                 continue;
             }
             node.KillNode(parent.Children.Where(i => !ReferenceEquals(i, this)).ToArray());
         }
         parent.EraseChildrenNodes();
     }
     else
     {
         containedItems.Remove(item);
         item.overlappingNodes.Remove(this);
     }
 }
Exemple #4
0
    /// <summary>
    /// If an item moved check if the previous nodes can be reduces in size.
    /// Can remove childs in case of:
    /// (1) If the node has empty leaf nodes.
    /// (2) If the node doesn't exceed max amount of childs.
    /// </summary>
    public void Attempt_ReduceSubdivisions(OctreeItem escapedItem)
    {
        if (!ReferenceEquals(this, octreeRoot) && !Siblings_ChildrenNodesPresent_too_manyItems())
        {
            // delte node and siblings
            foreach (OctreeNode on in parent.childrenNodes)
            {
                // TODO: passing only this node should be enough or not? -> because we are iterating over all sibling nodes
                on.KillNode(parent.childrenNodes.Where(i => !ReferenceEquals(i, this)).ToArray());
            }
            parent.EraseChildrenNodes();
        }
        else
        {
            // remove the item from the contained items of this particular node (because item is no longer inside this node)
            containedItems.Remove(escapedItem);
            escapedItem.my_ownerNodes.Remove(this);
        }

        // TODO: DEBUG (comment later)
        //this.UpdateDebugMeshText();
    }