From bcecb4fe37b250302ea78fb3991375ae9eb17f9d Mon Sep 17 00:00:00 2001 From: Yuri Rubinsky Date: Tue, 31 Jan 2023 09:36:47 +0300 Subject: Use mix for vector types in switch node in the visual shader --- scene/resources/visual_shader_nodes.cpp | 35 +++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp index 12be0f46a6..0695492e7f 100644 --- a/scene/resources/visual_shader_nodes.cpp +++ b/scene/resources/visual_shader_nodes.cpp @@ -6923,15 +6923,34 @@ void VisualShaderNodeSwitch::_bind_methods() { // static } String VisualShaderNodeSwitch::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { + bool use_mix = false; + switch (op_type) { + case OP_TYPE_FLOAT: { + use_mix = true; + } break; + case OP_TYPE_VECTOR_2D: { + use_mix = true; + } break; + case OP_TYPE_VECTOR_3D: { + use_mix = true; + } break; + case OP_TYPE_VECTOR_4D: { + use_mix = true; + } break; + default: { + } break; + } + String code; - code += " if(" + p_input_vars[0] + ")\n"; - code += " {\n"; - code += " " + p_output_vars[0] + " = " + p_input_vars[1] + ";\n"; - code += " }\n"; - code += " else\n"; - code += " {\n"; - code += " " + p_output_vars[0] + " = " + p_input_vars[2] + ";\n"; - code += " }\n"; + if (use_mix) { + code += " " + p_output_vars[0] + " = mix(" + p_input_vars[2] + ", " + p_input_vars[1] + ", float(" + p_input_vars[0] + "));\n"; + } else { + code += " if (" + p_input_vars[0] + ") {\n"; + code += " " + p_output_vars[0] + " = " + p_input_vars[1] + ";\n"; + code += " } else {\n"; + code += " " + p_output_vars[0] + " = " + p_input_vars[2] + ";\n"; + code += " }\n"; + } return code; } -- cgit v1.2.3 From fab6065e353fcb0594d6f632519fd124add21461 Mon Sep 17 00:00:00 2001 From: aXu-AP <1621768+aXu-AP@users.noreply.github.com> Date: Tue, 31 Jan 2023 23:41:40 +0200 Subject: Fix AnimatableBody3D not being movable in editor --- scene/3d/physics_body_3d.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index f4ab09cd9b..c8cfcf7d7a 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -333,6 +333,11 @@ void AnimatableBody3D::_body_state_changed(PhysicsDirectBodyState3D *p_state) { } void AnimatableBody3D::_notification(int p_what) { +#ifdef TOOLS_ENABLED + if (Engine::get_singleton()->is_editor_hint()) { + return; + } +#endif switch (p_what) { case NOTIFICATION_ENTER_TREE: { last_valid_transform = get_global_transform(); -- cgit v1.2.3