Minor fixes to Node3DEditorPlugin

* Change EditorNode3D::update_all_gizmos() to start at the edited scene
  root instead of the whole editor root.
* Call update_all_gizmos() only once at start instead of evrey time a
  gizmo plugin is added.
* Add missing null check.
This commit is contained in:
jfons 2021-07-27 17:43:12 +02:00
parent f32c042f3e
commit 49361034f9

View File

@ -690,6 +690,7 @@ void Node3DEditorViewport::_select_region() {
Node3D *single_selected = spatial_editor->get_single_selected_node();
Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(single_selected);
if (se) {
Ref<EditorNode3DGizmo> old_gizmo;
if (!clicked_wants_append) {
se->subgizmos.clear();
@ -739,6 +740,7 @@ void Node3DEditorViewport::_select_region() {
return;
}
}
}
if (!clicked_wants_append) {
_clear_selected();
@ -4776,13 +4778,13 @@ void _update_all_gizmos(Node *p_node) {
}
void Node3DEditor::update_all_gizmos(Node *p_node) {
if (!p_node) {
if (SceneTree::get_singleton()) {
p_node = SceneTree::get_singleton()->get_root();
} else {
// No scene tree, so nothing to update.
return;
if (!p_node && get_tree()) {
p_node = get_tree()->get_edited_scene_root();
}
if (!p_node) {
// No edited scene, so nothing to update.
return;
}
_update_all_gizmos(p_node);
}
@ -6591,6 +6593,7 @@ void Node3DEditor::_notification(int p_what) {
_register_all_gizmos();
_update_gizmos_menu();
_init_indicators();
update_all_gizmos();
} break;
case NOTIFICATION_EXIT_TREE: {
_finish_indicators();
@ -7724,7 +7727,6 @@ void Node3DEditor::add_gizmo_plugin(Ref<EditorNode3DGizmoPlugin> p_plugin) {
gizmo_plugins_by_name.sort_custom<_GizmoPluginNameComparator>();
_update_gizmos_menu();
Node3DEditor::get_singleton()->update_all_gizmos();
}
void Node3DEditor::remove_gizmo_plugin(Ref<EditorNode3DGizmoPlugin> p_plugin) {