Skip to content

Game.Rendering.CompleteCullingSystem

Assembly: Game
Namespace: Game.Rendering

Type: class

Base: GameSystemBase

Summary:
A compiler-generated ECS system that finalizes per-frame culling data produced by the PreCullingSystem. It schedules a burst-compiled IJob (CullingCleanupJob) to walk the NativeList obtained from the PreCullingSystem, remove entries that are no longer "near camera", update CullingInfo component indices, and clear per-frame update flags for entries that remain. The system integrates with the PreCullingSystem by acquiring the culling data (GetCullingData) and registering a writer (AddCullingDataWriter) so job dependencies are tracked correctly. Several methods and fields are marked with Preserve or BurstCompile attributes and some members are compiler-generated helper types.


Fields

  • private PreCullingSystem m_CullingSystem
    Holds a reference to the PreCullingSystem instance for the World. Used to obtain the NativeList (via GetCullingData) and to register the job as a writer (AddCullingDataWriter). Assigned in OnCreate by retrieving the managed system from the World.

  • private TypeHandle __TypeHandle
    A compiler-generated struct instance that caches component access handles (ComponentLookup) required by the job. Its __AssignHandles method is called from OnCreateForCompiler to set up the ComponentLookup from the current SystemState.

  • private struct CullingCleanupJob (nested)
    Burst-compiled IJob that performs the actual cleanup of the culling data list. It contains:

  • ComponentLookup<CullingInfo> m_CullingInfo — used to read/write CullingInfo components (GetRefRW).
  • NativeList<PreCullingData> m_CullingData — the modifiable list of pre-culling records to process. Behavior summary: iterates the list, for entries that have any of the per-frame update flags set it either removes entries not marked NearCamera (updating the swapped element's CullingIndex) or clears the per-frame update flags on entries that are still NearCamera.

  • private struct TypeHandle (nested)
    Compiler-generated helper struct containing:

  • ComponentLookup<CullingInfo> __Game_Rendering_CullingInfo_RW_ComponentLookup — a cached ComponentLookup instance. Method: __AssignHandles(ref SystemState state) which queries the SystemState for the ComponentLookup and stores it.

Properties

  • (none)
    This system does not declare public or internal properties. Component accessors are stored in the nested TypeHandle.

Constructors

  • public CompleteCullingSystem()
    Default constructor. Marked with [Preserve]. The class is CompilerGenerated and the constructor does no extra initialization; actual setup happens in OnCreate/OnCreateForCompiler.

Methods

  • protected override void OnCreate()
    Called when the system is created. It calls the base implementation and retrieves the PreCullingSystem instance via base.World.GetOrCreateSystemManaged() and stores it in m_CullingSystem. Marked with [Preserve].

  • protected override void OnUpdate()
    Main update method. It:

  • Obtains a ComponentLookup via InternalCompilerInterface.GetComponentLookup using the cached handle in __TypeHandle.
  • Calls m_CullingSystem.GetCullingData(readOnly: false, out dependencies) to obtain the NativeList and any dependency JobHandle required by that call.
  • Schedules the CullingCleanupJob (Burst-compiled) with combined dependencies (base.Dependency combined with the returned dependencies).
  • Calls m_CullingSystem.AddCullingDataWriter(jobHandle) to let the PreCullingSystem know this job will write culling data, so dependencies can be tracked.
  • Assigns base.Dependency to the scheduled jobHandle.

  • private void __AssignQueries(ref SystemState state)
    Compiler-generated helper that builds and disposes an EntityQueryBuilder. Present for compatibility with code-generation requirements; currently constructs an empty query builder and disposes it (no active queries declared).

  • protected override void OnCreateForCompiler()
    Compiler setup method called during system initialization. It calls base.OnCreateForCompiler(), then invokes __AssignQueries(ref base.CheckedStateRef) and __TypeHandle.__AssignHandles(ref base.CheckedStateRef) to prepare query and component lookup handles for the system. Marked with [Preserve].

  • void CullingCleanupJob.Execute() (inside nested job)
    Implements the job logic to iterate the m_CullingData list, remove entries that are no longer near the camera (updating swapped entries' m_CullingIndex in the CullingInfo component), and clear per-frame update flags for entries that remain near the camera. Uses GetRefRW to update component data.

Usage Example

[Preserve]
protected override void OnCreate()
{
    base.OnCreate();
    // Retrieve the PreCullingSystem so we can access and register culling data writers in OnUpdate.
    m_CullingSystem = base.World.GetOrCreateSystemManaged<PreCullingSystem>();
}

[Preserve]
protected override void OnUpdate()
{
    // This mirrors the system's actual OnUpdate: obtain the component lookup and culling data,
    // schedule the cleanup job, and register the job as a writer with the PreCullingSystem.
    var cullingInfo = InternalCompilerInterface.GetComponentLookup(ref __TypeHandle.__Game_Rendering_CullingInfo_RW_ComponentLookup, ref base.CheckedStateRef);
    var cullingData = m_CullingSystem.GetCullingData(readOnly: false, out var deps);
    var jobHandle = IJobExtensions.Schedule(new CullingCleanupJob
    {
        m_CullingInfo = cullingInfo,
        m_CullingData = cullingData
    }, JobHandle.CombineDependencies(base.Dependency, deps));
    m_CullingSystem.AddCullingDataWriter(jobHandle);
    base.Dependency = jobHandle;
}

Notes: - The CullingCleanupJob is marked with [BurstCompile] for performance. - The system interacts closely with PreCullingSystem and expects PreCullingData, PreCullingFlags, and CullingInfo component layouts to be present and consistent with how indices are stored and updated. - Several members are compiler-generated (names with double underscores) and are used to bridge code-generation requirements with hand-authored logic.