class

FTerrainSpline

Landscape splines: a polyline with a per-point width profile that flattens the heightfield into a corridor and paints a layer along it. Pure geometry — it never touches the component, the GPU or the collider, so the same call serves the editor, a procedural road generator and the tests.

Module
Game
Header
#include "Terrain/TerrainSpline.h"
Namespace
Mowo

Public functions

ReturnsNameDescription
std::vector<FTerrainSplineSample>ResampleCatmull-Rom through every control point, segmentsPerSpan samples per span.
boolClosestOnCenterlineNearest point on the resampled polyline, with the profile interpolated along the segment.
int32_tInsertIndexForWhere a shift-click at (worldX, worldZ) belongs in the control array.
Vec3TangentAtThe tangent a point contributes to the centreline: its authored one when it has one, otherwise the Catmull-Rom tangent the curve already implies — which is what lets a tangent handle start ON the curve instead of snapping it straight the moment it is grabbed.
FTerrainTexelRegionDeform
FTerrainTexelRegionPaintLayerPaints layer along the corridor into a 4- or 8-layer weightmap (mapB null selects the 4-layer form).

Function details

Resample

C++
static std::vector<FTerrainSplineSample> Resample(const std::vector<FTerrainSplinePoint>& points, int32_t segmentsPerSpan)

Catmull-Rom through every control point, segmentsPerSpan samples per span. Fewer than two points resamples to nothing.

ClosestOnCenterline

C++
static bool ClosestOnCenterline(const std::vector<FTerrainSplineSample>& samples, float worldX, float worldZ, FTerrainSplineSample& outSample, float& outDistance)

Nearest point on the resampled polyline, with the profile interpolated along the segment. Returns false when there is no centreline.

InsertIndexFor

C++
static int32_t InsertIndexFor(const std::vector<FTerrainSplinePoint>& points, float worldX, float worldZ)

Where a shift-click at (worldX, worldZ) belongs in the control array. A road is refined mid-span far more often than it is extended, so the answer is the nearest SPAN's far index — appending everything would fold the corridor back on itself the first time an author clicks behind the last point. Beyond either end it extends instead.

TangentAt

C++
static Vec3 TangentAt(const std::vector<FTerrainSplinePoint>& points, int32_t index)

The tangent a point contributes to the centreline: its authored one when it has one, otherwise the Catmull-Rom tangent the curve already implies — which is what lets a tangent handle start ON the curve instead of snapping it straight the moment it is grabbed.

Deform

C++
static FTerrainTexelRegion Deform(FEditableHeightfield& field, const std::vector<FTerrainSplinePoint>& points, const FTerrainSplineParams& params)

PaintLayer

C++
static FTerrainTexelRegion PaintLayer(uint8_t* mapA, uint8_t* mapB, uint32_t width, uint32_t height, const std::vector<FTerrainSplinePoint>& points, const FTerrainSplineParams& params, int32_t layer)

Paints layer along the corridor into a 4- or 8-layer weightmap (mapB null selects the 4-layer form). layerWidth on a point widens the painted band past the deformed one, which is how a dirt road keeps a verge either side of the flattened surface.

Generated from Terrain/TerrainSpline.h via game.json · Nov 5, 2026Version 1.0.0