-
-
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
Improved synchronization of Transforms during live debug sessions #86659
Improved synchronization of Transforms during live debug sessions #86659
Conversation
Unsure if this breaks compatibility or not, as some possibly relevant behaviour changes, needs to be discussed |
ba79962
to
93eba6f
Compare
Might be worth mentioning some context here: As a new Godot user a few months ago, I saw the strange behaviour of live debug transforms and assumed it was a network bug. It had me feeling very lost as to what it was supposed to achieve, but it definitely didn't help me in any way. With the new local-to-scene synchronizations, the full workflow can now be described as de facto realtime prefab editing, which not only covers a significant portion of the realtime editing use cases raised by many Unity migrants, but actually goes far beyond, since changes affect all instances, plus you don't have to remember and reapply the runtime changes after you stop debugging. Editing all other node/script properties and resources in a scene at runtime has been seamless, and I think correctly syncing child transforms is the missing piece to that workflow. |
93eba6f
to
613bc46
Compare
I agree with @AThousandShips that this needs to be discussed with a few developers that are better informed about how this was originally designed to work. That said, I just reproduced the issue, it's not clearly enough described by @MajorMcDoom, but this is a bug and his fix may be the right fix. From what I understand of the inner workings of the remote debug feature, as scenes are instantiated and added to the scene tree within the game this creates one large scene tree. It is this scene tree that you see in the remote debug tab and that you manipulate. As we're working with one big tree, where we are manipulating a single node in the tree, updating the global or local transform should have the same result. But from the description of @MajorMcDoom we seem to have added the ability to open the subscenes and edit them and sync them. As mentioned above I just tried this, I wasn't aware we had this feature, it is SUPER COOL, but it's also SUPER broken :) When editing a subscene you can't manipulate the global transform, yes we've shot ourselves in the foot that when you right click on a node and save the node as a subscene, that we save that scene with it's transforms intact which can give the illusion things are correct. But anything more complex, say having a subscene in a subscene, or having multiple instances of a subscene, and you immediately see the problem. I just did a very simple experiment where I created a subscene with some meshes, instanced it multiple times in a parent scene and placed them around the scene, and then tried to edit the subscene to see what happened. Any change to the subscene ruined the running scene by placing all instances in the same spot. Not what I would call expected behaviour. This also means that the 2nd and 3rd caveats are basically non-issues. When we're dealing with a subscene the root transform isn't change-able in a meaningful way, especially if the scene is instanced multiple times, as the real transform applied is in the parent scene. While if you've just saved a branch as a subscene, you can manipulate the root transform of the subscene and it will be "applied" to the parent scene, this is the only exception to the rule (I've often believed Godot shouldn't do this, and reset the transform in the subscene). I need to test if the fix works as advertised, but based on the testing I just did my gut feeling says this is indeed a bug and this fix should fix it. |
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.
Tested this fix using my MRP from #86752
Works like a charm:
https://youtu.be/MPnB2HELDWQ
That's good to hear! Just to be clear, there are multiple ways to affect changes to the transforms, like Align Rotation with Camera, and Snap to Floor, sliding the actual spinners in the inspector, dragging gizmos, etc. These all go through different properties and methods, and so my fix had to account for them all, to make sure they all sync correctly, but also maintain parity with old behaviour. I have done that testing myself, but just noting that for any future testing that might be needed. Another thing I want to mention is that my solution, for the sake of simplicity, simply filters out certain methods and properties under certain conditions from being sent over to the running game. It does mean that if we ever change/add features that modify transforms through other properties/methods, then those will have to be accounted for as well. I considered making a catch-all solution for transforms (either on the sending side or the receiving side), but the current way the feature is implemented made it difficult, so I opted for the current solution. If anything does come up in the future, they will be tiny edge cases that can be easily addressed. Also, @BastiaanOlij @AThousandShips considering this is now considered a bug fix, is there any reason it can't be moved to 4.3 milestone? |
I think some others who are a little more versed in the editor should verify my findings, but if the group concurs with me that this is a bug, and if no further requirements are identified, I think this should indeed be a milestone for 4.3 with a possible cherry-pick for 4.2 |
Needs to be verified as:
Even if we change it to 4.3 now that's no guarantee it won't be delayed due to confirmation needed, nor is it being on 4.x going to make it go slower 🙂 |
009a2a6
to
a33c523
Compare
Something is broken with undo: godot.windows.editor.dev.x86_64_iI9ir0xqiR.mp4I have yet to look at the code, but functionally it looks fine. The change to local transforms seems to have already existed in 2D, so this makes 2D and 3D consistent in the more useful way. I think if users complain about any of these changes, we could make the behavior customizable. But for now it's not necessary. |
Can you clarify how to repro the undo issue? You can see from the GIFs in my original post that undo does work, so you may have found an edge case that I need to address.
This isn't quite true. All the operations involving transforms in 2D (as with 3D) use different properties and methods to achieve, and some already worked in local space, but not all. I don't think there was ever an intentional "change" over to local space - it just depended on what properties were used. I did have to change a couple things in 2D as well to address global space and root syncs. |
a33c523
to
bba9302
Compare
@KoBeWi I have found a repro for the undo bug you encountered. Fixing now. |
bba9302
to
27a6433
Compare
@KoBeWi Undo bug has been fixed. |
27a6433
to
3fd1dcd
Compare
UPDATE:
|
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.
Functionally looks fine.
I'm wondering about the debugger code though. The PR adds a dependency on Node3D and CanvasItem. It can be avoided by using is_class()
and call()
instead (which I think might be preferred, given the dynamic nature of the debugger).
Another thing is that the transform is preserved by remembering old transform and reverting it. I think the previous property-based approach could've been better.
But that's more for the debugger team to asses.
…instead of global space. Fixed a couple of bugs when syncing transforms to debug instance.
3fd1dcd
to
97f9dbd
Compare
As per your suggestion, I've updated it to work with variants, As for the record-restore approach, I think it makes more sense as a catch-all. If we use the property/method check approach, if anyone in the future changes how "Align Rotation with Camera" works, or introduces a new feature that moves a 2D sprite in the editor, it could break this, and someone would have to go in and reconcile the new property/function list. Plus it is not something that executes frequently, so performance isn't an issue. That said, I agree, debugger team feedback on this would be great. |
@KoBeWi I think we need to be really careful with this because it could lead to the user making and saving changes, that once re-running are lost because the parent scene overrides the transform. The expected behavior here would only work if the user has just saved a branch as scene. Any changes the user does from here, even if the subscene is used only once, runs the risk of the parent transform becoming useless. So my gut feeling says we should exclude this at all times, and preferably even disable the transform field in debug mode (if we can). Then have a good explanation in a comment as to why we've made this limitation. Other than that, this is looking really good @MajorMcDoom :) |
Thank you! As for your responses to @KoBeWi concerning the exceptional cases to allow, I think we should distinguish between different use cases mentioned, because they do deserve different treatment:
I'm not sure about your idea of disabling the root Transform in the editor though. First, it's not really practical because it's not just a field - it's any operation that can affect the transform that is being blocked. Second, we don't really want to prevent edits to the project. We simply don't want them to propagate them to the running game in a way that doesn't make sense. |
@MajorMcDoom sorry I wasn't clear, I was purely talking about that second use case (e.g. Editing the root of a scene that is a single-instance child in the running game.), the first situation it makes sense it is editable. Anyway I think the way you made it work is fine, disabling the transform field would be a nice to have and indeed as you say, it would likely remain incomplete. As long as we clearly document the behaviour and why we did what we did, it's a great fix. |
ping @akien-mga Imho this is an important bug fix that should not fall through the cracks. Right now this is marked as needing consensus with no further action seeming to happen nor clarity on who could provide that consensus. This sadly is an area of the editor that doesn't see heavy enough use within core contributors to gain their feedback. Users who do make use of this, won't test this until it's merged, possibly not even until it's in stable. @Faless, it's a little hidden in the "4.3 merge queue" thingy but you're tagged there to weigh in on the debugger changes here. If you have a moment that would be cool! |
Couldn't get a final review, so let's get this merged. Sorry for the delay :) |
Thanks! And congrats for your first merged Godot contribution 🎉 |
Awesome. Thanks y'all! :) |
What problems was this meant to address?
In the GIF below, you can see the current, undesirable outcome:
What was changed?
In the GIF below, you can see the new, expected behaviour:
Are there any caveats or tradeoffs?