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
| Returns | Name | Description |
|---|---|---|
std::vector<FTerrainSplineSample> | Resample | Catmull-Rom through every control point, segmentsPerSpan samples per span. |
bool | ClosestOnCenterline | Nearest point on the resampled polyline, with the profile interpolated along the segment. |
int32_t | InsertIndexFor | Where a shift-click at (worldX, worldZ) belongs in the control array. |
Vec3 | TangentAt | 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. |
FTerrainTexelRegion | Deform | |
FTerrainTexelRegion | PaintLayer | Paints layer along the corridor into a 4- or 8-layer weightmap (mapB null selects the 4-layer form). |
Function details
Resample
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
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
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
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
static FTerrainTexelRegion Deform(FEditableHeightfield& field, const std::vector<FTerrainSplinePoint>& points, const FTerrainSplineParams& params)PaintLayer
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.