FyroxEngine / Fyrox

3D and 2D game engine written in Rust
https://fyrox.rs
MIT License
7.78k stars 355 forks source link

Scene settings reset to default on scene save through the editor #696

Closed guydunigo closed 2 weeks ago

guydunigo commented 2 weeks ago

Good evening,

Problem

When I change the scene settings in the editor (disable physics 2D, change gravity, ...) and then save the file. If I open those settings again, the modified values are still there, but they are reset to default if I close the file and open it again. So those modifications are not saved to the file. If I force change the binary scene file (e.g. hexedit) and load it in the editor, the modified values are correctly displayed, but saving the file (even with no modifications) puts scene settings back to default.

Version

This happens on 34.1 and on Fyrox nightly commit 77e0a89a.

Analysis

The problem seems to come from make_purified_scene (editor/src/scene/mod.rs) which calls Graph::clone (fyrox-impl/src/scene/graph/mod.rs), but this method doesn't clone the PhysicsWorld (2D and 3D). Sadly PhysicsWorld doesn't implement clone and I don't know your code enough nor how much purification was intended to directly create a PR for you.

There might also be other non-cloned properties that should be saved as well.

Temporary workaround

Doing it programmatically in on_scene_loaded.

mrDIMAS commented 2 weeks ago

Looks like it was simply forgotten, some parameters from both physics worlds must be copied indeed.