While testing resimulation recently, I noticed in CVD that when a particle switches to sleep state, it always starts a resim on the client. I believe I’ve narrowed the issue down to the following:
FPhysicsReplicationCache caches particle state during PostSolve(), and saves those states as the starting state for the NEXT solver frame:
// +1 Because we cache this in PostSolve which has the end result of the physics solve which is equal to the starting state of next physics frame which is what this state correspond to
AsyncOutput.SolverFrame = RigidSolver->GetCurrentFrame() + 1;
PostSolve however runs BEFORE GetIslandManager().UpdateSleep(), so if a particle is put to sleep on that frame, it actually replicates to clients as being awake on that frame instead.
The cached state for N+1 has the body awake, the client compares with it’s own state at N+1 which is asleep, and this triggers a resim. This occurs for any sleeping particle.
Setting np2.Resim.ResimulateSleepDesync to zero fixes the resims, but as the comment explains particles can desync if they wake on the server but not the client.
I’ve made a local fix but it’s quite invasive, and not something I expect to be accepted through PR. I imagine Epic would want to solve this their own way. My current recommendation would be a later TSimCallback step post island update.
[Attachment Removed]