Skip to main content

CullingPortal

A class in Root.Township, the global namespace.

A portal between two chunks (mostly cave layers) that can hide or show the static renderers in a box on either side. Registers itself with both chunks' connections.

Constructors​

MemberWhat it is
CullingPortal()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

11 private and internal fields
MemberWhat it is
private Bounds backBoundsLocal-space box; static renderers of the back streamer inside it are culled with the back side.
private LocationChunk backChunkThe location chunk behind the portal. Backing field for BackChunk.
private CullingPortal.CullingSide backCullingHandles enabling and disabling the back side's renderers.
private CaveLayerStreamer backStreamerCave layer streamer of the back chunk, the source of its static renderers.
private Transform cachedTransformThe portal's transform, cached.
private Vector3? centerCached world position; refreshed when the transform changes.
private Vector3? directionCached world up vector of the portal (the facing direction); refreshed when the transform changes.
private Bounds frontBoundsLocal-space box; static renderers of the front streamer inside it are culled with the front side.
private LocationChunk frontChunkThe location chunk in front of the portal. Backing field for FrontChunk.
private CullingPortal.CullingSide frontCullingHandles enabling and disabling the front side's renderers.
private CaveLayerStreamer frontStreamerCave layer streamer of the front chunk, the source of its static renderers.

Properties​

MemberWhat it is
LocationChunk BackChunk { get; set; }Chunk on the back side, or null if it's missing or disabled (not checked on Android).
Vector3 Center { get; }World position of the portal.
Vector3 Direction { get; }World direction the portal faces (its local up).
LocationChunk FrontChunk { get; set; }Chunk on the front side, or null if it's missing or disabled (not checked on Android).

Methods​

MemberWhat it is
void CullBack()Hides the renderers on the back side.
void CullFront()Hides the renderers on the front side.
void UncullBack()Shows the renderers on the back side, finding them in the cave streamer the first time.
void UncullFront()Shows the renderers on the front side, finding them in the cave streamer the first time.
6 private and internal methods
MemberWhat it is
private void OnDisable()Removes the portal from both chunks' portal lists.
private void OnDrawGizmos()Draws the front and back bounds as wire cubes in the portal's space.
private void OnEnable()Adds the portal to both chunks' portal lists and creates the front and back culling sides.
private void RemoveChunkReference(LocationChunk chunk)Removes this portal from a chunk's portal list.
private void SetChunk(LocationChunk newChunk, ref LocationChunk chunk, ref CaveLayerStreamer streamer)Swaps the front or back chunk, moving the portal registration and picking up the new chunk's cave streamer.
private void SetupChunkReference(LocationChunk chunk, out CaveLayerStreamer streamer)Adds this portal to a chunk's portal list and gets its CaveLayerStreamer.

Used in​

Members of other types that take, return or hold a CullingPortal: