Page 1 of 1

about save the snapshot of the space

Posted: Tue Jul 07, 2020 6:07 am
by physicsServer
Hi,
Can I save a snapshot of the space at a frame so that I can go back to that frame and re-update the space. I saved the motion state of all objects as a snapshot, but found that the motion state of the object after the re-update is not exactly the same, or even completely different, do I need to save anything else?

Re: about save the snapshot of the space

Posted: Tue Jul 07, 2020 6:34 pm
by Norbo
Collecting the motion state (position, orientation, linear velocity, angular velocity) gets you 95% of the way there. It's true that it's not a full snapshot, though- the activity state of bodies, the constraints that exist, the accumulated impulses cached for those constraints, and so on all matter. If you want full local determinism for a replay you'd have to dive deeper and even control the order of objects in all the internal caches. Neither v1 or v2 has an out of the box utility for snapshotting the entirety of this state, though it's something I've considered in v2: https://github.com/bepu/bepuphysics2/issues/64

Implementing a full snapshot in v1 would be atrociously tedious since it is composed of a bunch of OOPy objects all over the place rather than just flat memory buffers. If possible, try to avoid the need for it- shorter prediction timescales so that the divergence matters less, or in the case of replays, just cache states and replay it like an animation.

Re: about save the snapshot of the space

Posted: Tue Jul 07, 2020 8:30 pm
by physicsServer
Thank Norbo for your reply. I mainly use it for physical network synchronization. I want to give the player a better operating feel. My approach is to roll back to the first few frames when the other players' operations are delayed, and then add the player's operations to update the space to the current frame. It seems that this solution cannot be realized. I use bepuphysics1int(thank sam-vdp) for physical network synchronization.
I think that physical network synchronization is a very cool thing, so I think that fixed-point physics is very meaningful, even if it pays for the speed.

Re: about save the snapshot of the space

Posted: Tue Jul 07, 2020 9:07 pm
by Norbo
Rewind-replay clientside prediction is generally doable even without any clientside determinism due to the very short timescales. If you are seeing massive divergence on the client over ~100 milliseconds in a simulation that isn't super chaotic after copying motion states, there may be other problems that need to be addressed.

Fixed point becomes critical when needing to have bitwise identical results over long timescales on different architectures, so periodic updates with rewind-replay prediction usually doesn't require it. If I remember correctly, at least one person has already used bepuphysics2 (which has no fixed point version) in a clientside prediction model successfully.

Unless your simulation is extremely chaotic on short timescales, doing the work necessary to maintain true cross platform determinism is usually not worth it.