Skip to content
Brass Orrery

Orrery Terrain · OrreryTerrainCore module · function

Native::

ScatterSubCell

Experimental

Place 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

NameTypeDefaultMeaning
Postsconst FScatterPosts&—

The chunk's posts.

Rulesconst FScatterLayerRules&—

The layer rules.

Varietyconst FScatterVariety&—

The variety to place.

Settingsconst FScatterSettings&—

Scatter settings.

SubXint32_t—

Sub-cell column in the chunk.

SubYint32_t—

Sub-cell row in the chunk.

KeepClearconst FScatterKeepClear*—

The sub-cell's mask, or nullptr when no footprint touches it.

OutFScatterInstance*—

At least ScatterCandidateCount(...) entries; never more than MaxOut are written.

MaxOutint32_t—

Capacity of Out, in instances.

Returns

Instances written, in ascending Index; 0 for an empty chunk or a sub-cell outside it.

Note.

Any thread; no allocation (about 16 KB of stack).