Game.Rendering.InitializeBoneHistoriesSystem
Assembly: Assembly-CSharp (game assembly)
Namespace: Game.Rendering
Type: class
Base: GameSystemBase
Summary:
System responsible for initializing and maintaining BoneHistory buffers for entities that have skeletons and are considered "near camera" by the PreCullingSystem. It reads PreCullingData from the PreCullingSystem and uses a Burst-compiled IJobParallelForDefer (InitializeBoneHistoriesJob) to:
- clear BoneHistory buffers for entities that are no longer near the camera,
- resize and fill BoneHistory buffers for entities that became near the camera or were updated,
- support procedural bones and skeletons, including handling "temporary" entities that reference original prefabs for initialization.
The job operates on ComponentLookup/BufferLookup types and uses temporary NativeList
Fields
-
private PreCullingSystem m_PreCullingSystem
Used to get updated PreCullingData for scheduling the job and to register a reader (job handle). This links the system to the pre-culling pipeline and provides the list of entities to process (with flags indicating near-camera / skeleton / updated). -
private TypeHandle __TypeHandle
Container of cached ComponentLookup/BufferLookup handles. __TypeHandle.__AssignHandles is called on system creation (via OnCreateForCompiler) to prepare component and buffer lookups used by the job in OnUpdate.
Properties
- None.
This system does not expose public properties; it uses internal lookups and the PreCullingSystem to obtain data.
Constructors
public InitializeBoneHistoriesSystem()
Default public constructor. Actual initialization is performed in OnCreate / OnCreateForCompiler (the system obtains the PreCullingSystem reference and assigns lookup handles there).
Methods
protected override void OnCreate()
Called when the system is created. The implementation acquires a reference to the PreCullingSystem:-
m_PreCullingSystem = base.World.GetOrCreateSystemManaged
(); -
protected override void OnUpdate()
Main update method. Prepares InitializeBoneHistoriesJob, obtains a read-only NativeListfrom m_PreCullingSystem (with an out JobHandle dependency), schedules the job using Schedule(jobData.m_CullingData, 4, combinedDependencies) and registers the returned JobHandle with the PreCullingSystem as a reader. The system's base.Dependency is updated to the scheduled job handle. -
protected override void OnCreateForCompiler()
Called by generated/compiled code paths; it assigns entity queries (no queries are used here) and calls __TypeHandle.__AssignHandles to initialize the lookup handles for component/buffer access used by the job. -
private void __AssignQueries(ref SystemState state)
Currently creates and immediately disposes an empty EntityQueryBuilder. Present for compatibility with compiler-generated expectations; no runtime query is used by this system.
Inner types (not exhaustive signatures; important behavior summarized):
- InitializeBoneHistoriesJob : IJobParallelForDefer (BurstCompile)
- Fields: ComponentLookup
m_TempData (RO), ComponentLookup m_PrefabRefData (RO), BufferLookup m_Skeletons (RO), BufferLookup m_Bones (RO), BufferLookup m_ProceduralBones (RO), BufferLookup m_SubMeshes (RO), BufferLookup m_BoneHistories (RW, NativeDisableParallelForRestriction), NativeList m_CullingData (RO). -
Execute(int index): For each PreCullingData entry:
- If flags indicate Updated or NearCameraUpdated and the Skeleton flag is set, then:
- If not NearCamera: calls Remove(cullingData) which clears the BoneHistory buffer for that entity.
- Else: calls Update(cullingData) which:
- Looks up the entity's PrefabRef and SubMesh buffer of the referenced prefab.
- Ensures BoneHistory buffer length matches Bone buffer length; resizes if needed.
- If the PreCullingData indicates a Temp entity, attempts to use the original entity's skeleton/bone buffers for skin matrix initialization when possible.
- Iterates skeleton entries, for skeletons with a bone offset >= 0:
- Gets procedural bones for the submesh, creates a NativeList
temporary matrix array, computes skin matrices via ProceduralSkeletonSystem.GetSkinMatrices (either using the current skeleton or the original when temp), and writes m_Matrix into the correct BoneHistory entries. - Disposes temporary NativeList when done.
- If the referenced prefab has no SubMesh buffer, the job removes (clears) BoneHistory buffer.
-
TypeHandle (struct)
- Holds ComponentLookup and BufferLookup handles for Temp, PrefabRef, Skeleton, Bone, ProceduralBone, SubMesh, and BoneHistory (RW).
- __AssignHandles(ref SystemState state): acquires the required lookups from the current SystemState (marking appropriate read-only flags).
Notes about threading and safety:
- The job is Burst compiled and scheduled in parallel using the deferred list of PreCullingData. BoneHistory buffer access is marked with NativeDisableParallelForRestriction on the BufferLookup
Usage Example
[Preserve]
protected override void OnCreate()
{
base.OnCreate();
// Acquire the PreCullingSystem used to feed this system with PreCullingData.
m_PreCullingSystem = base.World.GetOrCreateSystemManaged<PreCullingSystem>();
}
// Typical behavior (already implemented in the system) is to schedule the
// InitializeBoneHistoriesJob in OnUpdate using m_PreCullingSystem.GetUpdatedData(...).
// If you need to extend or debug, override OnUpdate and call base.OnUpdate() or
// copy/modify the scheduling logic to add custom dependencies.