diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 2da9d66d9a43..4d3b51ee1f1e 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -311,8 +311,8 @@ void VisualShaderGraphPlugin::set_input_port_default_value(VisualShader::Type p_ Vector3 v = p_value; button->set_text(String::num(v.x, 3) + "," + String::num(v.y, 3) + "," + String::num(v.z, 3)); } break; - case Variant::QUATERNION: { - Quaternion v = p_value; + case Variant::VECTOR4: { + Vector4 v = p_value; button->set_text(String::num(v.x, 3) + "," + String::num(v.y, 3) + "," + String::num(v.z, 3) + "," + String::num(v.w, 3)); } break; default: { @@ -3119,7 +3119,6 @@ void VisualShaderEditor::_edit_port_default_input(Object *p_button, int p_node, popup_pref_size.width = 320; break; case Variant::VECTOR4: - case Variant::QUATERNION: case Variant::PLANE: case Variant::TRANSFORM2D: case Variant::TRANSFORM3D: @@ -7533,7 +7532,7 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref &p_par prop->set_custom_minimum_size(Size2(100 * EDSCALE, 0)); } else if (Object::cast_to(prop) || Object::cast_to(prop)) { prop->set_custom_minimum_size(Size2(250 * EDSCALE, 0)); - } else if (Object::cast_to(prop)) { + } else if (Object::cast_to(prop)) { prop->set_custom_minimum_size(Size2(320 * EDSCALE, 0)); } else if (Object::cast_to(prop)) { prop->set_custom_minimum_size(Size2(100 * EDSCALE, 0)); diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp index 5f70a24fcd65..7c4ddb2db6cc 100644 --- a/scene/resources/visual_shader_nodes.cpp +++ b/scene/resources/visual_shader_nodes.cpp @@ -581,9 +581,17 @@ Quaternion VisualShaderNodeVec4Constant::get_constant() const { return constant; } +void VisualShaderNodeVec4Constant::_set_constant_v4(const Vector4 &p_constant) { + set_constant(Quaternion(p_constant.x, p_constant.y, p_constant.z, p_constant.w)); +} + +Vector4 VisualShaderNodeVec4Constant::_get_constant_v4() const { + return Vector4(constant.x, constant.y, constant.z, constant.w); +} + Vector VisualShaderNodeVec4Constant::get_editable_properties() const { Vector props; - props.push_back("constant"); + props.push_back("constant_v4"); return props; } @@ -591,7 +599,11 @@ void VisualShaderNodeVec4Constant::_bind_methods() { ClassDB::bind_method(D_METHOD("set_constant", "constant"), &VisualShaderNodeVec4Constant::set_constant); ClassDB::bind_method(D_METHOD("get_constant"), &VisualShaderNodeVec4Constant::get_constant); + ClassDB::bind_method(D_METHOD("_set_constant_v4", "constant"), &VisualShaderNodeVec4Constant::_set_constant_v4); + ClassDB::bind_method(D_METHOD("_get_constant_v4"), &VisualShaderNodeVec4Constant::_get_constant_v4); + ADD_PROPERTY(PropertyInfo(Variant::QUATERNION, "constant"), "set_constant", "get_constant"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR4, "constant_v4", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_INTERNAL), "_set_constant_v4", "_get_constant_v4"); } VisualShaderNodeVec4Constant::VisualShaderNodeVec4Constant() { diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h index 7a37ffa0e0d3..052cc498ceac 100644 --- a/scene/resources/visual_shader_nodes.h +++ b/scene/resources/visual_shader_nodes.h @@ -341,6 +341,9 @@ class VisualShaderNodeVec4Constant : public VisualShaderNodeConstant { void set_constant(const Quaternion &p_constant); Quaternion get_constant() const; + void _set_constant_v4(const Vector4 &p_constant); + Vector4 _get_constant_v4() const; + virtual Vector get_editable_properties() const override; VisualShaderNodeVec4Constant();