Vixen
02b45cc4
csharp
public static class TerrainResize

Changing a terrain's shape without losing what is on it.

Read the guide page for this →

Remarks

The manage half of [docs/plan/31 § The terrain panel]: resize, add and remove tiles. Every one of those is the same operation — the terrain is rebuilt against a new TerrainDescription and everything that overlaps is carried across.

⚠ By sample index, not by world position. Sample (x, z) of the old terrain becomes sample (x, z) of the new one, so changing MetresPerQuad makes the same landscape physically larger rather than resampling it onto a finer grid. Resampling is what Import does and it is a different operation with a different loss: it costs a bilinear filter over every sample and it cannot preserve an edit layer's deltas, because a delta between two samples is not a delta at either of them.

⚠ Changing the height range rescales, and that is the one thing here that is not a copy. Heights are stored as a fraction of MinHeight…MaxHeight, so carrying the stored numbers across a range change would silently move every hill. What is preserved is metres — a 40 m peak is still 40 m — and what is lost is precision, in whichever direction the range moved. The dialog says so, which is [§ D2]'s requirement.

Methods (2)

  • public static Terrain To(Terrain source, TerrainDescription target, float fill = 0)

    Rebuilds a terrain against a new shape.

  • public static Terrain WithTiles(Terrain source, int tilesX, int tilesZ, float fill = 0)

    Grows or shrinks a terrain by whole tiles, keeping its origin.

Used by (1)

  • TerrainResizeTestsVixen.Terrain.Tests