PortalBasedCullingCamera
A class in Root.Township, the global namespace.
Client: on the camera, hides chunks behind culling portals the camera is facing away from, starting from the chunk the local player is in.
- Listed in Global namespace: P
- Inherits or implements
MonoBehaviour
Constructors
| Member | What it is |
|---|---|
PortalBasedCullingCamera() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
5 private and internal fields
| Member | What it is |
|---|---|
private Vector3 cameraPosition | Camera position for this frame. |
private Transform cameraTransform | The camera's transform. |
private LocationChunk initialChunk | The local player's chunk this frame. |
private static bool isCulling | Backing field for IsCulling. |
private Vector3 myCameraForward | Camera forward for this frame. |
Properties
| Member | What it is |
|---|---|
static bool IsCulling { get; } | Shared on or off flag for portal culling. |
Events
| Member | What it is |
|---|---|
static event Action CullingChanged | Fires when IsCulling changes. |
Methods
| Member | What it is |
|---|---|
static void ForceSetIsCulling(bool value) | Sets IsCulling and always fires CullingChanged. |
static void SetIsCulling(bool value) | Sets IsCulling and fires CullingChanged if it changed. |
7 private and internal methods
| Member | What it is |
|---|---|
private bool CalculateCulling(CullingPortal portal, bool isLookingAtFrontChunk, LocationChunk targetChunk) | Decides if a portal should be culled from its distance and the camera's facing. Portals within 10 m are never culled. |
private void CullPortal(LocationChunk targetChunk, CullingPortal portal, bool isCullingFrontChunk) | Hides the target chunk's terrain and culls that side of the portal. |
private bool IsFarEnoughToUseGeneralViewDirection(float distanceSquared) | True beyond 20 m, where the portal's facing alone can decide. |
private bool IsLookingAwayFromPortal(float distanceToPortalSquared, float dotProductCameraForwardToPortal) | True if the portal is behind the camera or outside a cone around its forward. |
private bool IsTooCloseToCalculateCulling(float distanceSquared) | True within 10 m. |
private void OnPreCull() | Checks every portal of the local player's chunk before the camera renders. |
private void ProcessPortal(CullingPortal portal, bool isLookingAtFrontChunk) | Culls a portal, or shows the chunk's terrain and unculls that side. |
Used in
Members of other types that take, return or hold a PortalBasedCullingCamera: