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.c114
1 files changed, 64 insertions, 50 deletions
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 2cffb3ecdec..29860de88f1 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -1557,7 +1557,7 @@ static int edbm_vert_connect_path_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Invalid selection order");
return OPERATOR_CANCELLED;
}
- else if (failed_connect_len == objects_len) {
+ if (failed_connect_len == objects_len) {
BKE_report(op->reports, RPT_ERROR, "Could not connect vertices");
return OPERATOR_CANCELLED;
}
@@ -2035,19 +2035,26 @@ static bool flip_custom_normals(BMesh *bm, BMLoopNorEditDataArray *lnors_ed_arr)
}
BMFace *f;
- BMLoop *l;
- BMIter iter_f, iter_l;
+ BMLoop *l, *l_start;
+ BMIter iter_f;
BM_ITER_MESH (f, &iter_f, bm, BM_FACES_OF_MESH) {
+ /* Flip all the custom loop normals on the selected faces. */
if (!BM_elem_flag_test(f, BM_ELEM_SELECT)) {
continue;
}
- /* Flip all the custom loop normals on the selected faces. */
- BM_ITER_ELEM (l, &iter_l, f, BM_LOOPS_OF_FACE) {
+ /* Because the winding has changed, we need to go the reverse way around the face to get the
+ * correct placement of the normals. However we need to derive the old loop index to get the
+ * correct data. Note that the first loop index is the same though. So the loop starts and ends
+ * in the same place as before the flip.
+ */
+ l_start = l = BM_FACE_FIRST_LOOP(f);
+ int old_index = BM_elem_index_get(l);
+ do {
int loop_index = BM_elem_index_get(l);
- BMLoopNorEditData *lnor_ed = lnors_ed_arr->lidx_to_lnor_editdata[loop_index];
+ BMLoopNorEditData *lnor_ed = lnors_ed_arr->lidx_to_lnor_editdata[old_index];
BMLoopNorEditData *lnor_ed_new = lnors_ed_arr_new_full->lidx_to_lnor_editdata[loop_index];
BLI_assert(lnor_ed != NULL && lnor_ed_new != NULL);
@@ -2055,7 +2062,10 @@ static bool flip_custom_normals(BMesh *bm, BMLoopNorEditDataArray *lnors_ed_arr)
BKE_lnor_space_custom_normal_to_data(
bm->lnor_spacearr->lspacearr[loop_index], lnor_ed->nloc, lnor_ed_new->clnors_data);
- }
+
+ old_index++;
+ l = l->prev;
+ } while (l != l_start);
}
BM_loop_normal_editdata_array_free(lnors_ed_arr_new_full);
return true;
@@ -2686,7 +2696,7 @@ static int edbm_do_smooth_laplacian_vertex_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_WARNING, "No selected vertex");
return OPERATOR_CANCELLED;
}
- else if (tot_invalid == objects_len) {
+ if (tot_invalid == objects_len) {
BKE_report(op->reports, RPT_WARNING, "Selected faces must be triangles or quads");
return OPERATOR_CANCELLED;
}
@@ -3505,7 +3515,7 @@ static int edbm_shape_propagate_to_all_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No selected vertex");
return OPERATOR_CANCELLED;
}
- else if (tot_shapekeys == 0) {
+ if (tot_shapekeys == 0) {
BKE_report(op->reports,
RPT_ERROR,
objects_len > 1 ? "Meshes do not have shape keys" :
@@ -3562,7 +3572,7 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Active mesh does not have shape keys");
return OPERATOR_CANCELLED;
}
- else if (shape_ref >= totshape_ref) {
+ if (shape_ref >= totshape_ref) {
/* This case occurs if operator was used before on object with more keys than current one. */
shape_ref = 0; /* default to basis */
}
@@ -3592,10 +3602,8 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op)
if (!key) {
continue;
}
- else {
- kb = BKE_keyblock_find_name(key, kb_ref->name);
- shape = BLI_findindex(&key->block, kb);
- }
+ kb = BKE_keyblock_find_name(key, kb_ref->name);
+ shape = BLI_findindex(&key->block, kb);
if (kb) {
/* Perform blending on selected vertices. */
@@ -3679,7 +3687,10 @@ static void edbm_blend_from_shape_ui(bContext *C, wmOperator *op)
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
RNA_id_pointer_create((ID *)me->key, &ptr_key);
- uiItemPointerR(layout, &ptr, "shape", &ptr_key, "key_blocks", "", ICON_SHAPEKEY_DATA);
+ uiLayoutSetPropSep(layout, true);
+ uiLayoutSetPropDecorate(layout, false);
+
+ uiItemPointerR(layout, &ptr, "shape", &ptr_key, "key_blocks", NULL, ICON_SHAPEKEY_DATA);
uiItemR(layout, &ptr, "blend", 0, NULL, ICON_NONE);
uiItemR(layout, &ptr, "add", 0, NULL, ICON_NONE);
}
@@ -3861,7 +3872,7 @@ static float bm_edge_seg_isect(const float sco_a[2],
return perc;
}
/* test e->v2 */
- else if ((x11 == x22 && y11 == y22) || (x12 == x22 && y12 == y22)) {
+ if ((x11 == x22 && y11 == y22) || (x12 == x22 && y12 == y22)) {
perc = 0;
*isected = 2;
return perc;
@@ -4171,7 +4182,8 @@ static Base *mesh_separate_tagged(
BKE_object_material_array_assign(bmain,
base_new->object,
BKE_object_material_array_p(obedit),
- *BKE_object_material_len_p(obedit));
+ *BKE_object_material_len_p(obedit),
+ false);
ED_object_base_select(base_new, BA_SELECT);
@@ -4243,7 +4255,8 @@ static Base *mesh_separate_arrays(Main *bmain,
BKE_object_material_array_assign(bmain,
base_new->object,
BKE_object_material_array_p(obedit),
- *BKE_object_material_len_p(obedit));
+ *BKE_object_material_len_p(obedit),
+ false);
ED_object_base_select(base_new, BA_SELECT);
@@ -5589,25 +5602,26 @@ static bool edbm_decimate_check(bContext *UNUSED(C), wmOperator *UNUSED(op))
static void edbm_decimate_ui(bContext *UNUSED(C), wmOperator *op)
{
- uiLayout *layout = op->layout, *box, *row, *col;
+ uiLayout *layout = op->layout, *row, *col, *sub;
PointerRNA ptr;
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
+ uiLayoutSetPropSep(layout, true);
+
uiItemR(layout, &ptr, "ratio", 0, NULL, ICON_NONE);
- box = uiLayoutBox(layout);
- uiItemR(box, &ptr, "use_vertex_group", 0, NULL, ICON_NONE);
- col = uiLayoutColumn(box, false);
+ uiItemR(layout, &ptr, "use_vertex_group", 0, NULL, ICON_NONE);
+ col = uiLayoutColumn(layout, false);
uiLayoutSetActive(col, RNA_boolean_get(&ptr, "use_vertex_group"));
uiItemR(col, &ptr, "vertex_group_factor", 0, NULL, ICON_NONE);
uiItemR(col, &ptr, "invert_vertex_group", 0, NULL, ICON_NONE);
- box = uiLayoutBox(layout);
- uiItemR(box, &ptr, "use_symmetry", 0, NULL, ICON_NONE);
- row = uiLayoutRow(box, true);
- uiLayoutSetActive(row, RNA_boolean_get(&ptr, "use_symmetry"));
- uiItemR(row, &ptr, "symmetry_axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+ row = uiLayoutRowWithHeading(layout, true, IFACE_("Symmetry"));
+ uiItemR(row, &ptr, "use_symmetry", 0, "", ICON_NONE);
+ sub = uiLayoutRow(row, true);
+ uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_symmetry"));
+ uiItemR(sub, &ptr, "symmetry_axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
}
void MESH_OT_decimate(wmOperatorType *ot)
@@ -5662,7 +5676,7 @@ static void edbm_dissolve_prop__use_verts(wmOperatorType *ot, bool value, int fl
PropertyRNA *prop;
prop = RNA_def_boolean(
- ot->srna, "use_verts", value, "Dissolve Verts", "Dissolve remaining vertices");
+ ot->srna, "use_verts", value, "Dissolve Vertices", "Dissolve remaining vertices");
if (flag) {
RNA_def_property_flag(prop, flag);
@@ -5727,7 +5741,7 @@ void MESH_OT_dissolve_verts(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Dissolve Vertices";
- ot->description = "Dissolve verts, merge edges and faces";
+ ot->description = "Dissolve vertices, merge edges and faces";
ot->idname = "MESH_OT_dissolve_verts";
/* api callbacks */
@@ -5885,12 +5899,10 @@ static int edbm_dissolve_mode_exec(bContext *C, wmOperator *op)
if (em->selectmode & SCE_SELECT_VERTEX) {
return edbm_dissolve_verts_exec(C, op);
}
- else if (em->selectmode & SCE_SELECT_EDGE) {
+ if (em->selectmode & SCE_SELECT_EDGE) {
return edbm_dissolve_edges_exec(C, op);
}
- else {
- return edbm_dissolve_faces_exec(C, op);
- }
+ return edbm_dissolve_faces_exec(C, op);
}
void MESH_OT_dissolve_mode(wmOperatorType *ot)
@@ -5996,7 +6008,7 @@ void MESH_OT_dissolve_limited(wmOperatorType *ot)
ot->name = "Limited Dissolve";
ot->idname = "MESH_OT_dissolve_limited";
ot->description =
- "Dissolve selected edges and verts, limited by the angle of surrounding geometry";
+ "Dissolve selected edges and vertices, limited by the angle of surrounding geometry";
/* api callbacks */
ot->exec = edbm_dissolve_limited_exec;
@@ -6814,9 +6826,7 @@ static bool edbm_sort_elements_poll_property(const bContext *UNUSED(C),
if (action == SRT_RANDOMIZE) {
return true;
}
- else {
- return false;
- }
+ return false;
}
/* Hide seed for reverse and randomize actions! */
@@ -6824,9 +6834,7 @@ static bool edbm_sort_elements_poll_property(const bContext *UNUSED(C),
if (ELEM(action, SRT_RANDOMIZE, SRT_REVERSE)) {
return false;
}
- else {
- return true;
- }
+ return true;
}
return true;
@@ -7211,7 +7219,7 @@ void MESH_OT_wireframe(wmOperatorType *ot)
PropertyRNA *prop;
/* identifiers */
- ot->name = "Wire Frame";
+ ot->name = "Wireframe";
ot->idname = "MESH_OT_wireframe";
ot->description = "Create a solid wire-frame from faces";
@@ -7507,10 +7515,8 @@ static int mesh_symmetrize_exec(bContext *C, wmOperator *op)
if (!EDBM_op_finish(em, &bmop, op, true)) {
continue;
}
- else {
- EDBM_update_generic(obedit->data, true, true);
- EDBM_selectmode_flush(em);
- }
+ EDBM_update_generic(obedit->data, true, true);
+ EDBM_selectmode_flush(em);
}
MEM_freeN(objects);
@@ -7889,7 +7895,7 @@ void MESH_OT_mark_freestyle_face(wmOperatorType *ot)
/* NOTE: these defines are saved in keymap files, do not change values but just add new ones */
/* NOTE: We could add more here, like e.g. a switch between local or global coordinates of target,
- * use numinput to type in explicit vector values... */
+ * use number-input to type in explicit vector values. */
enum {
/* Generic commands. */
EDBM_CLNOR_MODAL_CANCEL = 1,
@@ -8413,6 +8419,8 @@ static void edbm_point_normals_ui(bContext *C, wmOperator *op)
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
+ uiLayoutSetPropSep(layout, true);
+
/* Main auto-draw call */
uiDefAutoButsRNA(layout, &ptr, point_normals_draw_check_prop, NULL, NULL, '\0', false);
}
@@ -8701,17 +8709,21 @@ enum {
};
static EnumPropertyItem average_method_items[] = {
- {EDBM_CLNOR_AVERAGE_LOOP, "CUSTOM_NORMAL", 0, "Custom Normal", "Take Average of vert Normals"},
+ {EDBM_CLNOR_AVERAGE_LOOP,
+ "CUSTOM_NORMAL",
+ 0,
+ "Custom Normal",
+ "Take average of vertex normals"},
{EDBM_CLNOR_AVERAGE_FACE_AREA,
"FACE_AREA",
0,
"Face Area",
- "Set all vert normals by Face Area"},
+ "Set all vertex normals by face area"},
{EDBM_CLNOR_AVERAGE_ANGLE,
"CORNER_ANGLE",
0,
"Corner Angle",
- "Set all vert normals by Corner Angle"},
+ "Set all vertex normals by corner angle"},
{0, NULL, 0, NULL, NULL},
};
@@ -8869,7 +8881,7 @@ static bool average_normals_draw_check_prop(PointerRNA *ptr,
if (STREQ(prop_id, "weight")) {
return (average_type == EDBM_CLNOR_AVERAGE_LOOP);
}
- else if (STREQ(prop_id, "threshold")) {
+ if (STREQ(prop_id, "threshold")) {
return (average_type == EDBM_CLNOR_AVERAGE_LOOP);
}
@@ -8885,6 +8897,8 @@ static void edbm_average_normals_ui(bContext *C, wmOperator *op)
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
+ uiLayoutSetPropSep(layout, true);
+
/* Main auto-draw call */
uiDefAutoButsRNA(layout, &ptr, average_normals_draw_check_prop, NULL, NULL, '\0', false);
}