diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c index 439e41b963b..aa1f23163a0 100644 --- a/source/blender/nodes/intern/node_common.c +++ b/source/blender/nodes/intern/node_common.c @@ -84,13 +84,11 @@ bool node_group_poll_instance(bNode *node, bNodeTree *nodetree) if (grouptree) { return nodeGroupPoll(nodetree, grouptree); } - else { - return true; /* without a linked node tree, group node is always ok */ - } - } - else { - return false; + + return true; /* without a linked node tree, group node is always ok */ } + + return false; } int nodeGroupPoll(bNodeTree *nodetree, bNodeTree *grouptree) diff --git a/source/blender/nodes/intern/node_tree_multi_function.cc b/source/blender/nodes/intern/node_tree_multi_function.cc index 82842c4ef32..09a80fd23f4 100644 --- a/source/blender/nodes/intern/node_tree_multi_function.cc +++ b/source/blender/nodes/intern/node_tree_multi_function.cc @@ -176,13 +176,12 @@ static fn::MFOutputSocket *try_find_origin(CommonMFNetworkBuilderData &common, } return nullptr; } - else { - const DGroupInput &from_group_input = *from_group_inputs[0]; - if (is_multi_function_data_socket(from_group_input.bsocket())) { - return &common.network_map.lookup(from_group_input); - } - return nullptr; + + const DGroupInput &from_group_input = *from_group_inputs[0]; + if (is_multi_function_data_socket(from_group_input.bsocket())) { + return &common.network_map.lookup(from_group_input); } + return nullptr; } using ImplicitConversionsMap = diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.c b/source/blender/nodes/shader/nodes/node_shader_attribute.c index 6b5d46e250b..116bc181997 100644 --- a/source/blender/nodes/shader/nodes/node_shader_attribute.c +++ b/source/blender/nodes/shader/nodes/node_shader_attribute.c @@ -55,17 +55,16 @@ static int node_shader_gpu_attribute(GPUMaterial *mat, return 1; } - else { - GPUNodeLink *cd_attr = GPU_attribute(mat, CD_AUTO_FROM_NAME, attr->name); - GPU_stack_link(mat, node, "node_attribute", in, out, cd_attr); - /* for each output. */ - for (int i = 0; sh_node_attribute_out[i].type != -1; i++) { - node_shader_gpu_bump_tex_coord(mat, node, &out[i].link); - } + GPUNodeLink *cd_attr = GPU_attribute(mat, CD_AUTO_FROM_NAME, attr->name); + GPU_stack_link(mat, node, "node_attribute", in, out, cd_attr); - return 1; + /* for each output. */ + for (int i = 0; sh_node_attribute_out[i].type != -1; i++) { + node_shader_gpu_bump_tex_coord(mat, node, &out[i].link); } + + return 1; } /* node type definition */ diff --git a/source/blender/nodes/shader/nodes/node_shader_clamp.cc b/source/blender/nodes/shader/nodes/node_shader_clamp.cc index 1077f616a62..d3a893e1d76 100644 --- a/source/blender/nodes/shader/nodes/node_shader_clamp.cc +++ b/source/blender/nodes/shader/nodes/node_shader_clamp.cc @@ -60,9 +60,8 @@ static void sh_node_clamp_expand_in_mf_network(blender::nodes::NodeMFNetworkBuil if (a < b) { return clamp_f(value, a, b); } - else { - return clamp_f(value, b, a); - } + + return clamp_f(value, b, a); }}; int clamp_type = builder.bnode().custom1; diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.c b/source/blender/nodes/shader/nodes/node_shader_curves.c index 06aaf9e74cb..42299a193e2 100644 --- a/source/blender/nodes/shader/nodes/node_shader_curves.c +++ b/source/blender/nodes/shader/nodes/node_shader_curves.c @@ -215,20 +215,19 @@ static int gpu_shader_curve_rgb(GPUMaterial *mat, GPU_uniform(range_rgba), GPU_uniform(ext_rgba[3])); } - else { - return GPU_stack_link(mat, - node, - "curves_rgb", - in, - out, - tex, - GPU_constant(&layer), - GPU_uniform(range_rgba), - GPU_uniform(ext_rgba[0]), - GPU_uniform(ext_rgba[1]), - GPU_uniform(ext_rgba[2]), - GPU_uniform(ext_rgba[3])); - } + + return GPU_stack_link(mat, + node, + "curves_rgb", + in, + out, + tex, + GPU_constant(&layer), + GPU_uniform(range_rgba), + GPU_uniform(ext_rgba[0]), + GPU_uniform(ext_rgba[1]), + GPU_uniform(ext_rgba[2]), + GPU_uniform(ext_rgba[3])); } void register_node_type_sh_curve_rgb(void) diff --git a/source/blender/nodes/shader/nodes/node_shader_displacement.c b/source/blender/nodes/shader/nodes/node_shader_displacement.c index 22fbe4e4da6..649aad370c0 100644 --- a/source/blender/nodes/shader/nodes/node_shader_displacement.c +++ b/source/blender/nodes/shader/nodes/node_shader_displacement.c @@ -64,10 +64,9 @@ static int gpu_shader_displacement(GPUMaterial *mat, return GPU_stack_link( mat, node, "node_displacement_object", in, out, GPU_builtin(GPU_OBJECT_MATRIX)); } - else { - return GPU_stack_link( - mat, node, "node_displacement_world", in, out, GPU_builtin(GPU_OBJECT_MATRIX)); - } + + return GPU_stack_link( + mat, node, "node_displacement_world", in, out, GPU_builtin(GPU_OBJECT_MATRIX)); } /* node type definition */ diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.c b/source/blender/nodes/shader/nodes/node_shader_mapping.c index 6750acf5ee1..774e7fed029 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mapping.c +++ b/source/blender/nodes/shader/nodes/node_shader_mapping.c @@ -53,9 +53,8 @@ static int gpu_shader_mapping(GPUMaterial *mat, if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) { return GPU_stack_link(mat, node, names[node->custom1], in, out); } - else { - return 0; - } + + return 0; } static void node_shader_update_mapping(bNodeTree *UNUSED(ntree), bNode *node) diff --git a/source/blender/nodes/shader/nodes/node_shader_math.cc b/source/blender/nodes/shader/nodes/node_shader_math.cc index c7035da8c70..e7bbadfbcb0 100644 --- a/source/blender/nodes/shader/nodes/node_shader_math.cc +++ b/source/blender/nodes/shader/nodes/node_shader_math.cc @@ -141,9 +141,8 @@ static int gpu_shader_math(GPUMaterial *mat, } return ret; } - else { - return 0; - } + + return 0; } static const blender::fn::MultiFunction &get_base_multi_function( diff --git a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c index 93e88664d1a..38c7f9cb3fc 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c @@ -98,9 +98,8 @@ static int gpu_shader_mix_rgb(GPUMaterial *mat, } return ret; } - else { - return 0; - } + + return 0; } void register_node_type_sh_mix_rgb(void) diff --git a/source/blender/nodes/shader/nodes/node_shader_tangent.c b/source/blender/nodes/shader/nodes/node_shader_tangent.c index e8bedde0a62..2c12bf9bc01 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tangent.c +++ b/source/blender/nodes/shader/nodes/node_shader_tangent.c @@ -45,28 +45,27 @@ static int node_shader_gpu_tangent(GPUMaterial *mat, return GPU_stack_link( mat, node, "node_tangentmap", in, out, GPU_attribute(mat, CD_TANGENT, attr->uv_map)); } - else { - GPUNodeLink *orco = GPU_attribute(mat, CD_ORCO, ""); - if (attr->axis == SHD_TANGENT_AXIS_X) { - GPU_link(mat, "tangent_orco_x", orco, &orco); - } - else if (attr->axis == SHD_TANGENT_AXIS_Y) { - GPU_link(mat, "tangent_orco_y", orco, &orco); - } - else { - GPU_link(mat, "tangent_orco_z", orco, &orco); - } + GPUNodeLink *orco = GPU_attribute(mat, CD_ORCO, ""); - return GPU_stack_link(mat, - node, - "node_tangent", - in, - out, - GPU_builtin(GPU_WORLD_NORMAL), - orco, - GPU_builtin(GPU_OBJECT_MATRIX)); + if (attr->axis == SHD_TANGENT_AXIS_X) { + GPU_link(mat, "tangent_orco_x", orco, &orco); } + else if (attr->axis == SHD_TANGENT_AXIS_Y) { + GPU_link(mat, "tangent_orco_y", orco, &orco); + } + else { + GPU_link(mat, "tangent_orco_z", orco, &orco); + } + + return GPU_stack_link(mat, + node, + "node_tangent", + in, + out, + GPU_builtin(GPU_WORLD_NORMAL), + orco, + GPU_builtin(GPU_OBJECT_MATRIX)); } /* node type definition */ diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c index 94ffbbe0c55..9ef05d781bd 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c @@ -170,7 +170,7 @@ static int node_shader_gpu_tex_sky(GPUMaterial *mat, GPU_uniform(xyz_to_rgb.g), GPU_uniform(xyz_to_rgb.b)); } - else if (tex->sky_model == 1) { + if (tex->sky_model == 1) { /* Hosek / Wilkie */ sun_angles[0] = fmin(M_PI_2, sun_angles[0]); /* clamp to horizon */ SKY_ArHosekSkyModelState *sky_state = SKY_arhosek_xyz_skymodelstate_alloc_init( @@ -210,9 +210,8 @@ static int node_shader_gpu_tex_sky(GPUMaterial *mat, GPU_uniform(xyz_to_rgb.g), GPU_uniform(xyz_to_rgb.b)); } - else { - return GPU_stack_link(mat, node, "node_tex_sky_nishita", in, out); - } + + return GPU_stack_link(mat, node, "node_tex_sky_nishita", in, out); } static void node_shader_update_sky(bNodeTree *UNUSED(ntree), bNode *node) diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.c b/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.c index 817ccdc8b6a..56ecb6d4476 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.c @@ -54,9 +54,8 @@ static int gpu_shader_tex_white_noise(GPUMaterial *mat, if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) { return GPU_stack_link(mat, node, names[node->custom1], in, out); } - else { - return 0; - } + + return 0; } static void node_shader_update_tex_white_noise(bNodeTree *UNUSED(ntree), bNode *node) diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc b/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc index 7f712b0db40..7b4e568e923 100644 --- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc +++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc @@ -121,9 +121,8 @@ static int gpu_shader_valtorgb(GPUMaterial *mat, if (coba->ipotype == COLBAND_INTERP_CONSTANT) { return GPU_stack_link(mat, node, "valtorgb_nearest", in, out, tex, GPU_constant(&layer)); } - else { - return GPU_stack_link(mat, node, "valtorgb", in, out, tex, GPU_constant(&layer)); - } + + return GPU_stack_link(mat, node, "valtorgb", in, out, tex, GPU_constant(&layer)); } class ColorBandFunction : public blender::fn::MultiFunction { diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c b/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c index c9f79293328..0e82f346529 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c +++ b/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c @@ -55,13 +55,12 @@ static int gpu_shader_vector_displacement(GPUMaterial *mat, GPU_builtin(GPU_OBJECT_MATRIX), GPU_builtin(GPU_VIEW_MATRIX)); } - else if (node->custom1 == SHD_SPACE_OBJECT) { + if (node->custom1 == SHD_SPACE_OBJECT) { return GPU_stack_link( mat, node, "node_vector_displacement_object", in, out, GPU_builtin(GPU_OBJECT_MATRIX)); } - else { - return GPU_stack_link(mat, node, "node_vector_displacement_world", in, out); - } + + return GPU_stack_link(mat, node, "node_vector_displacement_world", in, out); } /* node type definition */ diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc index c18ad8bb244..e8396c7cfc1 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc @@ -103,9 +103,8 @@ static int gpu_shader_vector_math(GPUMaterial *mat, if (name != nullptr) { return GPU_stack_link(mat, node, name, in, out); } - else { - return 0; - } + + return 0; } static void node_shader_update_vector_math(bNodeTree *UNUSED(ntree), bNode *node) diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_rotate.c b/source/blender/nodes/shader/nodes/node_shader_vector_rotate.c index 46a6ff1f353..b2132c59cde 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_rotate.c +++ b/source/blender/nodes/shader/nodes/node_shader_vector_rotate.c @@ -53,9 +53,8 @@ static int gpu_shader_vector_rotate(GPUMaterial *mat, float invert = (node->custom2) ? -1.0 : 1.0; return GPU_stack_link(mat, node, names[node->custom1], in, out, GPU_constant(&invert)); } - else { - return 0; - } + + return 0; } static void node_shader_update_vector_rotate(bNodeTree *UNUSED(ntree), bNode *node) diff --git a/source/blender/nodes/shader/nodes/node_shader_wireframe.c b/source/blender/nodes/shader/nodes/node_shader_wireframe.c index d1ed13e1ffd..37e60ddb205 100644 --- a/source/blender/nodes/shader/nodes/node_shader_wireframe.c +++ b/source/blender/nodes/shader/nodes/node_shader_wireframe.c @@ -42,15 +42,14 @@ static int node_shader_gpu_wireframe(GPUMaterial *mat, return GPU_stack_link( mat, node, "node_wireframe_screenspace", in, out, GPU_builtin(GPU_BARYCENTRIC_TEXCO)); } - else { - return GPU_stack_link(mat, - node, - "node_wireframe", - in, - out, - GPU_builtin(GPU_BARYCENTRIC_TEXCO), - GPU_builtin(GPU_BARYCENTRIC_DIST)); - } + + return GPU_stack_link(mat, + node, + "node_wireframe", + in, + out, + GPU_builtin(GPU_BARYCENTRIC_TEXCO), + GPU_builtin(GPU_BARYCENTRIC_DIST)); } /* node type definition */ diff --git a/source/blender/nodes/texture/node_texture_util.c b/source/blender/nodes/texture/node_texture_util.c index 1d7641753e0..981fc4e308a 100644 --- a/source/blender/nodes/texture/node_texture_util.c +++ b/source/blender/nodes/texture/node_texture_util.c @@ -145,14 +145,13 @@ void tex_output(bNode *node, /* do not add a delegate if the node is muted */ return; } + + if (!out->data) { + /* Freed in tex_end_exec (node.c) */ + dg = out->data = MEM_mallocN(sizeof(TexDelegate), "tex delegate"); + } else { - if (!out->data) { - /* Freed in tex_end_exec (node.c) */ - dg = out->data = MEM_mallocN(sizeof(TexDelegate), "tex delegate"); - } - else { - dg = out->data; - } + dg = out->data; } dg->cdata = cdata;