diff options
author | Yuri Roubinsky <chaosus89@gmail.com> | 2020-09-09 11:21:38 +0300 |
---|---|---|
committer | Yuri Roubinsky <chaosus89@gmail.com> | 2020-09-09 11:29:40 +0300 |
commit | ea49d8b9d53302baf0cde3aec0d13547f0669e84 (patch) | |
tree | 89bda694bbd4fcf9be9be083ade8594b5ad5d9a6 /scene | |
parent | 9568bcf1662b0feeaaf6c67ff7d0d25072f7860d (diff) |
Improve performance of Undo:change node position in visual shader
Diffstat (limited to 'scene')
-rw-r--r-- | scene/resources/visual_shader.cpp | 16 | ||||
-rw-r--r-- | scene/resources/visual_shader.h | 8 |
2 files changed, 24 insertions, 0 deletions
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index b851b4c4dc..394133dd47 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -317,6 +317,17 @@ VisualShaderNodeCustom::VisualShaderNodeCustom() { ///////////////////////////////////////////////////////// +void VisualShader::set_graph_node(Type p_type, int p_id, GraphNode *p_graph_node) { + ERR_FAIL_INDEX(p_type, TYPE_MAX); + Graph *g = &graph[p_type]; + ERR_FAIL_COND(!g->nodes.has(p_id)); + g->nodes[p_id].graph_node = p_graph_node; +} + +void VisualShader::set_shader_type(Type p_type) { + current_type = p_type; +} + void VisualShader::set_version(const String &p_version) { version = p_version; } @@ -400,6 +411,11 @@ void VisualShader::set_node_position(Type p_type, int p_id, const Vector2 &p_pos Graph *g = &graph[p_type]; ERR_FAIL_COND(!g->nodes.has(p_id)); g->nodes[p_id].position = p_position; + if (current_type == p_type) { + if (g->nodes[p_id].graph_node != nullptr) { + g->nodes[p_id].graph_node->set_offset(p_position); + } + } } Vector2 VisualShader::get_node_position(Type p_type, int p_id) const { diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h index 3f5266142a..d45029ec03 100644 --- a/scene/resources/visual_shader.h +++ b/scene/resources/visual_shader.h @@ -33,6 +33,7 @@ #include "core/string_builder.h" #include "scene/gui/control.h" +#include "scene/gui/graph_edit.h" #include "scene/resources/shader.h" class VisualShaderNodeUniform; @@ -69,10 +70,13 @@ public: }; private: + Type current_type; + struct Node { Ref<VisualShaderNode> node; Vector2 position; List<int> prev_connected_nodes; + GraphNode *graph_node; }; struct Graph { @@ -124,6 +128,10 @@ protected: bool _get(const StringName &p_name, Variant &r_ret) const; void _get_property_list(List<PropertyInfo> *p_list) const; +public: // internal methods + void set_graph_node(Type p_type, int p_id, GraphNode *p_graph_node); + void set_shader_type(Type p_type); + public: void set_version(const String &p_version); String get_version() const; |