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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/mesh/editmesh_tools.c')
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c221
1 files changed, 142 insertions, 79 deletions
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";