summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-10-22 17:55:02 +0200
committerGitHub <noreply@github.com>2021-10-22 17:55:02 +0200
commit83eb214bcfb44ab5ea56917f363b6135dc598c9b (patch)
tree3a5c6afbaf1e0abc371f1eab3c43fa84fab96f17 /editor
parent6c35e742286640cc0ae72f8ce0f243501263edc5 (diff)
parentaf08d497e229977b86df88dc8c972a8fce13a925 (diff)
Merge pull request #54126 from Chaosus/vs_fix_curve_texture
Diffstat (limited to 'editor')
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 0a067dfc17..09ca1f7608 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -31,6 +31,7 @@
#include "visual_shader_editor_plugin.h"
#include "core/config/project_settings.h"
+#include "core/core_string_names.h"
#include "core/input/input.h"
#include "core/io/resource_loader.h"
#include "core/math/math_defs.h"
@@ -212,19 +213,27 @@ void VisualShaderGraphPlugin::set_uniform_name(VisualShader::Type p_type, int p_
void VisualShaderGraphPlugin::update_curve(int p_node_id) {
if (links.has(p_node_id) && links[p_node_id].curve_editors[0]) {
- if (((VisualShaderNodeCurveTexture *)links[p_node_id].visual_node)->get_texture().is_valid()) {
- links[p_node_id].curve_editors[0]->set_curve(((VisualShaderNodeCurveTexture *)links[p_node_id].visual_node)->get_texture()->get_curve());
+ Ref<VisualShaderNodeCurveTexture> tex = Object::cast_to<VisualShaderNodeCurveTexture>(links[p_node_id].visual_node);
+ ERR_FAIL_COND(!tex.is_valid());
+
+ if (tex->get_texture().is_valid()) {
+ links[p_node_id].curve_editors[0]->set_curve(tex->get_texture()->get_curve());
}
+ tex->emit_signal(CoreStringNames::get_singleton()->changed);
}
}
void VisualShaderGraphPlugin::update_curve_xyz(int p_node_id) {
if (links.has(p_node_id) && links[p_node_id].curve_editors[0] && links[p_node_id].curve_editors[1] && links[p_node_id].curve_editors[2]) {
- if (((VisualShaderNodeCurveXYZTexture *)links[p_node_id].visual_node)->get_texture().is_valid()) {
- links[p_node_id].curve_editors[0]->set_curve(((VisualShaderNodeCurveXYZTexture *)links[p_node_id].visual_node)->get_texture()->get_curve_x());
- links[p_node_id].curve_editors[1]->set_curve(((VisualShaderNodeCurveXYZTexture *)links[p_node_id].visual_node)->get_texture()->get_curve_y());
- links[p_node_id].curve_editors[2]->set_curve(((VisualShaderNodeCurveXYZTexture *)links[p_node_id].visual_node)->get_texture()->get_curve_z());
+ Ref<VisualShaderNodeCurveXYZTexture> tex = Object::cast_to<VisualShaderNodeCurveXYZTexture>(links[p_node_id].visual_node);
+ ERR_FAIL_COND(!tex.is_valid());
+
+ if (tex->get_texture().is_valid()) {
+ links[p_node_id].curve_editors[0]->set_curve(tex->get_texture()->get_curve_x());
+ links[p_node_id].curve_editors[1]->set_curve(tex->get_texture()->get_curve_y());
+ links[p_node_id].curve_editors[2]->set_curve(tex->get_texture()->get_curve_z());
}
+ tex->emit_signal(CoreStringNames::get_singleton()->changed);
}
}