Add both preview sun and sky at the same time when holding Shift

This makes setting up scenes for prototyping faster.

A tooltip was added to let people know about this feature.
This commit is contained in:
Hugo Locurcio 2021-07-07 00:41:37 +02:00
parent 5d7c23dcc6
commit ddb3020758
No known key found for this signature in database
GPG key ID: 39E8F8BE30B0A49C
2 changed files with 19 additions and 6 deletions

View file

@ -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) {
EditorNode::get_singleton()->show_warning(TTR("A root node is needed for this operation"));
@ -6236,9 +6241,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) {
EditorNode::get_singleton()->show_warning(TTR("A root node is needed for this operation"));
@ -7178,7 +7189,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);
@ -7242,7 +7254,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);

View file

@ -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);