diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-08-07 12:49:59 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-08-07 13:01:40 +0300 |
commit | 156448ba4ba350dd6f9718b4610f14f4ba187af6 (patch) | |
tree | 5ad43590fbf4d7536f58a38935cbbac3c2ec27bd /source/blender/draw/intern | |
parent | 88cc3f167f7ee404640289ed9cfd6b13f0494d98 (diff) |
Cleanup: Draw, Clang-Tidy else-after-return fixes (incomplete)
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/draw` module. Not all warnings are addressed
in this commit.
No functional changes.
Diffstat (limited to 'source/blender/draw/intern')
-rw-r--r-- | source/blender/draw/intern/draw_cache.c | 100 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_extract_mesh.c | 25 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_gpencil.c | 5 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_lattice.c | 25 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_mesh.c | 5 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_particles.c | 20 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_common.c | 4 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 5 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager_data.c | 58 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager_exec.c | 7 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_view.c | 2 |
11 files changed, 110 insertions, 146 deletions
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index 20e346375a7..b36a177c19f 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -2909,9 +2909,8 @@ GPUBatch *DRW_cache_curve_edge_wire_get(Object *ob) if (mesh_eval != NULL) { return DRW_mesh_batch_cache_get_loose_edges(mesh_eval); } - else { - return DRW_curve_batch_cache_get_wire_edge(cu); - } + + return DRW_curve_batch_cache_get_wire_edge(cu); } GPUBatch *DRW_cache_curve_edge_normal_get(Object *ob) @@ -2947,9 +2946,8 @@ GPUBatch *DRW_cache_curve_surface_get(Object *ob) if (mesh_eval != NULL) { return DRW_mesh_batch_cache_get_surface(mesh_eval); } - else { - return DRW_curve_batch_cache_get_triangles_with_normals(cu); - } + + return DRW_curve_batch_cache_get_triangles_with_normals(cu); } GPUBatch *DRW_cache_curve_loose_edges_get(Object *ob) @@ -2961,11 +2959,10 @@ GPUBatch *DRW_cache_curve_loose_edges_get(Object *ob) if (mesh_eval != NULL) { return DRW_mesh_batch_cache_get_loose_edges(mesh_eval); } - else { - /* TODO */ - UNUSED_VARS(cu); - return NULL; - } + + /* TODO */ + UNUSED_VARS(cu); + return NULL; } GPUBatch *DRW_cache_curve_face_wireframe_get(Object *ob) @@ -2977,9 +2974,8 @@ GPUBatch *DRW_cache_curve_face_wireframe_get(Object *ob) if (mesh_eval != NULL) { return DRW_mesh_batch_cache_get_wireframes_face(mesh_eval); } - else { - return DRW_curve_batch_cache_get_wireframes_face(cu); - } + + return DRW_curve_batch_cache_get_wireframes_face(cu); } GPUBatch *DRW_cache_curve_edge_detection_get(Object *ob, bool *r_is_manifold) @@ -2990,9 +2986,8 @@ GPUBatch *DRW_cache_curve_edge_detection_get(Object *ob, bool *r_is_manifold) if (mesh_eval != NULL) { return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold); } - else { - return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold); - } + + return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold); } /* Return list of batches */ @@ -3007,9 +3002,8 @@ GPUBatch **DRW_cache_curve_surface_shaded_get(Object *ob, if (mesh_eval != NULL) { return DRW_mesh_batch_cache_get_surface_shaded(mesh_eval, gpumat_array, gpumat_array_len); } - else { - return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len); - } + + return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len); } /** \} */ @@ -3061,12 +3055,11 @@ GPUBatch *DRW_cache_text_edge_wire_get(Object *ob) if (!has_surface) { return NULL; } - else if (mesh_eval != NULL) { + if (mesh_eval != NULL) { return DRW_mesh_batch_cache_get_loose_edges(mesh_eval); } - else { - return DRW_curve_batch_cache_get_wire_edge(cu); - } + + return DRW_curve_batch_cache_get_wire_edge(cu); } GPUBatch *DRW_cache_text_surface_get(Object *ob) @@ -3080,9 +3073,8 @@ GPUBatch *DRW_cache_text_surface_get(Object *ob) if (mesh_eval != NULL) { return DRW_mesh_batch_cache_get_surface(mesh_eval); } - else { - return DRW_curve_batch_cache_get_triangles_with_normals(cu); - } + + return DRW_curve_batch_cache_get_triangles_with_normals(cu); } GPUBatch *DRW_cache_text_edge_detection_get(Object *ob, bool *r_is_manifold) @@ -3096,9 +3088,8 @@ GPUBatch *DRW_cache_text_edge_detection_get(Object *ob, bool *r_is_manifold) if (mesh_eval != NULL) { return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold); } - else { - return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold); - } + + return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold); } GPUBatch *DRW_cache_text_loose_edges_get(Object *ob) @@ -3112,9 +3103,8 @@ GPUBatch *DRW_cache_text_loose_edges_get(Object *ob) if (mesh_eval != NULL) { return DRW_mesh_batch_cache_get_loose_edges(mesh_eval); } - else { - return DRW_curve_batch_cache_get_wire_edge(cu); - } + + return DRW_curve_batch_cache_get_wire_edge(cu); } GPUBatch *DRW_cache_text_face_wireframe_get(Object *ob) @@ -3128,9 +3118,8 @@ GPUBatch *DRW_cache_text_face_wireframe_get(Object *ob) if (mesh_eval != NULL) { return DRW_mesh_batch_cache_get_wireframes_face(mesh_eval); } - else { - return DRW_curve_batch_cache_get_wireframes_face(cu); - } + + return DRW_curve_batch_cache_get_wireframes_face(cu); } GPUBatch **DRW_cache_text_surface_shaded_get(Object *ob, @@ -3146,9 +3135,8 @@ GPUBatch **DRW_cache_text_surface_shaded_get(Object *ob, if (mesh_eval != NULL) { return DRW_mesh_batch_cache_get_surface_shaded(mesh_eval, gpumat_array, gpumat_array_len); } - else { - return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len); - } + + return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len); } /** \} */ @@ -3166,9 +3154,8 @@ GPUBatch *DRW_cache_surf_surface_get(Object *ob) if (mesh_eval != NULL) { return DRW_mesh_batch_cache_get_surface(mesh_eval); } - else { - return DRW_curve_batch_cache_get_triangles_with_normals(cu); - } + + return DRW_curve_batch_cache_get_triangles_with_normals(cu); } GPUBatch *DRW_cache_surf_edge_wire_get(Object *ob) @@ -3180,9 +3167,8 @@ GPUBatch *DRW_cache_surf_edge_wire_get(Object *ob) if (mesh_eval != NULL) { return DRW_mesh_batch_cache_get_loose_edges(mesh_eval); } - else { - return DRW_curve_batch_cache_get_wire_edge(cu); - } + + return DRW_curve_batch_cache_get_wire_edge(cu); } GPUBatch *DRW_cache_surf_face_wireframe_get(Object *ob) @@ -3194,9 +3180,8 @@ GPUBatch *DRW_cache_surf_face_wireframe_get(Object *ob) if (mesh_eval != NULL) { return DRW_mesh_batch_cache_get_wireframes_face(mesh_eval); } - else { - return DRW_curve_batch_cache_get_wireframes_face(cu); - } + + return DRW_curve_batch_cache_get_wireframes_face(cu); } GPUBatch *DRW_cache_surf_edge_detection_get(Object *ob, bool *r_is_manifold) @@ -3207,9 +3192,8 @@ GPUBatch *DRW_cache_surf_edge_detection_get(Object *ob, bool *r_is_manifold) if (mesh_eval != NULL) { return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold); } - else { - return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold); - } + + return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold); } GPUBatch *DRW_cache_surf_loose_edges_get(Object *ob) @@ -3221,11 +3205,10 @@ GPUBatch *DRW_cache_surf_loose_edges_get(Object *ob) if (mesh_eval != NULL) { return DRW_mesh_batch_cache_get_loose_edges(mesh_eval); } - else { - /* TODO */ - UNUSED_VARS(cu); - return NULL; - } + + /* TODO */ + UNUSED_VARS(cu); + return NULL; } /* Return list of batches */ @@ -3240,9 +3223,8 @@ GPUBatch **DRW_cache_surf_surface_shaded_get(Object *ob, if (mesh_eval != NULL) { return DRW_mesh_batch_cache_get_surface_shaded(mesh_eval, gpumat_array, gpumat_array_len); } - else { - return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len); - } + + return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len); } /** \} */ diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c index cca8ebcf2a8..a1d2a7eeb4a 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh.c +++ b/source/blender/draw/intern/draw_cache_extract_mesh.c @@ -474,10 +474,9 @@ BLI_INLINE const float *bm_vert_co_get(const MeshRenderData *mr, const BMVert *e if (vert_coords != NULL) { return vert_coords[BM_elem_index_get(eve)]; } - else { - UNUSED_VARS(mr); - return eve->co; - } + + UNUSED_VARS(mr); + return eve->co; } BLI_INLINE const float *bm_vert_no_get(const MeshRenderData *mr, const BMVert *eve) @@ -486,10 +485,9 @@ BLI_INLINE const float *bm_vert_no_get(const MeshRenderData *mr, const BMVert *e if (vert_normals != NULL) { return vert_normals[BM_elem_index_get(eve)]; } - else { - UNUSED_VARS(mr); - return eve->no; - } + + UNUSED_VARS(mr); + return eve->no; } BLI_INLINE const float *bm_face_no_get(const MeshRenderData *mr, const BMFace *efa) @@ -498,10 +496,9 @@ BLI_INLINE const float *bm_face_no_get(const MeshRenderData *mr, const BMFace *e if (poly_normals != NULL) { return poly_normals[BM_elem_index_get(efa)]; } - else { - UNUSED_VARS(mr); - return efa->no; - } + + UNUSED_VARS(mr); + return efa->no; } /** \} */ @@ -2937,7 +2934,7 @@ static float evaluate_vertex_weight(const MDeformVert *dvert, const DRW_MeshWeig if ((wstate->defgroup_active < 0) && (wstate->defgroup_len > 0)) { return -2.0f; } - else if (dvert == NULL) { + if (dvert == NULL) { return (wstate->alert_mode != OB_DRAW_GROUPUSER_NONE) ? -1.0f : 0.0f; } @@ -4296,7 +4293,7 @@ static void statvis_calc_sharp(const MeshRenderData *mr, float *r_sharp) /* non-manifold edge, yet... */ continue; } - else if (*pval != NULL) { + if (*pval != NULL) { const float *f1_no = mr->poly_normals[mp_index]; const float *f2_no = *pval; angle = angle_normalized_v3v3(f1_no, f2_no); diff --git a/source/blender/draw/intern/draw_cache_impl_gpencil.c b/source/blender/draw/intern/draw_cache_impl_gpencil.c index e8355c1d8da..0ab14574fa6 100644 --- a/source/blender/draw/intern/draw_cache_impl_gpencil.c +++ b/source/blender/draw/intern/draw_cache_impl_gpencil.c @@ -135,9 +135,8 @@ static GpencilBatchCache *gpencil_batch_cache_get(Object *ob, int cfra) gpencil_batch_cache_clear(cache); return gpencil_batch_cache_init(ob, cfra); } - else { - return cache; - } + + return cache; } void DRW_gpencil_batch_cache_dirty_tag(bGPdata *gpd) diff --git a/source/blender/draw/intern/draw_cache_impl_lattice.c b/source/blender/draw/intern/draw_cache_impl_lattice.c index 66a67d6b8fe..0f80b5159a7 100644 --- a/source/blender/draw/intern/draw_cache_impl_lattice.c +++ b/source/blender/draw/intern/draw_cache_impl_lattice.c @@ -83,10 +83,9 @@ static int lattice_render_verts_len_get(Lattice *lt) if ((lt->flag & LT_OUTSIDE) == 0) { return vert_len_calc(u, v, w); } - else { - /* TODO remove internal coords */ - return vert_len_calc(u, v, w); - } + + /* TODO remove internal coords */ + return vert_len_calc(u, v, w); } static int lattice_render_edges_len_get(Lattice *lt) @@ -102,10 +101,9 @@ static int lattice_render_edges_len_get(Lattice *lt) if ((lt->flag & LT_OUTSIDE) == 0) { return edge_len_calc(u, v, w); } - else { - /* TODO remove internal coords */ - return edge_len_calc(u, v, w); - } + + /* TODO remove internal coords */ + return edge_len_calc(u, v, w); } /* ---------------------------------------------------------------------- */ @@ -252,12 +250,11 @@ static bool lattice_batch_cache_valid(Lattice *lt) if (cache->is_dirty) { return false; } - else { - if ((cache->dims.u_len != lt->pntsu) || (cache->dims.v_len != lt->pntsv) || - (cache->dims.w_len != lt->pntsw) || - ((cache->show_only_outside != ((lt->flag & LT_OUTSIDE) != 0)))) { - return false; - } + + if ((cache->dims.u_len != lt->pntsu) || (cache->dims.v_len != lt->pntsv) || + (cache->dims.w_len != lt->pntsw) || + ((cache->show_only_outside != ((lt->flag & LT_OUTSIDE) != 0)))) { + return false; } return true; diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index 361c66eca6e..d6faeb16583 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -803,9 +803,8 @@ GPUBatch *DRW_mesh_batch_cache_get_loose_edges(Mesh *me) if (cache->no_loose_wire) { return NULL; } - else { - return DRW_batch_request(&cache->batch.loose_edges); - } + + return DRW_batch_request(&cache->batch.loose_edges); } GPUBatch *DRW_mesh_batch_cache_get_surface_weights(Mesh *me) diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c index 331a1f80bec..3ecdbff1e96 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.c +++ b/source/blender/draw/intern/draw_cache_impl_particles.c @@ -128,9 +128,8 @@ static bool particle_batch_cache_valid(ParticleSystem *psys) if (cache->is_dirty == false) { return true; } - else { - return false; - } + + return false; return true; } @@ -647,14 +646,13 @@ static float particle_key_weight(const ParticleData *particle, int strand, float if (t == 1.0) { return hkeys[part->totkey - 1].weight; } - else { - float interp = t / edit_key_seg_t; - int index = (int)interp; - interp -= floorf(interp); /* Time between 2 edit key */ - float s1 = hkeys[index].weight; - float s2 = hkeys[index + 1].weight; - return s1 + interp * (s2 - s1); - } + + float interp = t / edit_key_seg_t; + int index = (int)interp; + interp -= floorf(interp); /* Time between 2 edit key */ + float s1 = hkeys[index].weight; + float s2 = hkeys[index + 1].weight; + return s1 + interp * (s2 - s1); } static int particle_batch_cache_fill_segments_edit( diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index 095e928aa74..0f26a8ddc09 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -455,11 +455,11 @@ bool DRW_object_is_flat(Object *ob, int *r_axis) *r_axis = 0; return true; } - else if (dim[1] == 0.0f) { + if (dim[1] == 0.0f) { *r_axis = 1; return true; } - else if (dim[2] == 0.0f) { + if (dim[2] == 0.0f) { *r_axis = 2; return true; } diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 656a62dffb5..d03b5107bb6 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -792,9 +792,8 @@ DrawDataList *DRW_drawdatalist_from_id(ID *id) IdDdtTemplate *idt = (IdDdtTemplate *)id; return &idt->drawdata; } - else { - return NULL; - } + + return NULL; } DrawData *DRW_drawdata_get(ID *id, DrawEngineType *engine_type) diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index 3184d6155d2..661a27c10b7 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -594,28 +594,26 @@ static DRWResourceHandle drw_resource_handle(DRWShadingGroup *shgroup, DRWResourceHandle handle = 0; return handle; } - else { - return drw_resource_handle_new(obmat, NULL); - } + + return drw_resource_handle_new(obmat, NULL); + } + + if (DST.ob_handle == 0) { + DST.ob_handle = drw_resource_handle_new(obmat, ob); + DST.ob_state_obinfo_init = false; } - else { - if (DST.ob_handle == 0) { - DST.ob_handle = drw_resource_handle_new(obmat, ob); - DST.ob_state_obinfo_init = false; - } - if (shgroup->objectinfo) { - if (!DST.ob_state_obinfo_init) { - DST.ob_state_obinfo_init = true; - DRWObjectInfos *ob_infos = DRW_memblock_elem_from_handle(DST.vmempool->obinfos, - &DST.ob_handle); + if (shgroup->objectinfo) { + if (!DST.ob_state_obinfo_init) { + DST.ob_state_obinfo_init = true; + DRWObjectInfos *ob_infos = DRW_memblock_elem_from_handle(DST.vmempool->obinfos, + &DST.ob_handle); - drw_call_obinfos_init(ob_infos, ob); - } + drw_call_obinfos_init(ob_infos, ob); } - - return DST.ob_handle; } + + return DST.ob_handle; } static void command_type_set(uint64_t *command_type_bits, int index, eDRWCommandType type) @@ -1904,9 +1902,8 @@ float DRW_view_near_distance_get(const DRWView *view) if (DRW_view_is_persp_get(view)) { return -projmat[3][2] / (projmat[2][2] - 1.0f); } - else { - return -(projmat[3][2] + 1.0f) / projmat[2][2]; - } + + return -(projmat[3][2] + 1.0f) / projmat[2][2]; } float DRW_view_far_distance_get(const DRWView *view) @@ -1917,9 +1914,8 @@ float DRW_view_far_distance_get(const DRWView *view) if (DRW_view_is_persp_get(view)) { return -projmat[3][2] / (projmat[2][2] + 1.0f); } - else { - return -(projmat[3][2] - 1.0f) / projmat[2][2]; - } + + return -(projmat[3][2] - 1.0f) / projmat[2][2]; } void DRW_view_viewmat_get(const DRWView *view, float mat[4][4], bool inverse) @@ -2026,18 +2022,16 @@ static int pass_shgroup_dist_sort(const void *a, const void *b) if (shgrp_a->z_sorting.distance < shgrp_b->z_sorting.distance) { return 1; } - else if (shgrp_a->z_sorting.distance > shgrp_b->z_sorting.distance) { + if (shgrp_a->z_sorting.distance > shgrp_b->z_sorting.distance) { return -1; } - else { - /* If distances are the same, keep original order. */ - if (shgrp_a->z_sorting.original_index > shgrp_b->z_sorting.original_index) { - return -1; - } - else { - return 0; - } + + /* If distances are the same, keep original order. */ + if (shgrp_a->z_sorting.original_index > shgrp_b->z_sorting.original_index) { + return -1; } + + return 0; } /* ------------------ Shading group sorting --------------------- */ diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index 91cbc03e5a4..4b63ea89e44 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -518,7 +518,7 @@ static bool draw_culling_box_test(const float (*frustum_planes)[4], const BoundB * Go to next plane. */ break; } - else if (v == 7) { + if (v == 7) { /* 8 points behind this plane. */ return false; } @@ -995,9 +995,8 @@ static void draw_call_single_do(DRWShadingGroup *shgroup, draw_select_buffer(shgroup, state, batch, &handle); return; } - else { - GPU_select_load_id(state->select_id); - } + + GPU_select_load_id(state->select_id); } draw_geometry_execute(shgroup, diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c index b42700b2c7e..1458ff5341c 100644 --- a/source/blender/draw/intern/draw_view.c +++ b/source/blender/draw/intern/draw_view.c @@ -88,7 +88,7 @@ static bool is_cursor_visible(const DRWContextState *draw_ctx, Scene *scene, Vie /* no exception met? then don't draw cursor! */ return false; } - else if (draw_ctx->object_mode & OB_MODE_WEIGHT_GPENCIL) { + if (draw_ctx->object_mode & OB_MODE_WEIGHT_GPENCIL) { /* grease pencil hide always in some modes */ return false; } |