diff options
Diffstat (limited to 'source/blender/bmesh')
21 files changed, 105 insertions, 99 deletions
diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt index 92c52f5d8d0..c215cf69e3a 100644 --- a/source/blender/bmesh/CMakeLists.txt +++ b/source/blender/bmesh/CMakeLists.txt @@ -183,7 +183,7 @@ set(LIB ) if(MSVC AND NOT MSVC_CLANG) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX /wd4101") + string(APPEND CMAKE_C_FLAGS " /WX /wd4101") endif() if(WITH_BULLET) diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index ca5693aa5ba..8631c224ce0 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -335,7 +335,7 @@ BMFace *BM_face_create_ngon_verts(BMesh *bm, /* we want to use the reverse winding to the existing order */ BM_edge_ordered_verts(edge_arr[i], &test_v2, &test_v1); winding[(vert_arr[i_prev] == test_v2)]++; - BLI_assert(vert_arr[i_prev] == test_v2 || vert_arr[i_prev] == test_v1); + BLI_assert(ELEM(vert_arr[i_prev], test_v2, test_v1)); } } diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index df5e7aadc64..b913bdd12e4 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -2289,6 +2289,7 @@ bool BM_vert_splice(BMesh *bm, BMVert *v_dst, BMVert *v_src) return true; } +/* -------------------------------------------------------------------- */ /** \name BM_vert_separate, bmesh_kernel_vert_separate and friends * \{ */ diff --git a/source/blender/bmesh/intern/bmesh_delete.c b/source/blender/bmesh/intern/bmesh_delete.c index b5ff24f6d61..f470361e5fb 100644 --- a/source/blender/bmesh/intern/bmesh_delete.c +++ b/source/blender/bmesh/intern/bmesh_delete.c @@ -28,9 +28,9 @@ #include "bmesh.h" #include "intern/bmesh_private.h" -/* -------------------------------------------------------------------- */ /* BMO functions */ +/* -------------------------------------------------------------------- */ /** \name BMesh Operator Delete Functions * \{ */ @@ -203,7 +203,6 @@ void BMO_mesh_delete_oflag_context(BMesh *bm, const short oflag, const int type) /** \} */ -/* -------------------------------------------------------------------- */ /* BM functions * * note! this is just a duplicate of the code above (bad!) @@ -211,6 +210,7 @@ void BMO_mesh_delete_oflag_context(BMesh *bm, const short oflag, const int type) * each time we need to remove some geometry. */ +/* -------------------------------------------------------------------- */ /** \name BMesh Delete Functions (no oflags) * \{ */ diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c index 0bbe86d2d2f..a15408d43be 100644 --- a/source/blender/bmesh/intern/bmesh_interp.c +++ b/source/blender/bmesh/intern/bmesh_interp.c @@ -1027,6 +1027,7 @@ void BM_elem_float_data_set(CustomData *cd, void *element, int type, const float } } +/* -------------------------------------------------------------------- */ /** \name Loop interpolation functions: BM_vert_loop_groups_data_layer_*** * * Handling loop custom-data such as UV's, while keeping contiguous fans is rather tedious. diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index a5d02cdc4e5..4fe6e6aee58 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -66,6 +66,7 @@ static void recount_totsels(BMesh *bm) } } +/* -------------------------------------------------------------------- */ /** \name BMesh helper functions for selection & hide flushing. * \{ */ @@ -540,7 +541,8 @@ void BM_face_select_set(BMesh *bm, BMFace *f, const bool select) } } -/** \name Non flushing versions element selection. +/* -------------------------------------------------------------------- */ +/** \name Non Flushing Versions Element Selection * \{ */ void BM_edge_select_set_noflush(BMesh *bm, BMEdge *e, const bool select) diff --git a/source/blender/bmesh/intern/bmesh_mesh_duplicate.c b/source/blender/bmesh/intern/bmesh_mesh_duplicate.c index 51f9d2eab1d..1d393abcd56 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_duplicate.c +++ b/source/blender/bmesh/intern/bmesh_mesh_duplicate.c @@ -50,9 +50,7 @@ static BMEdge *bm_edge_copy_with_arrays(BMesh *bm_src, } static BMFace *bm_face_copy_with_arrays( - BMesh *bm_src, BMesh *bm_dst, BMFace *f_src, BMVert **verts_dst, BMEdge **edges_dst - -) + BMesh *bm_src, BMesh *bm_dst, BMFace *f_src, BMVert **verts_dst, BMEdge **edges_dst) { BMFace *f_dst; BMVert **vtar = BLI_array_alloca(vtar, f_src->len); diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index c5e030c436a..c2421939aa8 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -963,7 +963,7 @@ void BMO_slot_buffer_from_single(BMOperator *op, BMOpSlot *slot, BMHeader *ele) BMO_ASSERT_SLOT_IN_OP(slot, op); BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); BLI_assert(slot->slot_subtype.elem & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE); - BLI_assert(slot->len == 0 || slot->len == 1); + BLI_assert(ELEM(slot->len, 0, 1)); BLI_assert(slot->slot_subtype.elem & ele->htype); @@ -979,7 +979,7 @@ void BMO_slot_buffer_from_array(BMOperator *op, { BMO_ASSERT_SLOT_IN_OP(slot, op); BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); - BLI_assert(slot->len == 0 || slot->len == ele_buffer_len); + BLI_assert(ELEM(slot->len, 0, ele_buffer_len)); if (slot->data.buf == NULL) { slot->data.buf = BLI_memarena_alloc(op->arena, sizeof(*slot->data.buf) * ele_buffer_len); @@ -993,7 +993,7 @@ void *BMO_slot_buffer_get_single(BMOpSlot *slot) { BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); BLI_assert(slot->slot_subtype.elem & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE); - BLI_assert(slot->len == 0 || slot->len == 1); + BLI_assert(ELEM(slot->len, 0, 1)); return slot->len ? (BMHeader *)slot->data.buf[0] : NULL; } diff --git a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c index 09c0f48c2f6..1d000b3b232 100644 --- a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c +++ b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c @@ -39,9 +39,9 @@ #include "intern/bmesh_private.h" /* -------------------------------------------------------------------- */ -/* Face Split Edge-Net */ - -/** \name BM_face_split_edgenet and helper functions. +/** \name Face Split Edge-Net + * + * #BM_face_split_edgenet and helper functions. * * \note Don't use #BM_edge_is_wire or #BM_edge_is_boundary * since we need to take flagged faces into account. @@ -702,9 +702,9 @@ bool BM_face_split_edgenet(BMesh *bm, /** \} */ /* -------------------------------------------------------------------- */ -/* Face Split Edge-Net Connect Islands */ - -/** \name BM_face_split_edgenet_connect_islands and helper functions. +/** \name Face Split Edge-Net Connect Islands + * + * #BM_face_split_edgenet_connect_islands and helper functions. * * Connect isolated mesh 'islands' so they form legal regions from which we can create faces. * diff --git a/source/blender/bmesh/intern/bmesh_query.c b/source/blender/bmesh/intern/bmesh_query.c index e95243f4f32..03655bccf1c 100644 --- a/source/blender/bmesh/intern/bmesh_query.c +++ b/source/blender/bmesh/intern/bmesh_query.c @@ -1605,7 +1605,7 @@ float BM_loop_calc_face_normal_safe_vcos_ex(const BMLoop *l, } /** - * #BM_loop_calc_face_normal_safe_ex with pre-defined sane epsilon. + * #BM_loop_calc_face_normal_safe_ex with predefined sane epsilon. * * Since this doesn't scale based on triangle size, fixed value works well. */ diff --git a/source/blender/bmesh/intern/bmesh_structure.c b/source/blender/bmesh/intern/bmesh_structure.c index d9f68f8aa62..ef4a9c9de1c 100644 --- a/source/blender/bmesh/intern/bmesh_structure.c +++ b/source/blender/bmesh/intern/bmesh_structure.c @@ -402,7 +402,7 @@ bool bmesh_radial_validate(int radlen, BMLoop *l) if (l_iter->e != l->e) { return false; } - if (l_iter->v != l->e->v1 && l_iter->v != l->e->v2) { + if (!ELEM(l_iter->v, l->e->v1, l->e->v2)) { return false; } diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c index dc9107a1616..7d56e560275 100644 --- a/source/blender/bmesh/intern/bmesh_walkers_impl.c +++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c @@ -37,6 +37,7 @@ } \ (void)0 +/* -------------------------------------------------------------------- */ /** \name Mask Flag Checks * \{ */ @@ -75,6 +76,7 @@ static bool bmw_mask_check_face(BMWalker *walker, BMFace *f) /** \} */ +/* -------------------------------------------------------------------- */ /** \name BMesh Queries (modified to check walker flags) * \{ */ @@ -94,8 +96,8 @@ static bool bmw_edge_is_wire(const BMWalker *walker, const BMEdge *e) } /** \} */ +/* -------------------------------------------------------------------- */ /** \name Shell Walker - * \{ * * Starts at a vertex on the mesh and walks over the 'shell' it belongs * to via visiting connected edges. @@ -104,7 +106,7 @@ static bool bmw_edge_is_wire(const BMWalker *walker, const BMEdge *e) * restrict flag acts on the edges as well. * * \todo Add restriction flag/callback for wire edges. - */ + * \{ */ static void bmw_VertShellWalker_visitEdge(BMWalker *walker, BMEdge *e) { BMwShellWalker *shellWalk = NULL; @@ -228,14 +230,14 @@ static void *bmw_VertShellWalker_step(BMWalker *walker) /** \} */ +/* -------------------------------------------------------------------- */ /** \name LoopShell Walker - * \{ * * Starts at any element on the mesh and walks over the 'shell' it belongs * to via visiting connected loops. * * \note this is mainly useful to loop over a shell delimited by edges. - */ + * \{ */ static void bmw_LoopShellWalker_visitLoop(BMWalker *walker, BMLoop *l) { BMwLoopShellWalker *shellWalk = NULL; @@ -352,10 +354,10 @@ static void *bmw_LoopShellWalker_step(BMWalker *walker) /** \} */ +/* -------------------------------------------------------------------- */ /** \name LoopShell & 'Wire' Walker - * \{ * - * Piggyback ontop of #BMwLoopShellWalker, but also walk over wire edges + * Piggyback on top of #BMwLoopShellWalker, but also walk over wire edges * This isn't elegant but users expect it when selecting linked, * so we can support delimiters _and_ walking over wire edges. * @@ -363,7 +365,7 @@ static void *bmw_LoopShellWalker_step(BMWalker *walker) * - can yield edges (as well as loops) * - only step over wire edges. * - verts and edges are stored in `visit_set_alt`. - */ + * \{ */ static void bmw_LoopShellWalker_visitEdgeWire(BMWalker *walker, BMEdge *e) { @@ -504,12 +506,12 @@ static void *bmw_LoopShellWireWalker_step(BMWalker *walker) /** \} */ +/* -------------------------------------------------------------------- */ /** \name FaceShell Walker - * \{ * * Starts at an edge on the mesh and walks over the 'shell' it belongs * to via visiting connected faces. - */ + * \{ */ static void bmw_FaceShellWalker_visitEdge(BMWalker *walker, BMEdge *e) { BMwShellWalker *shellWalk = NULL; @@ -567,13 +569,13 @@ static void *bmw_FaceShellWalker_step(BMWalker *walker) } /** \} */ +/* -------------------------------------------------------------------- */ /** \name Connected Vertex Walker - * \{ * * Similar to shell walker, but visits vertices instead of edges. * * Walk from a vertex to all connected vertices. - */ + * \{ */ static void bmw_ConnectedVertexWalker_visitVertex(BMWalker *walker, BMVert *v) { BMwConnectedVertexWalker *vwalk; @@ -629,8 +631,8 @@ static void *bmw_ConnectedVertexWalker_step(BMWalker *walker) /** \} */ +/* -------------------------------------------------------------------- */ /** \name Island Boundary Walker - * \{ * * Starts at a edge on the mesh and walks over the boundary of an island it belongs to. * @@ -640,7 +642,7 @@ static void *bmw_ConnectedVertexWalker_step(BMWalker *walker) * over the boundary. raises an error if it encounters non-manifold geometry. * * \todo Add restriction flag/callback for wire edges. - */ + * \{ */ static void bmw_IslandboundWalker_begin(BMWalker *walker, void *data) { BMLoop *l = data; @@ -723,13 +725,13 @@ static void *bmw_IslandboundWalker_step(BMWalker *walker) return owalk.curloop; } +/* -------------------------------------------------------------------- */ /** \name Island Walker - * \{ * * Starts at a tool flagged-face and walks over the face region * * \todo Add restriction flag/callback for wire edges. - */ + * \{ */ static void bmw_IslandWalker_begin(BMWalker *walker, void *data) { BMwIslandWalker *iwalk = NULL; @@ -828,11 +830,11 @@ static void *bmw_IslandManifoldWalker_step(BMWalker *walker) /** \} */ +/* -------------------------------------------------------------------- */ /** \name Edge Loop Walker - * \{ * * Starts at a tool-flagged edge and walks over the edge loop - */ + * \{ */ /* utility function to see if an edge is a part of an ngon boundary */ static bool bm_edge_is_single(BMEdge *e) @@ -981,7 +983,7 @@ static void *bmw_EdgeLoopWalker_step(BMWalker *walker) /* Typical loopiong over edges in the middle of a mesh */ /* However, why use 2 here at all? * I guess for internal ngon loops it can be useful. Antony R. */ - if (vert_edge_tot == 4 || vert_edge_tot == 2) { + if (ELEM(vert_edge_tot, 4, 2)) { int i_opposite = vert_edge_tot / 2; int i = 0; do { @@ -1070,13 +1072,13 @@ static void *bmw_EdgeLoopWalker_step(BMWalker *walker) /** \} */ +/* -------------------------------------------------------------------- */ /** \name Face Loop Walker - * \{ * * Starts at a tool-flagged face and walks over the face loop * Conditions for starting and stepping the face loop have been * tuned in an attempt to match the face loops built by EditMesh - */ + * \{ */ /* Check whether the face loop should includes the face specified * by the given BMLoop */ @@ -1216,13 +1218,13 @@ static void *bmw_FaceLoopWalker_step(BMWalker *walker) // #define BMW_EDGERING_NGON +/* -------------------------------------------------------------------- */ /** \name Edge Ring Walker - * \{ * * Starts at a tool-flagged edge and walks over the edge ring * Conditions for starting and stepping the edge ring have been * tuned to match behavior users expect (dating back to v2.4x). - */ + * \{ */ static void bmw_EdgeringWalker_begin(BMWalker *walker, void *data) { BMwEdgeringWalker *lwalk, owalk, *owalk_pt; @@ -1349,6 +1351,7 @@ static void *bmw_EdgeringWalker_step(BMWalker *walker) /** \} */ +/* -------------------------------------------------------------------- */ /** \name Boundary Edge Walker * \{ */ @@ -1420,14 +1423,14 @@ static void *bmw_EdgeboundaryWalker_step(BMWalker *walker) /** \} */ +/* -------------------------------------------------------------------- */ /** \name UV Edge Walker * * walk over uv islands; takes a loop as input. restrict flag * restricts the walking to loops whose vert has restrict flag set as a * tool flag. * - * the flag parameter to BMW_init maps to a loop customdata layer index. - * + * The flag parameter to BMW_init maps to a loop customdata layer index. * \{ */ static void bmw_UVEdgeWalker_begin(BMWalker *walker, void *data) diff --git a/source/blender/bmesh/operators/bmo_fill_grid.c b/source/blender/bmesh/operators/bmo_fill_grid.c index c97e855aa67..3aad37b3b02 100644 --- a/source/blender/bmesh/operators/bmo_fill_grid.c +++ b/source/blender/bmesh/operators/bmo_fill_grid.c @@ -96,9 +96,7 @@ static void quad_verts_to_barycentric_tri(float tri[3][3], #endif /* -------------------------------------------------------------------- */ -/* Handle Loop Pairs */ - -/** \name Loop Pairs +/** \name Handle Loop Pairs * \{ */ /** diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index 46dff99898c..8b2f9478aab 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -338,9 +338,9 @@ static void alter_co(BMVert *v, add_v3_v3v3(co2, v->co, params->fractal_ofs); mul_v3_fl(co2, 10.0f); - tvec[0] = fac * (BLI_gTurbulence(1.0, co2[0], co2[1], co2[2], 15, 0, 2) - 0.5f); - tvec[1] = fac * (BLI_gTurbulence(1.0, co2[1], co2[0], co2[2], 15, 0, 2) - 0.5f); - tvec[2] = fac * (BLI_gTurbulence(1.0, co2[1], co2[2], co2[0], 15, 0, 2) - 0.5f); + tvec[0] = fac * (BLI_noise_generic_turbulence(1.0, co2[0], co2[1], co2[2], 15, 0, 2) - 0.5f); + tvec[1] = fac * (BLI_noise_generic_turbulence(1.0, co2[1], co2[0], co2[2], 15, 0, 2) - 0.5f); + tvec[2] = fac * (BLI_noise_generic_turbulence(1.0, co2[1], co2[2], co2[0], 15, 0, 2) - 0.5f); /* add displacement */ madd_v3_v3fl(co, normal, tvec[0]); diff --git a/source/blender/bmesh/tests/bmesh_core_test.cc b/source/blender/bmesh/tests/bmesh_core_test.cc index afbc11e0722..202d16b09e3 100644 --- a/source/blender/bmesh/tests/bmesh_core_test.cc +++ b/source/blender/bmesh/tests/bmesh_core_test.cc @@ -16,8 +16,8 @@ TEST(bmesh_core, BMVertCreate) EXPECT_EQ(bm->totvert, 0); /* make a custom layer so we can see if it is copied properly */ BM_data_layer_add(bm, &bm->vdata, CD_PROP_FLOAT); - bv1 = BM_vert_create(bm, co1, NULL, BM_CREATE_NOP); - ASSERT_TRUE(bv1 != NULL); + bv1 = BM_vert_create(bm, co1, nullptr, BM_CREATE_NOP); + ASSERT_TRUE(bv1 != nullptr); EXPECT_EQ(bv1->co[0], 1.0f); EXPECT_EQ(bv1->co[1], 2.0f); EXPECT_EQ(bv1->co[2], 0.0f); @@ -25,14 +25,14 @@ TEST(bmesh_core, BMVertCreate) EXPECT_EQ(bv1->head.htype, (char)BM_VERT); EXPECT_EQ(bv1->head.hflag, 0); EXPECT_EQ(bv1->head.api_flag, 0); - bv2 = BM_vert_create(bm, NULL, NULL, BM_CREATE_NOP); - ASSERT_TRUE(bv2 != NULL); + bv2 = BM_vert_create(bm, nullptr, nullptr, BM_CREATE_NOP); + ASSERT_TRUE(bv2 != nullptr); EXPECT_TRUE(is_zero_v3(bv2->co)); /* create with example should copy custom data but not select flag */ BM_vert_select_set(bm, bv2, true); BM_elem_float_data_set(&bm->vdata, bv2, CD_PROP_FLOAT, 1.5f); bv3 = BM_vert_create(bm, co1, bv2, BM_CREATE_NOP); - ASSERT_TRUE(bv3 != NULL); + ASSERT_TRUE(bv3 != nullptr); EXPECT_FALSE(BM_elem_flag_test((BMElem *)bv3, BM_ELEM_SELECT)); EXPECT_EQ(BM_elem_float_data_get(&bm->vdata, bv3, CD_PROP_FLOAT), 1.5f); EXPECT_EQ(BM_mesh_elem_count(bm, BM_VERT), 3); diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index 309b6547a39..9497466723a 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -303,14 +303,14 @@ typedef enum { } FKind; /** Helper for keeping track of angle kind. */ -enum { +typedef enum AngleKind { /** Angle less than 180 degrees. */ ANGLE_SMALLER = -1, /** 180 degree angle. */ ANGLE_STRAIGHT = 0, /** Angle greater than 180 degrees. */ ANGLE_LARGER = 1, -}; +} AngleKind; /** Bevel parameters and state. */ typedef struct BevelParams { @@ -1101,7 +1101,7 @@ static bool is_outside_edge(EdgeHalf *e, const float co[3], BMVert **ret_closer_ } /* Return whether the angle is less than, equal to, or larger than 180 degrees. */ -static int edges_angle_kind(EdgeHalf *e1, EdgeHalf *e2, BMVert *v) +static AngleKind edges_angle_kind(EdgeHalf *e1, EdgeHalf *e2, BMVert *v) { BMVert *v1 = BM_edge_other_vert(e1->e, v); BMVert *v2 = BM_edge_other_vert(e2->e, v); @@ -1413,7 +1413,7 @@ static void offset_meet(BevelParams *bp, normalize_v3(norm_perp2); float off1a[3], off1b[3], off2a[3], off2b[3]; - if (bp->offset_type == BEVEL_AMT_PERCENT || bp->offset_type == BEVEL_AMT_ABSOLUTE) { + if (ELEM(bp->offset_type, BEVEL_AMT_PERCENT, BEVEL_AMT_ABSOLUTE)) { offset_meet_lines_percent_or_absolute(bp, e1, e2, v, off1a, off1b, off2a, off2b); } else { @@ -1570,7 +1570,7 @@ static bool offset_on_edge_between(BevelParams *bp, float meet1[3], meet2[3]; bool ok1 = offset_meet_edge(e1, emid, v, meet1, &ang1); bool ok2 = offset_meet_edge(emid, e2, v, meet2, &ang2); - if (bp->offset_type == BEVEL_AMT_PERCENT || bp->offset_type == BEVEL_AMT_ABSOLUTE) { + if (ELEM(bp->offset_type, BEVEL_AMT_PERCENT, BEVEL_AMT_ABSOLUTE)) { BMVert *v2 = BM_edge_other_vert(emid->e, v); if (bp->offset_type == BEVEL_AMT_PERCENT) { interp_v3_v3v3(meetco, v->co, v2->co, bp->offset / 100.0f); @@ -2172,7 +2172,7 @@ static void snap_to_superellipsoid(float co[3], const float super_r, bool midlin float x = a; float y = b; float z = c; - if (r == PRO_SQUARE_R || r == PRO_SQUARE_IN_R) { + if (ELEM(r, PRO_SQUARE_R, PRO_SQUARE_IN_R)) { /* Will only be called for 2d profile. */ BLI_assert(fabsf(z) < BEVEL_EPSILON); z = 0.0f; @@ -2455,7 +2455,7 @@ static void bevel_harden_normals(BevelParams *bp, BMesh *bm) BMFace *f; BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { FKind fkind = get_face_kind(bp, f); - if (fkind == F_ORIG || fkind == F_RECON) { + if (ELEM(fkind, F_ORIG, F_RECON)) { continue; } BMIter liter; @@ -3041,7 +3041,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct) for (EdgeHalf *e3 = e->next; e3 != e2; e3 = e3->next) { e3->leftv = e3->rightv = v; } - int ang_kind = edges_angle_kind(e, e2, bv->v); + AngleKind ang_kind = edges_angle_kind(e, e2, bv->v); /* Are we doing special mitering? * There can only be one outer reflex angle, so only one outer miter, @@ -3119,7 +3119,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct) } } else { /* construct == false. */ - int ang_kind = edges_angle_kind(e, e2, bv->v); + AngleKind ang_kind = edges_angle_kind(e, e2, bv->v); if ((miter_outer != BEVEL_MITER_SHARP && !emiter && ang_kind == ANGLE_LARGER) || (miter_inner != BEVEL_MITER_SHARP && ang_kind == ANGLE_SMALLER)) { if (ang_kind == ANGLE_LARGER) { @@ -4582,13 +4582,13 @@ static void snap_to_pipe_profile(BoundVert *vpipe, bool midline, float co[3]) sub_v3_v3v3(edir, e->e->v1->co, e->e->v2->co); plane_from_point_normal_v3(plane, co, edir); - float va0[3], vb0[3], vmid0[3]; - closest_to_plane_v3(va0, plane, pro->start); - closest_to_plane_v3(vb0, plane, pro->end); - closest_to_plane_v3(vmid0, plane, pro->middle); + float start_plane[3], end_plane[3], middle_plane[3]; + closest_to_plane_v3(start_plane, plane, pro->start); + closest_to_plane_v3(end_plane, plane, pro->end); + closest_to_plane_v3(middle_plane, plane, pro->middle); float m[4][4], minv[4][4]; - if (make_unit_square_map(va0, vmid0, vb0, m) && invert_m4_m4(minv, m)) { + if (make_unit_square_map(start_plane, middle_plane, end_plane, m) && invert_m4_m4(minv, m)) { /* Transform co and project it onto superellipse. */ float p[3]; mul_v3_m4v3(p, minv, co); @@ -4599,9 +4599,9 @@ static void snap_to_pipe_profile(BoundVert *vpipe, bool midline, float co[3]) copy_v3_v3(co, snap); } else { - /* Planar case: just snap to line va0--vb0. */ + /* Planar case: just snap to line start_plane--end_plane. */ float p[3]; - closest_to_line_segment_v3(p, co, va0, vb0); + closest_to_line_segment_v3(p, co, start_plane, end_plane); copy_v3_v3(co, p); } } @@ -4633,7 +4633,7 @@ static VMesh *pipe_adj_vmesh(BevelParams *bp, BevVert *bv, BoundVert *vpipe) if (bp->profile_type == BEVEL_PROFILE_CUSTOM) { /* Find both profile vertices that correspond to this point. */ float *profile_point_pipe1, *profile_point_pipe2, f; - if (i == ipipe1 || i == ipipe2) { + if (ELEM(i, ipipe1, ipipe2)) { if (n_bndv == 3 && i == ipipe1) { /* This part of the vmesh is the triangular corner between the two pipe profiles. */ int ring = max_ii(j, k); @@ -4942,7 +4942,7 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv) copy_v3_v3(bndco, bndv->nv.co); EdgeHalf *e1 = bndv->efirst; EdgeHalf *e2 = bndv->elast; - int ang_kind = ANGLE_STRAIGHT; + AngleKind ang_kind = ANGLE_STRAIGHT; if (e1 && e2) { ang_kind = edges_angle_kind(e1, e2, bv->v); } @@ -6243,7 +6243,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) break; } } - if (bp->offset_type != BEVEL_AMT_PERCENT && bp->offset_type != BEVEL_AMT_ABSOLUTE) { + if (!ELEM(bp->offset_type, BEVEL_AMT_PERCENT, BEVEL_AMT_ABSOLUTE)) { e->offset_r_spec = e->offset_l_spec; } if (bp->use_weights) { @@ -6785,7 +6785,7 @@ static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme) BMIter iter; BMLoop *l; BM_ITER_ELEM (l, &iter, r_f, BM_LOOPS_OF_FACE) { - if (l->v == verts[0] || l->v == verts[2]) { + if (ELEM(l->v, verts[0], verts[2])) { BM_elem_flag_enable(l, BM_ELEM_LONG_TAG); } } @@ -7246,7 +7246,7 @@ static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb) EdgeHalf *ec; BMVert *vd; float kc; - if (bp->offset_type == BEVEL_AMT_PERCENT || bp->offset_type == BEVEL_AMT_ABSOLUTE) { + if (ELEM(bp->offset_type, BEVEL_AMT_PERCENT, BEVEL_AMT_ABSOLUTE)) { if (ea->is_bev && ebother != NULL && ebother->prev->is_bev) { if (bp->offset_type == BEVEL_AMT_PERCENT) { return 50.0f; diff --git a/source/blender/bmesh/tools/bmesh_boolean.cc b/source/blender/bmesh/tools/bmesh_boolean.cc index 37010b6f438..39b425a41df 100644 --- a/source/blender/bmesh/tools/bmesh_boolean.cc +++ b/source/blender/bmesh/tools/bmesh_boolean.cc @@ -30,8 +30,7 @@ #include "bmesh_boolean.h" #include "bmesh_edgesplit.h" -namespace blender { -namespace meshintersect { +namespace blender::meshintersect { #ifdef WITH_GMP @@ -120,7 +119,8 @@ static bool bmvert_attached_to_wire(const BMVert *bmv) static bool bmvert_attached_to_hidden_face(BMVert *bmv) { BMIter iter; - for (BMFace *bmf = static_cast<BMFace *>(BM_iter_new(&iter, NULL, BM_FACES_OF_VERT, bmv)); bmf; + for (BMFace *bmf = static_cast<BMFace *>(BM_iter_new(&iter, nullptr, BM_FACES_OF_VERT, bmv)); + bmf; bmf = static_cast<BMFace *>(BM_iter_step(&iter))) { if (BM_elem_flag_test(bmf, BM_ELEM_HIDDEN)) { return true; @@ -133,7 +133,7 @@ static bool face_has_verts_in_order(BMesh *bm, BMFace *bmf, const BMVert *v1, co { BMIter liter; BMLoop *l = static_cast<BMLoop *>(BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, bmf)); - while (l != NULL) { + while (l != nullptr) { if (l->v == v1 && l->next->v == v2) { return true; } @@ -198,7 +198,7 @@ static bool apply_mesh_output_to_bmesh(BMesh *bm, IMesh &m_out, bool keep_hidden for (int i = 0; i < 3; ++i) { co[i] = static_cast<float>(d_co[i]); } - BMVert *bmv = BM_vert_create(bm, co, NULL, BM_CREATE_NOP); + BMVert *bmv = BM_vert_create(bm, co, nullptr, BM_CREATE_NOP); new_bmvs[v] = bmv; BM_elem_flag_enable(bmv, KEEP_FLAG); any_change = true; @@ -245,7 +245,7 @@ static bool apply_mesh_output_to_bmesh(BMesh *bm, IMesh &m_out, bool keep_hidden BMFace *bmf = BM_face_exists(face_bmverts.data(), flen); /* #BM_face_exists checks if the face exists with the vertices in either order. * We can only reuse the face if the orientations are the same. */ - if (bmf != NULL && face_has_verts_in_order(bm, bmf, face_bmverts[0], face_bmverts[1])) { + if (bmf != nullptr && face_has_verts_in_order(bm, bmf, face_bmverts[0], face_bmverts[1])) { BM_elem_flag_enable(bmf, KEEP_FLAG); } else { @@ -256,20 +256,20 @@ static bool apply_mesh_output_to_bmesh(BMesh *bm, IMesh &m_out, bool keep_hidden orig_face = old_bmfs[orig]; } else { - orig_face = NULL; + orig_face = nullptr; } /* Make or find #BMEdge's. */ for (int i = 0; i < flen; ++i) { BMVert *bmv1 = face_bmverts[i]; BMVert *bmv2 = face_bmverts[(i + 1) % flen]; BMEdge *bme = BM_edge_exists(bmv1, bmv2); - if (bme == NULL) { - BMEdge *orig_edge = NULL; + if (bme == nullptr) { + BMEdge *orig_edge = nullptr; if (face.edge_orig[i] != NO_INDEX) { orig_edge = old_edges[face.edge_orig[i]]; } bme = BM_edge_create(bm, bmv1, bmv2, orig_edge, BM_CREATE_NOP); - if (orig_edge != NULL) { + if (orig_edge != nullptr) { BM_elem_select_copy(bm, bme, orig_edge); } } @@ -283,15 +283,15 @@ static bool apply_mesh_output_to_bmesh(BMesh *bm, IMesh &m_out, bool keep_hidden } BMFace *bmf = BM_face_create( bm, face_bmverts.data(), face_bmedges.data(), flen, orig_face, BM_CREATE_NOP); - if (orig_face != NULL) { + if (orig_face != nullptr) { BM_elem_select_copy(bm, bmf, orig_face); } BM_elem_flag_enable(bmf, KEEP_FLAG); /* Now do interpolation of loop data (e.g., UV's) using the example face. */ - if (orig_face != NULL) { + if (orig_face != nullptr) { BMIter liter; BMLoop *l = static_cast<BMLoop *>(BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, bmf)); - while (l != NULL) { + while (l != nullptr) { BM_loop_interp_from_face(bm, l, orig_face, true, true); l = static_cast<BMLoop *>(BM_iter_step(&liter)); } @@ -304,8 +304,8 @@ static bool apply_mesh_output_to_bmesh(BMesh *bm, IMesh &m_out, bool keep_hidden /* #BM_ITER_MESH_MUTABLE macro needs type casts for C++, so expand here. * TODO(howard): make some nice C++ iterators for #BMesh. */ BMIter iter; - BMFace *bmf = static_cast<BMFace *>(BM_iter_new(&iter, bm, BM_FACES_OF_MESH, NULL)); - while (bmf != NULL) { + BMFace *bmf = static_cast<BMFace *>(BM_iter_new(&iter, bm, BM_FACES_OF_MESH, nullptr)); + while (bmf != nullptr) { # ifdef DEBUG iter.count = BM_iter_mesh_count(BM_FACES_OF_MESH, bm); # endif @@ -322,8 +322,8 @@ static bool apply_mesh_output_to_bmesh(BMesh *bm, IMesh &m_out, bool keep_hidden } bmf = bmf_next; } - BMVert *bmv = static_cast<BMVert *>(BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL)); - while (bmv != NULL) { + BMVert *bmv = static_cast<BMVert *>(BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, nullptr)); + while (bmv != nullptr) { # ifdef DEBUG iter.count = BM_iter_mesh_count(BM_VERTS_OF_MESH, bm); # endif @@ -389,8 +389,7 @@ static bool bmesh_boolean(BMesh *bm, #endif // WITH_GMP -} // namespace meshintersect -} // namespace blender +} // namespace blender::meshintersect extern "C" { /** @@ -493,7 +492,7 @@ bool BM_mesh_boolean_knife(BMesh *UNUSED(bm), const int UNUSED(nshapes), const bool UNUSED(use_self), const bool UNUSED(use_separate_all), - const bool UNUSED(keep_boolean)) + const bool UNUSED(keep_hidden)) { UNUSED_VARS(looptris, test_fn); return false; diff --git a/source/blender/bmesh/tools/bmesh_edgenet.c b/source/blender/bmesh/tools/bmesh_edgenet.c index 9f4327fd1e3..c332d88e83b 100644 --- a/source/blender/bmesh/tools/bmesh_edgenet.c +++ b/source/blender/bmesh/tools/bmesh_edgenet.c @@ -51,7 +51,7 @@ enum { */ static bool bm_edge_step_ok(BMEdge *e) { - return BM_elem_flag_test(e, BM_ELEM_TAG) && ((e->l == NULL) || (e->l->radial_next == e->l)); + return BM_elem_flag_test(e, BM_ELEM_TAG) && (ELEM(e->l, NULL, e->l->radial_next)); } static int bm_edge_face(BMEdge *e) diff --git a/source/blender/bmesh/tools/bmesh_path_region.c b/source/blender/bmesh/tools/bmesh_path_region.c index f8e981bbd58..23be3cdf117 100644 --- a/source/blender/bmesh/tools/bmesh_path_region.c +++ b/source/blender/bmesh/tools/bmesh_path_region.c @@ -74,6 +74,7 @@ static bool bm_vert_pair_ends(BMVert *v_pivot, BMVert *v_end_pair[2]) } #endif /* USE_EDGE_CHAIN */ +/* -------------------------------------------------------------------- */ /** \name Vertex in Region Checks * \{ */ @@ -386,6 +387,7 @@ static LinkNode *mesh_calc_path_region_elem(BMesh *bm, #undef USE_EDGE_CHAIN +/* -------------------------------------------------------------------- */ /** \name Main Functions (exposed externally). * \{ */ diff --git a/source/blender/bmesh/tools/bmesh_path_region_uv.c b/source/blender/bmesh/tools/bmesh_path_region_uv.c index d036c20d0e4..517913b5b56 100644 --- a/source/blender/bmesh/tools/bmesh_path_region_uv.c +++ b/source/blender/bmesh/tools/bmesh_path_region_uv.c @@ -72,6 +72,7 @@ static bool bm_loop_pair_ends(BMLoop *l_pivot, BMLoop *l_end_pair[2]) } #endif /* USE_EDGE_CHAIN */ +/* -------------------------------------------------------------------- */ /** \name Loop Vertex in Region Checks * \{ */ @@ -403,6 +404,7 @@ static LinkNode *mesh_calc_path_region_elem(BMesh *bm, #undef USE_EDGE_CHAIN +/* -------------------------------------------------------------------- */ /** \name Main Functions (exposed externally). * \{ */ diff --git a/source/blender/bmesh/tools/bmesh_region_match.c b/source/blender/bmesh/tools/bmesh_region_match.c index d222ea214c4..561b00544b5 100644 --- a/source/blender/bmesh/tools/bmesh_region_match.c +++ b/source/blender/bmesh/tools/bmesh_region_match.c @@ -67,8 +67,6 @@ #include "BLI_strict_flags.h" /* -------------------------------------------------------------------- */ -/* UUID-Walk API */ - /** \name Internal UUIDWalk API * \{ */ @@ -615,6 +613,7 @@ static uint bm_uuidwalk_init_from_edge(UUIDWalk *uuidwalk, BMEdge *e) /** \} */ +/* -------------------------------------------------------------------- */ /** \name Internal UUIDFaceStep API * \{ */ @@ -907,6 +906,7 @@ static void bm_face_array_visit(BMFace **faces, #ifdef USE_PIVOT_SEARCH +/* -------------------------------------------------------------------- */ /** \name Internal UUIDWalk API * \{ */ @@ -1226,11 +1226,11 @@ static BMEdge *bm_face_region_pivot_edge_find(BMFace **faces_region, #endif /* USE_PIVOT_SEARCH */ -/* -------------------------------------------------------------------- */ /* Quick UUID pass - identify candidates */ #ifdef USE_PIVOT_FASTMATCH +/* -------------------------------------------------------------------- */ /** \name Fast Match * \{ */ |