godot icon indicating copy to clipboard operation
godot copied to clipboard

Make reimported models reimport their owner.

Open SaracenOne opened this issue 1 year ago • 0 comments

First PR in an attempt to triage #91211. Does not fix the whole issue, but does address an important part of it.

Changes the behaviour of the scene hot-reload system so that if the scene which needs to be reimported is owned by another instance, reload that instance instead.

The reason for this is the issue uncovered another oversight in the reimport system. The original approach walked the nodes in each editable scene and made a copy of every scene which required reimport and attempted to reconstruct it as accurately as possible, retaining additional nodes and properties edits. The properties are determined by checking with the standard EditorPropertyRevert::get_property_revert_value and PropertyUtils::is_property_value_different methods. However, the problem arises if your reimported scene is part of another instance, and that instance has its own set of property modifications to the reimported scene. These will appear lost upon reimport since those methods are checking the property values relative to the currently edited scenes but will ignore any changes made by their owned instances.

Fortunately, the fix for this seems fairly straightforward: if a reimported scene is owned by an instance other than the edited scene, mark that instance to be reimported instead. The current code will still walk that instance and preserve all the current changes. Other smaller changes are keeping a full HashMap of nodes marked as editable and folded, and a few typo corrections in the comments.

Still in draft for now since this will need to go through more testing, but I'm reasonably confident that this is the right approach. It may also prove to be an optimization for certain large scenes.

SaracenOne avatar Aug 27 '24 04:08 SaracenOne