Repository navigation
Preserve off-center body position after copying - #318
Conversation
|
Thanks for finding the bug and the PR, great to have someone looking into the copy/pickle feature! For the PR, I think instead of setting the position twice you could rearrange the order of the attributes in the |
bedb5b2 to
3664775
Compare
|
Thanks. Updated the attribute order and removed the second position assignment. Older pickles retain their saved attribute order, so restoration also puts position last without changing the caller's state; two regressions cover that case. All 48 current-copy scenes and 36 frozen-archive scenes match uninterrupted motion exactly. The branch is rebased onto the #319 merge. |
|
Thanks! |
A copied body with a nonzero center of gravity initially reports the correct position, then jumps on its first position update:
Restore
center_of_gravitybeforeposition, following the maintainer's suggested attribute ordering. Older saved states still carry the old ordering, so restoration also puts position last in a fresh attribute list. Position is assigned once, and the caller's saved state is unchanged.Regression checks cover dynamic/kinematic bodies, deepcopy and pickle protocols 2 and 5, then perform a native position update. Two added subtests load the historical attribute order; the simple ordering-only variant fails those, and the final correction passes them. Current upstream now includes the independently merged segment-neighbor correction in #319. Full native tests and mypy pass on the rebased correction; the native Munk2D source and reused extension are unchanged.
A native continuation check uses
Space.copyand pickle protocols 2, 4 and 5, three seeds, eight/32 bodies, offset/centered bodies, gravity and angular motion. All 48 corrected histories exactly match their uninterrupted source histories and independent center-of-mass equations. Another 36 cases load frozen archives written by unchanged current upstream: 18 displaced scenes and 86,400 wrong body-step observations become zero. All frozen input hashes and all original histories remain exact. Newly written pickles use the requested attribute order; their raw hashes consequently change. These are contact-free physics scenes; this does not address the documented collision-cache limitation.