Cleanup: Modifiers, Clang-Tidy else-after-return fixes

This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/modifiers` module.

No functional changes.
This commit is contained in:
2020-08-07 12:40:29 +02:00
parent dee359e26e
commit 47f8c444a4
17 changed files with 94 additions and 111 deletions

View File

@@ -139,12 +139,11 @@ static int svert_sum_cmp(const void *e1, const void *e2)
if (sv1->sum_co > sv2->sum_co) {
return 1;
}
else if (sv1->sum_co < sv2->sum_co) {
if (sv1->sum_co < sv2->sum_co) {
return -1;
}
else {
return 0;
}
return 0;
}
static void svert_from_mvert(SortVertsElem *sv,
@@ -826,10 +825,10 @@ static bool isDisabled(const struct Scene *UNUSED(scene),
if (amd->curve_ob && amd->curve_ob->type != OB_CURVE) {
return true;
}
else if (amd->start_cap && amd->start_cap->type != OB_MESH) {
if (amd->start_cap && amd->start_cap->type != OB_MESH) {
return true;
}
else if (amd->end_cap && amd->end_cap->type != OB_MESH) {
if (amd->end_cap && amd->end_cap->type != OB_MESH) {
return true;
}

View File

@@ -103,9 +103,8 @@ static bool dependsOnTime(ModifierData *md)
if (dmd->texture) {
return BKE_texture_dependsOnTime(dmd->texture);
}
else {
return false;
}
return false;
}
static bool dependsOnNormals(ModifierData *md)

View File

@@ -1180,9 +1180,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
BKE_id_free(NULL, split_m);
return explode;
}
else {
return explodeMesh(emd, psmd, ctx, scene, mesh);
}
return explodeMesh(emd, psmd, ctx, scene, mesh);
}
return mesh;
}

View File

@@ -185,7 +185,7 @@ static float hook_falloff(const struct HookData_cb *hd, const float len_sq)
if (len_sq > hd->falloff_sq) {
return 0.0f;
}
else if (len_sq > 0.0f) {
if (len_sq > 0.0f) {
float fac;
if (hd->falloff_type == eHook_Falloff_Const) {

View File

@@ -238,22 +238,19 @@ bool MOD_meshcache_read_mdd_frame(FILE *fp,
MOD_meshcache_read_mdd_index(fp, vertexCos, verts_tot, index_range[0], 1.0f, err_str)) {
return true;
}
else {
return false;
}
return false;
}
else {
/* read both and interpolate */
if ((BLI_fseek(fp, 0, SEEK_SET) == 0) &&
MOD_meshcache_read_mdd_index(fp, vertexCos, verts_tot, index_range[0], 1.0f, err_str) &&
(BLI_fseek(fp, 0, SEEK_SET) == 0) &&
MOD_meshcache_read_mdd_index(fp, vertexCos, verts_tot, index_range[1], factor, err_str)) {
return true;
}
else {
return false;
}
/* read both and interpolate */
if ((BLI_fseek(fp, 0, SEEK_SET) == 0) &&
MOD_meshcache_read_mdd_index(fp, vertexCos, verts_tot, index_range[0], 1.0f, err_str) &&
(BLI_fseek(fp, 0, SEEK_SET) == 0) &&
MOD_meshcache_read_mdd_index(fp, vertexCos, verts_tot, index_range[1], factor, err_str)) {
return true;
}
return false;
}
bool MOD_meshcache_read_mdd_times(const char *filepath,

View File

@@ -213,22 +213,19 @@ bool MOD_meshcache_read_pc2_frame(FILE *fp,
MOD_meshcache_read_pc2_index(fp, vertexCos, verts_tot, index_range[0], 1.0f, err_str)) {
return true;
}
else {
return false;
}
return false;
}
else {
/* read both and interpolate */
if ((BLI_fseek(fp, 0, SEEK_SET) == 0) &&
MOD_meshcache_read_pc2_index(fp, vertexCos, verts_tot, index_range[0], 1.0f, err_str) &&
(BLI_fseek(fp, 0, SEEK_SET) == 0) &&
MOD_meshcache_read_pc2_index(fp, vertexCos, verts_tot, index_range[1], factor, err_str)) {
return true;
}
else {
return false;
}
/* read both and interpolate */
if ((BLI_fseek(fp, 0, SEEK_SET) == 0) &&
MOD_meshcache_read_pc2_index(fp, vertexCos, verts_tot, index_range[0], 1.0f, err_str) &&
(BLI_fseek(fp, 0, SEEK_SET) == 0) &&
MOD_meshcache_read_pc2_index(fp, vertexCos, verts_tot, index_range[1], factor, err_str)) {
return true;
}
return false;
}
bool MOD_meshcache_read_pc2_times(const char *filepath,

View File

@@ -472,7 +472,7 @@ static bool is_valid_target(NormalEditModifierData *enmd)
if (enmd->mode == MOD_NORMALEDIT_MODE_RADIAL) {
return true;
}
else if ((enmd->mode == MOD_NORMALEDIT_MODE_DIRECTIONAL) && enmd->target) {
if ((enmd->mode == MOD_NORMALEDIT_MODE_DIRECTIONAL) && enmd->target) {
return true;
}
BKE_modifier_set_error((ModifierData *)enmd, "Invalid target settings");

View File

@@ -198,12 +198,11 @@ static bool particle_skip(ParticleInstanceModifierData *pimd, ParticleSystem *ps
if (maxp > minp) {
return randp < minp || randp >= maxp;
}
else if (maxp < minp) {
if (maxp < minp) {
return randp < minp && randp >= maxp;
}
else {
return true;
}
return true;
return false;
}

View File

@@ -96,7 +96,7 @@ static bool isDisabled(const struct Scene *UNUSED(scene),
if (!smd->target || smd->target->type != OB_MESH) {
return true;
}
else if (smd->auxTarget && smd->auxTarget->type != OB_MESH) {
if (smd->auxTarget && smd->auxTarget->type != OB_MESH) {
return true;
}
return false;

View File

@@ -222,9 +222,8 @@ static bool skin_frame_find_contained_faces(const Frame *frame, BMFace *fill_fac
if (diag) {
return BM_edge_face_pair(diag, &fill_faces[0], &fill_faces[1]);
}
else {
return false;
}
return false;
}
/* Returns true if hull is successfully built, false otherwise */
@@ -814,9 +813,8 @@ static int calc_edge_subdivisions(const MVert *mvert,
if (v1_branch && v2_branch) {
return 2;
}
else {
return 0;
}
return 0;
}
avg_radius = half_v2(evs[0]->radius) + half_v2(evs[1]->radius);

View File

@@ -479,12 +479,12 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md,
old_edge_vert_ref->edges_len++;
break;
}
else if (vm[orig_medge[edge].v1] == vs[1 - j]) {
if (vm[orig_medge[edge].v1] == vs[1 - j]) {
invalid_edge_index = edge + 1;
invalid_edge_reversed = (j == 0);
break;
}
else if (vm[orig_medge[edge].v2] == vs[1 - j]) {
if (vm[orig_medge[edge].v2] == vs[1 - j]) {
invalid_edge_index = edge + 1;
invalid_edge_reversed = (j == 1);
break;
@@ -936,7 +936,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md,
}
break;
}
else if (edge->faces[0] == eg_track_faces[0]) {
if (edge->faces[0] == eg_track_faces[0]) {
insert_at_start = true;
eg_track_faces[0] = edge->faces[1];
found_edge = edge;
@@ -945,14 +945,14 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md,
}
break;
}
else if (edge->faces[1] != NULL) {
if (edge->faces[1] != NULL) {
if (edge->faces[1] == eg_track_faces[1]) {
insert_at_start = false;
eg_track_faces[1] = edge->faces[0];
found_edge = edge;
break;
}
else if (edge->faces[1] == eg_track_faces[0]) {
if (edge->faces[1] == eg_track_faces[0]) {
insert_at_start = true;
eg_track_faces[0] = edge->faces[0];
found_edge = edge;

View File

@@ -372,9 +372,8 @@ BLI_INLINE uint nearestVert(SDefBindCalcData *const data, const float point_co[3
len_squared_v3v3(point_co, data->targetCos[edge->v2])) {
return edge->v1;
}
else {
return edge->v2;
}
return edge->v2;
}
BLI_INLINE int isPolyValid(const float coords[][2], const uint nr)
@@ -1283,7 +1282,7 @@ static void surfacedeformModifier_do(ModifierData *md,
BKE_modifier_set_error(md, "Vertices changed from %u to %u", smd->numverts, numverts);
return;
}
else if (smd->numpoly != tnumpoly) {
if (smd->numpoly != tnumpoly) {
BKE_modifier_set_error(md, "Target polygons changed from %u to %u", smd->numpoly, tnumpoly);
return;
}

View File

@@ -179,12 +179,11 @@ static int modifier_is_simulation(ModifierData *md)
return 1;
}
/* Particle Tab */
else if (md->type == eModifierType_ParticleSystem) {
if (md->type == eModifierType_ParticleSystem) {
return 2;
}
else {
return 0;
}
return 0;
}
static bool modifier_can_delete(ModifierData *md)

View File

@@ -143,10 +143,9 @@ void MOD_get_texture_coords(MappingInfoModifierData *dmd,
MEM_freeN(done);
return;
}
else {
/* if there are no UVs, default to local */
texmapping = MOD_DISP_MAP_LOCAL;
}
/* if there are no UVs, default to local */
texmapping = MOD_DISP_MAP_LOCAL;
}
MVert *mv = mesh->mvert;

View File

@@ -123,9 +123,8 @@ static bool dependsOnTime(ModifierData *md)
if (wmd->texture) {
return BKE_texture_dependsOnTime(wmd->texture);
}
else {
return false;
}
return false;
}
static void freeData(ModifierData *md)

View File

@@ -95,16 +95,16 @@ static float mix_weight(float weight, float weight2, char mix_mode)
if (mix_mode == MOD_WVG_MIX_SET) {
return weight2;
}
else if (mix_mode == MOD_WVG_MIX_ADD) {
if (mix_mode == MOD_WVG_MIX_ADD) {
return (weight + weight2);
}
else if (mix_mode == MOD_WVG_MIX_SUB) {
if (mix_mode == MOD_WVG_MIX_SUB) {
return (weight - weight2);
}
else if (mix_mode == MOD_WVG_MIX_MUL) {
if (mix_mode == MOD_WVG_MIX_MUL) {
return (weight * weight2);
}
else if (mix_mode == MOD_WVG_MIX_DIV) {
if (mix_mode == MOD_WVG_MIX_DIV) {
/* Avoid dividing by zero (or really small values). */
if (weight2 < 0.0f && weight2 > -MOD_WVG_ZEROFLOOR) {
weight2 = -MOD_WVG_ZEROFLOOR;
@@ -114,7 +114,7 @@ static float mix_weight(float weight, float weight2, char mix_mode)
}
return (weight / weight2);
}
else if (mix_mode == MOD_WVG_MIX_DIF) {
if (mix_mode == MOD_WVG_MIX_DIF) {
return (weight < weight2 ? weight2 - weight : weight - weight2);
}
else if (mix_mode == MOD_WVG_MIX_AVG) {

View File

@@ -1850,23 +1850,22 @@ static Mesh *weldModifier_doWeld(WeldModifierData *wmd, const ModifierEvalContex
&iter, wp, weld_mesh.wloop, mloop, weld_mesh.loop_map, group_buffer)) {
continue;
}
else {
if (wp->poly_dst != OUT_OF_CONTEXT) {
continue;
}
while (weld_iter_loop_of_poly_next(&iter)) {
customdata_weld(&mesh->ldata, &result->ldata, group_buffer, iter.group_len, loop_cur);
uint v = vert_final[iter.v];
uint e = edge_final[iter.e];
r_ml->v = v;
r_ml->e = e;
r_ml++;
loop_cur++;
if (iter.type) {
result->medge[e].flag &= ~ME_LOOSEEDGE;
}
BLI_assert((result->medge[e].flag & ME_LOOSEEDGE) == 0);
if (wp->poly_dst != OUT_OF_CONTEXT) {
continue;
}
while (weld_iter_loop_of_poly_next(&iter)) {
customdata_weld(&mesh->ldata, &result->ldata, group_buffer, iter.group_len, loop_cur);
uint v = vert_final[iter.v];
uint e = edge_final[iter.e];
r_ml->v = v;
r_ml->e = e;
r_ml++;
loop_cur++;
if (iter.type) {
result->medge[e].flag &= ~ME_LOOSEEDGE;
}
BLI_assert((result->medge[e].flag & ME_LOOSEEDGE) == 0);
}
}
@@ -1885,24 +1884,24 @@ static Mesh *weldModifier_doWeld(WeldModifierData *wmd, const ModifierEvalContex
&iter, wp, weld_mesh.wloop, mloop, weld_mesh.loop_map, group_buffer)) {
continue;
}
else {
if (wp->poly_dst != OUT_OF_CONTEXT) {
continue;
}
while (weld_iter_loop_of_poly_next(&iter)) {
customdata_weld(&mesh->ldata, &result->ldata, group_buffer, iter.group_len, loop_cur);
uint v = vert_final[iter.v];
uint e = edge_final[iter.e];
r_ml->v = v;
r_ml->e = e;
r_ml++;
loop_cur++;
if (iter.type) {
result->medge[e].flag &= ~ME_LOOSEEDGE;
}
BLI_assert((result->medge[e].flag & ME_LOOSEEDGE) == 0);
}
if (wp->poly_dst != OUT_OF_CONTEXT) {
continue;
}
while (weld_iter_loop_of_poly_next(&iter)) {
customdata_weld(&mesh->ldata, &result->ldata, group_buffer, iter.group_len, loop_cur);
uint v = vert_final[iter.v];
uint e = edge_final[iter.e];
r_ml->v = v;
r_ml->e = e;
r_ml++;
loop_cur++;
if (iter.type) {
result->medge[e].flag &= ~ME_LOOSEEDGE;
}
BLI_assert((result->medge[e].flag & ME_LOOSEEDGE) == 0);
}
r_mp->loopstart = loop_start;
r_mp->totloop = loop_cur - loop_start;
r_mp++;