mirror of
https://github.com/godotengine/godot.git
synced 2024-11-25 13:43:15 +00:00
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
This commit is contained in:
commit
69f1048ef5
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user