diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/3d/audio_stream_player_3d.cpp | 3 | ||||
-rw-r--r-- | scene/3d/light_3d.cpp | 12 | ||||
-rw-r--r-- | scene/animation/animation_player.cpp | 11 | ||||
-rw-r--r-- | scene/animation/tween.cpp | 8 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 16 | ||||
-rw-r--r-- | scene/main/canvas_item.cpp | 63 | ||||
-rw-r--r-- | scene/main/node.cpp | 24 | ||||
-rw-r--r-- | scene/main/timer.cpp | 8 | ||||
-rw-r--r-- | scene/resources/animation.cpp | 27 | ||||
-rw-r--r-- | scene/resources/audio_stream_sample.cpp | 36 | ||||
-rw-r--r-- | scene/resources/material.cpp | 107 | ||||
-rw-r--r-- | scene/resources/particles_material.cpp | 9 | ||||
-rw-r--r-- | scene/resources/visual_shader.cpp | 40 | ||||
-rw-r--r-- | scene/resources/visual_shader_nodes.cpp | 154 |
14 files changed, 384 insertions, 134 deletions
diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index 5701d3cea2..8a00d67e12 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -320,7 +320,8 @@ float AudioStreamPlayer3D::_get_attenuation_db(float p_distance) const { case ATTENUATION_LOGARITHMIC: { att = -20 * Math::log(p_distance / unit_size + CMP_EPSILON); } break; - case ATTENUATION_DISABLED: break; + case ATTENUATION_DISABLED: + break; default: { ERR_PRINT("Unknown attenuation type"); break; diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp index c048f60ebd..0aa0f7e5ac 100644 --- a/scene/3d/light_3d.cpp +++ b/scene/3d/light_3d.cpp @@ -326,9 +326,15 @@ Light3D::Light3D(RenderingServer::LightType p_type) { type = p_type; switch (p_type) { - case RS::LIGHT_DIRECTIONAL: light = RenderingServer::get_singleton()->directional_light_create(); break; - case RS::LIGHT_OMNI: light = RenderingServer::get_singleton()->omni_light_create(); break; - case RS::LIGHT_SPOT: light = RenderingServer::get_singleton()->spot_light_create(); break; + case RS::LIGHT_DIRECTIONAL: + light = RenderingServer::get_singleton()->directional_light_create(); + break; + case RS::LIGHT_OMNI: + light = RenderingServer::get_singleton()->omni_light_create(); + break; + case RS::LIGHT_SPOT: + light = RenderingServer::get_singleton()->spot_light_create(); + break; default: { }; } diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 8228cf67bd..7bac09f839 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -1479,9 +1479,14 @@ void AnimationPlayer::_set_process(bool p_process, bool p_force) { switch (animation_process_mode) { - case ANIMATION_PROCESS_PHYSICS: set_physics_process_internal(p_process && active); break; - case ANIMATION_PROCESS_IDLE: set_process_internal(p_process && active); break; - case ANIMATION_PROCESS_MANUAL: break; + case ANIMATION_PROCESS_PHYSICS: + set_physics_process_internal(p_process && active); + break; + case ANIMATION_PROCESS_IDLE: + set_process_internal(p_process && active); + break; + case ANIMATION_PROCESS_MANUAL: + break; } processing = p_process; diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 963ba2a106..b826907a3a 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -826,8 +826,12 @@ void Tween::set_active(bool p_active) { // Depending on physics or idle, set processing switch (tween_process_mode) { - case TWEEN_PROCESS_IDLE: set_process_internal(p_active); break; - case TWEEN_PROCESS_PHYSICS: set_physics_process_internal(p_active); break; + case TWEEN_PROCESS_IDLE: + set_process_internal(p_active); + break; + case TWEEN_PROCESS_PHYSICS: + set_physics_process_internal(p_active); + break; } } diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index b5b61e2631..a6c0c99bdb 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -230,10 +230,18 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & } else { \ int used = wofs - margin; \ switch (align) { \ - case ALIGN_LEFT: l.offset_caches.push_back(0); break; \ - case ALIGN_CENTER: l.offset_caches.push_back(((p_width - margin) - used) / 2); break; \ - case ALIGN_RIGHT: l.offset_caches.push_back(((p_width - margin) - used)); break; \ - case ALIGN_FILL: l.offset_caches.push_back(line_wrapped ? ((p_width - margin) - used) : 0); break; \ + case ALIGN_LEFT: \ + l.offset_caches.push_back(0); \ + break; \ + case ALIGN_CENTER: \ + l.offset_caches.push_back(((p_width - margin) - used) / 2); \ + break; \ + case ALIGN_RIGHT: \ + l.offset_caches.push_back(((p_width - margin) - used)); \ + break; \ + case ALIGN_FILL: \ + l.offset_caches.push_back(line_wrapped ? ((p_width - margin) - used) : 0); \ + break; \ } \ l.height_caches.push_back(line_height); \ l.ascent_caches.push_back(line_ascent); \ diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp index b5d54b2199..e91826d44b 100644 --- a/scene/main/canvas_item.cpp +++ b/scene/main/canvas_item.cpp @@ -95,18 +95,35 @@ void CanvasItemMaterial::_update_shader() { String code = "shader_type canvas_item;\nrender_mode "; switch (blend_mode) { - case BLEND_MODE_MIX: code += "blend_mix"; break; - case BLEND_MODE_ADD: code += "blend_add"; break; - case BLEND_MODE_SUB: code += "blend_sub"; break; - case BLEND_MODE_MUL: code += "blend_mul"; break; - case BLEND_MODE_PREMULT_ALPHA: code += "blend_premul_alpha"; break; - case BLEND_MODE_DISABLED: code += "blend_disabled"; break; + case BLEND_MODE_MIX: + code += "blend_mix"; + break; + case BLEND_MODE_ADD: + code += "blend_add"; + break; + case BLEND_MODE_SUB: + code += "blend_sub"; + break; + case BLEND_MODE_MUL: + code += "blend_mul"; + break; + case BLEND_MODE_PREMULT_ALPHA: + code += "blend_premul_alpha"; + break; + case BLEND_MODE_DISABLED: + code += "blend_disabled"; + break; } switch (light_mode) { - case LIGHT_MODE_NORMAL: break; - case LIGHT_MODE_UNSHADED: code += ",unshaded"; break; - case LIGHT_MODE_LIGHT_ONLY: code += ",light_only"; break; + case LIGHT_MODE_NORMAL: + break; + case LIGHT_MODE_UNSHADED: + code += ",unshaded"; + break; + case LIGHT_MODE_LIGHT_ONLY: + code += ",light_only"; + break; } code += ";\n"; @@ -1372,10 +1389,18 @@ void CanvasItem::_update_texture_filter_changed(bool p_propagate) { } else { //from viewport switch (get_viewport()->get_default_canvas_item_texture_filter()) { - case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST: texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST; break; - case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR: texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR; break; - case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS: texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS; break; - case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS: texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS; break; + case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST: + texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST; + break; + case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR: + texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR; + break; + case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS: + texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS; + break; + case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS: + texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS; + break; default: { } } @@ -1421,9 +1446,15 @@ void CanvasItem::_update_texture_repeat_changed(bool p_propagate) { } else { //from viewport switch (get_viewport()->get_default_canvas_item_texture_repeat()) { - case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_DISABLED: texture_repeat_cache = RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED; break; - case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_ENABLED: texture_repeat_cache = RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED; break; - case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_MIRROR: texture_repeat_cache = RS::CANVAS_ITEM_TEXTURE_REPEAT_MIRROR; break; + case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_DISABLED: + texture_repeat_cache = RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED; + break; + case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_ENABLED: + texture_repeat_cache = RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED; + break; + case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_MIRROR: + texture_repeat_cache = RS::CANVAS_ITEM_TEXTURE_REPEAT_MIRROR; + break; default: { } } diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 4c02a15531..3d56b51e26 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -819,10 +819,14 @@ String Node::get_rpc_md5() const { bool Node::can_process_notification(int p_what) const { switch (p_what) { - case NOTIFICATION_PHYSICS_PROCESS: return data.physics_process; - case NOTIFICATION_PROCESS: return data.idle_process; - case NOTIFICATION_INTERNAL_PROCESS: return data.idle_process_internal; - case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: return data.physics_process_internal; + case NOTIFICATION_PHYSICS_PROCESS: + return data.physics_process; + case NOTIFICATION_PROCESS: + return data.idle_process; + case NOTIFICATION_INTERNAL_PROCESS: + return data.idle_process_internal; + case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: + return data.physics_process_internal; } return true; @@ -2994,10 +2998,14 @@ void Node::_bind_methods() { String Node::_get_name_num_separator() { switch (ProjectSettings::get_singleton()->get("node/name_num_separator").operator int()) { - case 0: return ""; - case 1: return " "; - case 2: return "_"; - case 3: return "-"; + case 0: + return ""; + case 1: + return " "; + case 2: + return "_"; + case 3: + return "-"; } return " "; } diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp index 7c847095e1..7cab4028b8 100644 --- a/scene/main/timer.cpp +++ b/scene/main/timer.cpp @@ -173,8 +173,12 @@ Timer::TimerProcessMode Timer::get_timer_process_mode() const { void Timer::_set_process(bool p_process, bool p_force) { switch (timer_process_mode) { - case TIMER_PROCESS_PHYSICS: set_physics_process_internal(p_process && !paused); break; - case TIMER_PROCESS_IDLE: set_process_internal(p_process && !paused); break; + case TIMER_PROCESS_PHYSICS: + set_physics_process_internal(p_process && !paused); + break; + case TIMER_PROCESS_IDLE: + set_process_internal(p_process && !paused); + break; } processing = p_process; } diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index ea4338519e..c5806ee7b3 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -349,12 +349,24 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const { switch (track_get_type(track)) { - case TYPE_TRANSFORM: r_ret = "transform"; break; - case TYPE_VALUE: r_ret = "value"; break; - case TYPE_METHOD: r_ret = "method"; break; - case TYPE_BEZIER: r_ret = "bezier"; break; - case TYPE_AUDIO: r_ret = "audio"; break; - case TYPE_ANIMATION: r_ret = "animation"; break; + case TYPE_TRANSFORM: + r_ret = "transform"; + break; + case TYPE_VALUE: + r_ret = "value"; + break; + case TYPE_METHOD: + r_ret = "method"; + break; + case TYPE_BEZIER: + r_ret = "bezier"; + break; + case TYPE_AUDIO: + r_ret = "audio"; + break; + case TYPE_ANIMATION: + r_ret = "animation"; + break; } return true; @@ -1842,7 +1854,8 @@ T Animation::_interpolate(const Vector<TKey<T>> &p_keys, float p_time, Interpola return _cubic_interpolate(p_keys[pre].value, p_keys[idx].value, p_keys[next].value, p_keys[post].value, c); } break; - default: return p_keys[idx].value; + default: + return p_keys[idx].value; } // do a barrel roll diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp index d630a1f3ee..fdf5e2c2d0 100644 --- a/scene/resources/audio_stream_sample.cpp +++ b/scene/resources/audio_stream_sample.cpp @@ -230,9 +230,15 @@ void AudioStreamPlaybackSample::mix(AudioFrame *p_buffer, float p_rate_scale, in int len = base->data_bytes; switch (base->format) { - case AudioStreamSample::FORMAT_8_BITS: len /= 1; break; - case AudioStreamSample::FORMAT_16_BITS: len /= 2; break; - case AudioStreamSample::FORMAT_IMA_ADPCM: len *= 2; break; + case AudioStreamSample::FORMAT_8_BITS: + len /= 1; + break; + case AudioStreamSample::FORMAT_16_BITS: + len /= 2; + break; + case AudioStreamSample::FORMAT_IMA_ADPCM: + len *= 2; + break; } if (base->stereo) { @@ -465,9 +471,15 @@ float AudioStreamSample::get_length() const { int len = data_bytes; switch (format) { - case AudioStreamSample::FORMAT_8_BITS: len /= 1; break; - case AudioStreamSample::FORMAT_16_BITS: len /= 2; break; - case AudioStreamSample::FORMAT_IMA_ADPCM: len *= 2; break; + case AudioStreamSample::FORMAT_8_BITS: + len /= 1; + break; + case AudioStreamSample::FORMAT_16_BITS: + len /= 2; + break; + case AudioStreamSample::FORMAT_IMA_ADPCM: + len *= 2; + break; } if (stereo) { @@ -536,9 +548,15 @@ Error AudioStreamSample::save_to_wav(const String &p_path) { int byte_pr_sample = 0; switch (format) { - case AudioStreamSample::FORMAT_8_BITS: byte_pr_sample = 1; break; - case AudioStreamSample::FORMAT_16_BITS: byte_pr_sample = 2; break; - case AudioStreamSample::FORMAT_IMA_ADPCM: byte_pr_sample = 4; break; + case AudioStreamSample::FORMAT_8_BITS: + byte_pr_sample = 1; + break; + case AudioStreamSample::FORMAT_16_BITS: + byte_pr_sample = 2; + break; + case AudioStreamSample::FORMAT_IMA_ADPCM: + byte_pr_sample = 4; + break; } String file_path = p_path; diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index fd8cff7cd0..e3bed171b0 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -414,13 +414,26 @@ void BaseMaterial3D::_update_shader() { String texfilter_str; switch (texture_filter) { - case TEXTURE_FILTER_NEAREST: texfilter_str = "filter_nearest"; break; - case TEXTURE_FILTER_LINEAR: texfilter_str = "filter_linear"; break; - case TEXTURE_FILTER_NEAREST_WITH_MIPMAPS: texfilter_str = "filter_nearest_mipmap"; break; - case TEXTURE_FILTER_LINEAR_WITH_MIPMAPS: texfilter_str = "filter_linear_mipmap"; break; - case TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC: texfilter_str = "filter_nearest_mipmap_aniso"; break; - case TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC: texfilter_str = "filter_linear_mipmap_aniso"; break; - case TEXTURE_FILTER_MAX: break; // Internal value, skip. + case TEXTURE_FILTER_NEAREST: + texfilter_str = "filter_nearest"; + break; + case TEXTURE_FILTER_LINEAR: + texfilter_str = "filter_linear"; + break; + case TEXTURE_FILTER_NEAREST_WITH_MIPMAPS: + texfilter_str = "filter_nearest_mipmap"; + break; + case TEXTURE_FILTER_LINEAR_WITH_MIPMAPS: + texfilter_str = "filter_linear_mipmap"; + break; + case TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC: + texfilter_str = "filter_nearest_mipmap_aniso"; + break; + case TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC: + texfilter_str = "filter_linear_mipmap_aniso"; + break; + case TEXTURE_FILTER_MAX: + break; // Internal value, skip. } if (flags[FLAG_USE_TEXTURE_REPEAT]) { @@ -433,10 +446,18 @@ void BaseMaterial3D::_update_shader() { String code = "shader_type spatial;\nrender_mode "; switch (blend_mode) { - case BLEND_MODE_MIX: code += "blend_mix"; break; - case BLEND_MODE_ADD: code += "blend_add"; break; - case BLEND_MODE_SUB: code += "blend_sub"; break; - case BLEND_MODE_MUL: code += "blend_mul"; break; + case BLEND_MODE_MIX: + code += "blend_mix"; + break; + case BLEND_MODE_ADD: + code += "blend_add"; + break; + case BLEND_MODE_SUB: + code += "blend_sub"; + break; + case BLEND_MODE_MUL: + code += "blend_mul"; + break; } DepthDrawMode ddm = depth_draw_mode; @@ -445,9 +466,15 @@ void BaseMaterial3D::_update_shader() { } switch (ddm) { - case DEPTH_DRAW_OPAQUE_ONLY: code += ",depth_draw_opaque"; break; - case DEPTH_DRAW_ALWAYS: code += ",depth_draw_always"; break; - case DEPTH_DRAW_DISABLED: code += ",depth_draw_never"; break; + case DEPTH_DRAW_OPAQUE_ONLY: + code += ",depth_draw_opaque"; + break; + case DEPTH_DRAW_ALWAYS: + code += ",depth_draw_always"; + break; + case DEPTH_DRAW_DISABLED: + code += ",depth_draw_never"; + break; } if (transparency == TRANSPARENCY_ALPHA_DEPTH_PRE_PASS) { @@ -455,23 +482,49 @@ void BaseMaterial3D::_update_shader() { } switch (cull_mode) { - case CULL_BACK: code += ",cull_back"; break; - case CULL_FRONT: code += ",cull_front"; break; - case CULL_DISABLED: code += ",cull_disabled"; break; + case CULL_BACK: + code += ",cull_back"; + break; + case CULL_FRONT: + code += ",cull_front"; + break; + case CULL_DISABLED: + code += ",cull_disabled"; + break; } switch (diffuse_mode) { - case DIFFUSE_BURLEY: code += ",diffuse_burley"; break; - case DIFFUSE_LAMBERT: code += ",diffuse_lambert"; break; - case DIFFUSE_LAMBERT_WRAP: code += ",diffuse_lambert_wrap"; break; - case DIFFUSE_OREN_NAYAR: code += ",diffuse_oren_nayar"; break; - case DIFFUSE_TOON: code += ",diffuse_toon"; break; + case DIFFUSE_BURLEY: + code += ",diffuse_burley"; + break; + case DIFFUSE_LAMBERT: + code += ",diffuse_lambert"; + break; + case DIFFUSE_LAMBERT_WRAP: + code += ",diffuse_lambert_wrap"; + break; + case DIFFUSE_OREN_NAYAR: + code += ",diffuse_oren_nayar"; + break; + case DIFFUSE_TOON: + code += ",diffuse_toon"; + break; } switch (specular_mode) { - case SPECULAR_SCHLICK_GGX: code += ",specular_schlick_ggx"; break; - case SPECULAR_BLINN: code += ",specular_blinn"; break; - case SPECULAR_PHONG: code += ",specular_phong"; break; - case SPECULAR_TOON: code += ",specular_toon"; break; - case SPECULAR_DISABLED: code += ",specular_disabled"; break; + case SPECULAR_SCHLICK_GGX: + code += ",specular_schlick_ggx"; + break; + case SPECULAR_BLINN: + code += ",specular_blinn"; + break; + case SPECULAR_PHONG: + code += ",specular_phong"; + break; + case SPECULAR_TOON: + code += ",specular_toon"; + break; + case SPECULAR_DISABLED: + code += ",specular_disabled"; + break; } if (features[FEATURE_SUBSURFACE_SCATTERING] && flags[FLAG_SUBSURFACE_MODE_SKIN]) { code += ",sss_mode_skin"; diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp index 83430aef9e..1a28e2586d 100644 --- a/scene/resources/particles_material.cpp +++ b/scene/resources/particles_material.cpp @@ -703,7 +703,8 @@ void ParticlesMaterial::set_param(Parameter p_param, float p_value) { case PARAM_ANIM_OFFSET: { RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset, p_value); } break; - case PARAM_MAX: break; // Can't happen, but silences warning + case PARAM_MAX: + break; // Can't happen, but silences warning } } float ParticlesMaterial::get_param(Parameter p_param) const { @@ -756,7 +757,8 @@ void ParticlesMaterial::set_param_randomness(Parameter p_param, float p_value) { case PARAM_ANIM_OFFSET: { RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset_random, p_value); } break; - case PARAM_MAX: break; // Can't happen, but silences warning + case PARAM_MAX: + break; // Can't happen, but silences warning } } float ParticlesMaterial::get_param_randomness(Parameter p_param) const { @@ -828,7 +830,8 @@ void ParticlesMaterial::set_param_texture(Parameter p_param, const Ref<Texture2D case PARAM_ANIM_OFFSET: { RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset_texture, p_texture); } break; - case PARAM_MAX: break; // Can't happen, but silences warning + case PARAM_MAX: + break; // Can't happen, but silences warning } _queue_shader_change(); diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index 3b245f908a..5637aaec9a 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -1229,11 +1229,21 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui for (int i = 0; i < output_count; i++) { String var_name = "n_out" + itos(node) + "p" + itos(i); switch (vsnode->get_output_port_type(i)) { - case VisualShaderNode::PORT_TYPE_SCALAR: outputs[i] = "float " + var_name; break; - case VisualShaderNode::PORT_TYPE_SCALAR_INT: outputs[i] = "int " + var_name; break; - case VisualShaderNode::PORT_TYPE_VECTOR: outputs[i] = "vec3 " + var_name; break; - case VisualShaderNode::PORT_TYPE_BOOLEAN: outputs[i] = "bool " + var_name; break; - case VisualShaderNode::PORT_TYPE_TRANSFORM: outputs[i] = "mat4 " + var_name; break; + case VisualShaderNode::PORT_TYPE_SCALAR: + outputs[i] = "float " + var_name; + break; + case VisualShaderNode::PORT_TYPE_SCALAR_INT: + outputs[i] = "int " + var_name; + break; + case VisualShaderNode::PORT_TYPE_VECTOR: + outputs[i] = "vec3 " + var_name; + break; + case VisualShaderNode::PORT_TYPE_BOOLEAN: + outputs[i] = "bool " + var_name; + break; + case VisualShaderNode::PORT_TYPE_TRANSFORM: + outputs[i] = "mat4 " + var_name; + break; default: { } } @@ -1243,11 +1253,21 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui for (int i = 0; i < output_count; i++) { outputs[i] = "n_out" + itos(node) + "p" + itos(i); switch (vsnode->get_output_port_type(i)) { - case VisualShaderNode::PORT_TYPE_SCALAR: code += String() + "\tfloat " + outputs[i] + ";\n"; break; - case VisualShaderNode::PORT_TYPE_SCALAR_INT: code += String() + "\tint " + outputs[i] + ";\n"; break; - case VisualShaderNode::PORT_TYPE_VECTOR: code += String() + "\tvec3 " + outputs[i] + ";\n"; break; - case VisualShaderNode::PORT_TYPE_BOOLEAN: code += String() + "\tbool " + outputs[i] + ";\n"; break; - case VisualShaderNode::PORT_TYPE_TRANSFORM: code += String() + "\tmat4 " + outputs[i] + ";\n"; break; + case VisualShaderNode::PORT_TYPE_SCALAR: + code += String() + "\tfloat " + outputs[i] + ";\n"; + break; + case VisualShaderNode::PORT_TYPE_SCALAR_INT: + code += String() + "\tint " + outputs[i] + ";\n"; + break; + case VisualShaderNode::PORT_TYPE_VECTOR: + code += String() + "\tvec3 " + outputs[i] + ";\n"; + break; + case VisualShaderNode::PORT_TYPE_BOOLEAN: + code += String() + "\tbool " + outputs[i] + ";\n"; + break; + case VisualShaderNode::PORT_TYPE_TRANSFORM: + code += String() + "\tmat4 " + outputs[i] + ";\n"; + break; default: { } } diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp index 7b9953a90f..03db8c3ac5 100644 --- a/scene/resources/visual_shader_nodes.cpp +++ b/scene/resources/visual_shader_nodes.cpp @@ -497,9 +497,14 @@ String VisualShaderNodeTexture::generate_global(Shader::Mode p_mode, VisualShade String u = "uniform sampler2D " + make_unique_id(p_type, p_id, "tex"); switch (texture_type) { - case TYPE_DATA: break; - case TYPE_COLOR: u += " : hint_albedo"; break; - case TYPE_NORMALMAP: u += " : hint_normal"; break; + case TYPE_DATA: + break; + case TYPE_COLOR: + u += " : hint_albedo"; + break; + case TYPE_NORMALMAP: + u += " : hint_normal"; + break; } return u + ";\n"; } @@ -869,9 +874,14 @@ String VisualShaderNodeCubemap::generate_global(Shader::Mode p_mode, VisualShade if (source == SOURCE_TEXTURE) { String u = "uniform samplerCube " + make_unique_id(p_type, p_id, "cube"); switch (texture_type) { - case TYPE_DATA: break; - case TYPE_COLOR: u += " : hint_albedo"; break; - case TYPE_NORMALMAP: u += " : hint_normal"; break; + case TYPE_DATA: + break; + case TYPE_COLOR: + u += " : hint_albedo"; + break; + case TYPE_NORMALMAP: + u += " : hint_normal"; + break; } return u + ";\n"; } @@ -1032,16 +1042,36 @@ String VisualShaderNodeFloatOp::generate_code(Shader::Mode p_mode, VisualShader: String code = "\t" + p_output_vars[0] + " = "; switch (op) { - case OP_ADD: code += p_input_vars[0] + " + " + p_input_vars[1] + ";\n"; break; - case OP_SUB: code += p_input_vars[0] + " - " + p_input_vars[1] + ";\n"; break; - case OP_MUL: code += p_input_vars[0] + " * " + p_input_vars[1] + ";\n"; break; - case OP_DIV: code += p_input_vars[0] + " / " + p_input_vars[1] + ";\n"; break; - case OP_MOD: code += "mod(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break; - case OP_POW: code += "pow(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break; - case OP_MAX: code += "max(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break; - case OP_MIN: code += "min(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break; - case OP_ATAN2: code += "atan(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break; - case OP_STEP: code += "step(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break; + case OP_ADD: + code += p_input_vars[0] + " + " + p_input_vars[1] + ";\n"; + break; + case OP_SUB: + code += p_input_vars[0] + " - " + p_input_vars[1] + ";\n"; + break; + case OP_MUL: + code += p_input_vars[0] + " * " + p_input_vars[1] + ";\n"; + break; + case OP_DIV: + code += p_input_vars[0] + " / " + p_input_vars[1] + ";\n"; + break; + case OP_MOD: + code += "mod(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + break; + case OP_POW: + code += "pow(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + break; + case OP_MAX: + code += "max(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + break; + case OP_MIN: + code += "min(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + break; + case OP_ATAN2: + code += "atan(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + break; + case OP_STEP: + code += "step(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + break; } return code; @@ -1124,13 +1154,27 @@ String VisualShaderNodeIntOp::generate_code(Shader::Mode p_mode, VisualShader::T String code = "\t" + p_output_vars[0] + " = "; switch (op) { - case OP_ADD: code += p_input_vars[0] + " + " + p_input_vars[1] + ";\n"; break; - case OP_SUB: code += p_input_vars[0] + " - " + p_input_vars[1] + ";\n"; break; - case OP_MUL: code += p_input_vars[0] + " * " + p_input_vars[1] + ";\n"; break; - case OP_DIV: code += p_input_vars[0] + " / " + p_input_vars[1] + ";\n"; break; - case OP_MOD: code += p_input_vars[0] + " % " + p_input_vars[1] + ";\n"; break; - case OP_MAX: code += "max(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break; - case OP_MIN: code += "min(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break; + case OP_ADD: + code += p_input_vars[0] + " + " + p_input_vars[1] + ";\n"; + break; + case OP_SUB: + code += p_input_vars[0] + " - " + p_input_vars[1] + ";\n"; + break; + case OP_MUL: + code += p_input_vars[0] + " * " + p_input_vars[1] + ";\n"; + break; + case OP_DIV: + code += p_input_vars[0] + " / " + p_input_vars[1] + ";\n"; + break; + case OP_MOD: + code += p_input_vars[0] + " % " + p_input_vars[1] + ";\n"; + break; + case OP_MAX: + code += "max(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + break; + case OP_MIN: + code += "min(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + break; } return code; @@ -1209,18 +1253,42 @@ String VisualShaderNodeVectorOp::generate_code(Shader::Mode p_mode, VisualShader String code = "\t" + p_output_vars[0] + " = "; switch (op) { - case OP_ADD: code += p_input_vars[0] + " + " + p_input_vars[1] + ";\n"; break; - case OP_SUB: code += p_input_vars[0] + " - " + p_input_vars[1] + ";\n"; break; - case OP_MUL: code += p_input_vars[0] + " * " + p_input_vars[1] + ";\n"; break; - case OP_DIV: code += p_input_vars[0] + " / " + p_input_vars[1] + ";\n"; break; - case OP_MOD: code += "mod(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break; - case OP_POW: code += "pow(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break; - case OP_MAX: code += "max(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break; - case OP_MIN: code += "min(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break; - case OP_CROSS: code += "cross(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break; - case OP_ATAN2: code += "atan(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break; - case OP_REFLECT: code += "reflect(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break; - case OP_STEP: code += "step(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break; + case OP_ADD: + code += p_input_vars[0] + " + " + p_input_vars[1] + ";\n"; + break; + case OP_SUB: + code += p_input_vars[0] + " - " + p_input_vars[1] + ";\n"; + break; + case OP_MUL: + code += p_input_vars[0] + " * " + p_input_vars[1] + ";\n"; + break; + case OP_DIV: + code += p_input_vars[0] + " / " + p_input_vars[1] + ";\n"; + break; + case OP_MOD: + code += "mod(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + break; + case OP_POW: + code += "pow(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + break; + case OP_MAX: + code += "max(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + break; + case OP_MIN: + code += "min(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + break; + case OP_CROSS: + code += "cross(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + break; + case OP_ATAN2: + code += "atan(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + break; + case OP_REFLECT: + code += "reflect(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + break; + case OP_STEP: + code += "step(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; + break; } return code; @@ -3752,8 +3820,12 @@ String VisualShaderNodeTextureUniform::generate_global(Shader::Mode p_mode, Visu else code += " : hint_albedo;\n"; break; - case TYPE_NORMALMAP: code += " : hint_normal;\n"; break; - case TYPE_ANISO: code += " : hint_aniso;\n"; break; + case TYPE_NORMALMAP: + code += " : hint_normal;\n"; + break; + case TYPE_ANISO: + code += " : hint_aniso;\n"; + break; } return code; @@ -4003,8 +4075,12 @@ String VisualShaderNodeCubemapUniform::generate_global(Shader::Mode p_mode, Visu else code += " : hint_albedo;\n"; break; - case TYPE_NORMALMAP: code += " : hint_normal;\n"; break; - case TYPE_ANISO: code += " : hint_aniso;\n"; break; + case TYPE_NORMALMAP: + code += " : hint_normal;\n"; + break; + case TYPE_ANISO: + code += " : hint_aniso;\n"; + break; } return code; |