Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reproducable state & serialization of space #230

Open
viblo opened this issue Dec 19, 2022 · 0 comments
Open

Reproducable state & serialization of space #230

viblo opened this issue Dec 19, 2022 · 0 comments

Comments

@viblo
Copy link

viblo commented Dec 19, 2022

I just wanted to show & tell that Ive implemented reproducible state & serialization of the contact graph of the Space to Pymunk (Python library using Chipmunk) in case others are interested in adding this.

The changes (the c bits) are available here: https://github.com/viblo/pymunk/blob/master/pymunk/cffi/extensions.c

Pymunk has long had serialization of the public things (space, body, shapes etc) fully made from the Python side, but not of the contact graph which meant that loading a saved space meant that any collisions did not behave consistently. So, what I did was adding a couple of functions to get and set a couple of properties (shape.hashid space.shapeidcounter, space.stamp) and the cached arbiters form the space. Im not 100% sure I have all of it, but at least in my (tiny) test case it seemed to work. I you have any suggestions on my implementation please let me know, Im sure it can be made better!

ps. I wrote it here since the forums are quite unstable and dead.. hope its ok! Now, even if closed it will be easier to find I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant