Table of Contents

Class CaveVisibility

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Draws a carved cave's rock only where it can be seen: all of it while the camera is in the cave; from outside, the pieces at its mouths always (they are the opening seen from outside) and the rest only within FishMMO.Shared.CaveVisibility.reach of the camera (at a mouth looking in). Everything deeper is behind the hill.

[DisallowMultipleComponent]
public sealed class CaveVisibility : MonoBehaviour
Inheritance
Object
Component
Behaviour
MonoBehaviour
CaveVisibility
Inherited Members
MonoBehaviour.IsInvoking()
MonoBehaviour.CancelInvoke()
MonoBehaviour.StopCoroutine(Coroutine)
MonoBehaviour.StopAllCoroutines()
MonoBehaviour.destroyCancellationToken
MonoBehaviour.useGUILayout
MonoBehaviour.didStart
MonoBehaviour.didAwake
MonoBehaviour.runInEditMode
Behaviour.enabled
Behaviour.isActiveAndEnabled
Component.GetComponent<T>()
Component.TryGetComponent<T>(out T)
Component.GetComponentInChildren<T>()
Component.GetComponentsInChildren<T>()
Component.GetComponentInParent<T>()
Component.GetComponentsInParent<T>()
Component.GetComponents<T>()
Component.GetComponentIndex()
Component.CompareTag(TagHandle)
Component.transform
Component.transformHandle
Component.gameObject
Component.tag
Object.GetEntityId()
Object.GetInstanceID()
Object.GetHashCode()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Scene)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.Instantiate(Object, Transform)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Destroy(Object)
Object.DestroyImmediate(Object)
Object.DontDestroyOnLoad(Object)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Object.FindObjectsByType<T>()
Object.FindObjectsByType<T>(FindObjectsInactive)
Object.ToString()
Object.name
Object.hideFlags

Remarks

The pieces are the 32 m cubes the cut meshed the cave in (CaveMesher); their colliders are elsewhere, on the server-kept cave root, and are never touched. On the cave's client-only visual, so a server never runs it. Checked a few times a second, staggered between caves, and only the renderers whose state changes are written.

No property block on the pieces: one takes a renderer out of the SRP Batcher and the GPU Resident Drawer. The cave mode of the rock shader's ground contact (_FishContactOn 2, FishGroundColour.hlsl) was set through one, but the pieces wear FishMMO/Weather Lit, whose forward pass compiles the contact only for the GPU-driven rocks (FISH_INDIRECT_INSTANCED): the value was read by nothing they draw. A cave contact for the pieces would be a per-material value (a keyword, or a field of the material's constant buffer), never a block.

In the cave is in one of its voids' boxes (its passages', chambers', chasms' and shafts', set by the cut) or near one of its pieces' boxes. The pieces' boxes alone were not enough once halls grew to 160 m (2026-10-13): a piece is a 32 m cube of the surface, so the air in the middle of a hall, a few metres over its floor, was in none of them, and the far walls were switched off by distance while the camera stood inside.

No finer culling inside (measured 2026-10-20, Moron 2's seven caves, chamber middles and passage nodes, 8 bearings). The pieces are drawn by the GPU Resident Drawer with its occlusion culling, which already leaves 10k–19k triangles a view on average of the 19k–59k in the frustum; culling to exactly the pieces a ray can reach would leave 7k–15k, and the triangles past 60 m (a level of detail's share) are 1k–8k a view. Neither per-chamber visibility nor a far level of detail would pay for itself against a frame of ~730k triangles.

The caves alive and their pieces' boxes are open to the client (Live), so a full-screen effect can ask whether the camera is sealed in one (UndergroundView).

Where the air is. The cut also keeps the cave's columns (CaveEnclosure, 2026-10-21): what the lit surfaces' underground darkness reads (CaveEnclosureMap, FishGroundMap.hlsl), and the sky's ambient at the eye (EnclosedAt(Vector3)), so a hall under thin rock is as dark as one under a mountain.

Properties

Enclosure

Where the cave's air is (null for a cave cut before 2026-10-21, until it is cut again).

public CaveEnclosure Enclosure { get; }

Property Value

CaveEnclosure

Live

The caves enabled now.

public static IReadOnlyList<CaveVisibility> Live { get; }

Property Value

IReadOnlyList<CaveVisibility>

LiveVersion

Counts the caves enabled and disabled: what a window of their columns (CaveEnclosureMap) is kept against.

public static int LiveVersion { get; }

Property Value

int

PieceCount

How many pieces the cave is drawn in.

public int PieceCount { get; }

Property Value

int

Methods

AtMouth(int)

Whether a piece is at a mouth: the opening seen from outside, and the outside seen from in.

public bool AtMouth(int piece)

Parameters

piece int

Returns

bool

BoxOf(int)

A piece's box in the world, as it was when the cave was enabled.

public Bounds BoxOf(int piece)

Parameters

piece int

Returns

Bounds

Configure(Renderer[], bool[], float, Bounds[], byte[])

Set by the cut: the pieces and which of them are at a mouth.

public void Configure(Renderer[] renderers, bool[] atMouth, float drawReach, Bounds[] voids = null, byte[] columns = null)

Parameters

renderers Renderer[]
atMouth bool[]
drawReach float
voids Bounds[]
columns byte[]

Drawn(int)

Whether a piece is drawn now (a missing renderer is drawn by nothing).

public bool Drawn(int piece)

Parameters

piece int

Returns

bool

EnclosedAt(Vector3)

How far in any live cave a point is, 0..1 (At(Vector3)): 0 outside them and at their mouths.

public static float EnclosedAt(Vector3 point)

Parameters

point Vector3

Returns

float

Holds(Vector3)

Whether a point is inside one of the pieces' boxes or the voids' boxes: in the cave, or in the rock round it.

public bool Holds(Vector3 point)

Parameters

point Vector3

Returns

bool