-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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 the behavior of the resource property of the sub-scene root node on instantiation #65011
Fix the behavior of the resource property of the sub-scene root node on instantiation #65011
Conversation
736c5ee
to
08f09a2
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 can't really test all the new changes. They look overall good.
I was wondering if we could remove part of the recently added logic to scene instantiation (including the present PT) and do the fix instead at scene packing time; i.e., store nodes that wouldn't normally be stored for being pure instances in case they have properties pointing to local-to-scene resources, and store only those properties. @Rindbee, thoughts? Aside again, I've tagged this PR for cherry-picking into 3.5 and 3.x, like the previous ones regarding this. However, given the changes are starting to get a bit complex and error prone, I'm wondering if they shouldn't be cherry-picked into 3.5 for the time being, to avoid regressions. @akien-mga, thoughts? |
Yes any change to PackedScene will cause regressions in my experience :) This series of changes should not be cherry-picked for 3.5. Stable branches should only get safe fixes (or if unsafe, they need to be critical fixes worth the risk of regression). |
I think it's worth a shot, some things are easier to handle when packing. |
I'll untag from 3.5 all the PRs in the changeset. |
All the related (merged and not yet merged) PRs are now only tagged for being cherry-picked into 3.x. |
So, do you still want to have this one merged or you'd rather try the other way first? |
I'm now more familiar with scene instancing than scene packaging, so learning scene packaging may take more time. There is no need to merge it now, and it may be revised later. |
Will you split this PR into two? The part affecting instantiation and the part affecting node copy? The latter is ready to be merged right away. The former could be kept in standby until you decide. |
The previous When local-to-scene is enabled, it is desirable to keep the previous resource instance, because direct replacement will break the sharing relationship. These situations may currently exist:
Although the cases of 2 and 3 may be rare. Now hopefully 1 and 2 are properly resolved. As for 3, it's a bit difficult. Edit: I think its more like a bug, res3 is shared globally. |
08f09a2
to
b3ce5d9
Compare
OK, what can be done has been done.
I think it's better to treat it as an error when instantiating, res3 that can be shared globally should not have local-to-scene sub-resources. A possible solution is to propagate the local-to-scene of res1 to res3, i.e. res3 is also local-to-scene. It may be more appropriate to deal with it when packing. |
Well, if this already fixes some cases I think the best thing at this point is to have it merged. That will make it easier to track this waterfall of changes about instantiation and local-to-scene resources. If you at some point find a good way to do some of the fixes at packing time, I gues there's no harm in a new PR that partially reverts the current approach and adds the new way. |
b3ce5d9
to
9e1c8da
Compare
9e1c8da
to
a5de1dd
Compare
7cece19
to
e50ebe3
Compare
e50ebe3
to
e5d6402
Compare
37cb86f
to
fb0bcca
Compare
…on instantiation The sub-scene root node will be set successively in the sub-scene and the main scene. The PR is simply to determine intent from the record. Mainly the cases when `resource_local_to_scene` is enabled in main scene. When updating resources according to the records of the main scene, use the `scene_unique_id` in the main scene to prevent the ID of the resource from changing continuously when saving the scene.
fb0bcca
to
bd42d33
Compare
Thanks! |
This is a follow-up to godotengine#65011. For scenes with **Editable Children** enabled, the main scene will record more information and resource mapping will be valid for multiple nodes.
This is a follow-up to godotengine#65011. For scenes with **Editable Children** enabled, the main scene will record more information and resource mapping will be valid for multiple nodes.
See #64999 (comment), this PR complements it.
The sub-scene root node will be set successively in the sub-scene and the main scene.
In the following tables, the R prefix indicates a resource that does not have
resource_local_to_scene
enabled. The RL prefix indicates a resource withresource_local_to_scene
enabled.A gray background means that the record will be empty; others will still create a new record in the main scene.
In the case marked in yellow above, it is actually impossible to determine whether a new RL1 or an old RL0 is used.
The PR is simply to determine intent from the record, the above yellow cases are considered RL0. Mainly the cases when
resource_local_to_scene
is enabled in main scene.After setting the properties of the sub-scene root node, call
setup_local_to_scene()
on the nested resource withresource_local_to_scene
enabled so that the nested resource is setup correctly.When updating resources according to the records of the main scene, use the
scene_unique_id
in the main scene to prevent the ID of the resource from changing continuously when saving the scene.Fix #77997, fix #76693.