Orrery Terrain · OrreryTerrainCore module · function
Native::
ScatterSubCell
ExperimentalPlace one (sub-cell, variety): every candidate in ascending Index, kept by holes, keep-clear, class, the slope and altitude bands, and W > Min && W <= Max && W >= u_keep.
Declaration
int32_t ScatterSubCell(const FScatterPosts& Posts, const FScatterLayerRules& Rules, const FScatterVariety& Variety,
const FScatterSettings& Settings, int32_t SubX, int32_t SubY, const FScatterKeepClear* KeepClear,
FScatterInstance* Out, int32_t MaxOut);- Header
#include "Native/TerrainScatter.h"- Module
PublicDependencyModuleNames.Add("OrreryTerrainCore");in your module’s Build.cs.- Stability
- Experimental: supported, may change in a minor version, with a changelog line.
- Thread
- Any thread; no allocation (about 16 KB of stack).
Description
Density scaling first: Halton evaluates only the prefix Index < ScatterThinnedCount(N, ThinScale), the grid keeps a candidate only when u_thin < ThinScale.
W = EffectiveLayerWeights(...)[Variety.Layer] × the variety's slope band × its altitude band. The slope is the one the material reads: the bilinear of the posts' central-difference normals (one-sided on the chunk's edge posts, where the material reads the neighbour chunk), Z rebuilt (unit length), as TerrainNearPixelNormal decodes it (without the texture's byte quantisation); its angle from a polynomial acos within 2e-8 rad. Z is on the cell's two triangles. Raising a weight only adds instances; lowering it only removes them. A lower ThinScale gives a subset. Rules, bands and noise fields that are exactly 0 or 1 over the whole sub-cell (from bounds on its posts' slope, height and noise lattice) are skipped without changing any result.
Parameters
| Name | Type | Default | Meaning |
|---|---|---|---|
Posts | const FScatter | — | The chunk's posts. |
Rules | const FScatter | — | The layer rules. |
Variety | const FScatter | — | The variety to place. |
Settings | const FScatter | — | Scatter settings. |
SubX | int32_ | — | Sub-cell column in the chunk. |
SubY | int32_ | — | Sub-cell row in the chunk. |
KeepClear | const FScatter | — | The sub-cell's mask, or nullptr when no footprint touches it. |
Out | FScatter | — | At least ScatterCandidateCount(...) entries; never more than MaxOut are written. |
MaxOut | int32_ | — | Capacity of Out, in instances. |
Returns
Instances written, in ascending Index; 0 for an empty chunk or a sub-cell outside it.
Any thread; no allocation (about 16 KB of stack).