From ead0e2d1f8ca4ad5ff223faf2c3814f17d264ec3 Mon Sep 17 00:00:00 2001 From: Sean Kim Date: Sat, 31 Aug 2024 04:04:34 +0200 Subject: [PATCH] Cleanup: Sculpt: Remove unnecessary default case statements Pull Request: https://projects.blender.org/blender/blender/pulls/127003 --- .../editors/sculpt_paint/paint_vertex.cc | 2 -- source/blender/editors/sculpt_paint/sculpt.cc | 12 +++------- .../sculpt_paint/sculpt_automasking.cc | 2 -- .../editors/sculpt_paint/sculpt_boundary.cc | 24 ------------------- .../editors/sculpt_paint/sculpt_face_set.cc | 18 ++++---------- .../editors/sculpt_paint/sculpt_gesture.cc | 5 ++-- 6 files changed, 9 insertions(+), 54 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc index a978ddbcfbe..04b61938484 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex.cc @@ -1888,8 +1888,6 @@ static void vpaint_paint_leaves(bContext *C, case VPAINT_TOOL_SMEAR: do_vpaint_brush_smear(C, vp, vpd, ob, mesh, nodes, node_mask, attribute); break; - default: - break; } } diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index d86bafd0daa..603d6932a16 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -2428,9 +2428,7 @@ static float brush_strength(const Sculpt &sd, case BRUSH_MASK_SMOOTH: return alpha * pressure * feather; } - BLI_assert_msg(0, "Not supposed to happen"); - return 0.0f; - + break; case SCULPT_TOOL_CREASE: case SCULPT_TOOL_BLOB: return alpha * flip * pressure * overlap * feather; @@ -2490,10 +2488,9 @@ static float brush_strength(const Sculpt &sd, case SCULPT_TOOL_POSE: case SCULPT_TOOL_BOUNDARY: return root_alpha * feather; - - default: - return 0.0f; } + BLI_assert_unreachable(); + return 0.0f; } void sculpt_apply_texture(const SculptSession &ss, @@ -3098,9 +3095,6 @@ void calc_brush_plane(const Depsgraph &depsgraph, normalize_v3(r_area_no); } break; - - default: - break; } /* For flatten center. */ diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.cc b/source/blender/editors/sculpt_paint/sculpt_automasking.cc index deaa1f30ff7..891840dd23d 100644 --- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc +++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc @@ -822,8 +822,6 @@ static void fill_topology_automasking_factors(const Depsgraph &depsgraph, case bke::pbvh::Type::BMesh: fill_topology_automasking_factors_bmesh(sd, ob, *ss.bm); break; - default: - BLI_assert_unreachable(); } } diff --git a/source/blender/editors/sculpt_paint/sculpt_boundary.cc b/source/blender/editors/sculpt_paint/sculpt_boundary.cc index aacd743752a..56ddadb1577 100644 --- a/source/blender/editors/sculpt_paint/sculpt_boundary.cc +++ b/source/blender/editors/sculpt_paint/sculpt_boundary.cc @@ -2956,9 +2956,6 @@ static std::pair calc_boundary_falloff(const SculptBoundary &bound /* For constant falloff distances are not allocated, so this should never happen. */ BLI_assert_unreachable(); break; - default: - BLI_assert_unreachable(); - break; } return {falloff_distance, direction}; @@ -3170,9 +3167,6 @@ static void init_boundary_mesh(const Depsgraph &depsgraph, case BRUSH_BOUNDARY_DEFORM_SMOOTH: /* Do nothing. These deform modes don't need any extra data to be precomputed. */ break; - default: - BLI_assert_unreachable(); - break; } init_falloff_mesh(mask, brush, ss.cache->initial_radius, *ss.cache->boundaries[symm_area]); @@ -3231,9 +3225,6 @@ static void init_boundary_grids(Object &object, case BRUSH_BOUNDARY_DEFORM_SMOOTH: /* Do nothing. These deform modes don't need any extra data to be precomputed. */ break; - default: - BLI_assert_unreachable(); - break; } init_falloff_grids( @@ -3288,9 +3279,6 @@ static void init_boundary_bmesh(Object &object, case BRUSH_BOUNDARY_DEFORM_SMOOTH: /* Do nothing. These deform modes don't need any extra data to be precomputed. */ break; - default: - BLI_assert_unreachable(); - break; } init_falloff_bmesh(bm, brush, ss.cache->initial_radius, *ss.cache->boundaries[symm_area]); @@ -3333,9 +3321,6 @@ static float get_mesh_strength(const SculptSession &ss, const Brush &brush) } case BRUSH_BOUNDARY_DEFORM_SMOOTH: return strength; - default: - BLI_assert_unreachable(); - break; } BLI_assert_unreachable(); @@ -3362,9 +3347,6 @@ void do_boundary_brush(const Depsgraph &depsgraph, case bke::pbvh::Type::BMesh: init_boundary_bmesh(ob, brush, symm_area); break; - default: - BLI_assert_unreachable(); - break; } } @@ -3430,9 +3412,6 @@ void do_boundary_brush(const Depsgraph &depsgraph, strength, eBrushDeformTarget(brush.deform_target)); break; - default: - BLI_assert_unreachable(); - break; } } @@ -3670,9 +3649,6 @@ std::unique_ptr preview_data_init(const Depsgraph &depsgr case bke::pbvh::Type::BMesh: boundary = data_init_bmesh(object, brush, std::get(initial_vert), radius); break; - default: - BLI_assert_unreachable(); - break; } if (boundary == nullptr) { diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.cc b/source/blender/editors/sculpt_paint/sculpt_face_set.cc index add30ed5ce8..09de4dabc7d 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.cc +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.cc @@ -1435,22 +1435,12 @@ static bool edit_is_operation_valid(const Object &object, return true; } -static void edit_modify_geometry(bContext *C, - Object &ob, - const int active_face_set, - const EditMode mode, - const bool modify_hidden, - wmOperator *op) +static void edit_modify_geometry( + bContext *C, Object &ob, const int active_face_set, const bool modify_hidden, wmOperator *op) { Mesh *mesh = static_cast(ob.data); undo::geometry_begin(ob, op); - switch (mode) { - case EditMode::DeleteGeometry: - delete_geometry(ob, active_face_set, modify_hidden); - break; - default: - BLI_assert_unreachable(); - } + delete_geometry(ob, active_face_set, modify_hidden); undo::geometry_end(ob); BKE_mesh_batch_cache_dirty_tag(mesh, BKE_MESH_BATCH_DIRTY_ALL); DEG_id_tag_update(&ob.id, ID_RECALC_GEOMETRY); @@ -1528,7 +1518,7 @@ static int edit_op_exec(bContext *C, wmOperator *op) switch (mode) { case EditMode::DeleteGeometry: - edit_modify_geometry(C, ob, active_face_set, mode, modify_hidden, op); + edit_modify_geometry(C, ob, active_face_set, modify_hidden, op); break; case EditMode::Grow: case EditMode::Shrink: diff --git a/source/blender/editors/sculpt_paint/sculpt_gesture.cc b/source/blender/editors/sculpt_paint/sculpt_gesture.cc index 456b1b7366e..6cf4023c703 100644 --- a/source/blender/editors/sculpt_paint/sculpt_gesture.cc +++ b/source/blender/editors/sculpt_paint/sculpt_gesture.cc @@ -363,10 +363,9 @@ static void update_affected_nodes_by_clip_planes(GestureData &gesture_data) return true; } return BKE_pbvh_node_frustum_exclude_AABB(&node, &frustum); - default: - BLI_assert_unreachable(); - return true; } + BLI_assert_unreachable(); + return false; }); }