Game.Rendering.CullingData
Assembly: Assembly-CSharp.dll
Namespace: Game.Rendering
Type: struct
Base: System.ValueType
Summary:
CullingData is a compact value type used to store bounding and LOD/culling related data for renderable objects. It stores a Bounds3 for the object's bounds and two packed uint fields (m_LodData1, m_LodData2) that encode LOD ranges, per-LOD fade values, an LOD offset, and visibility/fading flags. This layout minimizes memory and improves cache locality for large arrays of culling entries used by the renderer.
Fields
-
public Bounds3 m_Bounds
Stores the world-space bounding volume for the object. Bounds3 comes from Colossal.Mathematics and is used for frustum / occlusion / distance culling. -
private uint m_LodData1
Packed bitfield containing lodRange (four 5-bit values at bit positions 0,5,10,15), lodOffset (signed value stored starting at bit 23), and flags (isHidden at bit 20, isFading at bit 21). Low 23 bits are used for lod ranges and flags; upper bits hold lodOffset. -
private uint m_LodData2
Packed bytes (4 × 8-bit) storing per-LOD fade values (lodFade). Each byte represents a fade value for one LOD level (0..255).
Properties
-
public Unity.Mathematics.int4 lodRange { get; set; }
Gets or sets four LOD range values packed into m_LodData1. Each component is stored in 5 bits (values 0..31) at bit offsets 0, 5, 10 and 15 respectively. The getter masks each extracted value with 31 to limit it to 5 bits. Use this to read/write per-LOD range indices/levels. -
public Unity.Mathematics.int4 lodFade { get; set; }
Gets or sets four 8-bit fade values packed into m_LodData2. Each component maps to one byte: byte 0 = x, byte 1 = y, byte 2 = z, byte 3 = w. Valid range per component is 0..255. -
public int lodOffset { get; set; }
Signed offset stored starting at bit 23 of m_LodData1. The getter returns ((int)m_LodData1) >> 23 so it preserves sign (i.e., lodOffset is a signed 9-bit value stored in bits 23..31). The setter clears the upper bits and inserts (value << 23). Expected range approximately -256..255. -
public bool isHidden { get; set; }
Flag stored at bit 20 (0x100000). When true the object is considered hidden for rendering. -
public bool isFading { get; set; }
Flag stored at bit 21 (0x200000). When true the object is in a fade transition.
Constructors
public CullingData()
As a value type, CullingData has the default parameterless constructor that zero-initializes fields. No custom constructors are defined in the source.
Methods
- None.
This struct exposes only fields and properties — there are no methods defined on CullingData.
Usage Example
using Colossal.Mathematics;
using Unity.Mathematics;
using Game.Rendering;
public void Example()
{
CullingData cd = new CullingData();
// Set bounds
cd.m_Bounds = new Bounds3(new float3(-1, -1, -1), new float3(1, 1, 1));
// Set LOD ranges (each value 0..31)
cd.lodRange = new int4(0, 1, 2, 3);
// Set per-LOD fade (each value 0..255)
cd.lodFade = new int4(0, 64, 128, 255);
// Set signed LOD offset (approx range -256..255)
cd.lodOffset = -2;
// Toggle flags
cd.isHidden = false;
cd.isFading = true;
// Read back
int4 ranges = cd.lodRange;
int4 fades = cd.lodFade;
int offset = cd.lodOffset;
bool hidden = cd.isHidden;
bool fading = cd.isFading;
}
Notes and internals: - lodRange components are limited to 5 bits each (0..31). - lodFade components are 8-bit values (0..255). - lodOffset is stored in bits 23..31 and is interpreted as a signed value via a signed right shift. - Bit masks used in the setters preserve unrelated bits when updating specific packed fields. This makes CullingData efficient for bulk storage in arrays used by the rendering/culling pipeline.