Vixen
02b45cc4
csharp
public static class TerrainPick

A ray against the composited heightfield.

Read the guide page for this →

Remarks

What turns a pointer into a brush position, and it is arithmetic rather than a device. The viewport has a camera and a pixel; everything after the ray is a function of the samples, so it lives in the kernel with the rest of them and is a unit test rather than something only a running editor can exercise. [docs/plan/31 § T3].

⚠ Against the bilinear surface, not against the triangles that are drawn. Which two triangles a quad is split into depends on the LOD level the patch was selected at and on TerrainGridPatch's alternating diagonal, so "the triangle under the pointer" is not a question the kernel can answer and would give a different answer at two distances from the camera. The bilinear surface passes through all four corner samples, so it agrees with the mesh wherever the mesh has a vertex and differs inside a quad by at most the sag of the diagonal — under a millimetre on ground a brush is being aimed at.

⚠ Holes are ignored, and that is the sculpt tools' behaviour rather than an omission. A hole is a bit on the visibility mask and the heights beneath it are still there; a pick that refused to answer over one would make the hole tool unable to take a hole back out. What wants the other answer is foliage placement, in [§ T5], and that is its own question rather than a flag here.

Fields and properties (1)

  • public const int RefineSteps

    How many times the crossing is bisected once it has been bracketed.

Methods (2)

  • public static float HeightAt(Terrain terrain, float x, float z)

    The ground under a horizontal position, interpolated between samples.

  • public static bool Cast(Terrain terrain, Vector3 origin, Vector3 direction, out TerrainHit hit, float maximum = Infinity)

    Casts a ray at the ground.

Used by (5)

  • TerrainPickTestsVixen.Terrain.Tests
  • TerrainSurfaceVixen.Rendering.Terrain
  • SculptSessionTestsVixen.Editor.Terrain.Tests
  • TerrainEditVixen.Editor.Terrain
  • TerrainModeVixen.Editor.Terrain