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.c57
1 files changed, 30 insertions, 27 deletions
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index fe9656d277e..41a9f426798 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -44,6 +44,7 @@
#include "BLI_string.h"
#include "BKE_context.h"
+#include "BKE_customdata.h"
#include "BKE_deform.h"
#include "BKE_editmesh.h"
#include "BKE_key.h"
@@ -145,7 +146,7 @@ static int edbm_subdivide_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-/* Note, these values must match delete_mesh() event values */
+/* NOTE: these values must match delete_mesh() event values. */
static const EnumPropertyItem prop_mesh_cornervert_types[] = {
{SUBD_CORNER_INNERVERT, "INNERVERT", 0, "Inner Vert", ""},
{SUBD_CORNER_PATH, "PATH", 0, "Path", ""},
@@ -245,7 +246,7 @@ static void mesh_operator_edgering_props(wmOperatorType *ot,
const int cuts_min,
const int cuts_default)
{
- /* Note, these values must match delete_mesh() event values */
+ /* NOTE: these values must match delete_mesh() event values. */
static const EnumPropertyItem prop_subd_edgering_types[] = {
{SUBD_RING_INTERP_LINEAR, "LINEAR", 0, "Linear", ""},
{SUBD_RING_INTERP_PATH, "PATH", 0, "Blend Path", ""},
@@ -431,7 +432,7 @@ void MESH_OT_unsubdivide(wmOperatorType *ot)
/** \name Delete Operator
* \{ */
-/* Note, these values must match delete_mesh() event values */
+/* NOTE: these values must match delete_mesh() event values. */
enum {
MESH_DELETE_VERT = 0,
MESH_DELETE_EDGE = 1,
@@ -973,7 +974,7 @@ static int edbm_add_edge_face_exec(bContext *C, wmOperator *op)
#ifdef USE_FACE_CREATE_SEL_EXTEND
/* normally we would want to leave the new geometry selected,
* but being able to press F many times to add geometry is too useful! */
- if (ele_desel && (BMO_slot_buffer_count(bmop.slots_out, "faces.out") == 1) &&
+ if (ele_desel && (BMO_slot_buffer_len(bmop.slots_out, "faces.out") == 1) &&
(ele_desel_face = BMO_slot_buffer_get_first(bmop.slots_out, "faces.out"))) {
edbm_add_edge_face_exec__tricky_finalize_sel(em->bm, ele_desel, ele_desel_face);
}
@@ -1264,9 +1265,12 @@ static bool edbm_connect_vert_pair(BMEditMesh *em, struct Mesh *me, wmOperator *
}
}
if (checks_succeded) {
+ BMBackup em_backup = EDBM_redo_state_store(em);
+
BM_custom_loop_normals_to_vector_layer(bm);
BMO_op_exec(bm, &bmop);
+ const bool failure = BMO_error_occurred_at_level(bm, BMO_ERROR_FATAL);
len = BMO_slot_get(bmop.slots_out, "edges.out")->len;
if (len && is_pair) {
@@ -1275,8 +1279,14 @@ static bool edbm_connect_vert_pair(BMEditMesh *em, struct Mesh *me, wmOperator *
em->bm, bmop.slots_out, "edges.out", BM_EDGE, BM_ELEM_SELECT, true);
}
- if (!EDBM_op_finish(em, &bmop, op, true)) {
+ bool em_backup_free = true;
+ if (!EDBM_op_finish(em, &bmop, op, false)) {
+ len = 0;
+ }
+ else if (failure) {
len = 0;
+ EDBM_redo_state_restore_and_free(&em_backup, em, true);
+ em_backup_free = false;
}
else {
/* so newly created edges get the selection state from the vertex */
@@ -1291,6 +1301,10 @@ static bool edbm_connect_vert_pair(BMEditMesh *em, struct Mesh *me, wmOperator *
.is_destructive = true,
});
}
+
+ if (em_backup_free) {
+ EDBM_redo_state_free(&em_backup);
+ }
}
MEM_freeN(verts);
@@ -2331,7 +2345,7 @@ static int edbm_edge_rotate_selected_exec(bContext *C, wmOperator *op)
BMO_slot_buffer_hflag_enable(
em->bm, bmop.slots_out, "edges.out", BM_EDGE, BM_ELEM_SELECT, true);
- const int tot_rotate = BMO_slot_buffer_count(bmop.slots_out, "edges.out");
+ const int tot_rotate = BMO_slot_buffer_len(bmop.slots_out, "edges.out");
const int tot_failed = tot - tot_rotate;
tot_rotate_all += tot_rotate;
@@ -3012,10 +3026,8 @@ static int edbm_rotate_uvs_exec(bContext *C, wmOperator *op)
BMOperator bmop;
- /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */
EDBM_op_init(em, &bmop, op, "rotate_uvs faces=%hf use_ccw=%b", BM_ELEM_SELECT, use_ccw);
- /* execute the operator */
BMO_op_exec(em->bm, &bmop);
if (!EDBM_op_finish(em, &bmop, op, true)) {
@@ -3050,13 +3062,10 @@ static int edbm_reverse_uvs_exec(bContext *C, wmOperator *op)
BMOperator bmop;
- /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */
EDBM_op_init(em, &bmop, op, "reverse_uvs faces=%hf", BM_ELEM_SELECT);
- /* execute the operator */
BMO_op_exec(em->bm, &bmop);
- /* finish the operator */
if (!EDBM_op_finish(em, &bmop, op, true)) {
continue;
}
@@ -3091,13 +3100,10 @@ static int edbm_rotate_colors_exec(bContext *C, wmOperator *op)
BMOperator bmop;
- /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */
EDBM_op_init(em, &bmop, op, "rotate_colors faces=%hf use_ccw=%b", BM_ELEM_SELECT, use_ccw);
- /* execute the operator */
BMO_op_exec(em->bm, &bmop);
- /* finish the operator */
if (!EDBM_op_finish(em, &bmop, op, true)) {
continue;
}
@@ -3133,15 +3139,12 @@ static int edbm_reverse_colors_exec(bContext *C, wmOperator *op)
BMOperator bmop;
- /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */
EDBM_op_init(em, &bmop, op, "reverse_colors faces=%hf", BM_ELEM_SELECT);
- /* execute the operator */
BMO_op_exec(em->bm, &bmop);
- /* finish the operator */
if (!EDBM_op_finish(em, &bmop, op, true)) {
- return OPERATOR_CANCELLED;
+ continue;
}
EDBM_update(obedit->data,
@@ -4222,7 +4225,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
/* for ED_view3d_project_float_object */
ED_view3d_init_mats_rv3d(obedit, region->regiondata);
- /* TODO, investigate using index lookup for screen_vert_coords() rather than a hash table */
+ /* TODO: investigate using index lookup for #screen_vert_coords() rather than a hash table. */
/* the floating point coordinates of verts in screen space will be
* stored in a hash table according to the vertices pointer */
@@ -5737,7 +5740,7 @@ static int edbm_decimate_exec(bContext *C, wmOperator *op)
float *vweights = MEM_mallocN(sizeof(*vweights) * bm->totvert, __func__);
{
const int cd_dvert_offset = CustomData_get_offset(&bm->vdata, CD_MDEFORMVERT);
- const int defbase_act = obedit->actdef - 1;
+ const int defbase_act = BKE_object_defgroup_active_index_get(obedit) - 1;
if (use_vertex_group && (cd_dvert_offset == -1)) {
BKE_report(op->reports, RPT_WARNING, "No active vertex group");
@@ -5874,7 +5877,7 @@ void MESH_OT_decimate(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* Note, keep in sync with 'rna_def_modifier_decimate' */
+ /* NOTE: keep in sync with 'rna_def_modifier_decimate'. */
RNA_def_float(ot->srna, "ratio", 1.0f, 0.0f, 1.0f, "Ratio", "", 0.0f, 1.0f);
RNA_def_boolean(ot->srna,
@@ -6558,7 +6561,7 @@ enum {
typedef struct BMElemSort {
/** Sort factor */
float srt;
- /** Original index of this element _in its mempool_ */
+ /** Original index of this element (in its #BLI_mempool). */
int org_idx;
} BMElemSort;
@@ -6751,7 +6754,7 @@ static void sort_bmelem_flag(bContext *C,
BM_ITER_MESH_INDEX (fa, &iter, em->bm, BM_FACES_OF_MESH, i) {
if (BM_elem_flag_test(fa, flag)) {
/* Reverse materials' order, not order of faces inside each mat! */
- /* Note: cannot use totcol, as mat_nr may sometimes be greater... */
+ /* NOTE: cannot use totcol, as mat_nr may sometimes be greater... */
float srt = reverse ? (float)(MAXMAT - fa->mat_nr) : (float)fa->mat_nr;
pb[i] = false;
sb[affected[2]].org_idx = i;
@@ -7304,7 +7307,7 @@ static int edbm_bridge_edge_loops_for_single_editmesh(wmOperator *op,
BMO_op_exec(em->bm, &bmop);
- if (!BMO_error_occurred(em->bm)) {
+ if (!BMO_error_occurred_at_level(em->bm, BMO_ERROR_CANCEL)) {
/* when merge is used the edges are joined and remain selected */
if (use_merge == false) {
EDBM_flag_disable_all(em, BM_ELEM_SELECT);
@@ -7670,7 +7673,7 @@ static int edbm_convex_hull_exec(bContext *C, wmOperator *op)
BMO_op_exec(em->bm, &bmop);
/* Hull fails if input is coplanar */
- if (BMO_error_occurred(em->bm)) {
+ if (BMO_error_occurred_at_level(em->bm, BMO_ERROR_CANCEL)) {
EDBM_op_finish(em, &bmop, op, true);
continue;
}
@@ -8385,7 +8388,7 @@ static void point_normals_update_header(bContext *C, wmOperator *op)
ED_area_status_text(CTX_wm_area(C), header);
}
-/* TODO move that to generic function in BMesh? */
+/* TODO: move that to generic function in BMesh? */
static void bmesh_selected_verts_center_calc(BMesh *bm, float *r_center)
{
BMVert *v;
@@ -9691,7 +9694,7 @@ static int edbm_smooth_normals_exec(bContext *C, wmOperator *op)
BKE_lnor_space_custom_data_to_normal(
bm->lnor_spacearr->lspacearr[lnor_ed->loop_index], lnor_ed->clnors_data, current_normal);
- /* Note: again, this is not true spherical interpolation that normals would need...
+ /* NOTE: again, this is not true spherical interpolation that normals would need...
* But it's probably good enough for now. */
mul_v3_fl(current_normal, 1.0f - factor);
mul_v3_fl(smooth_normal[i], factor);