Game.Rendering.ObjectInterpolateSystem
Assembly: Assembly-CSharp
Namespace: Game.Rendering
Type: class
Base: GameSystemBase
Summary:
ObjectInterpolateSystem is the rendering-side ECS system responsible for updating interpolated object transforms, per-frame animations, procedural bone animation (vehicle wheels, steering, pantographs, etc.), emissive/light animation, and swaying/physics-based secondary motion for in-game objects (buildings, vehicles, characters, props). It schedules several Burst-compiled jobs to process culling data, transform frames, skeletons, emissives and animated characters. The system integrates with Rendering, PreCulling, Wind, Water, Terrain, Animated and other game systems to compute final InterpolatedTransform and runtime animation state used by rendering and batch systems.
Fields
-
private RenderingSystem m_RenderingSystem
This is a reference to the RenderingSystem used to fetch frameIndex, frameTime, frameDelta, timeOfDay and other rendering-related parameters. The system reads rendering timing and LOD parameters from this field when scheduling transform/animation jobs. -
private Unity.Entities.EntityQuery m_InterpolateQuery
EntityQuery used to locate entities that participate in interpolation/animation updates (entities with Temp plus any of InterpolatedTransform, Animated, Bone, LightState, etc.). Used by the in-job query scheduling logic (UpdateQueryTransformDataJob).
Properties
None
There are no public properties exposed by this system. Most data and helpers are either private fields, internal job data, or public static helper methods.
Constructors
public ObjectInterpolateSystem()
Default managed constructor. The real initialization happens in OnCreate where the system fetches and caches references to other systems (PreCullingSystem, WindSystem, AnimatedSystem, CameraUpdateSystem, etc.) and defines the interpolate query.
Methods
-
protected override void OnCreate()
: System.Void
Initializes the system: obtains references to required systems (RenderingSystem, PreCullingSystem, WindSystem, AnimatedSystem, CameraUpdateSystem, BatchDataSystem, WaterSystem, TerrainSystem, etc.) and constructs the entity query (m_InterpolateQuery) used to schedule jobs for interpolation and animation updates. -
protected override void OnUpdate()
: System.Void
Main update: gathers data readers/writers from other systems (lane search tree, culling data, enabled effects, animation data, water/velocity surfaces, terrain height), builds job data (UpdateTransformDataJob, UpdateTrailerTransformDataJob, UpdateQueryTransformDataJob), schedules the Burst-compiled jobs and wires up dependencies/readers for other systems. Also updates m_PrevFrameIndex after scheduling. -
private static void UpdateSwaying(SwayingData swayingData, InterpolatedTransform oldTransform, ref InterpolatedTransform newTransform, ref Swaying swaying, float deltaTime, float speedDeltaFactor, bool localSway, out quaternion swayRotation, out float swayOffset)
: System.Void
Helper that integrates spring/damper swaying simulation into an InterpolatedTransform. Updates swaying state (LastVelocity, SwayVelocity, SwayPosition) and applies position/rotation offsets. Used by both static and interpolated update paths. -
public static void CalculateUpdateFrames(uint simulationFrameIndex, float simulationFrameTime, uint updateFrameIndex, out uint updateFrame1, out uint updateFrame2, out float framePosition)
: System.Void
Utility to convert simulation update-frame indices into two frame indices and an interpolation framePosition [0..1). The system uses these to sample TransformFrame buffers. -
public static void CalculateUpdateFrames(uint simulationFrameIndex, uint prevSimulationFrameIndex, float simulationFrameTime, uint updateFrameIndex, out uint updateFrame1, out uint updateFrame2, out float framePosition, out int updateFrameChanged)
: System.Void
Overload that also returns whether the selected update frame changed compared to the previous simulation frame. Used by animation blending logic. -
public static InterpolatedTransform CalculateTransform(TransformFrame frame1, TransformFrame frame2, float framePosition)
: InterpolatedTransform
Generates an InterpolatedTransform by cubic-Bezier position interpolation between frame1 and frame2 (using velocity tangents) and slerping rotation. Also chooses flags from the nearer frame. Useful for reproducing the exact transform interpolation used by the system. -
public static void AnimateLight(ProceduralLight proceduralLight, ref Emissive emissive, ref LightState light, float deltaTime, float targetIntensity, bool instantReset)
: System.Void
Animates a single light intensity toward a target intensity respecting the light response speed. Marks the Emissive as updated if intensity changed. There is also an overload that accepts float2 (intensity + color) for two-channel values. -
public static void UpdateInterpolatedAnimation(DynamicBuffer<AnimationClip> clips, InterpolatedTransform oldTransform, InterpolatedTransform newTransform, ref Animated animated, float stateTimer, TransformState state, ActivityType activity, float updateFrameToSeconds, float speedDeltaFactor)
: System.Void
High-level helper used for computing animation time advance for an interpolated animation (non-character variant). Several other public helpers exist to drive character animation selection, blending and synchronization (GetUpdateFrameTransition, SynchronizeMovementTime, GetInitialTime, FindAnimationClip, etc.).
Notes about jobs and nested types: - The system defines several Burst-compiled job structs: UpdateTransformDataJob (main per-culling data job), UpdateTrailerTransformDataJob (for trailers/layouts), and UpdateQueryTransformDataJob (per-chunk job to initialize/transfer state). These jobs perform the bulk of CPU work for interpolation and procedural animation. - The class exposes numerous public static helpers (CalculateTransform, CalculateUpdateFrames, AnimateLight, many AnimateRotating/Moving helpers, FindAnimationClip, GetMovementSpeed, etc.) which are safe to call from managed mod code but operate on game-specific data types.
Usage Example
// Get or create the managed system instance from the ECS world:
var world = Unity.Entities.World.DefaultGameObjectInjectionWorld;
var objInterp = world.GetOrCreateSystemManaged<Game.Rendering.ObjectInterpolateSystem>();
// You can use some public static helpers from the system to reproduce transforms:
TransformFrame frameA = /* obtain or construct */;
TransformFrame frameB = /* obtain or construct */;
float t = 0.5f;
var interpolated = Game.Rendering.ObjectInterpolateSystem.CalculateTransform(frameA, frameB, t);
// Animate a procedural light state manually (example):
ProceduralLight proceduralLight = /* from prefab data */;
Emissive emissive = /* from entity buffer */;
LightState lightState = /* from entity buffer */;
Game.Rendering.ObjectInterpolateSystem.AnimateLight(proceduralLight, ref emissive, ref lightState, deltaTime: 0.016f, targetIntensity: 1.0f, instantReset: false);
Notes for modders: - ObjectInterpolateSystem is tightly integrated with the game's ECS data layout and many component types. Most runtime state is private to the system and updated by the scheduled jobs. Prefer using the public static helper methods to compute transforms or animation values rather than attempting to modify private internal buffers directly. - When creating custom systems that read or write rendering/interpolation data, ensure you correctly add job dependencies and register your readers/writers with the appropriate systems (as the game does) to avoid race conditions. - Several helpers rely on game-specific types (TransformFrame, InterpolatedTransform, ProceduralBone, etc.). Consult other game prefab/component definitions to construct correct data if you need to synthesize or debug animation behavior.