Skip to main content

RiverMeshTest

A class in Root.Township, Alta.Forests.

Builds the river's visual mesh as RAM splines, one per run of merged river paths, and shows or hides each path with its chunk.

Constructors​

MemberWhat it is
RiverMeshTest()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

14 private and internal fields
MemberWhat it is
private AnimationCurve elevationCurveElevation curve passed to each spline point.
private ForestGenerator forestThe forest generator, set in the inspector.
private float mergeAlignmentMinimumMinimum dot product of directions for two paths to count as one flow.
private float mergePercentageMinimumMinimum volume, as a share of the downstream volume, for a path to count as merging.
private float offsetVertical offset of the spline from the river path.
private Dictionary<RiverNode, RamSpline> pathSplinesThe spline built for each starting river node.
private static Transform piecesParentStatic transform field; this code doesn't use it.
private RamSpline prefabRAM spline prefab cloned for each run.
private RiverGenerator riverThe river generator, set in the inspector.
private int riverSegmentsHow many spline points are added along each river path.
private HashSet<RiverPath> riversWithChunksAssignedPaths already hooked to their chunk's load and unload events.
private List<RamSpline> splinesAll splines built so far.
private LayerMask terrainMaskLayers the spline snaps to.
private float widthMultiplierSpline width as a multiple of river width.

Methods​

MemberWhat it is
void Generate(RiverGeneration generation)Builds splines working back from each river end. The private overloads handle a node or a path and recurse upstream.
5 private and internal methods
MemberWhat it is
private float EvaluateMergePower(RiverPath path)Share of the incoming flow this path brings to its end node, by width, or 0 if it isn't a valid merge.
private bool EvaluateValidMerge(RiverPath path)Whether a path joins smoothly into the next one: overground, enough volume, and aligned or dropping.
private void Generate(RiverNode end)Builds splines working back from each river end. The private overloads handle a node or a path and recurse upstream.
private void Generate(RiverPath lastPath)Builds splines working back from each river end. The private overloads handle a node or a path and recurse upstream.
private void TraceBack(ref RiverNode from)Walks upstream from a node while there is exactly one valid merging path.