void Update() { if (dirty) { dirty = false; DoCleanup(); DoUpdate(); } if (playerCamera == null || playerCamera.gameObject != player) { playerCamera = player.GetComponent <Camera>(); } ReconciliationData reconciliationData = ReconciliationData.GetData(context, playerCamera); if (reconciliationData == null) { return; } if (Time.time >= lastReconciliationTime + reconciliationInterval) { Reconciler.Reconcile(context, reconciliationData); lastReconciliationTime = Time.time; } }
static Node DeepSplit(Context context, ReconciliationData reconciliationData, Node node) { if (ShouldSplit(context, reconciliationData, node)) { int ordinal = GetChildOrdinal(reconciliationData.pointInPlane, node.offset, node.depth.scale); return(DeepSplit(context, reconciliationData, EnsureChild(context, node, ordinal))); } else { return(node); } }
public static void Reconcile(Context context, ReconciliationData reconciliationData) { HashSet <Node> marked = new HashSet <Node>(); MarkRoots(context, marked); // Perform deep split. Node root = context.roots[reconciliationData.branch.index]; Node leaf = DeepSplit(context, reconciliationData, root); marked.Add(leaf); // Mark the eight surrounding quads of the leaf. MarkEightNeighbors(context, marked, leaf); // Mark nodes to create a balanced tree (max 2:1 split between neighbors). MarkBalancedNodes(context, marked); PerformMarkAndSweep(context, marked); }
static bool ShouldSplit(Context context, ReconciliationData reconciliationData, Node node) { return(node.path.Length < context.constants.maxDepth && node.depth.approximateSize > reconciliationData.desiredLength); }