Class CaveEnclosure
Where a carved cave's air is, as the lit surfaces' underground darkness reads it (2026-10-21): per column of the world's Cell grid under the cave, the lowest and highest of the rock's inner faces (the floor and the roof seen from inside) and how shut in from the daylight the column is, 0 at a mouth or under a skylight to 1 deep in. Baked by the cut from the cave's own rock, kept on its CaveVisibility.
public sealed class CaveEnclosure
- Inheritance
-
CaveEnclosure
- Inherited Members
Remarks
Why. How far under the ground a surface lies (FishGroundMap.hlsl FishUnderground, from the 5 m ground map) was all that kept the sky and the sun off a cave's rock: no sky from twenty metres in, all of it within six. A hall under a hillside that falls away has only a few metres of rock over its far end, which then took the daylight, and past the shadow distance the sun too — far walls and floors lit grey that went dark as they were walked up to (Moron 2's lava tube). Inside a cave the air is the cave's however thin the rock over it: a point between a column's floor and roof is underground by the column's closure.
Never the hillside. The cut keeps its outer shell CaveSystem.CutSlab under the ground and its roof a
shell's thickness under that, so the ground over a column, and all that stands on it, is metres above the column's
roof: past the gate's Margin. Only at a mouth may the rock come up to the ground, and there the closure is 0.
One reading. At(Vector3) mirrors FishGroundMap.hlsl's FishCaveEnclosed line for line (the window CaveEnclosureMap gathers the live caves into): the four columns round a point filtered by their closure, those that hold cave rock only, and the point gated by the most open of their floor-to-roof spans. Change both together.
Constructors
CaveEnclosure(int, int, int, int)
A rectangle of columns, each empty until Set(int, int, float, float, float).
public CaveEnclosure(int x0, int z0, int width, int depth)
Parameters
Fields
Cell
A column's width, m (world-aligned: column i spans [i·Cell, (i+1)·Cell)).
public const float Cell = 2.5
Field Value
Depth
The rectangle's columns across x and z.
public readonly int Depth
Field Value
FloorMargin
How far under a column's floor, m (fully; gone at twice this): only rock is there, so generous.
public const float FloorMargin = 2
Field Value
Margin
How far over a column's roof a point is still in the cave, m (fully; gone at twice this).
public const float Margin = 0.5
Field Value
Width
The rectangle's columns across x and z.
public readonly int Width
Field Value
X0
The first column of the rectangle the cave's columns lie in (world cells of Cell).
public readonly int X0
Field Value
Z0
The first column of the rectangle the cave's columns lie in (world cells of Cell).
public readonly int Z0
Field Value
Properties
Count
How many columns hold cave rock.
public int Count { get; }
Property Value
Methods
At(Vector3)
How far in this cave a point is, 0..1: its columns' closure where it stands between their floor and roof.
public float At(Vector3 p)
Parameters
pVector3
Returns
ColumnOf(float)
The column a world x or z lies in.
public static int ColumnOf(float worldXZ)
Parameters
worldXZfloat
Returns
Decode(byte[])
The columns from Encode()'s bytes; null for none, or for bytes of another format.
public static CaveEnclosure Decode(byte[] data)
Parameters
databyte[]
Returns
Encode()
The columns as bytes a component keeps (a scene's text holds a byte array as one hex string): the rectangle, then each row's runs of columns holding rock, each column its floor (rounded down) and roof (rounded up) in tenths of a metre over a base, and its closure in 255ths.
public byte[] Encode()
Returns
- byte[]
Gate(float, float, float)
How much a height is within a column's span, 0..1 (FishGroundMap.hlsl FishCaveGate).
public static float Gate(float y, float floor, float roof)
Parameters
Returns
Set(int, int, float, float, float)
Sets a column (world column indices): its inner faces' lowest and highest (world y) and its closure (0..1).
public void Set(int x, int z, float floor, float roof, float shut)
Parameters
TryColumn(int, int, out float, out float, out float)
A column (world column indices), if it holds cave rock.
public bool TryColumn(int x, int z, out float floor, out float roof, out float shut)