-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Make Viewports Resources #3915
Comments
I don’t see any explanation how one would use it if it was no longer a node. |
|
That explains nothing. Currently it's a node. You use node hierarchy to put a scene into a dedicated viewport. How would you put nodes inside of a viewport if it's a resource? Where would you put a viewport resources in your node tree? Can you give examples of before and after? With ViewportContainer, with render target and ViewportTexture? |
A Likewise, a |
You've got this very backwards. Godot has One, Singular, SceneTree. The root node of this tree, is a Viewport. |
I understand how it works currently. What I'm saying is that the logic is backwards and it should be the |
How would this work inside the editor? |
@SilencedPerson The only changes needed to |
How would anything get displayed? Where would Autoloads go? As children of your Scene? What if you don't want to use a default scene? What if I want multiple viewports for the same World space? |
None of this would change. |
I'm left feeling that the meat of @TheDuriel 's question remains unanswered. At least, the "what if I want multiple viewports..." portion. You say nothing would change, but given the current method of using multiple viewports is to add additional Viewport Nodes, were Viewport to be a Resource, that's going to be a bit of a challenge. Something is going to have to change. If SceneTree is a member of Viewport, how do I have multiple ViewPorts and where do I put them? |
A Viewport is a View into a World. Multiple Viewports may view the same World. With your proposal, a Viewport defines both a MainLoop and a World. Which invalidates many uses of Viewports. |
Seconding @TheDuriel: I use two or three viewports into the same 2D world for some minimap trickery... |
I believe this question was addressed here:
The SceneTree defines the world and one or many Viewports display it. |
This is false. Worlds are resources created by Viewports. |
So what I gathered so far is that concept of This is how the one SceneTree looks now,
How does it look after the change? |
Autoload does two things:
The handling of the constants would be a problem to solve (This would require the ScriptServer to store different constants for different roots, so that they do not interfere with each other) But otherwise, keeping the autoloaded Nodes as children of the Viewport would work just as before. |
Having multiple instances unique to each root, of what are supposed single instant globals, singletons, is... just not an acceptable tradeoff for no gain? Also still no answer about how one is supposed to have multiple cameras in the same world. |
The changes being proposed are about how Godot is designed under the hood. It's about following OOP design best practices. Specifically, it's about paying attention to the "is_a" vs "has_a" relationships as well as proper separation of responsibilities. To this I've added the need to follow Godot's own best practices. Specifically, not making everything a Beyond that, this proposal is not suggesting anything else changes; other than making everything work as it did before (or hopefully better). Therefore, all other questions about "how one is supposed to do ..." are moot at this high-level design point. |
We are simply naming a plethora of reasons for why it CAN NOT work the way you propose. Part of making a proposal, is figuring out how to implement it. Spouting rhetoric about OOP design doesn't achieve that. Yes, a Viewport doesn't need to be a node. If it had to be, it would not extend Node directly, but one of the three main types. But it being a node is the only viable option, and conveys many advantages that you are dismissing as "it'll be figured out". |
Describe the project you are working on
Godot engine
Describe the problem or limitation you are having in your project
There are a number of issues with the current class hierarchy:
Window
inheritsViewport
, but aWindow
is not aViewport
. It contains aViewport
, but it's not aViewport
. So,Window
should not inheritViewport
.Viewport
inheritsNode
, but aViewport
is not aNode
. As described in the documentation, aViewport
is "a surface on which the game is drawn". As detailed in Make viewports/containers usable inside Godot, improve viewport documentation and make it simpler to actually use viewports #2139, adding aViewport
to a scene only makes sense if it's a child of aViewportContainer
or linked to aViewportTexture
.Viewport
should not inheritNode
. Likewise, adding aWindow
to a scene makes even less sense. AWindow
should not inheritNode
either.SceneTree
has a hidden root node. In 4.0 it's aWindow
. In 3.x it's aViewport
. However, there is no apparent good reason for this. In fact, when we design our scenes, we can use anyNode
as the visible rootNode
. On the other hand, aViewport
has aSceneTree
that it displays. It's theViewport
that has aSceneTree
, not aSceneTree
that has aViewport
.There are also a number of issues with separation of responsibility:
Window
provides the interface to theDisplayServer
(which was part of OS in 3.x). AViewport
provides the interface to theRenderingServer
(VisualServer
in 3.x). However,Window
code contains a lot ofViewport
specific code including accessing theRenderingServer
. LikewiseViewport
code contains a lot ofWindow
specific code including accessing theDisplayServer
.Viewport
has a lot ofControl
specific code. This was done a long time ago in 72fcb8a because of "bugs when controls don't have a common parent".These issues have led to a lot of spaghetti code that makes it very difficult to troubleshoot, never mind fix, problems like godotengine/godot#20619, godotengine/godot#28665, godotengine/godot#30215, godotengine/godot#30950, godotengine/godot#32222, godotengine/godot#34805, godotengine/godot#35965, godotengine/godot#48368, etc.
Finally, the Godot Best Practices documentation has a section on When and how to avoid using nodes for everything that would suggest that a
Viewport
should be aResource
and a Window probably only anObject
.Describe the feature / enhancement and how it helps to overcome the problem or limitation
At a very high level:
Window
code intoWindow
.Viewport
code intoViewport
.Control
code intoControl
Viewport
a member ofWindow
.SceneTree
a member ofViewport
.Viewport
inherit fromResource
.Window
inherit fromObject
This will make the class hierarchy follow general C++ as well as Godot best practices, and generally make it easier to troubleshoot and fix issues associated with
Viewport
sCanvasLayer
s andControl
s when the problem currently lies elsewhere.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
This is more of a overall C++ design philosophy. The actual code changes will be whatever it takes to make it compile and run again.
If this enhancement will not be used often, can it be worked around with a few lines of script?
No.
Is there a reason why this should be core and not an add-on in the asset library?
It's core code.
The text was updated successfully, but these errors were encountered: