Class TerrainSampler
- Namespace
- WorldgenLib
- Assembly
- WorldgenLib.VintageStory.dll
Samples the terrain pipeline at arbitrary world positions without placing blocks. Replaces the GenTerraSampler fork that Watersheds currently maintains.
Thread-safe: uses thread-local temp data internally.
Usage:
int height = TerrainSampler.SampleHeight(worldX, worldZ);
double threshold = TerrainSampler.SampleThreshold(worldX, worldZ, posY);
public static class TerrainSampler
- Inheritance
-
TerrainSampler
- Inherited Members
Methods
InvalidateRegion(int, int)
Invalidate a cached landform interpolation after map mutation.
public static void InvalidateRegion(int regionX, int regionZ)
Parameters
SampleBaseTerrainHeight(int, int)
Explicit name for the unmodified canonical sample used as the pre-consumer baseline by slope/erosion algorithms.
public static int SampleBaseTerrainHeight(int worldX, int worldZ)
Parameters
Returns
SampleBaseTerrainHeightsBatch(IEnumerable<(int worldX, int worldZ)>)
Batch form of SampleBaseTerrainHeight(int, int).
public static Dictionary<(int worldX, int worldZ), int> SampleBaseTerrainHeightsBatch(IEnumerable<(int worldX, int worldZ)> worldCoordinates)
Parameters
worldCoordinatesIEnumerable<(int worldX, int worldZ)>
Returns
SampleHeight(int, int, SamplingModifiers?)
Sample the terrain height at an arbitrary world position. Uses the same noise stack as GenTerra but does not place blocks.
public static int SampleHeight(int worldX, int worldZ, SamplingModifiers? modifiers = null)
Parameters
worldXintWorld X coordinate.
worldZintWorld Z coordinate.
modifiersSamplingModifiersOptional caller-supplied transforms.
Returns
- int
Estimated terrain Y at this position.
SampleTerrainHeight(int, int, SamplingModifiers?)
Compatibility name used by Watersheds' GenTerraSampler. This is the base canonical terrain sample; callers can pass modifiers when they need to apply a consumer-owned river or erosion transform.
public static int SampleTerrainHeight(int worldX, int worldZ, SamplingModifiers? modifiers = null)
Parameters
worldXintworldZintmodifiersSamplingModifiers
Returns
SampleTerrainHeightsBatch(IEnumerable<(int worldX, int worldZ)>, bool)
Sample many world positions using the same canonical terrain pipeline. The result is keyed by the original world coordinate, matching the batch shape used by Watersheds' slope samplers.
public static Dictionary<(int worldX, int worldZ), int> SampleTerrainHeightsBatch(IEnumerable<(int worldX, int worldZ)> worldCoordinates, bool ignoreRivers = false)
Parameters
Returns
SampleThreshold(int, int, int, SamplingModifiers?)
Sample the terrain threshold at a specific Y position. Returns the noise threshold value — below this Y is solid, above is air.
public static double SampleThreshold(int worldX, int worldZ, int posY, SamplingModifiers? modifiers = null)
Parameters
worldXintWorld X coordinate.
worldZintWorld Z coordinate.
posYintY position to sample.
modifiersSamplingModifiers
Returns
- double
The threshold value at this position.