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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-02 17:05:23 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-02 17:05:23 +0300
commit43e6bb85cee0802887eae9489a2bd73836daf41d (patch)
treeeaa106429af8341bf2123d7445fdab0af71b3dda /source/blender/editors/mesh
parent7daeb1f9aee284d958abe87622b43c70c21af967 (diff)
parentffaf91b5fc03f91e1fc90bd2f1d5dc5aa75656ff (diff)
Merge 'master' into 'collada'
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r--source/blender/editors/mesh/CMakeLists.txt4
-rw-r--r--source/blender/editors/mesh/editface.c35
-rw-r--r--source/blender/editors/mesh/editmesh_add.c4
-rw-r--r--source/blender/editors/mesh/editmesh_add_gizmo.c3
-rw-r--r--source/blender/editors/mesh/editmesh_bevel.c42
-rw-r--r--source/blender/editors/mesh/editmesh_extrude.c29
-rw-r--r--source/blender/editors/mesh/editmesh_extrude_screw.c3
-rw-r--r--source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c3
-rw-r--r--source/blender/editors/mesh/editmesh_inset.c24
-rw-r--r--source/blender/editors/mesh/editmesh_intersect.c9
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c147
-rw-r--r--source/blender/editors/mesh/editmesh_loopcut.c12
-rw-r--r--source/blender/editors/mesh/editmesh_path.c46
-rw-r--r--source/blender/editors/mesh/editmesh_preselect_edgering.c3
-rw-r--r--source/blender/editors/mesh/editmesh_rip.c48
-rw-r--r--source/blender/editors/mesh/editmesh_rip_edge.c3
-rw-r--r--source/blender/editors/mesh/editmesh_select.c76
-rw-r--r--source/blender/editors/mesh/editmesh_select_similar.c12
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c221
-rw-r--r--source/blender/editors/mesh/editmesh_undo.c10
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c66
-rw-r--r--source/blender/editors/mesh/mesh_data.c96
-rw-r--r--source/blender/editors/mesh/mesh_mirror.c18
-rw-r--r--source/blender/editors/mesh/mesh_ops.c22
-rw-r--r--source/blender/editors/mesh/meshtools.c118
25 files changed, 673 insertions, 381 deletions
diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt
index e67d63b01a5..57bf67e825e 100644
--- a/source/blender/editors/mesh/CMakeLists.txt
+++ b/source/blender/editors/mesh/CMakeLists.txt
@@ -21,8 +21,8 @@ set(INC
../../blenkernel
../../blenlib
../../blentranslation
- ../../depsgraph
../../bmesh
+ ../../depsgraph
../../gpu
../../imbuf
../../makesdna
@@ -30,8 +30,8 @@ set(INC
../../render/extern/include
../../windowmanager
../../../../intern/clog
- ../../../../intern/guardedalloc
../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
)
set(INC_SYS
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index f342cc3a809..990250792a1 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -65,8 +65,9 @@ void paintface_flush_flags(struct bContext *C, Object *ob, short flag)
BLI_assert((flag & ~(SELECT | ME_HIDE)) == 0);
- if (me == NULL)
+ if (me == NULL) {
return;
+ }
/* note, call #BKE_mesh_flush_hidden_from_verts_ex first when changing hidden flags */
@@ -120,7 +121,7 @@ void paintface_flush_flags(struct bContext *C, Object *ob, short flag)
BKE_mesh_batch_cache_dirty_tag(me_eval, BKE_MESH_BATCH_DIRTY_ALL);
}
else {
- BKE_mesh_batch_cache_dirty_tag(me_eval, BKE_MESH_BATCH_DIRTY_SELECT);
+ BKE_mesh_batch_cache_dirty_tag(me_eval, BKE_MESH_BATCH_DIRTY_SELECT_PAINT);
}
DEG_id_tag_update(ob->data, ID_RECALC_SELECT);
@@ -139,8 +140,9 @@ void paintface_hide(bContext *C, Object *ob, const bool unselected)
int a;
me = BKE_mesh_from_object(ob);
- if (me == NULL || me->totpoly == 0)
+ if (me == NULL || me->totpoly == 0) {
return;
+ }
mpoly = me->mpoly;
a = me->totpoly;
@@ -170,8 +172,9 @@ void paintface_reveal(bContext *C, Object *ob, const bool select)
int a;
me = BKE_mesh_from_object(ob);
- if (me == NULL || me->totpoly == 0)
+ if (me == NULL || me->totpoly == 0) {
return;
+ }
mpoly = me->mpoly;
a = me->totpoly;
@@ -227,8 +230,9 @@ static void select_linked_tfaces_with_seams(Mesh *me, const unsigned int index,
/* expand selection */
mp = me->mpoly;
for (a = 0; a < me->totpoly; a++, mp++) {
- if (mp->flag & ME_HIDE)
+ if (mp->flag & ME_HIDE) {
continue;
+ }
if (!BLI_BITMAP_TEST(poly_tag, a)) {
mark = false;
@@ -269,8 +273,9 @@ void paintface_select_linked(bContext *C, Object *ob, const int mval[2], const b
unsigned int index = (unsigned int)-1;
me = BKE_mesh_from_object(ob);
- if (me == NULL || me->totpoly == 0)
+ if (me == NULL || me->totpoly == 0) {
return;
+ }
if (mval) {
if (!ED_mesh_pick_face(C, ob, mval, ED_MESH_PICK_DEFAULT_FACE_DIST, &index)) {
@@ -364,8 +369,9 @@ bool paintface_minmax(Object *ob, float r_min[3], float r_max[3])
mvert = me->mvert;
mp = me->mpoly;
for (a = me->totpoly; a > 0; a--, mp++) {
- if (mp->flag & ME_HIDE || !(mp->flag & ME_FACE_SEL))
+ if (mp->flag & ME_HIDE || !(mp->flag & ME_FACE_SEL)) {
continue;
+ }
ml = me->mloop + mp->totloop;
for (b = 0; b < mp->totloop; b++, ml++) {
@@ -399,8 +405,9 @@ bool paintface_mouse_select(
}
mpoly_sel = me->mpoly + index;
- if (mpoly_sel->flag & ME_HIDE)
+ if (mpoly_sel->flag & ME_HIDE) {
return false;
+ }
/* clear flags */
if (!extend && !deselect && !toggle) {
@@ -416,10 +423,12 @@ bool paintface_mouse_select(
mpoly_sel->flag &= ~ME_FACE_SEL;
}
else if (toggle) {
- if (mpoly_sel->flag & ME_FACE_SEL)
+ if (mpoly_sel->flag & ME_FACE_SEL) {
mpoly_sel->flag &= ~ME_FACE_SEL;
- else
+ }
+ else {
mpoly_sel->flag |= ME_FACE_SEL;
+ }
}
else {
mpoly_sel->flag |= ME_FACE_SEL;
@@ -512,15 +521,17 @@ void paintvert_flush_flags(Object *ob)
int totvert;
int i;
- if (me == NULL)
+ if (me == NULL) {
return;
+ }
/* we could call this directly in all areas that change selection,
* since this could become slow for realtime updates (circle-select for eg) */
BKE_mesh_flush_select_from_verts(me);
- if (me_eval == NULL)
+ if (me_eval == NULL) {
return;
+ }
index_array = CustomData_get_layer(&me_eval->vdata, CD_ORIGINDEX);
diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c
index 815f51a4772..a7d1e54ad59 100644
--- a/source/blender/editors/mesh/editmesh_add.c
+++ b/source/blender/editors/mesh/editmesh_add.c
@@ -490,8 +490,8 @@ void MESH_OT_primitive_grid_add(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
- /* Note that if you use MESH_ADD_VERTS_MAXI for both x and y at the same time you will still reach
- * impossible values (10^12 vertices or so...). */
+ /* Note that if you use MESH_ADD_VERTS_MAXI for both x and y at the same time
+ * you will still reach impossible values (10^12 vertices or so...). */
RNA_def_int(
ot->srna, "x_subdivisions", 10, 2, MESH_ADD_VERTS_MAXI, "X Subdivisions", "", 2, 1000);
RNA_def_int(
diff --git a/source/blender/editors/mesh/editmesh_add_gizmo.c b/source/blender/editors/mesh/editmesh_add_gizmo.c
index 9ed2c15f1c1..839ee186016 100644
--- a/source/blender/editors/mesh/editmesh_add_gizmo.c
+++ b/source/blender/editors/mesh/editmesh_add_gizmo.c
@@ -58,7 +58,8 @@
* When we place a shape, pick a plane.
*
* We may base this choice on context,
- * for now pick the "ground" based on the 3D cursor's dominant plane pointing down relative to the view.
+ * for now pick the "ground" based on the 3D cursor's dominant plane
+ * pointing down relative to the view.
*/
static void calc_initial_placement_point_from_view(bContext *C,
const float mval[2],
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c
index 2c0c8b2c708..f6940cae953 100644
--- a/source/blender/editors/mesh/editmesh_bevel.c
+++ b/source/blender/editors/mesh/editmesh_bevel.c
@@ -120,10 +120,12 @@ static float get_bevel_offset(wmOperator *op)
{
float val;
- if (RNA_enum_get(op->ptr, "offset_type") == BEVEL_AMT_PERCENT)
+ if (RNA_enum_get(op->ptr, "offset_type") == BEVEL_AMT_PERCENT) {
val = RNA_float_get(op->ptr, "offset_pct");
- else
+ }
+ else {
val = RNA_float_get(op->ptr, "offset");
+ }
return val;
}
@@ -491,7 +493,8 @@ static int edbm_bevel_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* for OFFSET_VALUE only, the scale is the size of a pixel under the mouse in 3d space */
opdata->scale[OFFSET_VALUE] = rv3d ? ED_view3d_pixel_size(rv3d, center_3d) : 1.0f;
- /* since we are affecting untransformed object but seeing in transformed space, compensate for that */
+ /* since we are affecting untransformed object but seeing in transformed space,
+ * compensate for that */
opdata->scale[OFFSET_VALUE] /= opdata->max_obj_scale;
edbm_bevel_calc_initial_length(op, event, false);
@@ -578,10 +581,12 @@ static bool edbm_bevel_poll_property(const bContext *UNUSED(C),
if (STRPREFIX(prop_id, "offset")) {
int offset_type = RNA_enum_get(op->ptr, "offset_type");
- if (STREQ(prop_id, "offset") && offset_type == BEVEL_AMT_PERCENT)
+ if (STREQ(prop_id, "offset") && offset_type == BEVEL_AMT_PERCENT) {
return false;
- else if (STREQ(prop_id, "offset_pct") && offset_type != BEVEL_AMT_PERCENT)
+ }
+ else if (STREQ(prop_id, "offset_pct") && offset_type != BEVEL_AMT_PERCENT) {
return false;
+ }
}
return true;
@@ -647,8 +652,9 @@ wmKeyMap *bevel_modal_keymap(wmKeyConfig *keyconf)
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Bevel Modal Map");
/* this function is called for each spacetype, only needs to add map once */
- if (keymap && keymap->modal_items)
+ if (keymap && keymap->modal_items) {
return NULL;
+ }
keymap = WM_modalkeymap_add(keyconf, "Bevel Modal Map", modal_items);
@@ -688,10 +694,12 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
else if (etype == MOUSEPAN) {
float delta = 0.02f * (event->y - event->prevy);
- if (opdata->segments >= 1 && opdata->segments + delta < 1)
+ if (opdata->segments >= 1 && opdata->segments + delta < 1) {
opdata->segments = 1;
- else
+ }
+ else {
opdata->segments += delta;
+ }
RNA_int_set(op->ptr, "segments", (int)opdata->segments);
edbm_bevel_calc(op);
edbm_bevel_update_header(C, op);
@@ -732,13 +740,16 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (type > BEVEL_AMT_PERCENT) {
type = BEVEL_AMT_OFFSET;
}
- if (opdata->value_mode == OFFSET_VALUE && type == BEVEL_AMT_PERCENT)
+ if (opdata->value_mode == OFFSET_VALUE && type == BEVEL_AMT_PERCENT) {
opdata->value_mode = OFFSET_VALUE_PERCENT;
- else if (opdata->value_mode == OFFSET_VALUE_PERCENT && type != BEVEL_AMT_PERCENT)
+ }
+ else if (opdata->value_mode == OFFSET_VALUE_PERCENT && type != BEVEL_AMT_PERCENT) {
opdata->value_mode = OFFSET_VALUE;
+ }
RNA_enum_set(op->ptr, "offset_type", type);
- if (opdata->initial_length[opdata->value_mode] == -1.0f)
+ if (opdata->initial_length[opdata->value_mode] == -1.0f) {
edbm_bevel_calc_initial_length(op, event, true);
+ }
}
/* Update offset accordingly to new offset_type. */
if (!has_numinput &&
@@ -804,10 +815,12 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
case BEV_MODAL_INNER_MITER_CHANGE: {
int miter_inner = RNA_enum_get(op->ptr, "miter_inner");
miter_inner++;
- if (miter_inner == BEVEL_MITER_PATCH)
+ if (miter_inner == BEVEL_MITER_PATCH) {
miter_inner++; /* no patch option for inner miter */
- if (miter_inner > BEVEL_MITER_ARC)
+ }
+ if (miter_inner > BEVEL_MITER_ARC) {
miter_inner = BEVEL_MITER_SHARP;
+ }
RNA_enum_set(op->ptr, "miter_inner", miter_inner);
edbm_bevel_calc(op);
edbm_bevel_update_header(C, op);
@@ -818,8 +831,9 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
case BEV_MODAL_OUTER_MITER_CHANGE: {
int miter_outer = RNA_enum_get(op->ptr, "miter_outer");
miter_outer++;
- if (miter_outer > BEVEL_MITER_ARC)
+ if (miter_outer > BEVEL_MITER_ARC) {
miter_outer = BEVEL_MITER_SHARP;
+ }
RNA_enum_set(op->ptr, "miter_outer", miter_outer);
edbm_bevel_calc(op);
edbm_bevel_update_header(C, op);
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c
index eeda7ec5f2d..82cff8363f8 100644
--- a/source/blender/editors/mesh/editmesh_extrude.c
+++ b/source/blender/editors/mesh/editmesh_extrude.c
@@ -347,28 +347,37 @@ static bool edbm_extrude_mesh(Object *obedit, BMEditMesh *em, wmOperator *op)
bool changed = false;
if (em->selectmode & SCE_SELECT_VERTEX) {
- if (em->bm->totvertsel == 0)
+ if (em->bm->totvertsel == 0) {
nr = NONE;
- else if (em->bm->totvertsel == 1)
+ }
+ else if (em->bm->totvertsel == 1) {
nr = VERT_ONLY;
- else if (em->bm->totedgesel == 0)
+ }
+ else if (em->bm->totedgesel == 0) {
nr = VERT_ONLY;
- else
+ }
+ else {
nr = ELEM_FLAG;
+ }
}
else if (em->selectmode & SCE_SELECT_EDGE) {
- if (em->bm->totedgesel == 0)
+ if (em->bm->totedgesel == 0) {
nr = NONE;
- else if (em->bm->totfacesel == 0)
+ }
+ else if (em->bm->totfacesel == 0) {
nr = EDGE_ONLY;
- else
+ }
+ else {
nr = ELEM_FLAG;
+ }
}
else {
- if (em->bm->totfacesel == 0)
+ if (em->bm->totfacesel == 0) {
nr = NONE;
- else
+ }
+ else {
nr = ELEM_FLAG;
+ }
}
switch (nr) {
@@ -431,7 +440,7 @@ void MESH_OT_extrude_region(wmOperatorType *ot)
ot->description = "Extrude region of faces";
/* api callbacks */
- //ot->invoke = mesh_extrude_region_invoke;
+ // ot->invoke = mesh_extrude_region_invoke;
ot->exec = edbm_extrude_region_exec;
ot->poll = ED_operator_editmesh;
diff --git a/source/blender/editors/mesh/editmesh_extrude_screw.c b/source/blender/editors/mesh/editmesh_extrude_screw.c
index c9422545c7b..252f95a10ac 100644
--- a/source/blender/editors/mesh/editmesh_extrude_screw.c
+++ b/source/blender/editors/mesh/editmesh_extrude_screw.c
@@ -125,8 +125,9 @@ static int edbm_screw_exec(bContext *C, wmOperator *op)
sub_v3_v3v3(dvec, v1_co_global, v2_co_global);
mul_v3_fl(dvec, 1.0f / steps);
- if (dot_v3v3(nor, dvec) > 0.0f)
+ if (dot_v3v3(nor, dvec) > 0.0f) {
negate_v3(dvec);
+ }
BMOperator spinop;
if (!EDBM_op_init(
diff --git a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
index 85be7d902ad..269ead7b23f 100644
--- a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
+++ b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
@@ -1018,7 +1018,8 @@ static void gizmo_mesh_spin_redo_draw_prepare(const bContext *UNUSED(C), wmGizmo
ggd->data.op = WM_operator_last_redo((bContext *)ggd->data.context);
}
- /* Not essential, just avoids feedback loop where matrices could shift because of float precision.
+ /* Not essential, just avoids feedback loop where matrices
+ * could shift because of float precision.
* Updates in this case are also redundant. */
bool is_modal = false;
for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) {
diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c
index 7bee030bb46..2955488a597 100644
--- a/source/blender/editors/mesh/editmesh_inset.c
+++ b/source/blender/editors/mesh/editmesh_inset.c
@@ -91,8 +91,9 @@ static void edbm_inset_update_header(wmOperator *op, bContext *C)
if (sa) {
char flts_str[NUM_STR_REP_LEN * 2];
- if (hasNumInput(&opdata->num_input))
+ if (hasNumInput(&opdata->num_input)) {
outputNumInput(&opdata->num_input, flts_str, &sce->unit);
+ }
else {
BLI_snprintf(flts_str, NUM_STR_REP_LEN, "%f", RNA_float_get(op->ptr, "thickness"));
BLI_snprintf(
@@ -413,18 +414,21 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
/* Fake shift-transform... */
- if (opdata->shift)
+ if (opdata->shift) {
amount = (amount - opdata->shift_amount) * 0.1f + opdata->shift_amount;
+ }
- if (opdata->modify_depth)
+ if (opdata->modify_depth) {
RNA_float_set(op->ptr, "depth", amount);
+ }
else {
amount = max_ff(amount, 0.0f);
RNA_float_set(op->ptr, "thickness", amount);
}
- if (edbm_inset_calc(op))
+ if (edbm_inset_calc(op)) {
edbm_inset_update_header(op, C);
+ }
else {
edbm_inset_cancel(C, op);
return OPERATOR_CANCELLED;
@@ -446,10 +450,12 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event)
case LEFTSHIFTKEY:
case RIGHTSHIFTKEY:
if (event->val == KM_PRESS) {
- if (opdata->modify_depth)
+ if (opdata->modify_depth) {
opdata->shift_amount = RNA_float_get(op->ptr, "depth");
- else
+ }
+ else {
opdata->shift_amount = RNA_float_get(op->ptr, "thickness");
+ }
opdata->shift = true;
handled = true;
}
@@ -469,14 +475,16 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (event->val == KM_PRESS) {
opdata->old_thickness = RNA_float_get(op->ptr, "thickness");
- if (opdata->shift)
+ if (opdata->shift) {
opdata->shift_amount = opdata->old_thickness;
+ }
opdata->modify_depth = true;
}
else {
opdata->old_depth = RNA_float_get(op->ptr, "depth");
- if (opdata->shift)
+ if (opdata->shift) {
opdata->shift_amount = opdata->old_depth;
+ }
opdata->modify_depth = false;
}
opdata->initial_length = len_v2(mlen);
diff --git a/source/blender/editors/mesh/editmesh_intersect.c b/source/blender/editors/mesh/editmesh_intersect.c
index 06e2ef6e304..370cc6a2a6d 100644
--- a/source/blender/editors/mesh/editmesh_intersect.c
+++ b/source/blender/editors/mesh/editmesh_intersect.c
@@ -512,12 +512,15 @@ static int bm_edge_sort_length_cb(const void *e_a_v, const void *e_b_v)
const float val_a = -BM_edge_calc_length_squared(*((BMEdge **)e_a_v));
const float val_b = -BM_edge_calc_length_squared(*((BMEdge **)e_b_v));
- if (val_a > val_b)
+ if (val_a > val_b) {
return 1;
- else if (val_a < val_b)
+ }
+ else if (val_a < val_b) {
return -1;
- else
+ }
+ else {
return 0;
+ }
}
static void bm_face_split_by_edges_island_connect(
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index f4979c8f2a8..cc0c2f5bbe4 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -157,7 +157,7 @@ typedef struct KnifeTool_OpData {
void *draw_handle; /* for drawing preview loop */
ViewContext vc; /* note: _don't_ use 'mval', instead use the one we define below */
float mval[2]; /* mouse value with snapping applied */
- //bContext *C;
+ // bContext *C;
Scene *scene;
Object *ob;
@@ -366,8 +366,9 @@ static Ref *find_ref(ListBase *lb, void *ref)
Ref *ref1;
for (ref1 = lb->first; ref1; ref1 = ref1->next) {
- if (ref1->ref == ref)
+ if (ref1->ref == ref) {
return ref1;
+ }
}
return NULL;
@@ -375,8 +376,9 @@ static Ref *find_ref(ListBase *lb, void *ref)
static void knife_append_list_no_dup(KnifeTool_OpData *kcd, ListBase *lst, void *elem)
{
- if (!find_ref(lst, elem))
+ if (!find_ref(lst, elem)) {
knife_append_list(kcd, lst, elem);
+ }
}
static KnifeEdge *new_knife_edge(KnifeTool_OpData *kcd)
@@ -410,8 +412,9 @@ static BMFace *knife_find_common_face(ListBase *faces1, ListBase *faces2)
for (ref1 = faces1->first; ref1; ref1 = ref1->next) {
for (ref2 = faces2->first; ref2; ref2 = ref2->next) {
- if (ref1->ref == ref2->ref)
+ if (ref1->ref == ref2->ref) {
return (BMFace *)(ref1->ref);
+ }
}
}
return NULL;
@@ -441,10 +444,12 @@ static KnifeVert *get_bm_knife_vert(KnifeTool_OpData *kcd, BMVert *v)
BMIter bmiter;
BMFace *f;
- if (BM_elem_index_get(v) >= 0)
+ if (BM_elem_index_get(v) >= 0) {
cageco = kcd->cagecos[BM_elem_index_get(v)];
- else
+ }
+ else {
cageco = v->co;
+ }
kfv = new_knife_vert(kcd, v->co, cageco);
kfv->v = v;
BLI_ghash_insert(kcd->origvertmap, v, kfv);
@@ -493,8 +498,9 @@ static void set_lowest_face_tri(KnifeTool_OpData *kcd, BMFace *f, int index)
{
int i;
- if (BLI_ghash_lookup(kcd->facetrimap, f))
+ if (BLI_ghash_lookup(kcd->facetrimap, f)) {
return;
+ }
BLI_assert(index >= 0 && index < kcd->em->tottri);
BLI_assert(kcd->em->looptris[index][0]->f == f);
@@ -504,8 +510,9 @@ static void set_lowest_face_tri(KnifeTool_OpData *kcd, BMFace *f, int index)
break;
}
}
- if (i == -1)
+ if (i == -1) {
i++;
+ }
BLI_ghash_insert(kcd->facetrimap, f, POINTER_FROM_INT(i + 1));
}
@@ -594,8 +601,9 @@ static KnifeVert *knife_split_edge(KnifeTool_OpData *kcd,
* If v1 and v2 are in multiple faces together (e.g., if they
* are in doubled polys) then this arbitrarily chooses one of them */
f = knife_find_common_face(&kfe->v1->faces, &kfe->v2->faces);
- if (f)
+ if (f) {
knife_append_list(kcd, &newkfe->v2->faces, f);
+ }
}
newkfe->basef = kfe->basef;
@@ -605,8 +613,9 @@ static KnifeVert *knife_split_edge(KnifeTool_OpData *kcd,
kfe->v1 = newkfe->v2;
BLI_addtail(&kfe->v1->edges, ref);
- for (ref = kfe->faces.first; ref; ref = ref->next)
+ for (ref = kfe->faces.first; ref; ref = ref->next) {
knife_edge_append_face(kcd, newkfe, ref->ref);
+ }
knife_add_to_vert_edges(kcd, newkfe);
@@ -637,22 +646,29 @@ static int linehit_compare(const void *vlh1, const void *vlh2)
const KnifeLineHit *lh1 = vlh1;
const KnifeLineHit *lh2 = vlh2;
- if (lh1->l < lh2->l)
+ if (lh1->l < lh2->l) {
return -1;
- else if (lh1->l > lh2->l)
+ }
+ else if (lh1->l > lh2->l) {
return 1;
+ }
else {
- if (lh1->m < lh2->m)
+ if (lh1->m < lh2->m) {
return -1;
- else if (lh1->m > lh2->m)
+ }
+ else if (lh1->m > lh2->m) {
return 1;
+ }
else {
- if (lh1->v < lh2->v)
+ if (lh1->v < lh2->v) {
return -1;
- else if (lh1->v > lh2->v)
+ }
+ else if (lh1->v > lh2->v) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
}
}
@@ -670,8 +686,9 @@ static void prepare_linehits_for_cut(KnifeTool_OpData *kcd)
n = kcd->totlinehit;
linehits = kcd->linehits;
- if (n == 0)
+ if (n == 0) {
return;
+ }
qsort(linehits, n, sizeof(KnifeLineHit), linehit_compare);
@@ -725,8 +742,9 @@ static void prepare_linehits_for_cut(KnifeTool_OpData *kcd)
memcpy(&linehits[i], &linehits[j], sizeof(KnifeLineHit));
}
else {
- if (i + 1 != j)
+ if (i + 1 != j) {
memcpy(&linehits[i + 1], &linehits[j], sizeof(KnifeLineHit));
+ }
i++;
}
j++;
@@ -851,8 +869,9 @@ static void knife_add_single_cut(KnifeTool_OpData *kcd,
knife_add_to_vert_edges(kcd, kfe);
/* TODO: check if this is ever needed */
- if (kfe->basef && !find_ref(&kfe->faces, kfe->basef))
+ if (kfe->basef && !find_ref(&kfe->faces, kfe->basef)) {
knife_edge_append_face(kcd, kfe, kfe->basef);
+ }
}
/* Given a list of KnifeLineHits for one face, sorted by l
@@ -863,8 +882,9 @@ static void knife_cut_face(KnifeTool_OpData *kcd, BMFace *f, ListBase *hits)
{
Ref *r;
- if (BLI_listbase_count_at_most(hits, 2) != 2)
+ if (BLI_listbase_count_at_most(hits, 2) != 2) {
return;
+ }
for (r = hits->first; r->next; r = r->next) {
knife_add_single_cut(kcd, r->ref, r->next->ref, f);
@@ -1167,8 +1187,9 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void
BLI_mempool_iternew(kcd->kedges, &iter);
for (kfe = BLI_mempool_iterstep(&iter); kfe; kfe = BLI_mempool_iterstep(&iter)) {
- if (!kfe->is_cut)
+ if (!kfe->is_cut) {
continue;
+ }
immVertex3fv(pos, kfe->v1->cageco);
immVertex3fv(pos, kfe->v2->cageco);
@@ -1191,8 +1212,9 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void
BLI_mempool_iternew(kcd->kverts, &iter);
for (kfv = BLI_mempool_iterstep(&iter); kfv; kfv = BLI_mempool_iterstep(&iter)) {
- if (!kfv->is_cut)
+ if (!kfv->is_cut) {
continue;
+ }
immVertex3fv(pos, kfv->cageco);
}
@@ -1249,8 +1271,9 @@ static bool knife_ray_intersect_face(KnifeTool_OpData *kcd,
float ray_tri_uv[2];
tri = kcd->em->looptris[tri_i];
- if (tri[0]->f != f)
+ if (tri[0]->f != f) {
break;
+ }
lv1 = kcd->cagecos[BM_elem_index_get(tri[0]->v)];
lv2 = kcd->cagecos[BM_elem_index_get(tri[1]->v)];
lv3 = kcd->cagecos[BM_elem_index_get(tri[2]->v)];
@@ -1594,8 +1617,9 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
* (which may involve using doubles everywhere!),
* limit the distance between these points */
if (kcd->is_ortho && (kcd->vc.rv3d->persp != RV3D_CAMOB)) {
- if (kcd->ortho_extent == 0.0f)
+ if (kcd->ortho_extent == 0.0f) {
calc_ortho_extent(kcd);
+ }
clip_to_ortho_planes(v1, v3, kcd->ortho_extent_center, kcd->ortho_extent + 10.0f);
clip_to_ortho_planes(v2, v4, kcd->ortho_extent_center, kcd->ortho_extent + 10.0f);
}
@@ -1642,8 +1666,9 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
lst = knife_get_face_kedges(kcd, f);
for (ref = lst->first; ref; ref = ref->next) {
kfe = ref->ref;
- if (BLI_smallhash_haskey(&kfes, (uintptr_t)kfe))
+ if (BLI_smallhash_haskey(&kfes, (uintptr_t)kfe)) {
continue;
+ }
BLI_smallhash_insert(&kfes, (uintptr_t)kfe, kfe);
v = kfe->v1;
BLI_smallhash_reinsert(&kfvs, (uintptr_t)v, v);
@@ -1653,7 +1678,8 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
}
/* Now go through the candidates and find intersections */
- /* These tolerances, in screen space, are for intermediate hits, as ends are already snapped to screen */
+ /* These tolerances, in screen space, are for intermediate hits,
+ * as ends are already snapped to screen. */
if (kcd->is_interactive) {
vert_tol = KNIFE_FLT_EPS_PX_VERT;
@@ -1663,8 +1689,8 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
else {
/* Use 1/100th of a pixel, see T43896 (too big), T47910 (too small).
*
- * Update, leave this as is until we investigate not using pixel coords for geometry calculations: T48023
- */
+ * Update, leave this as is until we investigate not using pixel coords
+ * for geometry calculations: T48023. */
vert_tol = line_tol = face_tol = 0.5f;
}
@@ -1724,12 +1750,14 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
if (isect_kind == -1) {
/* isect_seg_seg_v2_simple doesn't do tolerance test around ends of s1-s2 */
closest_to_line_segment_v2(sint, s1, se1, se2);
- if (len_squared_v2v2(sint, s1) <= line_tol_sq)
+ if (len_squared_v2v2(sint, s1) <= line_tol_sq) {
isect_kind = 1;
+ }
else {
closest_to_line_segment_v2(sint, s2, se1, se2);
- if (len_squared_v2v2(sint, s2) <= line_tol_sq)
+ if (len_squared_v2v2(sint, s2) <= line_tol_sq) {
isect_kind = 1;
+ }
}
}
if (isect_kind == 1) {
@@ -1808,8 +1836,9 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
BLI_smallhash_release(&kfes);
BLI_smallhash_release(&kfvs);
BLI_bvhtree_free(planetree);
- if (results)
+ if (results) {
MEM_freeN(results);
+ }
}
static void knife_input_ray_segment(KnifeTool_OpData *kcd,
@@ -1851,8 +1880,9 @@ static BMFace *knife_find_closest_face(KnifeTool_OpData *kcd,
f = NULL;
}
- if (is_space)
+ if (is_space) {
*is_space = !f;
+ }
if (!f) {
if (kcd->is_interactive) {
@@ -2024,8 +2054,9 @@ static KnifeEdge *knife_find_closest_edge(
copy_v3_v3(cur_cagep, test_cagep);
}
- if (fptr)
+ if (fptr) {
*fptr = f;
+ }
if (cure) {
if (!kcd->ignore_edge_snapping || !(cure->e)) {
@@ -2055,8 +2086,9 @@ static KnifeEdge *knife_find_closest_edge(
return cure;
}
- if (fptr)
+ if (fptr) {
*fptr = NULL;
+ }
return NULL;
}
@@ -2132,8 +2164,9 @@ static KnifeVert *knife_find_closest_vert(
}
if (!kcd->ignore_vert_snapping || !(curv && curv->v)) {
- if (fptr)
+ if (fptr) {
*fptr = f;
+ }
if (curv) {
copy_v3_v3(p, curv->co);
@@ -2148,15 +2181,17 @@ static KnifeVert *knife_find_closest_vert(
return curv;
}
else {
- if (fptr)
+ if (fptr) {
*fptr = f;
+ }
return NULL;
}
}
- if (fptr)
+ if (fptr) {
*fptr = NULL;
+ }
return NULL;
}
@@ -2261,12 +2296,15 @@ static int sort_verts_by_dist_cb(void *co_p, const void *cur_a_p, const void *cu
const float a_sq = len_squared_v3v3(co, cur_a->co);
const float b_sq = len_squared_v3v3(co, cur_b->co);
- if (a_sq < b_sq)
+ if (a_sq < b_sq) {
return -1;
- else if (a_sq > b_sq)
+ }
+ else if (a_sq > b_sq) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
static bool knife_verts_edge_in_face(KnifeVert *v1, KnifeVert *v2, BMFace *f)
@@ -2275,8 +2313,9 @@ static bool knife_verts_edge_in_face(KnifeVert *v1, KnifeVert *v2, BMFace *f)
bool v1_inface, v2_inface;
BMLoop *l1, *l2;
- if (!f || !v1 || !v2)
+ if (!f || !v1 || !v2) {
return false;
+ }
l1 = v1->v ? BM_face_vert_share_loop(f, v1->v) : NULL;
l2 = v2->v ? BM_face_vert_share_loop(f, v2->v) : NULL;
@@ -2453,8 +2492,9 @@ static void knife_make_cuts(KnifeTool_OpData *kcd)
}
f = kfe->basef;
- if (!f || kfe->e)
+ if (!f || kfe->e) {
continue;
+ }
lst = BLI_smallhash_lookup(fhash, (uintptr_t)f);
if (!lst) {
lst = knife_empty_list(kcd);
@@ -2466,21 +2506,24 @@ static void knife_make_cuts(KnifeTool_OpData *kcd)
/* put list of splitting vertices for an edge into ehash, keyed by edge */
BLI_mempool_iternew(kcd->kverts, &iter);
for (kfv = BLI_mempool_iterstep(&iter); kfv; kfv = BLI_mempool_iterstep(&iter)) {
- if (kfv->v)
+ if (kfv->v) {
continue; /* already have a BMVert */
+ }
for (ref = kfv->edges.first; ref; ref = ref->next) {
kfe = ref->ref;
e = kfe->e;
- if (!e)
+ if (!e) {
continue;
+ }
lst = BLI_smallhash_lookup(ehash, (uintptr_t)e);
if (!lst) {
lst = knife_empty_list(kcd);
BLI_smallhash_insert(ehash, (uintptr_t)e, lst);
}
/* there can be more than one kfe in kfv's list with same e */
- if (!find_ref(lst, kfv))
+ if (!find_ref(lst, kfv)) {
knife_append_list(kcd, lst, kfv);
+ }
}
}
@@ -2544,8 +2587,9 @@ static void knife_recalc_projmat(KnifeTool_OpData *kcd)
/* called when modal loop selection is done... */
static void knifetool_exit_ex(bContext *C, KnifeTool_OpData *kcd)
{
- if (!kcd)
+ if (!kcd) {
return;
+ }
if (kcd->is_interactive) {
WM_cursor_modal_restore(CTX_wm_window(C));
@@ -2575,8 +2619,9 @@ static void knifetool_exit_ex(bContext *C, KnifeTool_OpData *kcd)
knifetool_free_bmbvh(kcd);
- if (kcd->linehits)
+ if (kcd->linehits) {
MEM_freeN(kcd->linehits);
+ }
/* destroy kcd itself */
MEM_freeN(kcd);
@@ -2773,8 +2818,9 @@ wmKeyMap *knifetool_modal_keymap(wmKeyConfig *keyconf)
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Knife Tool Modal Map");
/* this function is called for each spacetype, only needs to add map once */
- if (keymap && keymap->modal_items)
+ if (keymap && keymap->modal_items) {
return NULL;
+ }
keymap = WM_modalkeymap_add(keyconf, "Knife Tool Modal Map", modal_items);
@@ -2801,8 +2847,9 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event)
view3d_operator_needs_opengl(C);
ED_view3d_init_mats_rv3d(obedit, kcd->vc.rv3d); /* needed to initialize clipping */
- if (kcd->mode == MODE_PANNING)
+ if (kcd->mode == MODE_PANNING) {
kcd->mode = kcd->prevmode;
+ }
/* handle modal keymap */
if (event->type == EVT_MODAL_MAP) {
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index d0988811d15..528235e693a 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -545,8 +545,9 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
case RETKEY:
case PADENTER:
case LEFTMOUSE: /* confirm */ // XXX hardcoded
- if (event->val == KM_PRESS)
+ if (event->val == KM_PRESS) {
return loopcut_finish(lcd, C, op);
+ }
ED_region_tag_redraw(lcd->ar);
handled = true;
@@ -573,8 +574,9 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
case MOUSEPAN:
if (event->alt == 0) {
cuts += 0.02f * (event->y - event->prevy);
- if (cuts < 1 && lcd->cuts >= 1)
+ if (cuts < 1 && lcd->cuts >= 1) {
cuts = 1;
+ }
}
else {
smoothness += 0.002f * (event->y - event->prevy);
@@ -584,8 +586,9 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
case PADPLUSKEY:
case PAGEUPKEY:
case WHEELUPMOUSE: /* change number of cuts */
- if (event->val == KM_RELEASE)
+ if (event->val == KM_RELEASE) {
break;
+ }
if (event->alt == 0) {
cuts += 1;
}
@@ -597,8 +600,9 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
case PADMINUS:
case PAGEDOWNKEY:
case WHEELDOWNMOUSE: /* change number of cuts */
- if (event->val == KM_RELEASE)
+ if (event->val == KM_RELEASE) {
break;
+ }
if (event->alt == 0) {
cuts = max_ff(cuts - 1, 1);
}
diff --git a/source/blender/editors/mesh/editmesh_path.c b/source/blender/editors/mesh/editmesh_path.c
index c6b1ab9f1f2..f8ec4334427 100644
--- a/source/blender/editors/mesh/editmesh_path.c
+++ b/source/blender/editors/mesh/editmesh_path.c
@@ -281,10 +281,12 @@ static void edgetag_set_cb(BMEdge *e, bool val, void *user_data_v)
case EDGE_MODE_TAG_FREESTYLE: {
FreestyleEdge *fed;
fed = CustomData_bmesh_get(&bm->edata, e->head.data, CD_FREESTYLE_EDGE);
- if (!val)
+ if (!val) {
fed->flag &= ~FREESTYLE_EDGE_MARK;
- else
+ }
+ else {
fed->flag |= FREESTYLE_EDGE_MARK;
+ }
break;
}
#endif
@@ -396,8 +398,9 @@ static void mouse_mesh_shortest_path_edge(Scene *UNUSED(scene),
if (op_params->edge_mode != EDGE_MODE_SELECT) {
if (op_params->track_active) {
/* simple rules - last edge is _always_ active and selected */
- if (e_act)
+ if (e_act) {
BM_edge_select_set(bm, e_act, false);
+ }
BM_edge_select_set(bm, e_dst_last, true);
BM_select_history_store(bm, e_dst_last);
}
@@ -408,10 +411,12 @@ static void mouse_mesh_shortest_path_edge(Scene *UNUSED(scene),
if (op_params->track_active) {
/* even if this is selected it may not be in the selection list */
if (op_params->edge_mode == EDGE_MODE_SELECT) {
- if (edgetag_test_cb(e_dst_last, &user_data) == 0)
+ if (edgetag_test_cb(e_dst_last, &user_data) == 0) {
BM_select_history_remove(bm, e_dst_last);
- else
+ }
+ else {
BM_select_history_store(bm, e_dst_last);
+ }
}
}
@@ -429,12 +434,12 @@ static bool facetag_filter_cb(BMFace *f, void *UNUSED(user_data_v))
{
return !BM_elem_flag_test(f, BM_ELEM_HIDDEN);
}
-//static bool facetag_test_cb(Scene *UNUSED(scene), BMesh *UNUSED(bm), BMFace *f)
+// static bool facetag_test_cb(Scene *UNUSED(scene), BMesh *UNUSED(bm), BMFace *f)
static bool facetag_test_cb(BMFace *f, void *UNUSED(user_data_v))
{
return BM_elem_flag_test_bool(f, BM_ELEM_SELECT);
}
-//static void facetag_set_cb(BMesh *bm, Scene *UNUSED(scene), BMFace *f, const bool val)
+// static void facetag_set_cb(BMesh *bm, Scene *UNUSED(scene), BMFace *f, const bool val)
static void facetag_set_cb(BMFace *f, bool val, void *user_data_v)
{
struct UserData *user_data = user_data_v;
@@ -777,12 +782,15 @@ static int edbm_shortest_path_select_exec(bContext *C, wmOperator *op)
if ((em->selectmode & SCE_SELECT_VERTEX) && (bm->totvertsel >= 2)) {
BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
- if (ele_src == NULL)
+ if (ele_src == NULL) {
ele_src = ele;
- else if (ele_dst == NULL)
+ }
+ else if (ele_dst == NULL) {
ele_dst = ele;
- else
+ }
+ else {
break;
+ }
}
}
}
@@ -791,12 +799,15 @@ static int edbm_shortest_path_select_exec(bContext *C, wmOperator *op)
ele_src = NULL;
BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
- if (ele_src == NULL)
+ if (ele_src == NULL) {
ele_src = ele;
- else if (ele_dst == NULL)
+ }
+ else if (ele_dst == NULL) {
ele_dst = ele;
- else
+ }
+ else {
break;
+ }
}
}
}
@@ -805,12 +816,15 @@ static int edbm_shortest_path_select_exec(bContext *C, wmOperator *op)
ele_src = NULL;
BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) {
if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
- if (ele_src == NULL)
+ if (ele_src == NULL) {
ele_src = ele;
- else if (ele_dst == NULL)
+ }
+ else if (ele_dst == NULL) {
ele_dst = ele;
- else
+ }
+ else {
break;
+ }
}
}
}
diff --git a/source/blender/editors/mesh/editmesh_preselect_edgering.c b/source/blender/editors/mesh/editmesh_preselect_edgering.c
index b007343e14e..92a8c7da71d 100644
--- a/source/blender/editors/mesh/editmesh_preselect_edgering.c
+++ b/source/blender/editors/mesh/editmesh_preselect_edgering.c
@@ -93,8 +93,9 @@ static void edgering_find_order(BMEdge *eed_last, BMEdge *eed, BMVert *eve_last,
if (!(BM_edge_in_face(eed, l->f) && BM_edge_in_face(eed_last, l->f))) {
BMIter liter;
BM_ITER_ELEM (l, &liter, l, BM_LOOPS_OF_LOOP) {
- if (BM_edge_in_face(eed, l->f) && BM_edge_in_face(eed_last, l->f))
+ if (BM_edge_in_face(eed, l->f) && BM_edge_in_face(eed_last, l->f)) {
break;
+ }
}
}
diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c
index 42521d04008..ffdb434405e 100644
--- a/source/blender/editors/mesh/editmesh_rip.c
+++ b/source/blender/editors/mesh/editmesh_rip.c
@@ -86,8 +86,7 @@ static float edbm_rip_edgedist_squared(ARegion *ar,
#if 0
static float edbm_rip_linedist(
- ARegion *ar, float mat[4][4],
- const float co1[3], const float co2[3], const float mvalf[2])
+ ARegion *ar, float mat[4][4], const float co1[3], const float co2[3], const float mvalf[2])
{
float vec1[2], vec2[2];
@@ -171,23 +170,26 @@ static float edbm_rip_edge_side_measure(
*
* The method used for checking the side of selection is as follows...
* - First tag all rip-able edges.
- * - Build a contiguous edge list by looping over tagged edges and following each ones tagged siblings in both
- * directions.
- * - The loops are not stored in an array, Instead both loops on either side of each edge has its index values set
- * to count down from the last edge, this way, once we have the 'last' edge its very easy to walk down the
- * connected edge loops.
- * The reason for using loops like this is because when the edges are split we don't which face user gets the newly
- * created edge (its as good as random so we cant assume new edges will be on once side).
- * After splitting, its very simple to walk along boundary loops since each only has one edge from a single side.
- * - The end loop pairs are stored in an array however to support multiple edge-selection-islands, so you can rip
- * multiple selections at once.
+ * - Build a contiguous edge list by looping over tagged edges and following each ones tagged
+ * siblings in both directions.
+ * - The loops are not stored in an array, Instead both loops on either side of each edge has
+ * its index values set to count down from the last edge, this way, once we have the 'last'
+ * edge its very easy to walk down the connected edge loops.
+ * The reason for using loops like this is because when the edges are split we don't which
+ * face user gets the newly created edge
+ * (its as good as random so we cant assume new edges will be on once side).
+ * After splitting, its very simple to walk along boundary loops since each only has one edge
+ * from a single side.
+ * - The end loop pairs are stored in an array however to support multiple edge-selection-islands,
+ * so you can rip multiple selections at once.
* - * Execute the split *
- * - For each #EdgeLoopPair walk down both sides of the split using the loops and measure which is facing the mouse.
+ * - For each #EdgeLoopPair walk down both sides of the split using the loops and measure
+ * which is facing the mouse.
* - Deselect the edge loop facing away.
*
* Limitation!
- * This currently works very poorly with intersecting edge islands (verts with more than 2 tagged edges)
- * This is nice to but for now not essential.
+ * This currently works very poorly with intersecting edge islands
+ * (verts with more than 2 tagged edges). This is nice to but for now not essential.
*
* - campbell.
*/
@@ -540,8 +542,9 @@ static int edbm_rip_invoke__vert(bContext *C, const wmEvent *event, Object *obed
ese.ele = NULL;
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(v, BM_ELEM_SELECT))
+ if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
break;
+ }
}
}
@@ -810,8 +813,9 @@ static int edbm_rip_invoke__vert(bContext *C, const wmEvent *event, Object *obed
BM_vert_select_set(bm, v_rip, true);
}
else {
- if (fill_uloop_pairs)
+ if (fill_uloop_pairs) {
MEM_freeN(fill_uloop_pairs);
+ }
return OPERATOR_CANCELLED;
}
}
@@ -905,6 +909,9 @@ static int edbm_rip_invoke__edge(bContext *C, const wmEvent *event, Object *obed
if (BM_elem_flag_test(e, BM_ELEM_SELECT)) {
e_best = e;
i++;
+ /* Tag the edge verts so we know which verts to rip */
+ BM_elem_flag_enable(e->v1, BM_ELEM_TAG);
+ BM_elem_flag_enable(e->v2, BM_ELEM_TAG);
}
totedge_manifold++;
}
@@ -932,13 +939,14 @@ static int edbm_rip_invoke__edge(bContext *C, const wmEvent *event, Object *obed
l_b;
l = BM_loop_other_edge_loop(l, v);
- /* important edge is manifold else we can be attempting to split off a fan that don't budge,
- * not crashing but adds duplicate edge. */
+ /* Important edge is manifold else we can be attempting to split off
+ * a fan that don't budge, not crashing but adds duplicate edge. */
if (BM_edge_is_manifold(l->e)) {
l = l->radial_next;
- if (totedge_manifold != 3)
+ if (totedge_manifold != 3) {
l = BM_loop_other_edge_loop(l, v);
+ }
if (l) {
BLI_assert(!BM_elem_flag_test(l->e, BM_ELEM_TAG));
diff --git a/source/blender/editors/mesh/editmesh_rip_edge.c b/source/blender/editors/mesh/editmesh_rip_edge.c
index e2b77d8c83b..61253f06f9f 100644
--- a/source/blender/editors/mesh/editmesh_rip_edge.c
+++ b/source/blender/editors/mesh/editmesh_rip_edge.c
@@ -71,8 +71,9 @@ static int edbm_rip_edge_invoke(bContext *C, wmOperator *UNUSED(op), const wmEve
float projectMat[4][4];
- if (bm->totvertsel == 0)
+ if (bm->totvertsel == 0) {
continue;
+ }
ED_view3d_ob_project_mat_get(rv3d, obedit, projectMat);
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 94886266d24..9df03a81762 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -110,8 +110,9 @@ void EDBM_select_mirrored(
EDBM_verts_mirror_cache_begin(em, axis, true, true, use_topology);
- if (!extend)
+ if (!extend) {
EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+ }
if (bm->selectmode & SCE_SELECT_VERTEX) {
BMVert *v;
@@ -241,19 +242,22 @@ bool EDBM_backbuf_check(unsigned int index)
/* odd logic, if selbuf is NULL we assume no zbuf-selection is enabled
* and just ignore the depth buffer, this is error prone since its possible
* code doesn't set the depth buffer by accident, but leave for now. - Campbell */
- if (selbuf == NULL)
+ if (selbuf == NULL) {
return true;
+ }
- if (index > 0 && index <= bm_vertoffs)
+ if (index > 0 && index <= bm_vertoffs) {
return BLI_BITMAP_TEST_BOOL(selbuf, index);
+ }
return false;
}
void EDBM_backbuf_free(void)
{
- if (selbuf)
+ if (selbuf) {
MEM_freeN(selbuf);
+ }
selbuf = NULL;
}
@@ -458,7 +462,8 @@ static void findnearestvert__doClosest(void *userData,
*
* \param r_dist: (in/out), minimal distance to the nearest and at the end, actual distance
* \param use_select_bias:
- * - When true, selected vertices are given a 5 pixel bias to make them further than unselect verts.
+ * - When true, selected vertices are given a 5 pixel bias
+ * to make them further than unselect verts.
* - When false, unselected vertices are given the bias.
* \param use_cycle: Cycle over elements within #FIND_NEAR_CYCLE_THRESHOLD_MIN in order of index.
*/
@@ -1173,9 +1178,7 @@ bool EDBM_unified_findnearest_from_raycast(ViewContext *vc,
float point[3];
#if 0
const float dist_sq_test = dist_squared_ray_to_seg_v3(
- ray_origin, ray_direction,
- e->v1->co, e->v2->co,
- point, &depth);
+ ray_origin, ray_direction, e->v1->co, e->v2->co, point, &depth);
#else
if (coords) {
mid_v3_v3v3(
@@ -1425,10 +1428,12 @@ static int edbm_select_mode_invoke(bContext *C, wmOperator *op, const wmEvent *e
/* detecting these options based on shift/ctrl here is weak, but it's done
* to make this work when clicking buttons or menus */
- if (!RNA_struct_property_is_set(op->ptr, "use_extend"))
+ if (!RNA_struct_property_is_set(op->ptr, "use_extend")) {
RNA_boolean_set(op->ptr, "use_extend", event->shift);
- if (!RNA_struct_property_is_set(op->ptr, "use_expand"))
+ }
+ if (!RNA_struct_property_is_set(op->ptr, "use_expand")) {
RNA_boolean_set(op->ptr, "use_expand", event->ctrl);
+ }
return edbm_select_mode_exec(C, op);
}
@@ -1801,7 +1806,8 @@ static bool mouse_mesh_loop(
length_2 = len_squared_v2v2(mvalf, v2_co);
}
#if 0
- printf("mouse to v1: %f\nmouse to v2: %f\n", len_squared_v2v2(mvalf, v1_co),
+ printf("mouse to v1: %f\nmouse to v2: %f\n",
+ len_squared_v2v2(mvalf, v1_co),
len_squared_v2v2(mvalf, v2_co));
#endif
BM_select_history_store(em->bm, (length_1 < length_2) ? eed->v1 : eed->v2);
@@ -2205,8 +2211,9 @@ static void edbm_strip_selections(BMEditMesh *em)
ese = em->bm->selected.first;
while (ese) {
nextese = ese->next;
- if (ese->htype == BM_VERT)
+ if (ese->htype == BM_VERT) {
BLI_freelinkN(&(em->bm->selected), ese);
+ }
ese = nextese;
}
}
@@ -2214,8 +2221,9 @@ static void edbm_strip_selections(BMEditMesh *em)
ese = em->bm->selected.first;
while (ese) {
nextese = ese->next;
- if (ese->htype == BM_EDGE)
+ if (ese->htype == BM_EDGE) {
BLI_freelinkN(&(em->bm->selected), ese);
+ }
ese = nextese;
}
}
@@ -2223,8 +2231,9 @@ static void edbm_strip_selections(BMEditMesh *em)
ese = em->bm->selected.first;
while (ese) {
nextese = ese->next;
- if (ese->htype == BM_FACE)
+ if (ese->htype == BM_FACE) {
BLI_freelinkN(&(em->bm->selected), ese);
+ }
ese = nextese;
}
}
@@ -2576,8 +2585,9 @@ bool EDBM_deselect_by_material(BMEditMesh *em, const short index, const bool sel
bool changed = false;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
continue;
+ }
if (efa->mat_nr == index) {
changed = true;
BM_face_select_set(em->bm, efa, select);
@@ -2588,10 +2598,12 @@ bool EDBM_deselect_by_material(BMEditMesh *em, const short index, const bool sel
void EDBM_select_toggle_all(BMEditMesh *em) /* exported for UV */
{
- if (em->bm->totvertsel || em->bm->totedgesel || em->bm->totfacesel)
+ if (em->bm->totvertsel || em->bm->totedgesel || em->bm->totfacesel) {
EDBM_flag_disable_all(em, BM_ELEM_SELECT);
- else
+ }
+ else {
EDBM_flag_enable_all(em, BM_ELEM_SELECT);
+ }
}
void EDBM_select_swap(BMEditMesh *em) /* exported for UV */
@@ -2603,22 +2615,25 @@ void EDBM_select_swap(BMEditMesh *em) /* exported for UV */
if (em->bm->selectmode & SCE_SELECT_VERTEX) {
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(eve, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
continue;
+ }
BM_vert_select_set(em->bm, eve, !BM_elem_flag_test(eve, BM_ELEM_SELECT));
}
}
else if (em->selectmode & SCE_SELECT_EDGE) {
BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
- if (BM_elem_flag_test(eed, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
continue;
+ }
BM_edge_select_set(em->bm, eed, !BM_elem_flag_test(eed, BM_ELEM_SELECT));
}
}
else {
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
continue;
+ }
BM_face_select_set(em->bm, efa, !BM_elem_flag_test(efa, BM_ELEM_SELECT));
}
}
@@ -2675,8 +2690,9 @@ bool EDBM_select_interior_faces(BMEditMesh *em)
bool changed = false;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
continue;
+ }
ok = true;
BM_ITER_ELEM (eed, &eiter, efa, BM_EDGES_OF_FACE) {
@@ -4602,8 +4618,9 @@ static int edbm_region_to_loop_exec(bContext *C, wmOperator *UNUSED(op))
totsel += BM_elem_flag_test(l2->f, BM_ELEM_SELECT) != 0;
}
- if ((tot != totsel && totsel > 0) || (totsel == 1 && tot == 1))
+ if ((tot != totsel && totsel > 0) || (totsel == 1 && tot == 1)) {
BM_elem_flag_enable(l1->e, BM_ELEM_TAG);
+ }
}
}
@@ -4671,8 +4688,9 @@ static int loop_find_region(BMLoop *l, int flag, GSet *visit_face_set, BMFace **
BLI_array_append(region, f);
BM_ITER_ELEM (l1, &liter1, f, BM_LOOPS_OF_FACE) {
- if (BM_elem_flag_test(l1->e, flag))
+ if (BM_elem_flag_test(l1->e, flag)) {
continue;
+ }
BM_ITER_ELEM (l2, &liter2, l1->e, BM_LOOPS_OF_EDGE) {
/* avoids finding same region twice
@@ -4702,10 +4720,12 @@ static int verg_radial(const void *va, const void *vb)
const int a = BM_edge_face_count(e_a);
const int b = BM_edge_face_count(e_b);
- if (a > b)
+ if (a > b) {
return -1;
- if (a < b)
+ }
+ if (a < b) {
return 1;
+ }
return 0;
}
@@ -4748,12 +4768,14 @@ static int loop_find_regions(BMEditMesh *em, const bool selbigger)
e = edges[i];
- if (!BM_elem_flag_test(e, BM_ELEM_TAG))
+ if (!BM_elem_flag_test(e, BM_ELEM_TAG)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, e, BM_LOOPS_OF_EDGE) {
- if (BLI_gset_haskey(visit_face_set, l->f))
+ if (BLI_gset_haskey(visit_face_set, l->f)) {
continue;
+ }
c = loop_find_region(l, BM_ELEM_SELECT, visit_face_set, &region_out);
diff --git a/source/blender/editors/mesh/editmesh_select_similar.c b/source/blender/editors/mesh/editmesh_select_similar.c
index 3006e2ed73d..2782cc92aca 100644
--- a/source/blender/editors/mesh/editmesh_select_similar.c
+++ b/source/blender/editors/mesh/editmesh_select_similar.c
@@ -1218,12 +1218,15 @@ static int edbm_select_similar_exec(bContext *C, wmOperator *op)
ts->select_thresh = RNA_property_float_get(op->ptr, prop);
}
- if (type < 100)
+ if (type < 100) {
return similar_vert_select_exec(C, op);
- else if (type < 200)
+ }
+ else if (type < 200) {
return similar_edge_select_exec(C, op);
- else
+ }
+ else {
return similar_face_select_exec(C, op);
+ }
}
static const EnumPropertyItem *select_similar_type_itemf(bContext *C,
@@ -1233,8 +1236,9 @@ static const EnumPropertyItem *select_similar_type_itemf(bContext *C,
{
Object *obedit;
- if (!C) /* needed for docs and i18n tools */
+ if (!C) { /* needed for docs and i18n tools */
return prop_similar_types;
+ }
obedit = CTX_data_edit_object(C);
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 79bbf021829..cd9d046ae04 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -885,8 +885,9 @@ static void edbm_add_edge_face_exec__tricky_finalize_sel(BMesh *bm, BMElem *ele_
BM_select_history_clear(bm);
/* Notes on hidden geometry:
- * - un-hide the face since its possible hidden was copied when copying surrounding face attributes.
- * - un-hide before adding to select history
+ * - Un-hide the face since its possible hidden was copied when copying
+ * surrounding face attributes.
+ * - Un-hide before adding to select history
* since we may extend into an existing, hidden vert/edge.
*/
@@ -946,8 +947,8 @@ static int edbm_add_edge_face_exec(bContext *C, wmOperator *op)
BMElem *ele_desel;
BMFace *ele_desel_face;
- /* be extra clever, figure out if a partial selection should be extended so we can create geometry
- * with single vert or single edge selection */
+ /* be extra clever, figure out if a partial selection should be extended so we can create
+ * geometry with single vert or single edge selection. */
ele_desel = edbm_add_edge_face_exec__tricky_extend_sel(em->bm);
#endif
if (!EDBM_op_init(em,
@@ -980,7 +981,8 @@ static int edbm_add_edge_face_exec(bContext *C, wmOperator *op)
/* Newly created faces may include existing hidden edges,
* copying face data from surrounding, may have copied hidden face flag too.
*
- * Important that faces use flushing since 'edges.out' wont include hidden edges that already existed.
+ * Important that faces use flushing since 'edges.out'
+ * wont include hidden edges that already existed.
*/
BMO_slot_buffer_hflag_disable(
em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_HIDDEN, true);
@@ -2207,7 +2209,7 @@ static int edbm_normals_make_consistent_exec(bContext *C, wmOperator *op)
void MESH_OT_normals_make_consistent(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Make Normals Consistent";
+ ot->name = "Recalculate Normals";
ot->description = "Make face and vertex normals point either outside or inside the mesh";
ot->idname = "MESH_OT_normals_make_consistent";
@@ -2271,12 +2273,15 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op)
MirrorModifierData *mmd = (MirrorModifierData *)md;
if (mmd->flag & MOD_MIR_CLIPPING) {
- if (mmd->flag & MOD_MIR_AXIS_X)
+ if (mmd->flag & MOD_MIR_AXIS_X) {
mirrx = true;
- if (mmd->flag & MOD_MIR_AXIS_Y)
+ }
+ if (mmd->flag & MOD_MIR_AXIS_Y) {
mirry = true;
- if (mmd->flag & MOD_MIR_AXIS_Z)
+ }
+ if (mmd->flag & MOD_MIR_AXIS_Z) {
mirrz = true;
+ }
clip_dist = mmd->tolerance;
}
@@ -2496,8 +2501,9 @@ static void mesh_set_smooth_faces(BMEditMesh *em, short smooth)
BMIter iter;
BMFace *efa;
- if (em == NULL)
+ if (em == NULL) {
return;
+ }
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
@@ -2768,7 +2774,7 @@ void MESH_OT_uvs_reverse(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
- //RNA_def_enum(ot->srna, "axis", axis_items, DIRECTION_CW, "Axis", "Axis to mirror UVs around");
+ // RNA_def_enum(ot->srna, "axis", axis_items, DIRECTION_CW, "Axis", "Axis to mirror UVs around");
}
void MESH_OT_colors_rotate(wmOperatorType *ot)
@@ -2804,7 +2810,9 @@ void MESH_OT_colors_reverse(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
- //RNA_def_enum(ot->srna, "axis", axis_items, DIRECTION_CW, "Axis", "Axis to mirror colors around");
+#if 0
+ RNA_def_enum(ot->srna, "axis", axis_items, DIRECTION_CW, "Axis", "Axis to mirror colors around");
+#endif
}
/** \} */
@@ -2835,31 +2843,37 @@ static bool merge_firstlast(BMEditMesh *em,
/* do sanity check in mergemenu in edit.c ?*/
if (use_first == false) {
- if (!em->bm->selected.last || ((BMEditSelection *)em->bm->selected.last)->htype != BM_VERT)
+ if (!em->bm->selected.last || ((BMEditSelection *)em->bm->selected.last)->htype != BM_VERT) {
return false;
+ }
ese = em->bm->selected.last;
mergevert = (BMVert *)ese->ele;
}
else {
- if (!em->bm->selected.first || ((BMEditSelection *)em->bm->selected.first)->htype != BM_VERT)
+ if (!em->bm->selected.first || ((BMEditSelection *)em->bm->selected.first)->htype != BM_VERT) {
return false;
+ }
ese = em->bm->selected.first;
mergevert = (BMVert *)ese->ele;
}
- if (!BM_elem_flag_test(mergevert, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(mergevert, BM_ELEM_SELECT)) {
return false;
+ }
if (use_uvmerge) {
if (!EDBM_op_callf(
- em, wmop, "pointmerge_facedata verts=%hv vert_snap=%e", BM_ELEM_SELECT, mergevert))
+ em, wmop, "pointmerge_facedata verts=%hv vert_snap=%e", BM_ELEM_SELECT, mergevert)) {
return false;
+ }
}
- if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, mergevert->co))
+ if (!EDBM_op_callf(
+ em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, mergevert->co)) {
return false;
+ }
return true;
}
@@ -2886,14 +2900,16 @@ static bool merge_target(BMEditMesh *em,
float fac;
int i = 0;
BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
- if (!BM_elem_flag_test(v, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(v, BM_ELEM_SELECT)) {
continue;
+ }
add_v3_v3(cent, v->co);
i++;
}
- if (!i)
+ if (!i) {
return false;
+ }
fac = 1.0f / (float)i;
mul_v3_fl(cent, fac);
@@ -2901,16 +2917,19 @@ static bool merge_target(BMEditMesh *em,
vco = co;
}
- if (!vco)
+ if (!vco) {
return false;
+ }
if (use_uvmerge) {
- if (!EDBM_op_callf(em, wmop, "average_vert_facedata verts=%hv", BM_ELEM_SELECT))
+ if (!EDBM_op_callf(em, wmop, "average_vert_facedata verts=%hv", BM_ELEM_SELECT)) {
return false;
+ }
}
- if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, co))
+ if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, co)) {
return false;
+ }
return true;
}
@@ -2994,8 +3013,9 @@ static const EnumPropertyItem *merge_type_itemf(bContext *C,
EnumPropertyItem *item = NULL;
int totitem = 0;
- if (!C) /* needed for docs */
+ if (!C) { /* needed for docs */
return merge_type_items;
+ }
obedit = CTX_data_edit_object(C);
if (obedit && obedit->type == OB_MESH) {
@@ -3092,12 +3112,15 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op)
/* avoid losing selection state (select -> tags) */
char htype_select;
- if (em->selectmode & SCE_SELECT_VERTEX)
+ if (em->selectmode & SCE_SELECT_VERTEX) {
htype_select = BM_VERT;
- else if (em->selectmode & SCE_SELECT_EDGE)
+ }
+ else if (em->selectmode & SCE_SELECT_EDGE) {
htype_select = BM_EDGE;
- else
+ }
+ else {
htype_select = BM_FACE;
+ }
/* store selection as tags */
BM_mesh_elem_hflag_enable_test(em->bm, htype_select, BM_ELEM_TAG, true, true, BM_ELEM_SELECT);
@@ -3146,8 +3169,8 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op)
void MESH_OT_remove_doubles(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Remove Doubles";
- ot->description = "Remove duplicate vertices";
+ ot->name = "Merge by Distance";
+ ot->description = "Merge vertices based on their proximity";
ot->idname = "MESH_OT_remove_doubles";
/* api callbacks */
@@ -3330,8 +3353,9 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op)
if (kb) {
/* Perform blending on selected vertices. */
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
- if (!BM_elem_flag_test(eve, BM_ELEM_SELECT) || BM_elem_flag_test(eve, BM_ELEM_HIDDEN))
+ if (!BM_elem_flag_test(eve, BM_ELEM_SELECT) || BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
continue;
+ }
/* Get coordinates of shapekey we're blending from. */
sco = CustomData_bmesh_get_n(&em->bm->vdata, eve->head.data, CD_SHAPEKEY, shape);
@@ -3381,8 +3405,9 @@ static const EnumPropertyItem *shape_itemf(bContext *C,
int a;
for (a = 0; a < em->bm->vdata.totlayer; a++) {
- if (em->bm->vdata.layers[a].type != CD_SHAPEKEY)
+ if (em->bm->vdata.layers[a].type != CD_SHAPEKEY) {
continue;
+ }
tmp.value = totitem;
tmp.identifier = em->bm->vdata.layers[a].name;
@@ -3425,7 +3450,8 @@ void MESH_OT_blend_from_shape(wmOperatorType *ot)
/* api callbacks */
ot->exec = edbm_blend_from_shape_exec;
- // ot->invoke = WM_operator_props_popup_call; /* disable because search popup closes too easily */
+ /* disable because search popup closes too easily */
+ // ot->invoke = WM_operator_props_popup_call;
ot->ui = edbm_blend_from_shape_ui;
ot->poll = ED_operator_editmesh;
@@ -3547,7 +3573,7 @@ static float bm_edge_seg_isect(const float sco_a[2],
float threshold = 0.0;
int i;
- //threshold = 0.000001; /* tolerance for vertex intersection */
+ // threshold = 0.000001; /* tolerance for vertex intersection */
// XXX threshold = scene->toolsettings->select_thresh / 100;
/* Get screen coords of verts */
@@ -3616,11 +3642,13 @@ static float bm_edge_seg_isect(const float sco_a[2],
/* sqrt(m2 * m2 + 1); Only looking for change in sign. Skip extra math .*/
dist = (y12 - m2 * x12 - b2);
}
- else
+ else {
dist = x22 - x12;
+ }
- if (i == 0)
+ if (i == 0) {
lastdist = dist;
+ }
/* if dist changes sign, and intersect point in edge's Bound Box */
if ((lastdist * dist) <= 0) {
@@ -3681,11 +3709,13 @@ static float bm_edge_seg_isect(const float sco_a[2],
}
}
}
- if ((m2 <= 1.0f) && (m2 >= -1.0f))
+ if ((m2 <= 1.0f) && (m2 >= -1.0f)) {
perc = (xi - x21) / (x22 - x21);
- else
+ }
+ else {
perc = (yi - y21) / (y22 - y21); /* lower slope more accurate */
- //isect = 32768.0 * (perc + 0.0000153); /* Percentage in 1 / 32768ths */
+ }
+ // isect = 32768.0 * (perc + 0.0000153); /* Percentage in 1 / 32768ths */
break;
}
@@ -3717,8 +3747,9 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
float(*screen_vert_coords)[2], (*sco)[2], (*mouse_path)[2];
/* edit-object needed for matrix, and ar->regiondata for projections to work */
- if (ELEM(NULL, obedit, ar, ar->regiondata))
+ if (ELEM(NULL, obedit, ar, ar->regiondata)) {
return OPERATOR_CANCELLED;
+ }
if (bm->totvertsel < 2) {
BKE_report(op->reports, RPT_ERROR, "No edges are selected to operate on");
@@ -3794,8 +3825,9 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
BMO_slot_buffer_from_enabled_flag(bm, &bmop, bmop.slots_in, "edges", BM_EDGE, ELE_EDGE_CUT);
- if (mode == KNIFE_MIDPOINT)
+ if (mode == KNIFE_MIDPOINT) {
numcuts = 1;
+ }
BMO_slot_int_set(bmop.slots_in, "cuts", numcuts);
BMO_slot_int_set(bmop.slots_in, "quad_corner_type", SUBD_CORNER_STRAIGHT_CUT);
@@ -4267,7 +4299,7 @@ void MESH_OT_separate(wmOperatorType *ot)
static const EnumPropertyItem prop_separate_types[] = {
{MESH_SEPARATE_SELECTED, "SELECTED", 0, "Selection", ""},
{MESH_SEPARATE_MATERIAL, "MATERIAL", 0, "By Material", ""},
- {MESH_SEPARATE_LOOSE, "LOOSE", 0, "By loose parts", ""},
+ {MESH_SEPARATE_LOOSE, "LOOSE", 0, "By Loose Parts", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -5904,19 +5936,28 @@ void MESH_OT_split(wmOperatorType *ot)
* \{ */
enum {
- SRT_VIEW_ZAXIS = 1, /* Use view Z (deep) axis. */
- SRT_VIEW_XAXIS, /* Use view X (left to right) axis. */
- SRT_CURSOR_DISTANCE, /* Use distance from element to 3D cursor. */
- SRT_MATERIAL, /* Face only: use mat number. */
- SRT_SELECTED, /* Move selected elements in first, without modifying
- * relative order of selected and unselected elements. */
- SRT_RANDOMIZE, /* Randomize selected elements. */
- SRT_REVERSE, /* Reverse current order of selected elements. */
+ /** Use view Z (deep) axis. */
+ SRT_VIEW_ZAXIS = 1,
+ /** Use view X (left to right) axis. */
+ SRT_VIEW_XAXIS,
+ /** Use distance from element to 3D cursor. */
+ SRT_CURSOR_DISTANCE,
+ /** Face only: use mat number. */
+ SRT_MATERIAL,
+ /** Move selected elements in first, without modifying
+ * relative order of selected and unselected elements. */
+ SRT_SELECTED,
+ /** Randomize selected elements. */
+ SRT_RANDOMIZE,
+ /** Reverse current order of selected elements. */
+ SRT_REVERSE,
};
typedef struct BMElemSort {
- float srt; /* Sort factor */
- int org_idx; /* Original index of this element _in its mempool_ */
+ /** Sort factor */
+ float srt;
+ /** Original index of this element _in its mempool_ */
+ int org_idx;
} BMElemSort;
static int bmelemsort_comp(const void *v1, const void *v2)
@@ -5953,15 +5994,19 @@ static void sort_bmelem_flag(bContext *C,
int affected[3] = {0, 0, 0};
int i, j;
- if (!(types && flag && action))
+ if (!(types && flag && action)) {
return;
+ }
- if (types & BM_VERT)
+ if (types & BM_VERT) {
totelem[0] = em->bm->totvert;
- if (types & BM_EDGE)
+ }
+ if (types & BM_EDGE) {
totelem[1] = em->bm->totedge;
- if (types & BM_FACE)
+ }
+ if (types & BM_FACE) {
totelem[2] = em->bm->totface;
+ }
if (ELEM(action, SRT_VIEW_ZAXIS, SRT_VIEW_XAXIS)) {
float mat[4][4];
@@ -6173,8 +6218,9 @@ static void sort_bmelem_flag(bContext *C,
int aff = affected[j];
tb = tbuf[j];
mp = map[j];
- if (!(tb && mp))
+ if (!(tb && mp)) {
continue;
+ }
if (ELEM(aff, 0, tot)) {
MEM_freeN(tb);
MEM_freeN(mp);
@@ -6315,12 +6361,15 @@ static void sort_bmelem_flag(bContext *C,
/* printf("%d faces: %d to be affected...\n", totelem[2], affected[2]);*/
if (affected[0] == 0 && affected[1] == 0 && affected[2] == 0) {
for (j = 3; j--;) {
- if (pblock[j])
+ if (pblock[j]) {
MEM_freeN(pblock[j]);
- if (sblock[j])
+ }
+ if (sblock[j]) {
MEM_freeN(sblock[j]);
- if (map[j])
+ }
+ if (map[j]) {
MEM_freeN(map[j]);
+ }
}
return;
}
@@ -6350,10 +6399,12 @@ static void sort_bmelem_flag(bContext *C,
}
}
}
- if (pb)
+ if (pb) {
MEM_freeN(pb);
- if (sb)
+ }
+ if (sb) {
MEM_freeN(sb);
+ }
}
BM_mesh_remap(em->bm, map[0], map[1], map[2]);
@@ -6361,8 +6412,9 @@ static void sort_bmelem_flag(bContext *C,
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
for (j = 3; j--;) {
- if (map[j])
+ if (map[j]) {
MEM_freeN(map[j]);
+ }
}
}
@@ -6394,12 +6446,15 @@ static int edbm_sort_elements_exec(bContext *C, wmOperator *op)
}
else {
BMEditMesh *em = BKE_editmesh_from_object(ob_active);
- if (em->selectmode & SCE_SELECT_VERTEX)
+ if (em->selectmode & SCE_SELECT_VERTEX) {
elem_types |= BM_VERT;
- if (em->selectmode & SCE_SELECT_EDGE)
+ }
+ if (em->selectmode & SCE_SELECT_EDGE) {
elem_types |= BM_EDGE;
- if (em->selectmode & SCE_SELECT_FACE)
+ }
+ if (em->selectmode & SCE_SELECT_FACE) {
elem_types |= BM_FACE;
+ }
RNA_enum_set(op->ptr, "elements", elem_types);
}
@@ -6441,18 +6496,22 @@ static bool edbm_sort_elements_poll_property(const bContext *UNUSED(C),
/* Only show seed for randomize action! */
if (STREQ(prop_id, "seed")) {
- if (action == SRT_RANDOMIZE)
+ if (action == SRT_RANDOMIZE) {
return true;
- else
+ }
+ else {
return false;
+ }
}
/* Hide seed for reverse and randomize actions! */
if (STREQ(prop_id, "reverse")) {
- if (ELEM(action, SRT_RANDOMIZE, SRT_REVERSE))
+ if (ELEM(action, SRT_RANDOMIZE, SRT_REVERSE)) {
return false;
- else
+ }
+ else {
return true;
+ }
}
return true;
@@ -6953,7 +7012,8 @@ void MESH_OT_offset_edge_loops(wmOperatorType *ot)
ot->exec = edbm_offset_edgeloop_exec;
ot->poll = ED_operator_editmesh;
- /* Keep internal, since this is only meant to be accessed via 'MESH_OT_offset_edge_loops_slide' */
+ /* Keep internal, since this is only meant to be accessed via
+ * 'MESH_OT_offset_edge_loops_slide'. */
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
@@ -7589,8 +7649,9 @@ wmKeyMap *point_normals_modal_keymap(wmKeyConfig *keyconf)
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, keymap_name);
/* We only need to add map once */
- if (keymap && keymap->modal_items)
+ if (keymap && keymap->modal_items) {
return NULL;
+ }
keymap = WM_modalkeymap_add(keyconf, keymap_name, modal_items);
@@ -7721,7 +7782,8 @@ static void point_normals_apply(bContext *C, wmOperator *op, float target[3], co
copy_v3_v3(lnor_ed->nloc, lnor_ed->niloc);
}
else if (do_spherize) {
- /* Note that this is *not* real spherical interpolation. Probably good enough in this case though? */
+ /* Note that this is *not* real spherical interpolation.
+ * Probably good enough in this case though? */
const float strength = RNA_float_get(op->ptr, "spherize_strength");
float spherized_normal[3];
@@ -8801,12 +8863,13 @@ static int edbm_smoothen_normals_exec(bContext *C, wmOperator *op)
float(*smooth_normal)[3] = MEM_callocN(sizeof(*smooth_normal) * lnors_ed_arr->totloop, __func__);
- /* This is weird choice of operation, taking all loops of faces of current vertex... Could lead to some rather
- * far away loops weighting as much as very close ones (topologically speaking), with complex polygons.
- * Using topological distance here (rather than geometrical one) makes sense imho, but would rather go with
- * a more consistent and flexible code, we could even add max topological distance to take into account,
- * and a weighting curve...
- * Would do that later though, think for now we can live with that choice. --mont29 */
+ /* This is weird choice of operation, taking all loops of faces of current vertex.
+ * Could lead to some rather far away loops weighting as much as very close ones
+ * (topologically speaking), with complex polygons.
+ * Using topological distance here (rather than geometrical one)
+ * makes sense imho, but would rather go with a more consistent and flexible code,
+ * we could even add max topological distance to take into account, * and a weighting curve.
+ * Would do that later though, think for now we can live with that choice. --mont29. */
BMLoopNorEditData *lnor_ed = lnors_ed_arr->lnor_editdata;
for (int i = 0; i < lnors_ed_arr->totloop; i++, lnor_ed++) {
l = lnor_ed->loop;
@@ -8864,7 +8927,7 @@ static int edbm_smoothen_normals_exec(bContext *C, wmOperator *op)
void MESH_OT_smoothen_normals(struct wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Smoothen Normals";
+ ot->name = "Smooth Normals Vectors";
ot->description = "Smoothen custom normals based on adjacent vertex normals";
ot->idname = "MESH_OT_smoothen_normals";
@@ -8941,7 +9004,7 @@ static int edbm_mod_weighted_strength_exec(bContext *C, wmOperator *op)
void MESH_OT_mod_weighted_strength(struct wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Face Strength";
+ ot->name = "Face Normals Strength";
ot->description = "Set/Get strength of face (used in Weighted Normal modifier)";
ot->idname = "MESH_OT_mod_weighted_strength";
diff --git a/source/blender/editors/mesh/editmesh_undo.c b/source/blender/editors/mesh/editmesh_undo.c
index 2e855d9c5de..28b14b0060d 100644
--- a/source/blender/editors/mesh/editmesh_undo.c
+++ b/source/blender/editors/mesh/editmesh_undo.c
@@ -93,13 +93,13 @@ typedef struct UndoMesh {
int selectmode;
/** \note
- * this isn't a prefect solution, if you edit keys and change shapes this works well (fixing [#32442]),
- * but editing shape keys, going into object mode, removing or changing their order,
- * then go back into editmode and undo will give issues - where the old index will be out of sync
- * with the new object index.
+ * this isn't a prefect solution, if you edit keys and change shapes this works well
+ * (fixing T32442), but editing shape keys, going into object mode, removing or changing their
+ * order, then go back into editmode and undo will give issues - where the old index will be
+ * out of sync with the new object index.
*
* There are a few ways this could be made to work but for now its a known limitation with mixing
- * object and editmode operations - Campbell */
+ * object and editmode operations - Campbell. */
int shapenr;
#ifdef USE_ARRAY_STORE
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index 1cb550fccc4..d7ed14184fa 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -363,10 +363,8 @@ void EDBM_mesh_load(Main *bmain, Object *ob)
* cycles.
*/
#if 0
- for (Object *other_object = bmain->objects.first;
- other_object != NULL;
- other_object = other_object->id.next)
- {
+ for (Object *other_object = bmain->objects.first; other_object != NULL;
+ other_object = other_object->id.next) {
if (other_object->data == ob->data) {
BKE_object_free_derived_caches(other_object);
}
@@ -575,8 +573,7 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm,
tf_uv = (float(*)[2])BLI_buffer_reinit_data(&tf_uv_buf, vec2f, efa->len);
}
- BM_ITER_ELEM_INDEX(l, &liter, efa, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
buf->loop_of_poly_index = i;
buf->poly_index = a;
buf->separate = 0;
@@ -629,10 +626,12 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm,
if (fabsf(uvdiff[0]) < limit[0] && fabsf(uvdiff[1]) < limit[1] &&
(!use_winding || winding[iterv->poly_index] == winding[v->poly_index])) {
- if (lastv)
+ if (lastv) {
lastv->next = next;
- else
+ }
+ else {
vlist = next;
+ }
iterv->next = newvlist;
newvlist = iterv;
}
@@ -725,8 +724,7 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
tf_uv = (float(*)[2])BLI_buffer_reinit_data(&tf_uv_buf, vec2f, efa->len);
}
- BM_ITER_ELEM_INDEX(l, &liter, efa, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) {
buf->l = l;
buf->separate = 0;
buf->island = INVALID_ISLAND;
@@ -780,10 +778,12 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
if (fabsf(uvdiff[0]) < STD_UV_CONNECT_LIMIT && fabsf(uvdiff[1]) < STD_UV_CONNECT_LIMIT &&
(!use_winding ||
winding[BM_elem_index_get(iterv->l->f)] == winding[BM_elem_index_get(v->l->f)])) {
- if (lastv)
+ if (lastv) {
lastv->next = next;
- else
+ }
+ else {
vlist = next;
+ }
iterv->next = newvlist;
newvlist = iterv;
}
@@ -837,8 +837,9 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
UvElement *element, *initelement = element_map->vert[BM_elem_index_get(l->v)];
for (element = initelement; element; element = element->next) {
- if (element->separate)
+ if (element->separate) {
initelement = element;
+ }
if (element->l->f == efa) {
/* found the uv corresponding to our face and vertex.
@@ -852,8 +853,9 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
islandbufsize++;
for (element = initelement; element; element = element->next) {
- if (element->separate && element != initelement)
+ if (element->separate && element != initelement) {
break;
+ }
if (island_number[BM_elem_index_get(element->l->f)] == INVALID_ISLAND) {
stack[stacksize++] = element->l->f;
@@ -875,8 +877,9 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
/* remap */
for (i = 0; i < bm->totvert; i++) {
/* important since we may do selection only. Some of these may be NULL */
- if (element_map->vert[i])
+ if (element_map->vert[i]) {
element_map->vert[i] = &islandbuf[map[element_map->vert[i] - element_map->buf]];
+ }
}
element_map->islandIndices = MEM_callocN(sizeof(*element_map->islandIndices) * nislands,
@@ -884,10 +887,12 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
j = 0;
for (i = 0; i < totuv; i++) {
UvElement *element = element_map->buf[i].next;
- if (element == NULL)
+ if (element == NULL) {
islandbuf[map[i]].next = NULL;
- else
+ }
+ else {
islandbuf[map[i]].next = &islandbuf[map[element - element_map->buf]];
+ }
if (islandbuf[i].island != j) {
j++;
@@ -911,10 +916,12 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
void BM_uv_vert_map_free(UvVertMap *vmap)
{
if (vmap) {
- if (vmap->vert)
+ if (vmap->vert) {
MEM_freeN(vmap->vert);
- if (vmap->buf)
+ }
+ if (vmap->buf) {
MEM_freeN(vmap->buf);
+ }
MEM_freeN(vmap);
}
}
@@ -922,12 +929,15 @@ void BM_uv_vert_map_free(UvVertMap *vmap)
void BM_uv_element_map_free(UvElementMap *element_map)
{
if (element_map) {
- if (element_map->vert)
+ if (element_map->vert) {
MEM_freeN(element_map->vert);
- if (element_map->buf)
+ }
+ if (element_map->buf) {
MEM_freeN(element_map->buf);
- if (element_map->islandIndices)
+ }
+ if (element_map->islandIndices) {
MEM_freeN(element_map->islandIndices);
+ }
MEM_freeN(element_map);
}
}
@@ -1021,7 +1031,8 @@ static BMVert *cache_mirr_intptr_as_bmvert(intptr_t *index_lookup, int index)
* \param use_select: Restrict to selected verts.
* \param use_topology: Use topology mirror.
* \param maxdist: Distance for close point test.
- * \param r_index: Optional array to write into, as an alternative to a customdata layer (length of total verts).
+ * \param r_index: Optional array to write into, as an alternative to a customdata layer
+ * (length of total verts).
*/
void EDBM_verts_mirror_cache_begin_ex(BMEditMesh *em,
const int axis,
@@ -1246,12 +1257,15 @@ bool EDBM_mesh_hide(BMEditMesh *em, bool swap)
char hflag_swap = swap ? BM_ELEM_SELECT : 0;
bool changed = true;
- if (em->selectmode & SCE_SELECT_VERTEX)
+ if (em->selectmode & SCE_SELECT_VERTEX) {
itermode = BM_VERTS_OF_MESH;
- else if (em->selectmode & SCE_SELECT_EDGE)
+ }
+ else if (em->selectmode & SCE_SELECT_EDGE) {
itermode = BM_EDGES_OF_MESH;
- else
+ }
+ else {
itermode = BM_FACES_OF_MESH;
+ }
BM_ITER_MESH (ele, &iter, em->bm, itermode) {
if (!BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) {
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index 2f4fbcab9bc..385b3c69422 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -183,8 +183,7 @@ static void mesh_uv_reset_bmface(BMFace *f, const int cd_loop_uv_offset)
BMLoop *l;
int i;
- BM_ITER_ELEM_INDEX(l, &liter, f, BM_LOOPS_OF_FACE, i)
- {
+ BM_ITER_ELEM_INDEX (l, &liter, f, BM_LOOPS_OF_FACE, i) {
fuv[i] = ((MLoopUV *)BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset))->uv;
}
@@ -218,8 +217,9 @@ void ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum)
BLI_assert(cd_loop_uv_offset != -1);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
mesh_uv_reset_bmface(efa, cd_loop_uv_offset);
}
@@ -262,8 +262,9 @@ int ED_mesh_uv_texture_add(Mesh *me, const char *name, const bool active_set, co
em = me->edit_mesh;
layernum_dst = CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPUV);
- if (layernum_dst >= MAX_MTFACE)
+ if (layernum_dst >= MAX_MTFACE) {
return -1;
+ }
/* CD_MLOOPUV */
BM_data_layer_add_named(em->bm, &em->bm->ldata, CD_MLOOPUV, name);
@@ -280,8 +281,9 @@ int ED_mesh_uv_texture_add(Mesh *me, const char *name, const bool active_set, co
}
else {
layernum_dst = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
- if (layernum_dst >= MAX_MTFACE)
+ if (layernum_dst >= MAX_MTFACE) {
return -1;
+ }
if (me->mloopuv && do_init) {
CustomData_add_layer_named(
@@ -323,13 +325,15 @@ void ED_mesh_uv_texture_ensure(struct Mesh *me, const char *name)
em = me->edit_mesh;
layernum_dst = CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPUV);
- if (layernum_dst == 0)
+ if (layernum_dst == 0) {
ED_mesh_uv_texture_add(me, name, true, true);
+ }
}
else {
layernum_dst = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
- if (layernum_dst == 0)
+ if (layernum_dst == 0) {
ED_mesh_uv_texture_add(me, name, true, true);
+ }
}
}
@@ -342,8 +346,9 @@ bool ED_mesh_uv_texture_remove_index(Mesh *me, const int n)
index = CustomData_get_layer_index_n(ldata, CD_MLOOPUV, n);
cdlu = (index == -1) ? NULL : &ldata->layers[index];
- if (!cdlu)
+ if (!cdlu) {
return false;
+ }
delete_customdata_layer(me, cdlu);
@@ -456,8 +461,9 @@ bool ED_mesh_color_remove_index(Mesh *me, const int n)
index = CustomData_get_layer_index_n(ldata, CD_MLOOPCOL, n);
cdl = (index == -1) ? NULL : &ldata->layers[index];
- if (!cdl)
+ if (!cdl) {
return false;
+ }
delete_customdata_layer(me, cdl);
DEG_id_tag_update(&me->id, 0);
@@ -502,8 +508,9 @@ static int mesh_uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
- if (ED_mesh_uv_texture_add(me, NULL, true, true) == -1)
+ if (ED_mesh_uv_texture_add(me, NULL, true, true) == -1) {
return OPERATOR_CANCELLED;
+ }
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
Scene *scene = CTX_data_scene(C);
@@ -534,8 +541,9 @@ static int mesh_uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
- if (!ED_mesh_uv_texture_remove_active(me))
+ if (!ED_mesh_uv_texture_remove_active(me)) {
return OPERATOR_CANCELLED;
+ }
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
Scene *scene = CTX_data_scene(C);
@@ -568,8 +576,9 @@ static int mesh_vertex_color_add_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
- if (ED_mesh_color_add(me, NULL, true, true) == -1)
+ if (ED_mesh_color_add(me, NULL, true, true) == -1) {
return OPERATOR_CANCELLED;
+ }
return OPERATOR_FINISHED;
}
@@ -594,8 +603,9 @@ static int mesh_vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
- if (!ED_mesh_color_remove_active(me))
+ if (!ED_mesh_color_remove_active(me)) {
return OPERATOR_CANCELLED;
+ }
return OPERATOR_FINISHED;
}
@@ -785,7 +795,8 @@ static int mesh_customdata_custom_splitnormals_add_exec(bContext *C, wmOperator
CustomData *data = GET_CD_DATA(me, ldata);
if (me->edit_mesh) {
- /* Tag edges as sharp according to smooth threshold if needed, to preserve autosmooth shading. */
+ /* Tag edges as sharp according to smooth threshold if needed,
+ * to preserve autosmooth shading. */
if (me->flag & ME_AUTOSMOOTH) {
BM_edges_sharp_from_angle_set(me->edit_mesh->bm, me->smoothresh);
}
@@ -793,7 +804,8 @@ static int mesh_customdata_custom_splitnormals_add_exec(bContext *C, wmOperator
BM_data_layer_add(me->edit_mesh->bm, data, CD_CUSTOMLOOPNORMAL);
}
else {
- /* Tag edges as sharp according to smooth threshold if needed, to preserve autosmooth shading. */
+ /* Tag edges as sharp according to smooth threshold if needed,
+ * to preserve autosmooth shading. */
if (me->flag & ME_AUTOSMOOTH) {
float(*polynors)[3] = MEM_mallocN(sizeof(*polynors) * (size_t)me->totpoly, __func__);
@@ -891,8 +903,9 @@ void ED_mesh_update(
BKE_mesh_calc_edges_loose(mesh);
}
- if (calc_edges || ((mesh->totpoly || mesh->totface) && mesh->totedge == 0))
+ if (calc_edges || ((mesh->totpoly || mesh->totface) && mesh->totedge == 0)) {
BKE_mesh_calc_edges(mesh, calc_edges, true);
+ }
if (calc_tessface) {
if (tessface_input == false) {
@@ -916,15 +929,17 @@ static void mesh_add_verts(Mesh *mesh, int len)
MVert *mvert;
int i, totvert;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totvert = mesh->totvert + len;
CustomData_copy(&mesh->vdata, &vdata, CD_MASK_MESH.vmask, CD_DEFAULT, totvert);
CustomData_copy_data(&mesh->vdata, &vdata, 0, 0, mesh->totvert);
- if (!CustomData_has_layer(&vdata, CD_MVERT))
+ if (!CustomData_has_layer(&vdata, CD_MVERT)) {
CustomData_add_layer(&vdata, CD_MVERT, CD_CALLOC, NULL, totvert);
+ }
CustomData_free(&mesh->vdata, mesh->totvert);
mesh->vdata = vdata;
@@ -934,8 +949,9 @@ static void mesh_add_verts(Mesh *mesh, int len)
/* set default flags */
mvert = &mesh->mvert[mesh->totvert];
- for (i = 0; i < len; i++, mvert++)
+ for (i = 0; i < len; i++, mvert++) {
mvert->flag |= SELECT;
+ }
/* set final vertex list size */
mesh->totvert = totvert;
@@ -947,8 +963,9 @@ static void mesh_add_edges(Mesh *mesh, int len)
MEdge *medge;
int i, totedge;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totedge = mesh->totedge + len;
@@ -956,8 +973,9 @@ static void mesh_add_edges(Mesh *mesh, int len)
CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH.emask, CD_DEFAULT, totedge);
CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge);
- if (!CustomData_has_layer(&edata, CD_MEDGE))
+ if (!CustomData_has_layer(&edata, CD_MEDGE)) {
CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
+ }
CustomData_free(&mesh->edata, mesh->totedge);
mesh->edata = edata;
@@ -965,8 +983,9 @@ static void mesh_add_edges(Mesh *mesh, int len)
/* set default flags */
medge = &mesh->medge[mesh->totedge];
- for (i = 0; i < len; i++, medge++)
+ for (i = 0; i < len; i++, medge++) {
medge->flag = ME_EDGEDRAW | ME_EDGERENDER | SELECT;
+ }
mesh->totedge = totedge;
}
@@ -977,8 +996,9 @@ static void mesh_add_tessfaces(Mesh *mesh, int len)
MFace *mface;
int i, totface;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totface = mesh->totface + len; /* new face count */
@@ -986,8 +1006,9 @@ static void mesh_add_tessfaces(Mesh *mesh, int len)
CustomData_copy(&mesh->fdata, &fdata, CD_MASK_MESH.fmask, CD_DEFAULT, totface);
CustomData_copy_data(&mesh->fdata, &fdata, 0, 0, mesh->totface);
- if (!CustomData_has_layer(&fdata, CD_MFACE))
+ if (!CustomData_has_layer(&fdata, CD_MFACE)) {
CustomData_add_layer(&fdata, CD_MFACE, CD_CALLOC, NULL, totface);
+ }
CustomData_free(&mesh->fdata, mesh->totface);
mesh->fdata = fdata;
@@ -995,8 +1016,9 @@ static void mesh_add_tessfaces(Mesh *mesh, int len)
/* set default flags */
mface = &mesh->mface[mesh->totface];
- for (i = 0; i < len; i++, mface++)
+ for (i = 0; i < len; i++, mface++) {
mface->flag = ME_FACE_SEL;
+ }
mesh->totface = totface;
}
@@ -1006,8 +1028,9 @@ static void mesh_add_loops(Mesh *mesh, int len)
CustomData ldata;
int totloop;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totloop = mesh->totloop + len; /* new face count */
@@ -1015,8 +1038,9 @@ static void mesh_add_loops(Mesh *mesh, int len)
CustomData_copy(&mesh->ldata, &ldata, CD_MASK_MESH.lmask, CD_DEFAULT, totloop);
CustomData_copy_data(&mesh->ldata, &ldata, 0, 0, mesh->totloop);
- if (!CustomData_has_layer(&ldata, CD_MLOOP))
+ if (!CustomData_has_layer(&ldata, CD_MLOOP)) {
CustomData_add_layer(&ldata, CD_MLOOP, CD_CALLOC, NULL, totloop);
+ }
CustomData_free(&mesh->ldata, mesh->totloop);
mesh->ldata = ldata;
@@ -1031,8 +1055,9 @@ static void mesh_add_polys(Mesh *mesh, int len)
MPoly *mpoly;
int i, totpoly;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totpoly = mesh->totpoly + len; /* new face count */
@@ -1040,8 +1065,9 @@ static void mesh_add_polys(Mesh *mesh, int len)
CustomData_copy(&mesh->pdata, &pdata, CD_MASK_MESH.pmask, CD_DEFAULT, totpoly);
CustomData_copy_data(&mesh->pdata, &pdata, 0, 0, mesh->totpoly);
- if (!CustomData_has_layer(&pdata, CD_MPOLY))
+ if (!CustomData_has_layer(&pdata, CD_MPOLY)) {
CustomData_add_layer(&pdata, CD_MPOLY, CD_CALLOC, NULL, totpoly);
+ }
CustomData_free(&mesh->pdata, mesh->totpoly);
mesh->pdata = pdata;
@@ -1049,8 +1075,9 @@ static void mesh_add_polys(Mesh *mesh, int len)
/* set default flags */
mpoly = &mesh->mpoly[mesh->totpoly];
- for (i = 0; i < len; i++, mpoly++)
+ for (i = 0; i < len; i++, mpoly++) {
mpoly->flag = ME_FACE_SEL;
+ }
mesh->totpoly = totpoly;
}
@@ -1059,8 +1086,9 @@ static void mesh_remove_verts(Mesh *mesh, int len)
{
int totvert;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totvert = mesh->totvert - len;
CustomData_free_elem(&mesh->vdata, totvert, len);
@@ -1073,8 +1101,9 @@ static void mesh_remove_edges(Mesh *mesh, int len)
{
int totedge;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totedge = mesh->totedge - len;
CustomData_free_elem(&mesh->edata, totedge, len);
@@ -1086,8 +1115,9 @@ static void mesh_remove_faces(Mesh *mesh, int len)
{
int totface;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totface = mesh->totface - len; /* new face count */
CustomData_free_elem(&mesh->fdata, totface, len);
diff --git a/source/blender/editors/mesh/mesh_mirror.c b/source/blender/editors/mesh/mesh_mirror.c
index 7d0ee19b5ea..eec0c4a57fa 100644
--- a/source/blender/editors/mesh/mesh_mirror.c
+++ b/source/blender/editors/mesh/mesh_mirror.c
@@ -50,8 +50,9 @@ int ED_mesh_mirror_spatial_table(
Object *ob, BMEditMesh *em, Mesh *me_eval, const float co[3], char mode)
{
if (mode == 'u') { /* use table */
- if (MirrKdStore.tree == NULL)
+ if (MirrKdStore.tree == NULL) {
ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 's');
+ }
if (MirrKdStore.tree) {
KDTreeNearest_3d nearest;
@@ -70,8 +71,9 @@ int ED_mesh_mirror_spatial_table(
const bool use_em = (!me_eval && em && me->edit_mesh == em);
const int totvert = use_em ? em->bm->totvert : me_eval ? me_eval->totvert : me->totvert;
- if (MirrKdStore.tree) /* happens when entering this call without ending it */
+ if (MirrKdStore.tree) { /* happens when entering this call without ending it */
ED_mesh_mirror_spatial_table(ob, em, me_eval, co, 'e');
+ }
MirrKdStore.tree = BLI_kdtree_3d_new(totvert);
@@ -126,19 +128,23 @@ typedef struct MirrTopoVert_t {
static int mirrtopo_hash_sort(const void *l1, const void *l2)
{
- if ((MirrTopoHash_t)(intptr_t)l1 > (MirrTopoHash_t)(intptr_t)l2)
+ if ((MirrTopoHash_t)(intptr_t)l1 > (MirrTopoHash_t)(intptr_t)l2) {
return 1;
- else if ((MirrTopoHash_t)(intptr_t)l1 < (MirrTopoHash_t)(intptr_t)l2)
+ }
+ else if ((MirrTopoHash_t)(intptr_t)l1 < (MirrTopoHash_t)(intptr_t)l2) {
return -1;
+ }
return 0;
}
static int mirrtopo_vert_sort(const void *v1, const void *v2)
{
- if (((MirrTopoVert_t *)v1)->hash > ((MirrTopoVert_t *)v2)->hash)
+ if (((MirrTopoVert_t *)v1)->hash > ((MirrTopoVert_t *)v2)->hash) {
return 1;
- else if (((MirrTopoVert_t *)v1)->hash < ((MirrTopoVert_t *)v2)->hash)
+ }
+ else if (((MirrTopoVert_t *)v1)->hash < ((MirrTopoVert_t *)v2)->hash) {
return -1;
+ }
return 0;
}
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index 8a51b9ba54e..ed5e6c39f85 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -242,7 +242,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "MESH_OT_duplicate");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_rip_move",
@@ -251,7 +251,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_rip");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_rip_edge_move",
@@ -260,7 +260,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "MESH_OT_rip_edge");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_extrude_region_move",
@@ -269,7 +269,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_extrude_context_move",
@@ -278,7 +278,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_context");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_extrude_region_shrink_fatten",
@@ -287,7 +287,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_extrude_faces_move",
@@ -296,7 +296,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_faces_indiv");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_extrude_edges_move",
@@ -305,7 +305,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_edges_indiv");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_extrude_vertices_move",
@@ -314,7 +314,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_verts_indiv");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_polybuild_face_at_cursor_move",
@@ -323,7 +323,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "MESH_OT_polybuild_face_at_cursor");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("MESH_OT_polybuild_split_at_cursor_move",
@@ -332,7 +332,7 @@ void ED_operatormacros_mesh(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "MESH_OT_polybuild_split_at_cursor");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_enum_set(otmacro->ptr, "proportional", 0);
+ RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
RNA_boolean_set(otmacro->ptr, "mirror", false);
}
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index ce7908bf0a3..c32fef42d27 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -150,9 +150,11 @@ static void join_mesh_single(Depsgraph *depsgraph,
mul_m4_v3(cmat, mvert->co);
}
- /* for each shapekey in destination mesh:
- * - if there's a matching one, copy it across (will need to transform vertices into new space...)
- * - otherwise, just copy own coordinates of mesh (no need to transform vertex coordinates into new space)
+ /* For each shapekey in destination mesh:
+ * - if there's a matching one, copy it across
+ * (will need to transform vertices into new space...).
+ * - otherwise, just copy own coordinates of mesh
+ * (no need to transform vertex coordinates into new space).
*/
if (key) {
/* if this mesh has any shapekeys, check first, otherwise just copy coordinates */
@@ -321,12 +323,14 @@ int join_mesh_exec(bContext *C, wmOperator *op)
totpoly += me->totpoly;
totmat += ob_iter->totcol;
- if (ob_iter == ob)
+ if (ob_iter == ob) {
ok = true;
+ }
/* check for shapekeys */
- if (me->key)
+ if (me->key) {
haskey++;
+ }
}
}
CTX_DATA_END;
@@ -337,7 +341,8 @@ int join_mesh_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- /* only join meshes if there are verts to join, there aren't too many, and we only had one mesh selected */
+ /* Only join meshes if there are verts to join,
+ * there aren't too many, and we only had one mesh selected. */
me = (Mesh *)ob->data;
key = me->key;
@@ -383,8 +388,9 @@ int join_mesh_exec(bContext *C, wmOperator *op)
/* for all keys in old block, clear data-arrays */
for (kb = key->block.first; kb; kb = kb->next) {
- if (kb->data)
+ if (kb->data) {
MEM_freeN(kb->data);
+ }
kb->data = MEM_callocN(sizeof(float) * 3 * totvert, "join_shapekey");
kb->totelem = totvert;
}
@@ -410,8 +416,9 @@ int join_mesh_exec(bContext *C, wmOperator *op)
BLI_addtail(&ob->defbase, odg);
}
}
- if (ob->defbase.first && ob->actdef == 0)
+ if (ob->defbase.first && ob->actdef == 0) {
ob->actdef = 1;
+ }
if (me->totvert) {
/* Add this object's materials to the base one's if they don't exist already
@@ -606,13 +613,15 @@ int join_mesh_exec(bContext *C, wmOperator *op)
/* old material array */
for (a = 1; a <= ob->totcol; a++) {
ma = ob->mat[a - 1];
- if (ma)
+ if (ma) {
id_us_min(&ma->id);
+ }
}
for (a = 1; a <= me->totcol; a++) {
ma = me->mat[a - 1];
- if (ma)
+ if (ma) {
id_us_min(&ma->id);
+ }
}
MEM_SAFE_FREE(ob->mat);
MEM_SAFE_FREE(ob->matbits);
@@ -680,21 +689,25 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
if (ob_iter->type == OB_MESH) {
selme = (Mesh *)ob_iter->data;
- if (selme->totvert == me->totvert)
+ if (selme->totvert == me->totvert) {
ok = true;
- else
+ }
+ else {
nonequal_verts = 1;
+ }
}
}
CTX_DATA_END;
if (!ok) {
- if (nonequal_verts)
+ if (nonequal_verts) {
BKE_report(op->reports, RPT_WARNING, "Selected meshes must have equal numbers of vertices");
- else
+ }
+ else {
BKE_report(op->reports,
RPT_WARNING,
"No additional selected meshes with equal vertex count to join");
+ }
return OPERATOR_CANCELLED;
}
@@ -748,9 +761,10 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
static MirrTopoStore_t mesh_topo_store = {NULL, -1. - 1, -1};
-/* mode is 's' start, or 'e' end, or 'u' use */
-/* if end, ob can be NULL */
-/* note, is supposed return -1 on error, which callers are currently checking for, but is not used so far */
+/** mode is 's' start, or 'e' end, or 'u' use
+ * if end, ob can be NULL.
+ * \note, is supposed return -1 on error,
+ * which callers are currently checking for, but is not used so far. */
int ED_mesh_mirror_topo_table(Object *ob, Mesh *me_eval, char mode)
{
if (mode == 'u') { /* use table */
@@ -789,8 +803,9 @@ static int mesh_get_x_mirror_vert_spatial(Object *ob, Mesh *mesh, int index)
static int mesh_get_x_mirror_vert_topo(Object *ob, Mesh *mesh, int index)
{
- if (ED_mesh_mirror_topo_table(ob, mesh, 'u') == -1)
+ if (ED_mesh_mirror_topo_table(ob, mesh, 'u') == -1) {
return -1;
+ }
return mesh_topo_store.index_lookup[index];
}
@@ -832,8 +847,9 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob,
int index)
{
intptr_t poinval;
- if (ED_mesh_mirror_topo_table(ob, NULL, 'u') == -1)
+ if (ED_mesh_mirror_topo_table(ob, NULL, 'u') == -1) {
return NULL;
+ }
if (index == -1) {
BMIter iter;
@@ -841,8 +857,9 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob,
index = 0;
BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
- if (v == eve)
+ if (v == eve) {
break;
+ }
index++;
}
@@ -853,8 +870,9 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob,
poinval = mesh_topo_store.index_lookup[index];
- if (poinval != -1)
+ if (poinval != -1) {
return (BMVert *)(poinval);
+ }
return NULL;
}
@@ -900,17 +918,15 @@ int ED_mesh_mirror_get_vert(Object *ob, int index)
#if 0
-static float *editmesh_get_mirror_uv(BMEditMesh *em, int axis, float *uv, float *mirrCent, float *face_cent)
+static float *editmesh_get_mirror_uv(
+ BMEditMesh *em, int axis, float *uv, float *mirrCent, float *face_cent)
{
float vec[2];
float cent_vec[2];
float cent[2];
/* ignore nan verts */
- if (isnan(uv[0]) || !isfinite(uv[0]) ||
- isnan(uv[1]) || !isfinite(uv[1])
- )
- {
+ if (isnan(uv[0]) || !isfinite(uv[0]) || isnan(uv[1]) || !isfinite(uv[1])) {
return NULL;
}
@@ -937,15 +953,14 @@ static float *editmesh_get_mirror_uv(BMEditMesh *em, int axis, float *uv, float
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
uv_poly_center(efa, cent, cd_loop_uv_offset);
- if ( (fabsf(cent[0] - cent_vec[0]) < 0.001f) && (fabsf(cent[1] - cent_vec[1]) < 0.001f) ) {
+ if ((fabsf(cent[0] - cent_vec[0]) < 0.001f) && (fabsf(cent[1] - cent_vec[1]) < 0.001f)) {
BMIter liter;
BMLoop *l;
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
MLoopUV *luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
- if ( (fabsf(luv->uv[0] - vec[0]) < 0.001f) && (fabsf(luv->uv[1] - vec[1]) < 0.001f) ) {
+ if ((fabsf(luv->uv[0] - vec[0]) < 0.001f) && (fabsf(luv->uv[1] - vec[1]) < 0.001f)) {
return luv->uv;
-
}
}
}
@@ -977,22 +992,29 @@ static unsigned int mirror_facehash(const void *ptr)
static int mirror_facerotation(MFace *a, MFace *b)
{
if (b->v4) {
- if (a->v1 == b->v1 && a->v2 == b->v2 && a->v3 == b->v3 && a->v4 == b->v4)
+ if (a->v1 == b->v1 && a->v2 == b->v2 && a->v3 == b->v3 && a->v4 == b->v4) {
return 0;
- else if (a->v4 == b->v1 && a->v1 == b->v2 && a->v2 == b->v3 && a->v3 == b->v4)
+ }
+ else if (a->v4 == b->v1 && a->v1 == b->v2 && a->v2 == b->v3 && a->v3 == b->v4) {
return 1;
- else if (a->v3 == b->v1 && a->v4 == b->v2 && a->v1 == b->v3 && a->v2 == b->v4)
+ }
+ else if (a->v3 == b->v1 && a->v4 == b->v2 && a->v1 == b->v3 && a->v2 == b->v4) {
return 2;
- else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v4 == b->v3 && a->v1 == b->v4)
+ }
+ else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v4 == b->v3 && a->v1 == b->v4) {
return 3;
+ }
}
else {
- if (a->v1 == b->v1 && a->v2 == b->v2 && a->v3 == b->v3)
+ if (a->v1 == b->v1 && a->v2 == b->v2 && a->v3 == b->v3) {
return 0;
- else if (a->v3 == b->v1 && a->v1 == b->v2 && a->v2 == b->v3)
+ }
+ else if (a->v3 == b->v1 && a->v1 == b->v2 && a->v2 == b->v3) {
return 1;
- else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v1 == b->v3)
+ }
+ else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v1 == b->v3) {
return 2;
+ }
}
return -1;
@@ -1027,14 +1049,16 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval)
ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 's');
- for (a = 0, mv = mvert; a < totvert; a++, mv++)
+ for (a = 0, mv = mvert; a < totvert; a++, mv++) {
mirrorverts[a] = mesh_get_x_mirror_vert(ob, me_eval, a, use_topology);
+ }
ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 'e');
fhash = BLI_ghash_new_ex(mirror_facehash, mirror_facecmp, "mirror_facehash gh", me->totface);
- for (a = 0, mf = mface; a < totface; a++, mf++)
+ for (a = 0, mf = mface; a < totface; a++, mf++) {
BLI_ghash_insert(fhash, mf, mf);
+ }
for (a = 0, mf = mface; a < totface; a++, mf++) {
mirrormf.v1 = mirrorverts[mf->v3];
@@ -1053,8 +1077,9 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval)
mirrorfaces[a * 2] = hashmf - mface;
mirrorfaces[a * 2 + 1] = mirror_facerotation(&mirrormf, hashmf);
}
- else
+ else {
mirrorfaces[a * 2] = -1;
+ }
}
BLI_ghash_free(fhash, NULL, NULL);
@@ -1079,8 +1104,9 @@ bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], uint dist_px,
BLI_assert(me && GS(me->id.name) == ID_ME);
- if (!me || me->totpoly == 0)
+ if (!me || me->totpoly == 0) {
return false;
+ }
ED_view3d_viewcontext_init(C, &vc);
@@ -1260,8 +1286,9 @@ bool ED_mesh_pick_vert(
BLI_assert(me && GS(me->id.name) == ID_ME);
- if (!me || me->totvert == 0)
+ if (!me || me->totvert == 0) {
return false;
+ }
ED_view3d_viewcontext_init(C, &vc);
@@ -1335,15 +1362,17 @@ MDeformVert *ED_mesh_active_dvert_get_em(Object *ob, BMVert **r_eve)
BMVert *eve = BM_mesh_active_vert_get(bm);
if (eve) {
- if (r_eve)
+ if (r_eve) {
*r_eve = eve;
+ }
return BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset);
}
}
}
- if (r_eve)
+ if (r_eve) {
*r_eve = NULL;
+ }
return NULL;
}
@@ -1351,8 +1380,9 @@ MDeformVert *ED_mesh_active_dvert_get_ob(Object *ob, int *r_index)
{
Mesh *me = ob->data;
int index = BKE_mesh_mselect_active_get(me, ME_VSEL);
- if (r_index)
+ if (r_index) {
*r_index = index;
+ }
if (index == -1 || me->dvert == NULL) {
return NULL;
}