diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-07-12 15:37:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-12 15:37:11 +0200 |
commit | 69f1048ef57edcab5c1e3d4498ec17bdde7fbd47 (patch) | |
tree | 75f129a74601472bb2841dbea11a0a61164f02ce /editor/plugins | |
parent | bea8d68a8ddf8dfaf03ad4c431626dc8e0cc44f8 (diff) | |
parent | ddb302075858f4be5c8bfda1f8abf91f745b8900 (diff) |
Merge pull request #50233 from Calinou/editor-add-both-environment-and-sun
Add both preview sun and sky at the same time when holding Shift
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/node_3d_editor_plugin.cpp | 21 | ||||
-rw-r--r-- | editor/plugins/node_3d_editor_plugin.h | 4 |
2 files changed, 19 insertions, 6 deletions
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index ec45ffc72d..c33984c003 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -6218,9 +6218,14 @@ void Node3DEditor::_sun_environ_settings_pressed() { sun_environ_popup->popup(); } -void Node3DEditor::_add_sun_to_scene() { +void Node3DEditor::_add_sun_to_scene(bool p_already_added_environment) { sun_environ_popup->hide(); + if (!p_already_added_environment && world_env_count == 0 && Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { + // Prevent infinite feedback loop between the sun and environment methods. + _add_environment_to_scene(true); + } + Node *base = get_tree()->get_edited_scene_root(); if (!base) { // Create a root node so we can add child nodes to it. @@ -6240,9 +6245,15 @@ void Node3DEditor::_add_sun_to_scene() { undo_redo->add_do_reference(new_sun); undo_redo->commit_action(); } -void Node3DEditor::_add_environment_to_scene() { + +void Node3DEditor::_add_environment_to_scene(bool p_already_added_sun) { sun_environ_popup->hide(); + if (!p_already_added_sun && directional_light_count == 0 && Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { + // Prevent infinite feedback loop between the sun and environment methods. + _add_sun_to_scene(true); + } + Node *base = get_tree()->get_edited_scene_root(); if (!base) { // Create a root node so we can add child nodes to it. @@ -7186,7 +7197,8 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { sun_add_to_scene = memnew(Button); sun_add_to_scene->set_text(TTR("Add Sun to Scene")); - sun_add_to_scene->connect("pressed", callable_mp(this, &Node3DEditor::_add_sun_to_scene)); + sun_add_to_scene->set_tooltip(TTR("Adds a DirectionalLight3D node matching the preview sun settings to the current scene.\nHold Shift while clicking to also add the preview environment to the current scene.")); + sun_add_to_scene->connect("pressed", callable_mp(this, &Node3DEditor::_add_sun_to_scene), varray(false)); sun_vb->add_spacer(); sun_vb->add_child(sun_add_to_scene); @@ -7250,7 +7262,8 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { environ_add_to_scene = memnew(Button); environ_add_to_scene->set_text(TTR("Add Environment to Scene")); - environ_add_to_scene->connect("pressed", callable_mp(this, &Node3DEditor::_add_environment_to_scene)); + environ_add_to_scene->set_tooltip(TTR("Adds a WorldEnvironment node matching the preview environment settings to the current scene.\nHold Shift while clicking to also add the preview sun to the current scene.")); + environ_add_to_scene->connect("pressed", callable_mp(this, &Node3DEditor::_add_environment_to_scene), varray(false)); environ_vb->add_spacer(); environ_vb->add_child(environ_add_to_scene); diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index ac0b2e1859..a195a0eee0 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -805,8 +805,8 @@ private: void _preview_settings_changed(); void _sun_environ_settings_pressed(); - void _add_sun_to_scene(); - void _add_environment_to_scene(); + void _add_sun_to_scene(bool p_already_added_environment = false); + void _add_environment_to_scene(bool p_already_added_sun = false); protected: void _notification(int p_what); |