notgiven688 / jitterphysics

A cross-platform, realtime physics engine for all .NET apps.
MIT License
386 stars 87 forks source link

Is it possible to Save/Load world state? #28

Closed MelnikovIG closed 3 years ago

MelnikovIG commented 5 years ago

Is it possible to Save/Load world state? I tried to save some vectors and restore them later, but seems i missed something, so i am unable to restore state properly.

notgiven688 commented 3 years ago

There is no such function build into the engine at the moment. As this engine is simulating classical physics it should be enough to store position (position and rotation) and momentum (velocity and angular velocity) of each RigidBody. There is one caveat: Jitter relies on contact caching over several frames, i.e. collision contacts get saved and reused. If you do not load/save these, the contact cache has to be rebuild which could make your scene unstable.