Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/bmesh/tools')
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.c42
-rw-r--r--source/blender/bmesh/tools/bmesh_boolean.cc39
-rw-r--r--source/blender/bmesh/tools/bmesh_edgenet.c2
-rw-r--r--source/blender/bmesh/tools/bmesh_path_region.c2
-rw-r--r--source/blender/bmesh/tools/bmesh_path_region_uv.c2
-rw-r--r--source/blender/bmesh/tools/bmesh_region_match.c6
6 files changed, 48 insertions, 45 deletions
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
* \{ */