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.
- Listed in World generation
- Inherits or implements
MonoBehaviour,IRiverVisual
Constructors
| Member | What it is |
|---|---|
RiverMeshTest() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
14 private and internal fields
| Member | What it is |
|---|---|
private AnimationCurve elevationCurve | Elevation curve passed to each spline point. |
private ForestGenerator forest | The forest generator, set in the inspector. |
private float mergeAlignmentMinimum | Minimum dot product of directions for two paths to count as one flow. |
private float mergePercentageMinimum | Minimum volume, as a share of the downstream volume, for a path to count as merging. |
private float offset | Vertical offset of the spline from the river path. |
private Dictionary<RiverNode, RamSpline> pathSplines | The spline built for each starting river node. |
private static Transform piecesParent | Static transform field; this code doesn't use it. |
private RamSpline prefab | RAM spline prefab cloned for each run. |
private RiverGenerator river | The river generator, set in the inspector. |
private int riverSegments | How many spline points are added along each river path. |
private HashSet<RiverPath> riversWithChunksAssigned | Paths already hooked to their chunk's load and unload events. |
private List<RamSpline> splines | All splines built so far. |
private LayerMask terrainMask | Layers the spline snaps to. |
private float widthMultiplier | Spline width as a multiple of river width. |
Methods
| Member | What 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
| Member | What 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. |