diff options
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/gradient_texture_2d_editor_plugin.cpp | 284 | ||||
-rw-r--r-- | editor/plugins/gradient_texture_2d_editor_plugin.h | 112 | ||||
-rw-r--r-- | editor/plugins/node_3d_editor_plugin.cpp | 6 | ||||
-rw-r--r-- | editor/plugins/skeleton_3d_editor_plugin.cpp | 4 | ||||
-rw-r--r-- | editor/plugins/theme_editor_plugin.cpp | 4 | ||||
-rw-r--r-- | editor/plugins/tiles/tile_map_editor.cpp | 1 | ||||
-rw-r--r-- | editor/plugins/tiles/tile_set_editor.cpp | 1 | ||||
-rw-r--r-- | editor/plugins/visual_shader_editor_plugin.cpp | 22 |
8 files changed, 414 insertions, 20 deletions
diff --git a/editor/plugins/gradient_texture_2d_editor_plugin.cpp b/editor/plugins/gradient_texture_2d_editor_plugin.cpp new file mode 100644 index 0000000000..e97c611e96 --- /dev/null +++ b/editor/plugins/gradient_texture_2d_editor_plugin.cpp @@ -0,0 +1,284 @@ +/*************************************************************************/ +/* gradient_texture_2d_editor_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "gradient_texture_2d_editor_plugin.h" + +#include "editor/editor_node.h" +#include "editor/editor_scale.h" +#include "scene/gui/box_container.h" +#include "scene/gui/flow_container.h" +#include "scene/gui/separator.h" + +Point2 GradientTexture2DEditorRect::_get_handle_position(const Handle p_handle) { + // Get the handle's mouse position in pixels relative to offset. + return (p_handle == HANDLE_FILL_FROM ? texture->get_fill_from() : texture->get_fill_to()).clamp(Vector2(), Vector2(1, 1)) * size; +} + +void GradientTexture2DEditorRect::_update_fill_position() { + if (handle == HANDLE_NONE) { + return; + } + + // Update the texture's fill_from/fill_to property based on mouse input. + Vector2 percent = ((get_local_mouse_position() - offset) / size).clamp(Vector2(), Vector2(1, 1)); + if (snap_enabled) { + percent = (percent - Vector2(0.5, 0.5)).snapped(Vector2(snap_size, snap_size)) + Vector2(0.5, 0.5); + } + + String property_name = handle == HANDLE_FILL_FROM ? "fill_from" : "fill_to"; + + undo_redo->create_action(vformat(TTR("Set %s"), property_name), UndoRedo::MERGE_ENDS); + undo_redo->add_do_property(texture.ptr(), property_name, percent); + undo_redo->add_undo_property(texture.ptr(), property_name, handle == HANDLE_FILL_FROM ? texture->get_fill_from() : texture->get_fill_to()); + undo_redo->commit_action(); +} + +void GradientTexture2DEditorRect::gui_input(const Ref<InputEvent> &p_event) { + // Grab/release handle. + const Ref<InputEventMouseButton> mb = p_event; + if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT) { + if (mb->is_pressed()) { + Point2 mouse_position = mb->get_position() - offset; + if (Rect2(_get_handle_position(HANDLE_FILL_FROM).round() - handle_size / 2, handle_size).has_point(mouse_position)) { + handle = HANDLE_FILL_FROM; + } else if (Rect2(_get_handle_position(HANDLE_FILL_TO).round() - handle_size / 2, handle_size).has_point(mouse_position)) { + handle = HANDLE_FILL_TO; + } else { + handle = HANDLE_NONE; + } + } else { + _update_fill_position(); + handle = HANDLE_NONE; + } + } + + // Move handle. + const Ref<InputEventMouseMotion> mm = p_event; + if (mm.is_valid()) { + _update_fill_position(); + } +} + +void GradientTexture2DEditorRect::set_texture(Ref<GradientTexture2D> &p_texture) { + texture = p_texture; + texture->connect("changed", callable_mp((CanvasItem *)this, &CanvasItem::update)); +} + +void GradientTexture2DEditorRect::set_snap_enabled(bool p_snap_enabled) { + snap_enabled = p_snap_enabled; + update(); +} + +void GradientTexture2DEditorRect::set_snap_size(float p_snap_size) { + snap_size = p_snap_size; + update(); +} + +void GradientTexture2DEditorRect::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + checkerboard->set_texture(get_theme_icon(SNAME("GuiMiniCheckerboard"), SNAME("EditorIcons"))); + } break; + + case NOTIFICATION_DRAW: { + if (texture.is_null()) { + return; + } + + const Ref<Texture2D> fill_from_icon = get_theme_icon(SNAME("EditorPathSmoothHandle"), SNAME("EditorIcons")); + const Ref<Texture2D> fill_to_icon = get_theme_icon(SNAME("EditorPathSharpHandle"), SNAME("EditorIcons")); + handle_size = fill_from_icon->get_size(); + + const int MAX_HEIGHT = 250 * EDSCALE; + Size2 rect_size = get_size(); + + // Get the size and position to draw the texture and handles at. + size = Size2(texture->get_width() * MAX_HEIGHT / texture->get_height(), MAX_HEIGHT); + if (size.width > rect_size.width) { + size.width = rect_size.width; + size.height = texture->get_height() * rect_size.width / texture->get_width(); + } + offset = Point2(Math::round((rect_size.width - size.width) / 2), 0) + handle_size / 2; + set_custom_minimum_size(Size2(0, size.height)); + size -= handle_size; + checkerboard->set_rect(Rect2(offset, size)); + + draw_set_transform(offset); + draw_texture_rect(texture, Rect2(Point2(), size)); + + // Draw grid snap lines. + if (snap_enabled) { + const Color primary_line_color = Color(0.5, 0.5, 0.5, 0.9); + const Color line_color = Color(0.5, 0.5, 0.5, 0.5); + + // Draw border and centered axis lines. + draw_rect(Rect2(Point2(), size), primary_line_color, false); + draw_line(Point2(size.width / 2, 0), Point2(size.width / 2, size.height), primary_line_color); + draw_line(Point2(0, size.height / 2), Point2(size.width, size.height / 2), primary_line_color); + + // Draw vertical lines. + int prev_idx = 0; + for (int x = 0; x < size.width; x++) { + int idx = int((x / size.width - 0.5) / snap_size); + + if (x > 0 && prev_idx != idx) { + draw_line(Point2(x, 0), Point2(x, size.height), line_color); + } + + prev_idx = idx; + } + + // Draw horizontal lines. + prev_idx = 0; + for (int y = 0; y < size.height; y++) { + int idx = int((y / size.height - 0.5) / snap_size); + + if (y > 0 && prev_idx != idx) { + draw_line(Point2(0, y), Point2(size.width, y), line_color); + } + + prev_idx = idx; + } + } + + // Draw handles. + draw_texture(fill_from_icon, (_get_handle_position(HANDLE_FILL_FROM) - handle_size / 2).round()); + draw_texture(fill_to_icon, (_get_handle_position(HANDLE_FILL_TO) - handle_size / 2).round()); + } break; + } +} + +GradientTexture2DEditorRect::GradientTexture2DEditorRect() { + undo_redo = EditorNode::get_singleton()->get_undo_redo(); + + checkerboard = memnew(TextureRect); + checkerboard->set_stretch_mode(TextureRect::STRETCH_TILE); + checkerboard->set_draw_behind_parent(true); + add_child(checkerboard); +} + +/////////////////////// + +void GradientTexture2DEditor::_reverse_button_pressed() { + undo_redo->create_action(TTR("Swap GradientTexture2D Fill Points")); + undo_redo->add_do_property(texture.ptr(), "fill_from", texture->get_fill_to()); + undo_redo->add_do_property(texture.ptr(), "fill_to", texture->get_fill_from()); + undo_redo->add_undo_property(texture.ptr(), "fill_from", texture->get_fill_from()); + undo_redo->add_undo_property(texture.ptr(), "fill_to", texture->get_fill_to()); + undo_redo->commit_action(); +} + +void GradientTexture2DEditor::_set_snap_enabled(bool p_enabled) { + texture_editor_rect->set_snap_enabled(p_enabled); + + snap_size_edit->set_visible(p_enabled); +} + +void GradientTexture2DEditor::_set_snap_size(float p_snap_size) { + texture_editor_rect->set_snap_size(MAX(p_snap_size, 0.01)); +} + +void GradientTexture2DEditor::set_texture(Ref<GradientTexture2D> &p_texture) { + texture = p_texture; + texture_editor_rect->set_texture(p_texture); +} + +void GradientTexture2DEditor::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + reverse_button->set_icon(get_theme_icon(SNAME("ReverseGradient"), SNAME("EditorIcons"))); + snap_button->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); + } break; + } +} + +GradientTexture2DEditor::GradientTexture2DEditor() { + undo_redo = EditorNode::get_singleton()->get_undo_redo(); + + HFlowContainer *toolbar = memnew(HFlowContainer); + add_child(toolbar); + + reverse_button = memnew(Button); + reverse_button->set_tooltip(TTR("Swap Gradient Fill Points")); + toolbar->add_child(reverse_button); + reverse_button->connect("pressed", callable_mp(this, &GradientTexture2DEditor::_reverse_button_pressed)); + + toolbar->add_child(memnew(VSeparator)); + + snap_button = memnew(Button); + snap_button->set_tooltip(TTR("Toggle Grid Snap")); + snap_button->set_toggle_mode(true); + toolbar->add_child(snap_button); + snap_button->connect("toggled", callable_mp(this, &GradientTexture2DEditor::_set_snap_enabled)); + + snap_size_edit = memnew(EditorSpinSlider); + snap_size_edit->set_min(0.01); + snap_size_edit->set_max(0.5); + snap_size_edit->set_step(0.01); + snap_size_edit->set_value(0.1); + snap_size_edit->set_custom_minimum_size(Size2(65 * EDSCALE, 0)); + toolbar->add_child(snap_size_edit); + snap_size_edit->connect("value_changed", callable_mp(this, &GradientTexture2DEditor::_set_snap_size)); + + texture_editor_rect = memnew(GradientTexture2DEditorRect); + add_child(texture_editor_rect); + + set_mouse_filter(MOUSE_FILTER_STOP); + _set_snap_enabled(snap_button->is_pressed()); + _set_snap_size(snap_size_edit->get_value()); +} + +/////////////////////// + +bool EditorInspectorPluginGradientTexture2D::can_handle(Object *p_object) { + return Object::cast_to<GradientTexture2D>(p_object) != nullptr; +} + +void EditorInspectorPluginGradientTexture2D::parse_begin(Object *p_object) { + GradientTexture2D *texture = Object::cast_to<GradientTexture2D>(p_object); + if (!texture) { + return; + } + Ref<GradientTexture2D> t(texture); + + GradientTexture2DEditor *editor = memnew(GradientTexture2DEditor); + editor->set_texture(t); + add_custom_control(editor); +} + +/////////////////////// + +GradientTexture2DEditorPlugin::GradientTexture2DEditorPlugin() { + Ref<EditorInspectorPluginGradientTexture2D> plugin; + plugin.instantiate(); + add_inspector_plugin(plugin); +} diff --git a/editor/plugins/gradient_texture_2d_editor_plugin.h b/editor/plugins/gradient_texture_2d_editor_plugin.h new file mode 100644 index 0000000000..4ce64ce1dc --- /dev/null +++ b/editor/plugins/gradient_texture_2d_editor_plugin.h @@ -0,0 +1,112 @@ +/*************************************************************************/ +/* gradient_texture_2d_editor_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef GRADIENT_TEXTURE_2D_EDITOR +#define GRADIENT_TEXTURE_2D_EDITOR + +#include "editor/editor_plugin.h" +#include "editor/editor_spin_slider.h" + +class GradientTexture2DEditorRect : public Control { + GDCLASS(GradientTexture2DEditorRect, Control); + + enum Handle { + HANDLE_NONE, + HANDLE_FILL_FROM, + HANDLE_FILL_TO + }; + + Ref<GradientTexture2D> texture; + UndoRedo *undo_redo = nullptr; + bool snap_enabled = false; + float snap_size = 0; + + TextureRect *checkerboard = nullptr; + + Handle handle = HANDLE_NONE; + Size2 handle_size; + Point2 offset; + Size2 size; + + Point2 _get_handle_position(const Handle p_handle); + void _update_fill_position(); + virtual void gui_input(const Ref<InputEvent> &p_event) override; + +protected: + void _notification(int p_what); + +public: + void set_texture(Ref<GradientTexture2D> &p_texture); + void set_snap_enabled(bool p_snap_enabled); + void set_snap_size(float p_snap_size); + + GradientTexture2DEditorRect(); +}; + +class GradientTexture2DEditor : public VBoxContainer { + GDCLASS(GradientTexture2DEditor, VBoxContainer); + + Ref<GradientTexture2D> texture; + UndoRedo *undo_redo = nullptr; + + Button *reverse_button = nullptr; + Button *snap_button = nullptr; + EditorSpinSlider *snap_size_edit = nullptr; + GradientTexture2DEditorRect *texture_editor_rect = nullptr; + + void _reverse_button_pressed(); + void _set_snap_enabled(bool p_enabled); + void _set_snap_size(float p_snap_size); + +protected: + void _notification(int p_what); + +public: + void set_texture(Ref<GradientTexture2D> &p_texture); + + GradientTexture2DEditor(); +}; + +class EditorInspectorPluginGradientTexture2D : public EditorInspectorPlugin { + GDCLASS(EditorInspectorPluginGradientTexture2D, EditorInspectorPlugin); + +public: + virtual bool can_handle(Object *p_object) override; + virtual void parse_begin(Object *p_object) override; +}; + +class GradientTexture2DEditorPlugin : public EditorPlugin { + GDCLASS(GradientTexture2DEditorPlugin, EditorPlugin); + +public: + GradientTexture2DEditorPlugin(); +}; + +#endif diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 39e2e0bc9b..52e60b606c 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -5935,9 +5935,9 @@ void fragment() { float angle_fade = abs(dot(dir, NORMAL)); angle_fade = smoothstep(0.05, 0.2, angle_fade); - vec3 world_pos = (CAMERA_MATRIX * vec4(VERTEX, 1.0)).xyz; - vec3 world_normal = (CAMERA_MATRIX * vec4(NORMAL, 0.0)).xyz; - vec3 camera_world_pos = CAMERA_MATRIX[3].xyz; + vec3 world_pos = (INV_VIEW_MATRIX * vec4(VERTEX, 1.0)).xyz; + vec3 world_normal = (INV_VIEW_MATRIX * vec4(NORMAL, 0.0)).xyz; + vec3 camera_world_pos = INV_VIEW_MATRIX[3].xyz; vec3 camera_world_pos_on_plane = camera_world_pos * (1.0 - world_normal); float dist_fade = 1.0 - (distance(world_pos, camera_world_pos_on_plane) / grid_size); dist_fade = smoothstep(0.02, 0.3, dist_fade); diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index aadc7a2e66..ef171e9115 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -811,7 +811,7 @@ void vertex() { COLOR.rgb = mix( pow((COLOR.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), COLOR.rgb* (1.0 / 12.92), lessThan(COLOR.rgb,vec3(0.04045)) ); } VERTEX = VERTEX; - POSITION=PROJECTION_MATRIX*INV_CAMERA_MATRIX*WORLD_MATRIX*vec4(VERTEX.xyz,1.0); + POSITION = PROJECTION_MATRIX * VIEW_MATRIX * MODEL_MATRIX * vec4(VERTEX.xyz, 1.0); POSITION.z = mix(POSITION.z, 0, 0.999); POINT_SIZE = point_size; } @@ -1104,7 +1104,7 @@ void vertex() { COLOR.rgb = mix( pow((COLOR.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), COLOR.rgb* (1.0 / 12.92), lessThan(COLOR.rgb,vec3(0.04045)) ); } VERTEX = VERTEX; - POSITION=PROJECTION_MATRIX*INV_CAMERA_MATRIX*WORLD_MATRIX*vec4(VERTEX.xyz,1.0); + POSITION = PROJECTION_MATRIX * VIEW_MATRIX * MODEL_MATRIX * vec4(VERTEX.xyz, 1.0); POSITION.z = mix(POSITION.z, 0, 0.998); } void fragment() { diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index d313b98a7f..e17bea0f2a 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -1887,7 +1887,6 @@ ThemeItemEditorDialog::ThemeItemEditorDialog(ThemeTypeEditor *p_theme_type_edito theme_type_editor = p_theme_type_editor; tc = memnew(TabContainer); - tc->set_tab_alignment(TabBar::ALIGNMENT_LEFT); add_child(tc); // Edit Items tab. @@ -2046,6 +2045,7 @@ ThemeItemEditorDialog::ThemeItemEditorDialog(ThemeTypeEditor *p_theme_type_edito // Import Items tab. TabContainer *import_tc = memnew(TabContainer); + import_tc->set_tab_alignment(TabBar::ALIGNMENT_CENTER); tc->add_child(import_tc); tc->set_tab_title(1, TTR("Import Items")); @@ -3393,6 +3393,7 @@ ThemeTypeEditor::ThemeTypeEditor() { add_default_items_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_add_default_type_items)); data_type_tabs = memnew(TabContainer); + data_type_tabs->set_tab_alignment(TabBar::ALIGNMENT_CENTER); main_vb->add_child(data_type_tabs); data_type_tabs->set_v_size_flags(SIZE_EXPAND_FILL); data_type_tabs->set_use_hidden_tabs_for_min_size(true); @@ -3640,7 +3641,6 @@ ThemeEditor::ThemeEditor() { preview_tabs_vb->add_child(preview_tabs_content); preview_tabs = memnew(TabBar); - preview_tabs->set_tab_alignment(TabBar::ALIGNMENT_LEFT); preview_tabs->set_h_size_flags(SIZE_EXPAND_FILL); preview_tabbar_hb->add_child(preview_tabs); preview_tabs->connect("tab_changed", callable_mp(this, &ThemeEditor::_change_preview_tab)); diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index 8d8c65f2c4..c1a95c11f6 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -3989,6 +3989,7 @@ TileMapEditor::TileMapEditor() { // TabBar. tabs_bar = memnew(TabBar); + tabs_bar->set_tab_alignment(TabBar::ALIGNMENT_CENTER); tabs_bar->set_clip_tabs(false); for (int plugin_index = 0; plugin_index < tile_map_editor_plugins.size(); plugin_index++) { Vector<TileMapEditorPlugin::TabData> tabs_vector = tile_map_editor_plugins[plugin_index]->get_tabs(); diff --git a/editor/plugins/tiles/tile_set_editor.cpp b/editor/plugins/tiles/tile_set_editor.cpp index 8b0b184f54..fb4a563992 100644 --- a/editor/plugins/tiles/tile_set_editor.cpp +++ b/editor/plugins/tiles/tile_set_editor.cpp @@ -664,6 +664,7 @@ TileSetEditor::TileSetEditor() { // TabBar. tabs_bar = memnew(TabBar); + tabs_bar->set_tab_alignment(TabBar::ALIGNMENT_CENTER); tabs_bar->set_clip_tabs(false); tabs_bar->add_tab(TTR("Tiles")); tabs_bar->add_tab(TTR("Patterns")); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 7f30dd91e5..50773836db 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -1773,8 +1773,6 @@ void VisualShaderEditor::_change_input_port_name(const String &p_text, Object *p undo_redo->create_action(TTR("Change Input Port Name")); undo_redo->add_do_method(node.ptr(), "set_input_port_name", p_port_id, validated_name); undo_redo->add_undo_method(node.ptr(), "set_input_port_name", p_port_id, node->get_input_port_name(p_port_id)); - undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type, p_node_id); - undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type, p_node_id); undo_redo->commit_action(); } @@ -1801,8 +1799,6 @@ void VisualShaderEditor::_change_output_port_name(const String &p_text, Object * undo_redo->create_action(TTR("Change Output Port Name")); undo_redo->add_do_method(node.ptr(), "set_output_port_name", p_port_id, validated_name); undo_redo->add_undo_method(node.ptr(), "set_output_port_name", p_port_id, prev_name); - undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type, p_node_id); - undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type, p_node_id); undo_redo->commit_action(); } @@ -4953,17 +4949,17 @@ VisualShaderEditor::VisualShaderEditor() { // NODE3D-FOR-ALL - add_options.push_back(AddOption("Camera", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "camera"), { "camera" }, VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL)); - add_options.push_back(AddOption("InvCamera", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "inv_camera"), { "inv_camera" }, VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL)); - add_options.push_back(AddOption("InvProjection", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "inv_projection"), { "inv_projection" }, VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL)); + add_options.push_back(AddOption("InvProjectionMatrix", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "inv_projection_matrix"), { "inv_projection_matrix" }, VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL)); + add_options.push_back(AddOption("InvViewMatrix", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "inv_view_matrix"), { "inv_view_matrix" }, VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL)); + add_options.push_back(AddOption("ModelMatrix", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "model_matrix"), { "model_matrix" }, VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("Normal", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "normal"), { "normal" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, -1, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("OutputIsSRGB", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "output_is_srgb"), { "output_is_srgb" }, VisualShaderNode::PORT_TYPE_BOOLEAN, -1, Shader::MODE_SPATIAL)); - add_options.push_back(AddOption("Projection", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "projection"), { "projection" }, VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL)); + add_options.push_back(AddOption("ProjectionMatrix", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "projection_matrix"), { "projection_matrix" }, VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("Time", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "time"), { "time" }, VisualShaderNode::PORT_TYPE_SCALAR, -1, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("UV", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "uv"), { "uv" }, VisualShaderNode::PORT_TYPE_VECTOR_2D, -1, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("UV2", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "uv2"), { "uv2" }, VisualShaderNode::PORT_TYPE_VECTOR_2D, -1, Shader::MODE_SPATIAL)); + add_options.push_back(AddOption("ViewMatrix", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "view_matrix"), { "view_matrix" }, VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("ViewportSize", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "viewport_size"), { "viewport_size" }, VisualShaderNode::PORT_TYPE_VECTOR_2D, -1, Shader::MODE_SPATIAL)); - add_options.push_back(AddOption("World", "Input", "All", "VisualShaderNodeInput", vformat(input_param_shader_modes, "world"), { "world" }, VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL)); // CANVASITEM-FOR-ALL @@ -5016,7 +5012,7 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("InstanceId", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "instance_id"), { "instance_id" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("InstanceCustom", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "instance_custom"), { "instance_custom" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("InstanceCustomAlpha", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "instance_custom_alpha"), { "instance_custom_alpha" }, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL)); - add_options.push_back(AddOption("ModelView", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "modelview"), { "modelview" }, VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL)); + add_options.push_back(AddOption("ModelViewMatrix", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "modelview_matrix"), { "modelview_matrix" }, VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("PointSize", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "point_size"), { "point_size" }, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("Tangent", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_mode, "tangent"), { "tangent" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("Vertex", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "vertex"), { "vertex" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL)); @@ -5057,15 +5053,15 @@ VisualShaderEditor::VisualShaderEditor() { // CANVASITEM INPUTS add_options.push_back(AddOption("AtLightPass", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "at_light_pass"), { "at_light_pass" }, VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM)); - add_options.push_back(AddOption("Canvas", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "canvas"), { "canvas" }, VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM)); + add_options.push_back(AddOption("CanvasMatrix", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "canvas_matrix"), { "canvas_matrix" }, VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM)); add_options.push_back(AddOption("InstanceCustom", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "instance_custom"), { "instance_custom" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM)); add_options.push_back(AddOption("InstanceCustomAlpha", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "instance_custom_alpha"), { "instance_custom_alpha" }, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM)); add_options.push_back(AddOption("InstanceId", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "instance_id"), { "instance_id" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM)); + add_options.push_back(AddOption("ModelMatrix", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "model_matrix"), { "model_matrix" }, VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM)); add_options.push_back(AddOption("PointSize", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "point_size"), { "point_size" }, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM)); - add_options.push_back(AddOption("Screen", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "screen"), { "screen" }, VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM)); + add_options.push_back(AddOption("ScreenMatrix", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "screen_matrix"), { "screen_matrix" }, VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM)); add_options.push_back(AddOption("Vertex", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_mode, "vertex"), { "vertex" }, VisualShaderNode::PORT_TYPE_VECTOR_2D, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM)); add_options.push_back(AddOption("VertexId", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "vertex_id"), { "vertex_id" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM)); - add_options.push_back(AddOption("World", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "world"), { "world" }, VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM)); add_options.push_back(AddOption("AtLightPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "at_light_pass"), { "at_light_pass" }, VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM)); add_options.push_back(AddOption("FragCoord", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "fragcoord"), { "fragcoord" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM)); |