Skip to content

Commit 6f7525c

Browse files
committed
Improve Scene Tree editor performance
We now cache the Node*<>TreeItem* mapping in the SceneTreeEditor. This allows us to make targeted updates to the Tree used to display the scene tree in the editor. Previously on almost all changes to the scene tree the editor would rebuild the entire widget, causing a large number of deallocations an allocations. We now carefully manipulate the Tree widget in-situ saving a large number of these allocations. In order to know what Nodes need to be updated we add a editor_state_changed signal to Node, this is a TOOLS_ENABLED, editor-only signal fired when changes to Node happen that are relevant to editor state. We also now make sure that when nodes are moved/renamed we don't check expensive properties that cannot contain NodePaths. This saves a lot of time when SceneTreeDock renames a node in a scene with a lot of MeshInstances. This makes renaming nodes go from ~27 seconds to ~2 seconds on large scenes. SceneTreeEditor instances will now also not do all of the potentially expensive update work if they are invisible. This behavior is turned off by default so it won't affect existing users. This change allows the editor to only update SceneTreeEditors that actually in view. In practice this means that for most changes instead of updating 6 SceneTreeEditors we only update 1 instantly, and the others only when they become visible. There is definitely more that could be done, but this is already a massive improvement. In complex scenes we see an improvement of 10x, things that used to take ~30 seconds now only take 2. This fixes #83460 I want to thank KoBeWi, TokisanGames, a-johnston, aniel080400 for their tireless testing. And AeioMuch for their testing and providing a fix for the hover issue.
1 parent 44dfa7e commit 6f7525c

15 files changed

+810
-173
lines changed

core/object/object.h

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ enum PropertyHint {
8989
PROPERTY_HINT_DICTIONARY_TYPE,
9090
PROPERTY_HINT_TOOL_BUTTON,
9191
PROPERTY_HINT_ONESHOT, ///< the property will be changed by self after setting, such as AudioStreamPlayer.playing, Particles.emitting.
92+
PROPERTY_HINT_NO_NODEPATH, /// < this property will not contain a NodePath, regardless of type (Array, Dictionary, List, etc.). Needed for SceneTreeDock.
9293
PROPERTY_HINT_MAX,
9394
};
9495

doc/classes/@GlobalScope.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2943,7 +2943,7 @@
29432943
<constant name="PROPERTY_HINT_ONESHOT" value="40" enum="PropertyHint">
29442944
Hints that a property will be changed on its own after setting, such as [member AudioStreamPlayer.playing] or [member GPUParticles3D.emitting].
29452945
</constant>
2946-
<constant name="PROPERTY_HINT_MAX" value="41" enum="PropertyHint">
2946+
<constant name="PROPERTY_HINT_MAX" value="42" enum="PropertyHint">
29472947
Represents the size of the [enum PropertyHint] enum.
29482948
</constant>
29492949
<constant name="PROPERTY_USAGE_NONE" value="0" enum="PropertyUsageFlags" is_bitfield="true">

doc/classes/Node.xml

+5
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,11 @@
10681068
Emitted when the node's editor description field changed.
10691069
</description>
10701070
</signal>
1071+
<signal name="editor_state_changed">
1072+
<description>
1073+
Emitted when an attribute of the node that is relevant to the editor is changed. Only emitted in the editor.
1074+
</description>
1075+
</signal>
10711076
<signal name="ready">
10721077
<description>
10731078
Emitted when the node is considered ready, after [method _ready] is called.

doc/classes/TreeItem.xml

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636
Calls the [param method] on the actual TreeItem and its children recursively. Pass parameters as a comma separated list.
3737
</description>
3838
</method>
39+
<method name="clear_buttons">
40+
<return type="void" />
41+
<description>
42+
Removes all buttons from all columns of this item.
43+
</description>
44+
</method>
3945
<method name="clear_custom_bg_color">
4046
<return type="void" />
4147
<param index="0" name="column" type="int" />

editor/connections_dialog.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@ ConnectDialog::ConnectDialog() {
735735
from_signal->set_editable(false);
736736

737737
tree = memnew(SceneTreeEditor(false));
738+
tree->set_update_when_invisible(false);
738739
tree->set_connecting_signal(true);
739740
tree->set_show_enabled_subscene(true);
740741
tree->set_v_size_flags(Control::SIZE_FILL | Control::SIZE_EXPAND);

0 commit comments

Comments
 (0)