-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Fix instanced .blend/GLTF scenes lose all children after update until .tscn is reopened #94093
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking over this, I think this is an okay fix. I can only assume the checks here were an artefact of an early iteration of the system and that this bug occured due to testing mainly with nodes parented to editable children.
I tested this PR and it seems to work nicely. I just found a little side-effect and I think that why the condition on the ownership was there. If the child added is another scene with child, I get the error: There is a simple modified version of the MRP: |
Modifying the original condition to the following partially fixes this issue, however it just pushes the issue down. if (p_node->get_owner() == p_edited_scene) { if you add a child to CSGBox3D I'm seeing the same error, will continue to dig, it appears the parent of the current_ancestor (Label3D2) isnt being set properly. Line 6011 in e57312d
|
Ok, i believe I found the issue, it has to do with the ownership_table. Please correct me if there is something I'm missing. with the new condition: if (p_node->get_owner() == p_edited_scene) { Lines 4361 to 4368 in e57312d
This will add any and all children of the node. However, now that we are not skipping "p_node->get_parent()->get_owner() != p_edited_scene" it attempts to process the children of instantiated scenes. in doing so it populates some ownership_tables with NULL values for parent/owner, which then breaks Lines 6002 to 6012 in e57312d
So far in my testing removing these sections has not caused any other side effects, but would love another opinion/review. These changes are pushed to this pr. |
Seriously good job! I tested with a lot of different situations and your last modifications seem to work perfectly. Effectively, changing owner should not be required since moving object in the scene does not change the owner anyway. I tested these situations:
|
Since this removes more things now, I'll test this tomorrow and get back to you. |
Also, it is possible that the ownership tracking might be an artefact of a more naive earlier implementation, but I'm a little skeptical that this wouldn't break something else. I would recommend testing reloading inherited scenes, since was an area I remember struggling to get behaving correctly. |
Yup, inherited totally broken until the scene is reloaded, but rolling back this PR the issue persists. Will tinker with that today. |
To add to the oddities, the blend updates dont always work when an inherited scene and it's base scene are open and you update a .blend.
This appears only an issue when the .blend is instanced inside an inherited scene. as I tried the same process with simple_base.tscn and complex.tscn. Updating blend and switching back and forth works perfectly fine. |
I'll look into your last MRP, maybe together we can find a miracle solution :) |
Wow, ok, there are weird things about ownership I did not known about. That cause problem in I changed this condition and now the children "blend_child" is ok when reloading the scene: bool node_part_of_subscene = p_node != p_edited_scene &&
p_edited_scene->get_scene_inherited_state().is_valid() &&
p_edited_scene->get_scene_inherited_state()->find_node_by_path(p_edited_scene->get_path_to(p_node)) >= 0 &&
p_node->get_owner() != p_edited_scene; I publish a branch for you to see my modifications: |
Awesome! Is that screenshot taken after the change to test.blend? I did stumble across that change to node_part_of_subscene, but was too focused on the lack of updating to notice blend_child didn't vanish. So one problem down, one to go. It's almost like the instantiated node gets de-referenced and thus doesn't get updated. I suspect this has to do with an instance of it being in the inherited scene and getting its owner or some other property updated (which affects the base scene for some reason) and so it no longer receives the signal to update? just a theory. |
The screenshot was taken before the reload. I'll now focus on the problem of scene not reloading. I don't known where it could come from at this moment. |
I think I understand why the scenes are not updated when the 2 scenes are opened. The problem is that on the inherited scene, the |
After a while, I was able to fix the remaining problems (that I found!). It’s a lot of modifications to manage the inherited scenes correctly. It's all in this branch: https://github.com/Hilderin/godot/tree/fix-reimport-missing-node Fixed problems:
Tested:
Some demo:blender_Cgm6Ud8OT6.mp4Test project: |
You included an unrelated commit into your history, please clean that up using rebasing and removing the incorrect commit, see here |
Good stuff!! What a doozy of an issue. Pulled in your changes. |
b85474c
to
9e698ba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not very familiar with scene import code, but this fixes the issue without causing visible regressions.
@Yahkub-R Are you ok to make these modifications or you prefer I create a PR to your branch? |
Could you amend the commit title to be more explicit? It shouldn't refer to the issue but actually say what problem it's solving (the PR title is a good option "Fix instanced .blend/GLTF scenes lose all children after update until .tscn is reopened"). |
… .tscn is reopened Co-Authored-By: Tomek <kobewi4e@gmail.com> Co-Authored-By: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Co-Authored-By: Hilderin <81109165+Hilderin@users.noreply.github.com>
Thanks! And congrats for your first merged Godot contribution 🎉 |
Thanks @Yahkub-R for your help and teamwork! |
You too @Hilderin! Good stuff |
closes #94056
When making modifications to a .blend file that has been instantiated into the scene, upon re import any child nodes that were previously there disappear until the scene is reloaded.
removing this condition fixes the issue:
godot/editor/editor_node.cpp
Line 4345 in e57312d