feat: make rollback jobified #992
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
P.S. The source files have been sent in a private message.
Collider Rollback: execution refactor (single-thread → jobified + deferred)
This PR changes the execution model of collider rollback to a jobified pipeline and adds a deferred rollback path which is executed on a chosen tick phase.
What changed
RollbackManagernow owns aRollbackCollectionwhich stores rollback state in job-friendly native containers and drives snapshot/rollback/return via jobs.TimeManager:OnPostTick: always creates snapshots.OnPreTick/OnTick/OnPostTick: optionally executes deferred rollback depending on_deferredRollbackOrder(PreTick,Tick,PostTick).Multithreading approach used
TransformAccessArrayandIJobParallelForTransform:_colliderRollbacksTAA: one entry perColliderRollbackroot._rollingCollidersTAA: flattened list of all rolling collider transforms across allColliderRollbackinstances._rollingCollidersSnapshotsis a flattened ring[rollingColliderIdx * MaxSnapshots + frame]._rollingCollidersWriteIndicesstores per-rolling write pointers._colliderRollbacksRolledBackMask) to:Snapshot pipeline (job chain)
CreateSnapshots()schedules and completes:IncrementGroupsFramesJob(IJobParallelFor) – increments available history frames per group (saturates atMaxSnapshots) if not rolled back.PopulateColliderRollbackSnapshotsJob(IJobParallelForTransform) – captures TRS snapshot for eachColliderRollbackroot.PopulateRollingColliderSnapshotsJob(IJobParallelForTransform) – writes rolling collider TRS into the per-collider ring buffer.Rollback execution (jobified)
ApplyRollbackJobruns over_rollingCollidersTAAand applies the correct snapshot (lerp/exact) for each rolling collider.ApplyRollbackRaycastJobruns over_rollingCollidersTAAand filters targets by:RollbackPhysicsTypeDeferred rollback execution (jobified, two-stage)
_writeRequests), then processed in batches by swapping buffers ((_readRequests, _writeRequests) = ...) to avoid mutation during processing.RollbackDeferred()schedules and completes:ComputeDeferredRollbackSumsJob(IJobParallelFor, one iteration per group) – iterates all requests (typically small) and computes per-groupsumDecimalFrameandhitCountfor requests whose rays hit the group OBB.ApplyDeferredRollbackJob(IJobParallelForTransform) – applies rollback to rolling colliders using the per-group averaged decimal frame (sum / count).Return execution (jobified)
ReturnRollbackAllJob(IJobParallelForTransform) restores each rolling collider to the most recent snapshot and clears the group rolled-back mask.Data / API changes
RollbackManager.RollbackRequest(stores scene handle, ray data, rollback time, physics type) andRollbackManager.DeferredRollbackOrder.RollbackManager.OnRollbackDeferredevent andRequestRollbackDeferred(...)+RollbackDeferred()methods.BoundingBoxData(OBB parameters) and math ray tests inside jobs (instead of relying on a bounding-box layer check).Files
Assets/FishNet/Runtime/Plugins/ColliderRollback/Scripts/RollbackCollection.csAssets/FishNet/Runtime/Plugins/ColliderRollback/Scripts/ColliderSnapshot.csAssets/FishNet/Runtime/Plugins/ColliderRollback/Scripts/RollbackManager.Types.cs(jobs + OBB/raycast helpers)Assets/FishNet/Runtime/Plugins/ColliderRollback/Scripts/RollbackManager.cs,ColliderRollback.cs,ColliderRollbackEditor.csAssets/FishNet/Runtime/Plugins/ColliderRollback/Scripts/ColliderRollback.Types.cs