Files
godot-website/article/core-refactoring-progress-report-2/index.html
2024-06-06 07:38:13 +00:00

14 lines
18 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html><html lang=en><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=author content="Godot Engine"><meta name=description content="As promised in my previous post, the core refactoring work I am undertaking took two months to complete. This means rewriting large parts of the core engine for consistency and features."><meta name=theme-color content="#3d8fcc"><meta property="og:site_name" content="Godot Engine"><meta property="og:url" content="https://godotengine.org/article/core-refactoring-progress-report-2/"><meta name=twitter:site content="@godotengine"><meta property="og:title" content="Core refactoring progress report #2"><meta property="og:description" content="As promised in my previous post, the core refactoring work I am undertaking took two months to complete. This means rewriting large parts of the core engine for consistency and features."><meta property="og:image" content="https://godotengine.org/storage/app/uploads/public/5e7/f74/307/5e7f74307ce34896455561.jpeg"><meta property="og:type" content="article"><meta name=twitter:card content="summary_large_image"><title>Core refactoring progress report #2</title><link rel=alternate type=application/rss+xml title="Godot News" href=/rss.xml><link rel=icon href=/assets/favicon.png sizes=any><link rel=icon href=/assets/favicon.svg type=image/svg+xml><link rel=stylesheet href=/assets/css/main.css?112><link rel=stylesheet href=/assets/css/tobii.min.css><link rel=preload as=font href=/assets/fonts/Montserrat-Bold.woff2 crossorigin><link rel=preload as=font href=/assets/fonts/Montserrat-ExtraBold.woff2 crossorigin><link rel=me href=https://mastodon.gamedev.place/@godotengine><input type=checkbox id=nav_toggle_cb><header><div class="container flex align-center"><div id=nav_head><a href=/ id=logo-link><img class=nav-logo src=/assets/logo.svg width=136 height=48 alt="Godot Engine">
<img class="nav-logo dark-logo" src=/assets/logo_dark.svg width=136 height=48 alt="Godot Engine"></a>
<label for=nav_toggle_cb id=nav_toggle_btn><img src=/assets/icons/hamburger.svg width=24 height=24 alt="Main menu"></label></div><nav id=nav><ul class=left><li><a href=/features/>Features</a><li class=only-on-mobile><a href=/showcase/>Showcase</a><li><a href=/blog/>Blog</a><li><a href=/community/>Community</a><li><a href=/contact/>About</a><li><a href=https://godotengine.org/asset-library/asset>Assets</a></ul><ul class=right><li><a href=/download/windows/ class=set-os-download-url>Download</a><li><a href=https://docs.godotengine.org>Docs</a><li><a href=https://docs.godotengine.org/en/stable/community/contributing/index.html>Contribute</a><li class=fund><a href=https://fund.godotengine.org>&#xFE0E; Donate</a></ul></nav></div></header><main><style>body{background-color:var(--background-color)}h1{margin-bottom:8px;margin-top:32px}:not(pre)>code{background:var(--code-background-color);padding:1px 4px;font-size:.95em;border-radius:3px}pre{background:var(--codeblock-background-color);color:var(--codeblock-color)}pre code{display:block;overflow-x:auto;padding:.5em}.date-big{line-height:2;margin-left:32px}article{background-color:var(--base-color);box-shadow:0 3px 2px rgba(0,0,0,.15)}figure{margin:0}figure img{margin:0}article img,article video{max-width:100%;height:auto;display:block;margin:auto;margin-top:16px;margin-bottom:16px}article h1{margin-top:64px}article h2,article h3,article h4{margin-top:42px}.article-info{display:flex;flex-direction:column;gap:8px}.article-metadata{display:flex;gap:24px;align-items:center;font-family:var(--header-font-family);margin-bottom:12px}@media(max-width:900px){.article-metadata{flex-direction:column;align-items:flex-start;gap:16px}}.article-author{color:var(--base-color-text-subtitle-date);font-weight:700;font-size:18px;flex-grow:1;display:flex;gap:12px;align-items:center}.article-author .avatar{border-radius:100%;margin:0}.article-author .by{color:var(--base-color-text-subtitle)}.article-metadata .date{color:var(--base-color-text-subtitle-date)}.article-metadata .date.post-recent-highlight{color:var(--post-recent-highlight-color);opacity:.8}.article-metadata .date.post-recent-highlight::after{font-size:80%;content:"NEW";border:2px solid var(--post-recent-highlight-color);padding:2px 3px;margin-left:8px}.tag.active{filter:saturate(.75)}@media screen and (min-width:900px){article .content{width:70%;margin:auto}}@media(max-width:900px){body{background-color:var(--base-color)}article{background-color:initial;box-shadow:none}article img:first-child,article video:first-child{max-width:100%}}</style><link rel=stylesheet href=/assets/css/highlight.obsidian.min.css><div class=container><article class=padded><div class="content article-container"><figure class=article-cover><img src=/storage/app/uploads/public/5e7/f74/307/5e7f74307ce34896455561.jpeg title alt=" " class=rounded-lg style=width:100%;height:auto;background-color:initial></figure><div class=article-info><h1>Core refactoring progress report #2</h1><div class=article-metadata><div class=article-author><span>By:</span>
<img class=avatar width=25 height=25 src=/assets/images/authors/reduzio.webp alt="Juan Linietsky" loading=lazy>
<span class=by>Juan Linietsky</span></div><span class=date data-post-date="2020-03-28 00:00:00 +0000">28 March 2020</span></div><div class=tags><a href=/blog/progress-report><div class="tag active">Progress Report</div></a></div></div><div class="card card-warning"><p>This article is from <strong>March 2020</strong>, some of its contents might be outdated and no longer accurate.<br>You can find up-to-date information about the engine in the <a href=https://docs.godotengine.org/en/stable/>official documentation</a>.</div><div class=article-body><p>As promised in my previous post, the core refactoring work I am undertaking took two months to complete. This means rewriting large parts of the core engine for consistency and features.<h3 id=core-refactoring>Core refactoring</h3><p>Core refactoring is mostly work on the most low level, critical and shared parts of the engine. This work is done only on major versions because it implies breaking compatibility and introducing instability and bugs (because of all the new added code), which is actually the case right now. The major refactoring undertaken for Godot 3.x, two years ago, changed a large part of the internals, but we were unable to do everything we wanted to do.<p>The migration to Vulkan already implied breaking compatibility and, together with all the user feedback we got since 3.x was released, we have a very good idea of what needed to change in this time.<p>So following is the list of what changed during March:<h4 id=os--displayserver-split>OS / DisplayServer split</h4><p>One of the largest singletons in Godot is the <a href=https://docs.godotengine.org/en/3.1/classes/class_os.html>OS</a> class. It allows access to low-level OS functions as well as window management.<p>This was cumbersome for many reasons and also imposed limitations, such as:<ul><li>Having a large, bloated OS class on every platform.<li>Inability to support different display APIs in a single binary. This is specially visible in Desktop Unixes, where you can use X11, Wayland or even EGL directly on Raspberry PI.<li>Proper support for multiple windows. This not only allows the editor to make some docks float so you can move them to another monitor (a very requested feature by users). This is also useful for games developed for certain types of dedicated hardware, or just for tools created with Godot as the base platform (which is something several users do).<li>Impossible to run the engine as headless (with a dummy display driver) in all platforms. The “server” platform had to be used as a workaround (and will now be deprecated).<li>Difficult to abstract window management functions to users, which had to access the OS class directly (and which is not as user friendly as working with nodes).</ul><p>The new implementation moves all low level window management to a new singleton, <strong>DisplayServer</strong>, which handles everything regarding display. To make implementation simpler and more portable, Godot will always assume you have one <em>main window</em> and, if platform supports, allow you to create <em>sub windows</em>.<h4 id=window-node>Window node</h4><p>The new <strong>DisplayServer</strong> allows managing multiple windows, but using it directly is still too low level and unfriendly for most users. To compensate, a new <strong>Window</strong> node has been introduced. This node inherits <strong>Viewport</strong> and gives it the ability to appear as a floating window. Working with it is easy: just place your nodes as children of Window! You can create UIs (with controls), or display the 3D world on it (just adding a <strong>Camera</strong> node). It s basically the same as a Viewport, so Using this new node is extremely easy and straightforward.<p><img src=/storage/app/uploads/public/5e7/f73/7eb/5e7f737eb5c64127870073.jpeg alt=embedded2.jpeg><p>Additionally, the root node in Godot (<code class="language-plaintext highlighter-rouge">get_tree().get_root()</code>), which used to be of type <strong>Viewport</strong>, has now changed to be of <strong>Window</strong> type. If you want to manage the game window, simple access this node directly.<p>All input events, which were previously sent to the <em>MainLoop</em> class, are now sent directly from <strong>DisplayServer</strong> to <em>Window</em> (so MainLoop and hence, <em>SceneTree</em> have been stripped of this functionality).<h4 id=multiple-window-support-in-editor>Multiple Window Support in Editor</h4><p>Likewise, the Godot Editor now supports making the docks float. For now, only docks and existing windows are supported but we will extend support for other parts of the editor.<p>It is important to note that by default <strong>docks will remain <em>docked</em> ** and nothing will change. Some users expressed concerns that we would now force them to always use floating windows. This **is not the case</strong>, you can make windows separate from the main one <strong>only if you want</strong> (like as an example, you have a second monitor and you want to make use of more screen-space), but by default <strong>nothing will change</strong>.<h4 id=embedded-mode>Embedded mode</h4><p>But, what if you are working on a full-screen game and need to use windows? Or what about platforms which dont support floating windows such as iOS, Android, HTML5 or even consoles?<p>One of the new features of this system is that the <strong>Viewport</strong> class can now be instructed to embed all children <strong>Window</strong> nodes and provide internal windows for them, so it will emulate a window manager within it, including decorations, resizing, title bar, close button, etc. This can be done manually by toggling the “embed subwindows” property.<p>At the same time the new <strong>DisplayServer</strong> can be queried for features and one of them is <em>subwindow</em> support, so the new root <strong>Window</strong> will check whether this is supported on each platform and toggle the property automatically. This is completely transparent to the user, so games (or the editor) dont need to be change to run on platforms that dont support subwindows.<p><img src=/storage/app/uploads/public/5e7/f73/92d/5e7f7392d353b123436098.png alt=embedded3.png><p>If, for debug purposes, you want to run the editor (or your game) using subwindows instead of hardware windows, use the <code class="language-plaintext highlighter-rouge">--single-window</code> command line flag.<h3 id=node-renames>Node renames</h3><p>The Godot scene system is known for its ease of use and its ability to represent your mental map as a data and file structure. That said, many node names were not clear or confusing. This is mainly evidenced when comparing their 2D and 3D counterparts.<p>Contrary to what many believe, Godot started as a 3D engine, but soon migrated to be a 2D one. This is why the 3D nodes dont have any suffix (like Area) while the 2D ones do (Area2D). This made it very misleading for users, where its not always obvious whether you are using the 2D or 3D versions.<p>To solve this, Godot 4.0 will rename all 3D nodes and give them proper suffixes. Nodes like “Area”,”RigidBody” or “Light” will become “Area3D”, “RigidBody3D” and “Light3D” respectively.<p>Additionally, due to popular demand, the “Spatial” node will be renamed to “Node3D”, to further enhance consistency with the 2D engine.<p><img src=/storage/app/uploads/public/5e7/f74/038/5e7f74038bd23290506434.png alt=nodenames.png><p>A compatibility system has been added so older scenes will convert the node types to the new ones on load.<h3 id=server-renames>Server renames</h3><p>Most servers in Godot are very old, and their naming conventions were by now obsolete. Because of this, most are being renamed:<ul><li><strong>VisualServer</strong> (a name that became even more ambiguous thanks to the introduction of DisplayServer) has been renamed to <strong>RenderingServer</strong>.<li><strong>NavigationServer</strong> and <strong>PhysicsServer</strong> have been renamed to <strong>NavigationServer3D</strong> and <strong>PhysicsServer3D</strong> respectively.<li>Likewise, to add more consistency, <strong>Physics2DServer</strong> and <strong>Navigation2DServer</strong> are now <strong>PhysicsServer2D</strong> and <strong>NavigationServer2D</strong>.</ul><h3 id=future>Future</h3><p>My work on core refactoring is mostly done, so next month (April) I will go back to working on Vulkan as promised. Hope to have new and exciting stuff to show by the end of next month!<p>And as always, please remember than our work on Godot is done out of love for you and the game development community, we want to provide you with a top notch free and open source game engine, so you can own your work down to the last line of engine code. If you are not yet, please consider becoming <a href=https://www.patreon.com/godotengine>our patron</a> and help us realize this dream sooner.</div></div></article></div><link rel=stylesheet href=/assets/css/anchor-link.css?1><link rel=stylesheet href=/assets/css/article-cards.css?2><script src=/assets/js/anchor-link.js></script>
<script>document.addEventListener('DOMContentLoaded',()=>{window.applyAnchorLinks('.article-body'),document.querySelectorAll('.article-cover img, .article-body img').forEach(b=>{if(b.classList.contains('lightbox-ignore'))return;const a=document.createElement('a');a.href=b.src,a.classList.add('lightbox'),a.dataset.group='article',b.parentNode.appendChild(a),a.appendChild(b)})})</script></main><footer><div class="container flex footer-container"><div id=copyright><p>© 2007-2024 Juan Linietsky, Ariel Manzur and <a href=https://github.com/godotengine/godot/blob/master/AUTHORS.md target=_blank rel=noopener>contributors</a>.<br>Hosted by the <a href=https://godot.foundation/ target=_blank rel=noopener>Godot Foundation</a>.<br>Website <a href=https://github.com/godotengine/godot-website target=_blank rel=noopener>source code on GitHub</a>.</div><div id=sitemap><ul class=sitemap-group><li><strong>Get Godot</strong><li><a href=/download/windows/ class=set-os-download-url>Download</a><li><a href=/download/archive/>Release Archive</a><li><a href=https://editor.godotengine.org/releases/latest/>Web Editor</a><li>&nbsp;<li><strong>Public Relations</strong><li><a href=/blog/>Blog</a><li><a href=/community/>Communities and Events</a><li><a href=/press/>Press Kit</a></ul><ul class=sitemap-group><li><strong>About Godot</strong><li><a href=/features/>Features</a><li><a href=/showcase/>Showcase</a><li><a href=/education/>Education</a><li><a href=/license/>License</a><li><a href=/code-of-conduct/>Code of Conduct</a><li><a href=/privacy-policy/>Privacy Policy</a><li><a href=https://fund.godotengine.org>Donate</a></ul><ul class=sitemap-group><li><strong>Project Team</strong><li><a href=/governance/>Governance</a><li><a href=/teams/>Teams</a><li>&nbsp;<li><strong>Extra Resources</strong><li><a href=https://godotengine.org/asset-library/asset>Asset Library</a><li><a href=https://docs.godotengine.org>Documentation</a><li><a href=https://github.com/godotengine>Code Repository</a></ul></div><div id=social class=dark-desaturate><h4 class=text-right><a href=/contact/>Contact us</a></h4><div class="flex justify-space-between" style=gap:3px><a href=https://github.com/godotengine target=_blank rel=noopener><img src=/assets/footer/github_logo.svg width=32 height=32 alt=GitHub></a>
<a href=https://mastodon.gamedev.place/@godotengine target=_blank rel=noopener><img src=/assets/footer/mastodon_logo.svg width=32 height=32 alt=Mastodon></a>
<a href=https://twitter.com/godotengine target=_blank rel=noopener><img src=/assets/footer/twitter_logo.svg width=32 height=32 alt=Twitter></a>
<a href=https://www.facebook.com/groups/godotengine/ target=_blank rel=noopener><img src=/assets/footer/facebook_logo.svg width=32 height=32 alt=Facebook></a>
<a href=https://www.reddit.com/r/godot target=_blank rel=noopener><img src=/assets/footer/reddit_logo.svg width=32 height=32 alt=Reddit></a>
<a href=/rss.xml target=_blank rel=noopener><img src=/assets/footer/feed_logo.svg width=32 height=32 alt="RSS feed"></a></div></div></div></footer><script defer src=/assets/js/tobii.min.js></script>
<script defer src=/assets/js/highlight.min.js?1></script>
<script defer src=/assets/js/highlight.gdscript.min.js?1></script>
<script>document.addEventListener('DOMContentLoaded',()=>{document.querySelectorAll('pre code').forEach(a=>{hljs.highlightBlock(a)}),document.querySelectorAll('[data-post-date]').forEach(a=>{Date.parse(a.dataset.postDate)>Date.now()-1e3*60*60*48&&a.classList.add("post-recent-highlight")}),new Tobii({zoom:!1});const a=document.querySelectorAll('.set-os-download-url');for(let b=0;b<a.length;b++){const c=a[b];let e='download';'version'in c.dataset&&c.dataset.version==='3'&&(e='download/3.x');let d='windows';navigator.platform.indexOf('Mac')!==-1?d='macos':navigator.platform.indexOf('Linux')!==-1&&(d='linux'),c.href=`/${e}/${d}/`}})</script>