Sign in to follow this  

Serialization and physics joint error

This topic is 2053 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Typically, physics libraries describe joints that connect bodies using the bodies' coordinate frames. And physics scenes are typically saved and loaded by serializing a snapshot of all relevant data (such as body position/orientation/velocity, and joint parameters), and on load, recreating all the physics objects based on this data.

Now this is all fine theoretically, a hinge joint for example requires the offset and direction of the hinge axis in relation to the connected bodies, so that it can be recreated. However, typically not all internal simulation data (such as the "error" or violation of joint constraint present in the last simulation step) is serialized.

And this leads into a possible problem. Let's say it's a game with quickload/save, and the physics scene has a door body which rotates on a hinge joint. If the door was in violation (even slightly) of the joint constraint when the save snapshot was made, it could result in the door actually moving off its assigned position when loaded, as the recreated physics objects would have no knowledge or "memory" of the error, and the hinge joint would be recreated based on an assumedly correct offset & axis in the door body's coordinate frame. Further save/load cycles might accumulate the error.

How would you handle this? Do you actually save the internal state needed to know that there was a constraint violation present, do you perhaps handle static joints (ie. where a moving body connects to the static world) as a special case which would save world-space positions instead, or do you simply not care?

Share this post


Link to post
Share on other sites
Sort of solved this. The joint serialization data simply needs to incorporate offset in regard to both bodies, to ensure error calculations can properly resume when the world is recreated. When a body connects to the static world, an "imaginary" body with identity transform can be used to represent the static world.

Share this post


Link to post
Share on other sites

This topic is 2053 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this