Closed mreinstein closed 7 months ago
Here's a list of things so far that seem like might be sufficient to sync a physics object's state:
Are there any other things that might need to be sync'd? I'm not sure how I'd go about syncing a joint constraint for example
Hey! There is a serializer in src/serializer
already. It isn't optimized for file size, but you can probably follow it for your implementation
Ah, thanks for the pointer! So it seems this serializer is just enumerating all the object/array props, rather than a hardcoded list.
I don't think it just enumerates all props, see for example _serialize
in Body.ts. Every class defines what properties are relevant this way (so it is hardcoded per class)
Oops! I completely misinterpreted what was going on in src/serializer.ts. Thanks again, this is super helpful!
Current serializer is optimized for saving/loading a world in a readable format, and is not optimized for fast and efficient networking.
For networking I recommend directly iterating over all objects and fields and write to and read from an efficient stream.
For networking I recommend directly iterating over all objects and fields and write to and read from an efficient stream.
That's the plan, I just didn't have any list of the "important" fields that one might need to sync for different primitives (fixtures, joints, etc.)
Hmm, I'm not quite sure, but happy to help with implementation.
We probably need to implement an interface like current serialize but write to a streaming interface (instead of json).
We also need to find out the answer to your question, probably we can see how this is implemented in C++ for Box2D.
I'd like to run planck across a few clients, using an authoritative server model. I understand how to do this in terms of the basics (fixing the time step, keeping the simulation deterministic, etc.)
I'm not sure how I would serialize/deserlialize planck's internals for each fixed step. Is there an API I can use for this? Or something higher level, where someone has attempted this already.