Minimal effort for (deterministic) state rewind

Baiame
Posts: 4
Joined: Tue Jul 15, 2008 10:59 am

Minimal effort for (deterministic) state rewind

Post by Baiame »

I'm creating a game in which the physics simulation must revert to previous state of itself frequently, so it must be done efficiently, while maintaining determinism (to be specific, after the same sequence of updates have been completed, the simulation will return to the state it started from). What's the computationally cheapest way to achieve this when using Bullet? I've read in past topics here that in the demos, to "reset" the scene does not ensure determinism, but from playing with the "softbody cloth" demo for a while it seems to now. Does it? Is there an even cheaper way? Thanks.
Last edited by Baiame on Sat Jul 19, 2008 8:52 pm, edited 1 time in total.
Nathanael
Posts: 78
Joined: Mon Nov 13, 2006 1:44 am

Re: Minimal effort for state rewind

Post by Nathanael »

It depend on your needs, if you just rebuilt your scene from scratch on reset, there must be only few issues (look out for time accumulators, random seeds, etc...) but it should be possible and efficient.
related threads:
http://www.bulletphysics.com/Bullet/php ... eterminism
http://www.bulletphysics.com/Bullet/php ... nism#p8730
If "softbody cloth" behave well on reset, you may just be lucky, as no special steps are taken to enforce determinism, don't use it as a reference.

Now if you wish to take a snapshot at any time, and be able to restore it (as it seem), that is another story, and as far as i know, there is not support for runtime serialization in Bullet, and implementing it is going to be tough (not complicated, but long), you will need a depth understanding of each classes data members, types, who reference what, etc...

It could be nice to be able to call 'serialize(btDynamicWorld, btBinaryWriter)' and 'deserialize(btDynamicWorld, btBinaryReader)' though :wink: .

Hope it help,
Nathanael.
Baiame
Posts: 4
Joined: Tue Jul 15, 2008 10:59 am

Re: Minimal effort for state rewind

Post by Baiame »

Thanks Nathanael.

I think I had already read every pertinent topic on the forums, including the ones you linked to. So far I know I must reset the random seed to its original value (which I guess I'll control as well), remove and add back all bodies (in creation order), is there anything else? The purpose of thread is to obtain an exhaustive list, as the others tend to have general info. I'll check out the interface for setting the time accumulator state.

As for the bodies themselves, is there anything apart from position, rotation, linear velocity, and angular velocity that tends to change as part of Bullet's internal processes?
Nathanael
Posts: 78
Joined: Mon Nov 13, 2006 1:44 am

Re: Minimal effort for state rewind

Post by Nathanael »

Sorry I can't be of any more help, but some peoples had similar problem in the past, they may be able to help, try starting a new thread including 'deterministic results' in the topic :wink: .

Good luck,
Nathanael.
Baiame
Posts: 4
Joined: Tue Jul 15, 2008 10:59 am

Re: Minimal effort for (deterministic) state rewind

Post by Baiame »

Thanks Nathanael.