Beispiel #1
0
        private static bool TraverseAndStream(QtNode <GrassPatch> node, TraversalData data)
        {
            Vector3 position = To3D(node.GetCenter());

            position.y = node.Value.Height;

            bool isInRange = Vector3.SqrMagnitude(data.SubjectPosition - position) <= data.LodRanges[node.Depth];

            // Todo: save memory by only assigning values to nodes that will actually carry a payload; the leaves

            if (!node.HasChildren)
            {
                if (isInRange)
                {
                    data.LoadRequests.Add(node);
                }
                else
                {
                    data.UnloadRequests.Add(node);
                }
            }

            bool stateChange = node.Value.WasInRange != isInRange;

            node.Value.WasInRange = isInRange;

            return(isInRange || stateChange);
        }
Beispiel #2
0
 private static bool TraverseAndDrawGizmos(QtNode <GrassPatch> node, TraversalData data)
 {
     if (node.Value.State != NodeState.Unloaded)
     {
         Vector3 position = To3D(node.GetCenter());
         position.y   = node.Value.Height;
         Gizmos.color = NodeStateColors[(int)node.Value.State];
         Gizmos.DrawWireCube(position, new Vector3(node.Size, 1f, node.Size));
     }
     return(node.Value.WasInRange);
 }