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:
authorCampbell Barton <ideasman42@gmail.com>2013-04-01 14:18:01 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-04-01 14:18:01 +0400
commit6d8e25dfdc44ecb068ab73fc52af31683483a663 (patch)
treeb44396db84e5984a4519b559356e0e942ad38a36 /source/blender
parente8d0e77856872037635c1d2bcd9a466a715910c4 (diff)
code cleanup: split editmesh_tools.c, into inset, bevel (both modal operators) and moved extrude operators into their own file.
also move some selection operators from editmesh_tools.c into editmesh_select.c
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/include/ED_mesh.h2
-rw-r--r--source/blender/editors/mesh/CMakeLists.txt3
-rw-r--r--source/blender/editors/mesh/editmesh_add.c3
-rw-r--r--source/blender/editors/mesh/editmesh_bevel.c368
-rw-r--r--source/blender/editors/mesh/editmesh_bvh.c7
-rw-r--r--source/blender/editors/mesh/editmesh_extrude.c921
-rw-r--r--source/blender/editors/mesh/editmesh_inset.c431
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c6
-rw-r--r--source/blender/editors/mesh/editmesh_knife_project.c9
-rw-r--r--source/blender/editors/mesh/editmesh_loopcut.c6
-rw-r--r--source/blender/editors/mesh/editmesh_rip.c4
-rw-r--r--source/blender/editors/mesh/editmesh_select.c587
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c2009
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c14
-rw-r--r--source/blender/editors/mesh/mesh_data.c2
-rw-r--r--source/blender/editors/mesh/mesh_intern.h184
-rw-r--r--source/blender/editors/mesh/mesh_navmesh.c3
-rw-r--r--source/blender/editors/mesh/mesh_ops.c8
-rw-r--r--source/blender/editors/mesh/meshtools.c1
19 files changed, 2349 insertions, 2219 deletions
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index f84281a4f08..ab112fde48d 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -278,7 +278,7 @@ void EDBM_redo_state_restore(struct BMBackup, struct BMEditMesh *em, int recalct
void EDBM_redo_state_free(struct BMBackup *, struct BMEditMesh *em, int recalctess);
-/* meshtools.c */
+/* *** meshtools.c *** */
int join_mesh_exec(struct bContext *C, struct wmOperator *op);
int join_mesh_shapes_exec(struct bContext *C, struct wmOperator *op);
diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt
index 0a45dd6704b..46d825b8c9d 100644
--- a/source/blender/editors/mesh/CMakeLists.txt
+++ b/source/blender/editors/mesh/CMakeLists.txt
@@ -42,7 +42,10 @@ set(INC_SYS
set(SRC
editface.c
editmesh_add.c
+ editmesh_bevel.c
editmesh_bvh.c
+ editmesh_extrude.c
+ editmesh_inset.c
editmesh_knife.c
editmesh_knife_project.c
editmesh_loopcut.c
diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c
index 3117f45156d..34666b363f3 100644
--- a/source/blender/editors/mesh/editmesh_add.c
+++ b/source/blender/editors/mesh/editmesh_add.c
@@ -30,7 +30,6 @@
*/
#include "DNA_object_types.h"
-#include "DNA_scene_types.h"
#include "BLI_math.h"
@@ -50,7 +49,7 @@
#include "ED_screen.h"
#include "ED_object.h"
-#include "mesh_intern.h"
+#include "mesh_intern.h" /* own include */
/* ********* add primitive operators ************* */
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c
new file mode 100644
index 00000000000..d79f12551dd
--- /dev/null
+++ b/source/blender/editors/mesh/editmesh_bevel.c
@@ -0,0 +1,368 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Joseph Eagar, Howard Trickey, Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/mesh/editmesh_bevel.c
+ * \ingroup edmesh
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_object_types.h"
+
+#include "BLI_string.h"
+#include "BLI_math.h"
+
+#include "BLF_translation.h"
+
+#include "BKE_context.h"
+#include "BKE_tessmesh.h"
+
+#include "RNA_define.h"
+#include "RNA_access.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "ED_mesh.h"
+#include "ED_numinput.h"
+#include "ED_screen.h"
+#include "ED_transform.h"
+#include "ED_view3d.h"
+
+#include "mesh_intern.h" /* own include */
+
+
+#define MVAL_PIXEL_MARGIN 5.0f
+
+typedef struct {
+ BMEditMesh *em;
+ BMBackup mesh_backup;
+ int mcenter[2];
+ float initial_length;
+ float pixel_size; /* use when mouse input is interpreted as spatial distance */
+ int is_modal;
+ NumInput num_input;
+ float shift_factor; /* The current factor when shift is pressed. Negative when shift not active. */
+} BevelData;
+
+#define HEADER_LENGTH 180
+
+static void edbm_bevel_update_header(wmOperator *op, bContext *C)
+{
+ const char *str = IFACE_("Confirm: Enter/LClick, Cancel: (Esc/RMB), Offset: %s, Segments: %d");
+
+ char msg[HEADER_LENGTH];
+ ScrArea *sa = CTX_wm_area(C);
+
+ if (sa) {
+ char offset_str[NUM_STR_REP_LEN];
+ BLI_snprintf(offset_str, NUM_STR_REP_LEN, "%f", RNA_float_get(op->ptr, "offset"));
+ BLI_snprintf(msg, HEADER_LENGTH, str,
+ offset_str,
+ RNA_int_get(op->ptr, "segments")
+ );
+
+ ED_area_headerprint(sa, msg);
+ }
+}
+
+static int edbm_bevel_init(bContext *C, wmOperator *op, int is_modal)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(obedit);
+ BevelData *opdata;
+
+ if (em == NULL) {
+ return 0;
+ }
+
+ op->customdata = opdata = MEM_mallocN(sizeof(BevelData), "beveldata_mesh_operator");
+
+ opdata->em = em;
+ opdata->is_modal = is_modal;
+ opdata->shift_factor = -1.0f;
+
+ initNumInput(&opdata->num_input);
+ opdata->num_input.flag = NUM_NO_NEGATIVE;
+
+ /* avoid the cost of allocating a bm copy */
+ if (is_modal)
+ opdata->mesh_backup = EDBM_redo_state_store(em);
+
+ return 1;
+}
+
+static int edbm_bevel_calc(wmOperator *op)
+{
+ BevelData *opdata = op->customdata;
+ BMEditMesh *em = opdata->em;
+ BMOperator bmop;
+ const float offset = RNA_float_get(op->ptr, "offset");
+ const int segments = RNA_int_get(op->ptr, "segments");
+ const bool vertex_only = RNA_boolean_get(op->ptr, "vertex_only");
+
+ /* revert to original mesh */
+ if (opdata->is_modal) {
+ EDBM_redo_state_restore(opdata->mesh_backup, em, false);
+ }
+
+ if (!EDBM_op_init(em, &bmop, op,
+ "bevel geom=%hev offset=%f segments=%i vertex_only=%b",
+ BM_ELEM_SELECT, offset, segments, vertex_only))
+ {
+ return 0;
+ }
+
+ BMO_op_exec(em->bm, &bmop);
+
+ if (offset != 0.0f) {
+ /* not essential, but we may have some loose geometry that
+ * won't get bevel'd and better not leave it selected */
+ EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+ BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true);
+ }
+
+ /* no need to de-select existing geometry */
+ if (!EDBM_op_finish(em, &bmop, op, true))
+ return 0;
+
+ EDBM_mesh_normals_update(opdata->em);
+
+ EDBM_update_generic(opdata->em, true, true);
+
+ return 1;
+}
+
+static void edbm_bevel_exit(bContext *C, wmOperator *op)
+{
+ BevelData *opdata = op->customdata;
+
+ ScrArea *sa = CTX_wm_area(C);
+
+ if (sa) {
+ ED_area_headerprint(sa, NULL);
+ }
+
+ if (opdata->is_modal) {
+ EDBM_redo_state_free(&opdata->mesh_backup, NULL, false);
+ }
+ MEM_freeN(opdata);
+ op->customdata = NULL;
+}
+
+static int edbm_bevel_cancel(bContext *C, wmOperator *op)
+{
+ BevelData *opdata = op->customdata;
+ if (opdata->is_modal) {
+ EDBM_redo_state_free(&opdata->mesh_backup, opdata->em, true);
+ EDBM_update_generic(opdata->em, false, true);
+ }
+
+ edbm_bevel_exit(C, op);
+
+ /* need to force redisplay or we may still view the modified result */
+ ED_region_tag_redraw(CTX_wm_region(C));
+ return OPERATOR_CANCELLED;
+}
+
+/* bevel! yay!!*/
+static int edbm_bevel_exec(bContext *C, wmOperator *op)
+{
+ if (!edbm_bevel_init(C, op, false)) {
+ edbm_bevel_exit(C, op);
+ return OPERATOR_CANCELLED;
+ }
+
+ if (!edbm_bevel_calc(op)) {
+ edbm_bevel_cancel(C, op);
+ return OPERATOR_CANCELLED;
+ }
+
+ edbm_bevel_exit(C, op);
+
+ return OPERATOR_FINISHED;
+}
+
+static int edbm_bevel_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ /* TODO make modal keymap (see fly mode) */
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
+ BevelData *opdata;
+ float mlen[2];
+ float center_3d[3];
+
+ if (!edbm_bevel_init(C, op, true)) {
+ return OPERATOR_CANCELLED;
+ }
+
+ opdata = op->customdata;
+
+ /* initialize mouse values */
+ if (!calculateTransformCenter(C, V3D_CENTROID, center_3d, opdata->mcenter)) {
+ /* in this case the tool will likely do nothing,
+ * ideally this will never happen and should be checked for above */
+ opdata->mcenter[0] = opdata->mcenter[1] = 0;
+ }
+ mlen[0] = opdata->mcenter[0] - event->mval[0];
+ mlen[1] = opdata->mcenter[1] - event->mval[1];
+ opdata->initial_length = len_v2(mlen);
+ opdata->pixel_size = rv3d ? ED_view3d_pixel_size(rv3d, center_3d) : 1.0f;
+
+ edbm_bevel_update_header(op, C);
+
+ if (!edbm_bevel_calc(op)) {
+ edbm_bevel_cancel(C, op);
+ return OPERATOR_CANCELLED;
+ }
+
+ WM_event_add_modal_handler(C, op);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static float edbm_bevel_mval_factor(wmOperator *op, const wmEvent *event)
+{
+ BevelData *opdata = op->customdata;
+ int use_dist = true;
+ float mdiff[2];
+ float factor;
+
+ mdiff[0] = opdata->mcenter[0] - event->mval[0];
+ mdiff[1] = opdata->mcenter[1] - event->mval[1];
+
+ if (use_dist) {
+ factor = ((len_v2(mdiff) - MVAL_PIXEL_MARGIN) - opdata->initial_length) * opdata->pixel_size;
+ }
+ else {
+ factor = (len_v2(mdiff) - MVAL_PIXEL_MARGIN) / opdata->initial_length;
+ factor = factor - 1.0f; /* a different kind of buffer where nothing happens */
+ }
+
+ /* Fake shift-transform... */
+ if (event->shift) {
+ if (opdata->shift_factor < 0.0f) {
+ opdata->shift_factor = RNA_float_get(op->ptr, "offset");
+ }
+ factor = (factor - opdata->shift_factor) * 0.1f + opdata->shift_factor;
+ }
+ else if (opdata->shift_factor >= 0.0f)
+ opdata->shift_factor = -1.0f;
+
+ /* clamp differently based on distance/factor */
+ if (use_dist) {
+ if (factor < 0.0f) factor = 0.0f;
+ }
+ else {
+ CLAMP(factor, 0.0f, 1.0f);
+ }
+
+ return factor;
+}
+
+static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ BevelData *opdata = op->customdata;
+ int segments = RNA_int_get(op->ptr, "segments");
+
+ if (event->val == KM_PRESS) {
+ /* Try to handle numeric inputs... */
+
+ if (handleNumInput(&opdata->num_input, event)) {
+ float value = RNA_float_get(op->ptr, "offset");
+ applyNumInput(&opdata->num_input, &value);
+ RNA_float_set(op->ptr, "offset", value);
+ edbm_bevel_calc(op);
+ edbm_bevel_update_header(op, C);
+ return OPERATOR_RUNNING_MODAL;
+ }
+ }
+
+ switch (event->type) {
+ case ESCKEY:
+ case RIGHTMOUSE:
+ edbm_bevel_cancel(C, op);
+ return OPERATOR_CANCELLED;
+
+ case MOUSEMOVE:
+ if (!hasNumInput(&opdata->num_input)) {
+ const float factor = edbm_bevel_mval_factor(op, event);
+ RNA_float_set(op->ptr, "offset", factor);
+
+ edbm_bevel_calc(op);
+ edbm_bevel_update_header(op, C);
+ }
+ break;
+
+ case LEFTMOUSE:
+ case PADENTER:
+ case RETKEY:
+ edbm_bevel_calc(op);
+ edbm_bevel_exit(C, op);
+ return OPERATOR_FINISHED;
+
+ case WHEELUPMOUSE: /* change number of segments */
+ case PAGEUPKEY:
+ if (event->val == KM_RELEASE)
+ break;
+
+ segments++;
+ RNA_int_set(op->ptr, "segments", segments);
+ edbm_bevel_calc(op);
+ edbm_bevel_update_header(op, C);
+ break;
+
+ case WHEELDOWNMOUSE: /* change number of segments */
+ case PAGEDOWNKEY:
+ if (event->val == KM_RELEASE)
+ break;
+
+ segments = max_ii(segments - 1, 1);
+ RNA_int_set(op->ptr, "segments", segments);
+ edbm_bevel_calc(op);
+ edbm_bevel_update_header(op, C);
+ break;
+ }
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+void MESH_OT_bevel(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Bevel";
+ ot->description = "Edge Bevel";
+ ot->idname = "MESH_OT_bevel";
+
+ /* api callbacks */
+ ot->exec = edbm_bevel_exec;
+ ot->invoke = edbm_bevel_invoke;
+ ot->modal = edbm_bevel_modal;
+ ot->cancel = edbm_bevel_cancel;
+ ot->poll = ED_operator_editmesh;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_POINTER | OPTYPE_BLOCKING;
+
+ RNA_def_float(ot->srna, "offset", 0.0f, -FLT_MAX, FLT_MAX, "Offset", "", 0.0f, 1.0f);
+ RNA_def_int(ot->srna, "segments", 1, 1, 50, "Segments", "Segments for curved edge", 1, 8);
+ RNA_def_boolean(ot->srna, "vertex_only", false, "Vertex only", "Bevel only vertices");
+}
diff --git a/source/blender/editors/mesh/editmesh_bvh.c b/source/blender/editors/mesh/editmesh_bvh.c
index 8e397797dd9..4c989a22291 100644
--- a/source/blender/editors/mesh/editmesh_bvh.c
+++ b/source/blender/editors/mesh/editmesh_bvh.c
@@ -29,9 +29,6 @@
* \ingroup edmesh
*/
-#define IN_EDITMESHBVH
-
-
#include "MEM_guardedalloc.h"
#include "DNA_scene_types.h"
@@ -39,18 +36,18 @@
#include "DNA_screen_types.h"
#include "DNA_view3d_types.h"
-
#include "BLI_math.h"
#include "BLI_smallhash.h"
#include "BKE_DerivedMesh.h"
#include "BKE_tessmesh.h"
-#include "ED_mesh.h"
#include "ED_view3d.h"
+#define IN_EDITMESHBVH /* needed for typedef workaround */
#include "editmesh_bvh.h" /* own include */
+
typedef struct BMBVHTree {
BMEditMesh *em;
BMesh *bm;
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c
new file mode 100644
index 00000000000..694053ae2f7
--- /dev/null
+++ b/source/blender/editors/mesh/editmesh_extrude.c
@@ -0,0 +1,921 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2004 by Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Joseph Eagar
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/mesh/editmesh_extrude.c
+ * \ingroup edmesh
+ */
+
+#include "DNA_modifier_types.h"
+#include "DNA_object_types.h"
+
+#include "BLI_math.h"
+
+#include "BKE_context.h"
+#include "BKE_object.h"
+#include "BKE_report.h"
+#include "BKE_tessmesh.h"
+
+#include "RNA_define.h"
+#include "RNA_access.h"
+
+#include "WM_types.h"
+
+#include "ED_mesh.h"
+#include "ED_screen.h"
+#include "ED_view3d.h"
+
+#include "mesh_intern.h" /* own include */
+
+/* allow accumulated normals to form a new direction but don't
+ * accept direct opposite directions else they will cancel each other out */
+static void add_normal_aligned(float nor[3], const float add[3])
+{
+ if (dot_v3v3(nor, add) < -0.9999f) {
+ sub_v3_v3(nor, add);
+ }
+ else {
+ add_v3_v3(nor, add);
+ }
+}
+
+/* individual face extrude */
+/* will use vertex normals for extrusion directions, so *nor is unaffected */
+static short edbm_extrude_discrete_faces(BMEditMesh *em, wmOperator *op, const char hflag, float *UNUSED(nor))
+{
+ BMOIter siter;
+ BMIter liter;
+ BMFace *f;
+ BMLoop *l;
+ BMOperator bmop;
+
+ EDBM_op_init(em, &bmop, op, "extrude_discrete_faces faces=%hf", hflag);
+
+ /* deselect original verts */
+ EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+
+ BMO_op_exec(em->bm, &bmop);
+
+ BMO_ITER (f, &siter, bmop.slots_out, "faces.out", BM_FACE) {
+ BM_face_select_set(em->bm, f, true);
+
+ /* set face vertex normals to face normal */
+ BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
+ copy_v3_v3(l->v->no, f->no);
+ }
+ }
+
+ if (!EDBM_op_finish(em, &bmop, op, true)) {
+ return 0;
+ }
+
+ return 's'; /* s is shrink/fatten */
+}
+
+/* extrudes individual edges */
+static short edbm_extrude_edges_indiv(BMEditMesh *em, wmOperator *op, const char hflag, float *UNUSED(nor))
+{
+ BMOperator bmop;
+
+ EDBM_op_init(em, &bmop, op, "extrude_edge_only edges=%he", hflag);
+
+ /* deselect original verts */
+ EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+
+ BMO_op_exec(em->bm, &bmop);
+ BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_VERT | BM_EDGE, BM_ELEM_SELECT, true);
+
+ if (!EDBM_op_finish(em, &bmop, op, true)) {
+ return 0;
+ }
+
+ return 'n'; /* n is normal grab */
+}
+
+/* extrudes individual vertices */
+static short edbm_extrude_verts_indiv(BMEditMesh *em, wmOperator *op, const char hflag, float *UNUSED(nor))
+{
+ BMOperator bmop;
+
+ EDBM_op_init(em, &bmop, op, "extrude_vert_indiv verts=%hv", hflag);
+
+ /* deselect original verts */
+ BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_in, "verts", BM_VERT, BM_ELEM_SELECT, true);
+
+ BMO_op_exec(em->bm, &bmop);
+ BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "verts.out", BM_VERT, BM_ELEM_SELECT, true);
+
+ if (!EDBM_op_finish(em, &bmop, op, true)) {
+ return 0;
+ }
+
+ return 'g'; /* g is grab */
+}
+
+static short edbm_extrude_edge(Object *obedit, BMEditMesh *em, const char hflag, float nor[3])
+{
+ BMesh *bm = em->bm;
+ BMIter iter;
+ BMOIter siter;
+ BMOperator extop;
+ BMEdge *edge;
+ BMFace *f;
+ ModifierData *md;
+ BMElem *ele;
+ BMOpSlot *slot_edges_exclude;
+
+ BMO_op_init(bm, &extop, BMO_FLAG_DEFAULTS, "extrude_face_region");
+ BMO_slot_buffer_from_enabled_hflag(bm, &extop, extop.slots_in, "geom", BM_VERT | BM_EDGE | BM_FACE, hflag);
+
+ slot_edges_exclude = BMO_slot_get(extop.slots_in, "edges_exclude");
+
+ /* If a mirror modifier with clipping is on, we need to adjust some
+ * of the cases above to handle edges on the line of symmetry.
+ */
+ md = obedit->modifiers.first;
+ for (; md; md = md->next) {
+ if ((md->type == eModifierType_Mirror) && (md->mode & eModifierMode_Realtime)) {
+ MirrorModifierData *mmd = (MirrorModifierData *) md;
+
+ if (mmd->flag & MOD_MIR_CLIPPING) {
+ float mtx[4][4];
+ if (mmd->mirror_ob) {
+ float imtx[4][4];
+ invert_m4_m4(imtx, mmd->mirror_ob->obmat);
+ mult_m4_m4m4(mtx, imtx, obedit->obmat);
+ }
+
+ BM_ITER_MESH (edge, &iter, bm, BM_EDGES_OF_MESH) {
+ if (BM_elem_flag_test(edge, hflag) &&
+ BM_edge_is_boundary(edge) &&
+ BM_elem_flag_test(edge->l->f, hflag))
+ {
+ float co1[3], co2[3];
+
+ copy_v3_v3(co1, edge->v1->co);
+ copy_v3_v3(co2, edge->v2->co);
+
+ if (mmd->mirror_ob) {
+ mul_v3_m4v3(co1, mtx, co1);
+ mul_v3_m4v3(co2, mtx, co2);
+ }
+
+ if (mmd->flag & MOD_MIR_AXIS_X) {
+ if ((fabsf(co1[0]) < mmd->tolerance) &&
+ (fabsf(co2[0]) < mmd->tolerance))
+ {
+ BMO_slot_map_empty_insert(&extop, slot_edges_exclude, edge);
+ }
+ }
+ if (mmd->flag & MOD_MIR_AXIS_Y) {
+ if ((fabsf(co1[1]) < mmd->tolerance) &&
+ (fabsf(co2[1]) < mmd->tolerance))
+ {
+ BMO_slot_map_empty_insert(&extop, slot_edges_exclude, edge);
+ }
+ }
+ if (mmd->flag & MOD_MIR_AXIS_Z) {
+ if ((fabsf(co1[2]) < mmd->tolerance) &&
+ (fabsf(co2[2]) < mmd->tolerance))
+ {
+ BMO_slot_map_empty_insert(&extop, slot_edges_exclude, edge);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+
+ BMO_op_exec(bm, &extop);
+
+ zero_v3(nor);
+
+ BMO_ITER (ele, &siter, extop.slots_out, "geom.out", BM_ALL) {
+ BM_elem_select_set(bm, ele, true);
+
+ if (ele->head.htype == BM_FACE) {
+ f = (BMFace *)ele;
+ add_normal_aligned(nor, f->no);
+ }
+ }
+
+ normalize_v3(nor);
+
+ BMO_op_finish(bm, &extop);
+
+ /* grab / normal constraint */
+ return is_zero_v3(nor) ? 'g' : 'n';
+}
+
+static short edbm_extrude_vert(Object *obedit, BMEditMesh *em, const char hflag, float nor[3])
+{
+ BMIter iter;
+ BMEdge *eed;
+
+ /* ensure vert flags are consistent for edge selections */
+ BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
+ if (BM_elem_flag_test(eed, hflag)) {
+ if (hflag & BM_ELEM_SELECT) {
+ BM_vert_select_set(em->bm, eed->v1, true);
+ BM_vert_select_set(em->bm, eed->v2, true);
+ }
+
+ BM_elem_flag_enable(eed->v1, hflag & ~BM_ELEM_SELECT);
+ BM_elem_flag_enable(eed->v2, hflag & ~BM_ELEM_SELECT);
+ }
+ else {
+ if (BM_elem_flag_test(eed->v1, hflag) && BM_elem_flag_test(eed->v2, hflag)) {
+ if (hflag & BM_ELEM_SELECT) {
+ BM_edge_select_set(em->bm, eed, true);
+ }
+
+ BM_elem_flag_enable(eed, hflag & ~BM_ELEM_SELECT);
+ }
+ }
+ }
+
+ return edbm_extrude_edge(obedit, em, hflag, nor);
+}
+
+static int edbm_extrude_repeat_exec(bContext *C, wmOperator *op)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(obedit);
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
+
+ const int steps = RNA_int_get(op->ptr, "steps");
+
+ const float offs = RNA_float_get(op->ptr, "offset");
+ float dvec[3], tmat[3][3], bmat[3][3], nor[3] = {0.0, 0.0, 0.0};
+ short a;
+
+ /* dvec */
+ normalize_v3_v3(dvec, rv3d->persinv[2]);
+ mul_v3_fl(dvec, offs);
+
+ /* base correction */
+ copy_m3_m4(bmat, obedit->obmat);
+ invert_m3_m3(tmat, bmat);
+ mul_m3_v3(tmat, dvec);
+
+ for (a = 0; a < steps; a++) {
+ edbm_extrude_edge(obedit, em, BM_ELEM_SELECT, nor);
+ //BMO_op_callf(em->bm, BMO_FLAG_DEFAULTS, "extrude_face_region geom=%hef", BM_ELEM_SELECT);
+ BMO_op_callf(em->bm, BMO_FLAG_DEFAULTS,
+ "translate vec=%v verts=%hv",
+ (float *)dvec, BM_ELEM_SELECT);
+ //extrudeflag(obedit, em, SELECT, nor);
+ //translateflag(em, SELECT, dvec);
+ }
+
+ EDBM_mesh_normals_update(em);
+
+ EDBM_update_generic(em, true, true);
+
+ return OPERATOR_FINISHED;
+}
+
+void MESH_OT_extrude_repeat(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Extrude Repeat Mesh";
+ ot->description = "Extrude selected vertices, edges or faces repeatedly";
+ ot->idname = "MESH_OT_extrude_repeat";
+
+ /* api callbacks */
+ ot->exec = edbm_extrude_repeat_exec;
+ ot->poll = ED_operator_editmesh_view3d;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* props */
+ RNA_def_float(ot->srna, "offset", 2.0f, 0.0f, FLT_MAX, "Offset", "", 0.0f, 100.0f);
+ RNA_def_int(ot->srna, "steps", 10, 0, INT_MAX, "Steps", "", 0, 180);
+}
+
+/* generic extern called extruder */
+static int edbm_extrude_mesh(Scene *scene, Object *obedit, BMEditMesh *em, wmOperator *op, float *norin)
+{
+ short nr, transmode = 0;
+ float stacknor[3] = {0.0f, 0.0f, 0.0f};
+ float *nor = norin ? norin : stacknor;
+
+ zero_v3(nor);
+
+ /* XXX If those popup menus were to be enabled again, please get rid of this "menu string" syntax! */
+ if (em->selectmode & SCE_SELECT_VERTEX) {
+ if (em->bm->totvertsel == 0) nr = 0;
+ else if (em->bm->totvertsel == 1) nr = 4;
+ else if (em->bm->totedgesel == 0) nr = 4;
+ else if (em->bm->totfacesel == 0)
+ nr = 3; /* pupmenu("Extrude %t|Only Edges %x3|Only Vertices %x4"); */
+ else if (em->bm->totfacesel == 1)
+ nr = 1; /* pupmenu("Extrude %t|Region %x1|Only Edges% x3|Only Vertices %x4"); */
+ else
+ nr = 1; /* pupmenu("Extrude %t|Region %x1|Individual Faces %x2|Only Edges %x3|Only Vertices %x4"); */
+ }
+ else if (em->selectmode & SCE_SELECT_EDGE) {
+ if (em->bm->totedgesel == 0) nr = 0;
+
+ nr = 1;
+#if 0
+ else if (em->totedgesel == 1) nr = 3;
+ else if (em->totfacesel == 0) nr = 3;
+ else if (em->totfacesel == 1)
+ nr = 1; /* pupmenu("Extrude %t|Region %x1|Only Edges %x3"); */
+ else
+ nr = 1; /* pupmenu("Extrude %t|Region %x1|Individual Faces %x2|Only Edges %x3"); */
+#endif
+ }
+ else {
+ if (em->bm->totfacesel == 0) nr = 0;
+ else if (em->bm->totfacesel == 1) nr = 1;
+ else
+ nr = 1; /* pupmenu("Extrude %t|Region %x1|Individual Faces %x2"); */
+ }
+
+ if (nr < 1) return 'g';
+
+ if (nr == 1 && (em->selectmode & SCE_SELECT_VERTEX))
+ transmode = edbm_extrude_vert(obedit, em, BM_ELEM_SELECT, nor);
+ else if (nr == 1) transmode = edbm_extrude_edge(obedit, em, BM_ELEM_SELECT, nor);
+ else if (nr == 4) transmode = edbm_extrude_verts_indiv(em, op, BM_ELEM_SELECT, nor);
+ else if (nr == 3) transmode = edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT, nor);
+ else transmode = edbm_extrude_discrete_faces(em, op, BM_ELEM_SELECT, nor);
+
+ if (transmode == 0) {
+ BKE_report(op->reports, RPT_ERROR, "Not a valid selection for extrude");
+ }
+ else {
+
+ /* We need to force immediate calculation here because
+ * transform may use derived objects (which are now stale).
+ *
+ * This shouldn't be necessary, derived queries should be
+ * automatically building this data if invalid. Or something.
+ */
+// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+ BKE_object_handle_update(scene, obedit);
+
+ /* individual faces? */
+// BIF_TransformSetUndo("Extrude");
+ if (nr == 2) {
+// initTransform(TFM_SHRINKFATTEN, CTX_NO_PET|CTX_NO_MIRROR);
+// Transform();
+ }
+ else {
+// initTransform(TFM_TRANSLATION, CTX_NO_PET|CTX_NO_MIRROR);
+ if (transmode == 'n') {
+ mul_m4_v3(obedit->obmat, nor);
+ sub_v3_v3v3(nor, nor, obedit->obmat[3]);
+// BIF_setSingleAxisConstraint(nor, "along normal");
+ }
+// Transform();
+ }
+ }
+
+ return transmode;
+}
+
+/* extrude without transform */
+static int edbm_extrude_region_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene = CTX_data_scene(C);
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(obedit);
+
+ edbm_extrude_mesh(scene, obedit, em, op, NULL);
+
+ /* This normally happens when pushing undo but modal operators
+ * like this one don't push undo data until after modal mode is
+ * done.*/
+ EDBM_mesh_normals_update(em);
+
+ EDBM_update_generic(em, true, true);
+
+ return OPERATOR_FINISHED;
+}
+
+void MESH_OT_extrude_region(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Extrude Region";
+ ot->idname = "MESH_OT_extrude_region";
+ ot->description = "Extrude region of faces";
+
+ /* api callbacks */
+ //ot->invoke = mesh_extrude_region_invoke;
+ ot->exec = edbm_extrude_region_exec;
+ ot->poll = ED_operator_editmesh;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
+}
+
+static int edbm_extrude_verts_exec(bContext *C, wmOperator *op)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(obedit);
+ float nor[3];
+
+ edbm_extrude_verts_indiv(em, op, BM_ELEM_SELECT, nor);
+
+ EDBM_update_generic(em, true, true);
+
+ return OPERATOR_FINISHED;
+}
+
+void MESH_OT_extrude_verts_indiv(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Extrude Only Vertices";
+ ot->idname = "MESH_OT_extrude_verts_indiv";
+ ot->description = "Extrude individual vertices only";
+
+ /* api callbacks */
+ ot->exec = edbm_extrude_verts_exec;
+ ot->poll = ED_operator_editmesh;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* to give to transform */
+ RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
+}
+
+static int edbm_extrude_edges_exec(bContext *C, wmOperator *op)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(obedit);
+ float nor[3];
+
+ edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT, nor);
+
+ EDBM_update_generic(em, true, true);
+
+ return OPERATOR_FINISHED;
+}
+
+void MESH_OT_extrude_edges_indiv(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Extrude Only Edges";
+ ot->idname = "MESH_OT_extrude_edges_indiv";
+ ot->description = "Extrude individual edges only";
+
+ /* api callbacks */
+ ot->exec = edbm_extrude_edges_exec;
+ ot->poll = ED_operator_editmesh;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* to give to transform */
+ RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
+}
+
+static int edbm_extrude_faces_exec(bContext *C, wmOperator *op)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(obedit);
+ float nor[3];
+
+ edbm_extrude_discrete_faces(em, op, BM_ELEM_SELECT, nor);
+
+ EDBM_update_generic(em, true, true);
+
+ return OPERATOR_FINISHED;
+}
+
+void MESH_OT_extrude_faces_indiv(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Extrude Individual Faces";
+ ot->idname = "MESH_OT_extrude_faces_indiv";
+ ot->description = "Extrude individual faces only";
+
+ /* api callbacks */
+ ot->exec = edbm_extrude_faces_exec;
+ ot->poll = ED_operator_editmesh;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
+}
+
+/* *************** add-click-mesh (extrude) operator ************** */
+static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ ViewContext vc;
+ BMVert *v1;
+ BMIter iter;
+ float min[3], max[3];
+ bool done = false;
+ bool use_proj;
+
+ em_setup_viewcontext(C, &vc);
+
+ ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d);
+
+
+ use_proj = ((vc.scene->toolsettings->snap_flag & SCE_SNAP) &&
+ (vc.scene->toolsettings->snap_mode == SCE_SNAP_MODE_FACE));
+
+ INIT_MINMAX(min, max);
+
+ BM_ITER_MESH (v1, &iter, vc.em->bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_flag_test(v1, BM_ELEM_SELECT)) {
+ minmax_v3v3_v3(min, max, v1->co);
+ done = true;
+ }
+ }
+
+ /* call extrude? */
+ if (done) {
+ const bool rot_src = RNA_boolean_get(op->ptr, "rotate_source");
+ BMEdge *eed;
+ float vec[3], cent[3], mat[3][3];
+ float nor[3] = {0.0, 0.0, 0.0};
+
+ /* 2D normal calc */
+ const float mval_f[2] = {(float)event->mval[0],
+ (float)event->mval[1]};
+
+ /* check for edges that are half selected, use for rotation */
+ done = false;
+ BM_ITER_MESH (eed, &iter, vc.em->bm, BM_EDGES_OF_MESH) {
+ if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
+ float co1[2], co2[2];
+
+ if ((ED_view3d_project_float_object(vc.ar, eed->v1->co, co1, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) &&
+ (ED_view3d_project_float_object(vc.ar, eed->v2->co, co2, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK))
+ {
+ /* 2D rotate by 90d while adding.
+ * (x, y) = (y, -x)
+ *
+ * accumulate the screenspace normal in 2D,
+ * with screenspace edge length weighting the result. */
+ if (line_point_side_v2(co1, co2, mval_f) >= 0.0f) {
+ nor[0] += (co1[1] - co2[1]);
+ nor[1] += -(co1[0] - co2[0]);
+ }
+ else {
+ nor[0] += (co2[1] - co1[1]);
+ nor[1] += -(co2[0] - co1[0]);
+ }
+ done = true;
+ }
+ }
+ }
+
+ if (done) {
+ float view_vec[3], cross[3];
+
+ /* convert the 2D nomal into 3D */
+ mul_mat3_m4_v3(vc.rv3d->viewinv, nor); /* worldspace */
+ mul_mat3_m4_v3(vc.obedit->imat, nor); /* local space */
+
+ /* correct the normal to be aligned on the view plane */
+ copy_v3_v3(view_vec, vc.rv3d->viewinv[2]);
+ mul_mat3_m4_v3(vc.obedit->imat, view_vec);
+ cross_v3_v3v3(cross, nor, view_vec);
+ cross_v3_v3v3(nor, view_vec, cross);
+ normalize_v3(nor);
+ }
+
+ /* center */
+ mid_v3_v3v3(cent, min, max);
+ copy_v3_v3(min, cent);
+
+ mul_m4_v3(vc.obedit->obmat, min); /* view space */
+ ED_view3d_win_to_3d_int(vc.ar, min, event->mval, min);
+ mul_m4_v3(vc.obedit->imat, min); // back in object space
+
+ sub_v3_v3(min, cent);
+
+ /* calculate rotation */
+ unit_m3(mat);
+ if (done) {
+ float angle;
+
+ normalize_v3_v3(vec, min);
+
+ angle = angle_normalized_v3v3(vec, nor);
+
+ if (angle != 0.0f) {
+ float axis[3];
+
+ cross_v3_v3v3(axis, nor, vec);
+
+ /* halve the rotation if its applied twice */
+ if (rot_src) {
+ angle *= 0.5f;
+ }
+
+ axis_angle_to_mat3(mat, axis, angle);
+ }
+ }
+
+ if (rot_src) {
+ EDBM_op_callf(vc.em, op, "rotate verts=%hv cent=%v matrix=%m3",
+ BM_ELEM_SELECT, cent, mat);
+
+ /* also project the source, for retopo workflow */
+ if (use_proj)
+ EMBM_project_snap_verts(C, vc.ar, vc.em);
+ }
+
+ edbm_extrude_edge(vc.obedit, vc.em, BM_ELEM_SELECT, nor);
+ EDBM_op_callf(vc.em, op, "rotate verts=%hv cent=%v matrix=%m3",
+ BM_ELEM_SELECT, cent, mat);
+ EDBM_op_callf(vc.em, op, "translate verts=%hv vec=%v",
+ BM_ELEM_SELECT, min);
+ }
+ else {
+ const float *curs = give_cursor(vc.scene, vc.v3d);
+ BMOperator bmop;
+ BMOIter oiter;
+
+ copy_v3_v3(min, curs);
+ ED_view3d_win_to_3d_int(vc.ar, min, event->mval, min);
+
+ invert_m4_m4(vc.obedit->imat, vc.obedit->obmat);
+ mul_m4_v3(vc.obedit->imat, min); // back in object space
+
+ EDBM_op_init(vc.em, &bmop, op, "create_vert co=%v", min);
+ BMO_op_exec(vc.em->bm, &bmop);
+
+ BMO_ITER (v1, &oiter, bmop.slots_out, "vert.out", BM_VERT) {
+ BM_vert_select_set(vc.em->bm, v1, true);
+ }
+
+ if (!EDBM_op_finish(vc.em, &bmop, op, true)) {
+ return OPERATOR_CANCELLED;
+ }
+ }
+
+ if (use_proj)
+ EMBM_project_snap_verts(C, vc.ar, vc.em);
+
+ /* This normally happens when pushing undo but modal operators
+ * like this one don't push undo data until after modal mode is
+ * done. */
+ EDBM_mesh_normals_update(vc.em);
+
+ EDBM_update_generic(vc.em, true, true);
+
+ return OPERATOR_FINISHED;
+}
+
+void MESH_OT_dupli_extrude_cursor(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Duplicate or Extrude at 3D Cursor";
+ ot->idname = "MESH_OT_dupli_extrude_cursor";
+ ot->description = "Duplicate and extrude selected vertices, edges or faces towards the mouse cursor";
+
+ /* api callbacks */
+ ot->invoke = edbm_dupli_extrude_cursor_invoke;
+ ot->poll = ED_operator_editmesh;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ RNA_def_boolean(ot->srna, "rotate_source", 1, "Rotate Source", "Rotate initial selection giving better shape");
+}
+
+
+static int edbm_spin_exec(bContext *C, wmOperator *op)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(obedit);
+ BMesh *bm = em->bm;
+ BMOperator spinop;
+ float cent[3], axis[3], imat[3][3];
+ float d[3] = {0.0f, 0.0f, 0.0f};
+ int steps, dupli;
+ float angle;
+
+ RNA_float_get_array(op->ptr, "center", cent);
+ RNA_float_get_array(op->ptr, "axis", axis);
+ steps = RNA_int_get(op->ptr, "steps");
+ angle = RNA_float_get(op->ptr, "angle");
+ //if (ts->editbutflag & B_CLOCKWISE)
+ angle = -angle;
+ dupli = RNA_boolean_get(op->ptr, "dupli");
+
+ /* undo object transformation */
+ copy_m3_m4(imat, obedit->imat);
+ sub_v3_v3(cent, obedit->obmat[3]);
+ mul_m3_v3(imat, cent);
+ mul_m3_v3(imat, axis);
+
+ if (!EDBM_op_init(em, &spinop, op,
+ "spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i angle=%f use_duplicate=%b",
+ BM_ELEM_SELECT, cent, axis, d, steps, angle, dupli))
+ {
+ return OPERATOR_CANCELLED;
+ }
+ BMO_op_exec(bm, &spinop);
+ EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+ BMO_slot_buffer_hflag_enable(bm, spinop.slots_out, "geom_last.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true);
+ if (!EDBM_op_finish(em, &spinop, op, true)) {
+ return OPERATOR_CANCELLED;
+ }
+
+ EDBM_update_generic(em, true, true);
+
+ return OPERATOR_FINISHED;
+}
+
+/* get center and axis, in global coords */
+static int edbm_spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ Scene *scene = CTX_data_scene(C);
+ View3D *v3d = CTX_wm_view3d(C);
+ RegionView3D *rv3d = ED_view3d_context_rv3d(C);
+
+ RNA_float_set_array(op->ptr, "center", give_cursor(scene, v3d));
+ RNA_float_set_array(op->ptr, "axis", rv3d->viewinv[2]);
+
+ return edbm_spin_exec(C, op);
+}
+
+void MESH_OT_spin(wmOperatorType *ot)
+{
+ PropertyRNA *prop;
+
+ /* identifiers */
+ ot->name = "Spin";
+ ot->description = "Extrude selected vertices in a circle around the cursor in indicated viewport";
+ ot->idname = "MESH_OT_spin";
+
+ /* api callbacks */
+ ot->invoke = edbm_spin_invoke;
+ ot->exec = edbm_spin_exec;
+ ot->poll = EDBM_view3d_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* props */
+ RNA_def_int(ot->srna, "steps", 9, 0, INT_MAX, "Steps", "Steps", 0, INT_MAX);
+ RNA_def_boolean(ot->srna, "dupli", 0, "Dupli", "Make Duplicates");
+ prop = RNA_def_float(ot->srna, "angle", DEG2RADF(90.0f), -FLT_MAX, FLT_MAX, "Angle", "Angle", DEG2RADF(-360.0f), DEG2RADF(360.0f));
+ RNA_def_property_subtype(prop, PROP_ANGLE);
+
+ RNA_def_float_vector(ot->srna, "center", 3, NULL, -FLT_MAX, FLT_MAX, "Center", "Center in global view space", -FLT_MAX, FLT_MAX);
+ RNA_def_float_vector(ot->srna, "axis", 3, NULL, -FLT_MAX, FLT_MAX, "Axis", "Axis in global view space", -1.0f, 1.0f);
+
+}
+
+static int edbm_screw_exec(bContext *C, wmOperator *op)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(obedit);
+ BMesh *bm = em->bm;
+ BMEdge *eed;
+ BMVert *eve, *v1, *v2;
+ BMIter iter, eiter;
+ BMOperator spinop;
+ float dvec[3], nor[3], cent[3], axis[3];
+ float imat[3][3];
+ int steps, turns;
+ int valence;
+
+
+ turns = RNA_int_get(op->ptr, "turns");
+ steps = RNA_int_get(op->ptr, "steps");
+ RNA_float_get_array(op->ptr, "center", cent);
+ RNA_float_get_array(op->ptr, "axis", axis);
+
+ /* undo object transformation */
+ copy_m3_m4(imat, obedit->imat);
+ sub_v3_v3(cent, obedit->obmat[3]);
+ mul_m3_v3(imat, cent);
+ mul_m3_v3(imat, axis);
+
+
+ /* find two vertices with valence count == 1, more or less is wrong */
+ v1 = NULL;
+ v2 = NULL;
+
+ BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
+ valence = 0;
+ BM_ITER_ELEM (eed, &eiter, eve, BM_EDGES_OF_VERT) {
+ if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
+ valence++;
+ }
+ }
+
+ if (valence == 1) {
+ if (v1 == NULL) {
+ v1 = eve;
+ }
+ else if (v2 == NULL) {
+ v2 = eve;
+ }
+ else {
+ v1 = NULL;
+ break;
+ }
+ }
+ }
+
+ if (v1 == NULL || v2 == NULL) {
+ BKE_report(op->reports, RPT_ERROR, "You have to select a string of connected vertices too");
+ return OPERATOR_CANCELLED;
+ }
+
+ /* calculate dvec */
+ sub_v3_v3v3(dvec, v1->co, v2->co);
+ mul_v3_fl(dvec, 1.0f / steps);
+
+ if (dot_v3v3(nor, dvec) > 0.000f)
+ negate_v3(dvec);
+
+ if (!EDBM_op_init(em, &spinop, op,
+ "spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i angle=%f use_duplicate=%b",
+ BM_ELEM_SELECT, cent, axis, dvec, turns * steps, DEG2RADF(360.0f * turns), false))
+ {
+ return OPERATOR_CANCELLED;
+ }
+ BMO_op_exec(bm, &spinop);
+ EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+ BMO_slot_buffer_hflag_enable(bm, spinop.slots_out, "geom_last.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true);
+ if (!EDBM_op_finish(em, &spinop, op, true)) {
+ return OPERATOR_CANCELLED;
+ }
+
+ EDBM_update_generic(em, true, true);
+
+ return OPERATOR_FINISHED;
+}
+
+/* get center and axis, in global coords */
+static int edbm_screw_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ Scene *scene = CTX_data_scene(C);
+ View3D *v3d = CTX_wm_view3d(C);
+ RegionView3D *rv3d = ED_view3d_context_rv3d(C);
+
+ RNA_float_set_array(op->ptr, "center", give_cursor(scene, v3d));
+ RNA_float_set_array(op->ptr, "axis", rv3d->viewinv[1]);
+
+ return edbm_screw_exec(C, op);
+}
+
+void MESH_OT_screw(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Screw";
+ ot->description = "Extrude selected vertices in screw-shaped rotation around the cursor in indicated viewport";
+ ot->idname = "MESH_OT_screw";
+
+ /* api callbacks */
+ ot->invoke = edbm_screw_invoke;
+ ot->exec = edbm_screw_exec;
+ ot->poll = EDBM_view3d_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* props */
+ RNA_def_int(ot->srna, "steps", 9, 1, INT_MAX, "Steps", "Steps", 3, 256);
+ RNA_def_int(ot->srna, "turns", 1, 1, INT_MAX, "Turns", "Turns", 1, 256);
+
+ RNA_def_float_vector(ot->srna, "center", 3, NULL, -FLT_MAX, FLT_MAX,
+ "Center", "Center in global view space", -FLT_MAX, FLT_MAX);
+ RNA_def_float_vector(ot->srna, "axis", 3, NULL, -FLT_MAX, FLT_MAX,
+ "Axis", "Axis in global view space", -1.0f, 1.0f);
+}
diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c
new file mode 100644
index 00000000000..10f384f5b7c
--- /dev/null
+++ b/source/blender/editors/mesh/editmesh_inset.c
@@ -0,0 +1,431 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/mesh/editmesh_inset.c
+ * \ingroup edmesh
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_object_types.h"
+
+#include "BLI_string.h"
+#include "BLI_math.h"
+
+#include "BLF_translation.h"
+
+#include "BKE_context.h"
+#include "BKE_tessmesh.h"
+
+#include "RNA_define.h"
+#include "RNA_access.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "ED_mesh.h"
+#include "ED_numinput.h"
+#include "ED_screen.h"
+#include "ED_transform.h"
+#include "ED_view3d.h"
+
+#include "mesh_intern.h" /* own include */
+
+
+#define HEADER_LENGTH 180
+
+typedef struct {
+ float old_thickness;
+ float old_depth;
+ int mcenter[2];
+ int modify_depth;
+ float initial_length;
+ float pixel_size; /* use when mouse input is interpreted as spatial distance */
+ int is_modal;
+ int shift;
+ float shift_amount;
+ BMBackup backup;
+ BMEditMesh *em;
+ NumInput num_input;
+} InsetData;
+
+
+static void edbm_inset_update_header(wmOperator *op, bContext *C)
+{
+ InsetData *opdata = op->customdata;
+
+ const char *str = IFACE_("Confirm: Enter/LClick, Cancel: (Esc/RClick), Thickness: %s, "
+ "Depth (Ctrl to tweak): %s (%s), Outset (O): (%s), Boundary (B): (%s)");
+
+ char msg[HEADER_LENGTH];
+ ScrArea *sa = CTX_wm_area(C);
+
+ if (sa) {
+ char flts_str[NUM_STR_REP_LEN * 2];
+ if (hasNumInput(&opdata->num_input))
+ outputNumInput(&opdata->num_input, flts_str);
+ else {
+ BLI_snprintf(flts_str, NUM_STR_REP_LEN, "%f", RNA_float_get(op->ptr, "thickness"));
+ BLI_snprintf(flts_str + NUM_STR_REP_LEN, NUM_STR_REP_LEN, "%f", RNA_float_get(op->ptr, "depth"));
+ }
+ BLI_snprintf(msg, HEADER_LENGTH, str,
+ flts_str,
+ flts_str + NUM_STR_REP_LEN,
+ opdata->modify_depth ? IFACE_("On") : IFACE_("Off"),
+ RNA_boolean_get(op->ptr, "use_outset") ? IFACE_("On") : IFACE_("Off"),
+ RNA_boolean_get(op->ptr, "use_boundary") ? IFACE_("On") : IFACE_("Off")
+ );
+
+ ED_area_headerprint(sa, msg);
+ }
+}
+
+
+static int edbm_inset_init(bContext *C, wmOperator *op, int is_modal)
+{
+ InsetData *opdata;
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(obedit);
+
+ op->customdata = opdata = MEM_mallocN(sizeof(InsetData), "inset_operator_data");
+
+ opdata->old_thickness = 0.01;
+ opdata->old_depth = 0.0;
+ opdata->modify_depth = false;
+ opdata->shift = false;
+ opdata->shift_amount = 0.0f;
+ opdata->is_modal = is_modal;
+ opdata->em = em;
+
+ initNumInput(&opdata->num_input);
+ opdata->num_input.idx_max = 1; /* Two elements. */
+
+ if (is_modal)
+ opdata->backup = EDBM_redo_state_store(em);
+
+ return 1;
+}
+
+static void edbm_inset_exit(bContext *C, wmOperator *op)
+{
+ InsetData *opdata;
+ ScrArea *sa = CTX_wm_area(C);
+
+ opdata = op->customdata;
+
+ if (opdata->is_modal)
+ EDBM_redo_state_free(&opdata->backup, NULL, false);
+
+ if (sa) {
+ ED_area_headerprint(sa, NULL);
+ }
+ MEM_freeN(op->customdata);
+}
+
+static int edbm_inset_cancel(bContext *C, wmOperator *op)
+{
+ InsetData *opdata;
+
+ opdata = op->customdata;
+ if (opdata->is_modal) {
+ EDBM_redo_state_free(&opdata->backup, opdata->em, true);
+ EDBM_update_generic(opdata->em, false, true);
+ }
+
+ edbm_inset_exit(C, op);
+
+ /* need to force redisplay or we may still view the modified result */
+ ED_region_tag_redraw(CTX_wm_region(C));
+ return OPERATOR_CANCELLED;
+}
+
+static int edbm_inset_calc(wmOperator *op)
+{
+ InsetData *opdata;
+ BMEditMesh *em;
+ BMOperator bmop;
+
+ const bool use_boundary = RNA_boolean_get(op->ptr, "use_boundary");
+ const bool use_even_offset = RNA_boolean_get(op->ptr, "use_even_offset");
+ const bool use_relative_offset = RNA_boolean_get(op->ptr, "use_relative_offset");
+ const float thickness = RNA_float_get(op->ptr, "thickness");
+ const float depth = RNA_float_get(op->ptr, "depth");
+ const bool use_outset = RNA_boolean_get(op->ptr, "use_outset");
+ const bool use_select_inset = RNA_boolean_get(op->ptr, "use_select_inset"); /* not passed onto the BMO */
+
+ opdata = op->customdata;
+ em = opdata->em;
+
+ if (opdata->is_modal) {
+ EDBM_redo_state_restore(opdata->backup, em, false);
+ }
+
+ EDBM_op_init(em, &bmop, op,
+ "inset faces=%hf use_boundary=%b use_even_offset=%b use_relative_offset=%b "
+ "thickness=%f depth=%f use_outset=%b",
+ BM_ELEM_SELECT, use_boundary, use_even_offset, use_relative_offset,
+ thickness, depth, use_outset);
+
+ BMO_op_exec(em->bm, &bmop);
+
+ if (use_select_inset) {
+ /* deselect original faces/verts */
+ EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+ BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true);
+ }
+ else {
+ BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE, BM_ELEM_SELECT, false);
+ BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, false);
+ /* re-select faces so the verts and edges get selected too */
+ BM_mesh_elem_hflag_enable_test(em->bm, BM_FACE, BM_ELEM_SELECT, true, BM_ELEM_SELECT);
+ }
+
+ if (!EDBM_op_finish(em, &bmop, op, true)) {
+ return 0;
+ }
+ else {
+ EDBM_update_generic(em, true, true);
+ return 1;
+ }
+}
+
+static int edbm_inset_exec(bContext *C, wmOperator *op)
+{
+ edbm_inset_init(C, op, false);
+
+ if (!edbm_inset_calc(op)) {
+ edbm_inset_exit(C, op);
+ return OPERATOR_CANCELLED;
+ }
+
+ edbm_inset_exit(C, op);
+ return OPERATOR_FINISHED;
+}
+
+static int edbm_inset_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
+ InsetData *opdata;
+ float mlen[2];
+ float center_3d[3];
+
+ edbm_inset_init(C, op, true);
+
+ opdata = op->customdata;
+
+ /* initialize mouse values */
+ if (!calculateTransformCenter(C, V3D_CENTROID, center_3d, opdata->mcenter)) {
+ /* in this case the tool will likely do nothing,
+ * ideally this will never happen and should be checked for above */
+ opdata->mcenter[0] = opdata->mcenter[1] = 0;
+ }
+ mlen[0] = opdata->mcenter[0] - event->mval[0];
+ mlen[1] = opdata->mcenter[1] - event->mval[1];
+ opdata->initial_length = len_v2(mlen);
+ opdata->pixel_size = rv3d ? ED_view3d_pixel_size(rv3d, center_3d) : 1.0f;
+
+ edbm_inset_calc(op);
+
+ edbm_inset_update_header(op, C);
+
+ WM_event_add_modal_handler(C, op);
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ InsetData *opdata = op->customdata;
+
+ if (event->val == KM_PRESS) {
+ /* Try to handle numeric inputs... */
+
+ if (handleNumInput(&opdata->num_input, event)) {
+ float amounts[2] = {RNA_float_get(op->ptr, "thickness"),
+ RNA_float_get(op->ptr, "depth")};
+ applyNumInput(&opdata->num_input, amounts);
+ amounts[0] = max_ff(amounts[0], 0.0f);
+ RNA_float_set(op->ptr, "thickness", amounts[0]);
+ RNA_float_set(op->ptr, "depth", amounts[1]);
+
+ if (edbm_inset_calc(op)) {
+ edbm_inset_update_header(op, C);
+ return OPERATOR_RUNNING_MODAL;
+ }
+ else {
+ edbm_inset_cancel(C, op);
+ return OPERATOR_CANCELLED;
+ }
+ }
+ }
+
+ switch (event->type) {
+ case ESCKEY:
+ case RIGHTMOUSE:
+ edbm_inset_cancel(C, op);
+ return OPERATOR_CANCELLED;
+
+ case MOUSEMOVE:
+ if (!hasNumInput(&opdata->num_input)) {
+ float mdiff[2];
+ float amount;
+
+ mdiff[0] = opdata->mcenter[0] - event->mval[0];
+ mdiff[1] = opdata->mcenter[1] - event->mval[1];
+
+ if (opdata->modify_depth)
+ amount = opdata->old_depth + ((len_v2(mdiff) - opdata->initial_length) * opdata->pixel_size);
+ else
+ amount = opdata->old_thickness - ((len_v2(mdiff) - opdata->initial_length) * opdata->pixel_size);
+
+ /* Fake shift-transform... */
+ if (opdata->shift)
+ amount = (amount - opdata->shift_amount) * 0.1f + opdata->shift_amount;
+
+ 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))
+ edbm_inset_update_header(op, C);
+ else {
+ edbm_inset_cancel(C, op);
+ return OPERATOR_CANCELLED;
+ }
+ }
+ break;
+
+ case LEFTMOUSE:
+ case PADENTER:
+ case RETKEY:
+ edbm_inset_calc(op);
+ edbm_inset_exit(C, op);
+ return OPERATOR_FINISHED;
+
+ case LEFTSHIFTKEY:
+ case RIGHTSHIFTKEY:
+ if (event->val == KM_PRESS) {
+ if (opdata->modify_depth)
+ opdata->shift_amount = RNA_float_get(op->ptr, "depth");
+ else
+ opdata->shift_amount = RNA_float_get(op->ptr, "thickness");
+ opdata->shift = true;
+ }
+ else {
+ opdata->shift_amount = 0.0f;
+ opdata->shift = false;
+ }
+ break;
+
+ case LEFTCTRLKEY:
+ case RIGHTCTRLKEY:
+ {
+ float mlen[2];
+
+ mlen[0] = opdata->mcenter[0] - event->mval[0];
+ mlen[1] = opdata->mcenter[1] - event->mval[1];
+
+ if (event->val == KM_PRESS) {
+ opdata->old_thickness = RNA_float_get(op->ptr, "thickness");
+ 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)
+ opdata->shift_amount = opdata->old_depth;
+ opdata->modify_depth = false;
+ }
+ opdata->initial_length = len_v2(mlen);
+
+ edbm_inset_update_header(op, C);
+ break;
+ }
+
+ case OKEY:
+ if (event->val == KM_PRESS) {
+ const bool use_outset = RNA_boolean_get(op->ptr, "use_outset");
+ RNA_boolean_set(op->ptr, "use_outset", !use_outset);
+ if (edbm_inset_calc(op)) {
+ edbm_inset_update_header(op, C);
+ }
+ else {
+ edbm_inset_cancel(C, op);
+ return OPERATOR_CANCELLED;
+ }
+ }
+ break;
+ case BKEY:
+ if (event->val == KM_PRESS) {
+ const bool use_boundary = RNA_boolean_get(op->ptr, "use_boundary");
+ RNA_boolean_set(op->ptr, "use_boundary", !use_boundary);
+ if (edbm_inset_calc(op)) {
+ edbm_inset_update_header(op, C);
+ }
+ else {
+ edbm_inset_cancel(C, op);
+ return OPERATOR_CANCELLED;
+ }
+ }
+ break;
+ }
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+
+void MESH_OT_inset(wmOperatorType *ot)
+{
+ PropertyRNA *prop;
+
+ /* identifiers */
+ ot->name = "Inset Faces";
+ ot->idname = "MESH_OT_inset";
+ ot->description = "Inset new faces into selected faces";
+
+ /* api callbacks */
+ ot->invoke = edbm_inset_invoke;
+ ot->modal = edbm_inset_modal;
+ ot->exec = edbm_inset_exec;
+ ot->cancel = edbm_inset_cancel;
+ ot->poll = ED_operator_editmesh;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_POINTER | OPTYPE_BLOCKING;
+
+ /* properties */
+ RNA_def_boolean(ot->srna, "use_boundary", true, "Boundary", "Inset face boundaries");
+ RNA_def_boolean(ot->srna, "use_even_offset", true, "Offset Even", "Scale the offset to give more even thickness");
+ RNA_def_boolean(ot->srna, "use_relative_offset", false, "Offset Relative", "Scale the offset by surrounding geometry");
+
+ prop = RNA_def_float(ot->srna, "thickness", 0.01f, 0.0f, FLT_MAX, "Thickness", "", 0.0f, 10.0f);
+ /* use 1 rather then 10 for max else dragging the button moves too far */
+ RNA_def_property_ui_range(prop, 0.0, 1.0, 0.01, 4);
+ prop = RNA_def_float(ot->srna, "depth", 0.0f, -FLT_MAX, FLT_MAX, "Depth", "", -10.0f, 10.0f);
+ RNA_def_property_ui_range(prop, -10.0f, 10.0f, 0.01, 4);
+
+ RNA_def_boolean(ot->srna, "use_outset", false, "Outset", "Outset rather than inset");
+ RNA_def_boolean(ot->srna, "use_select_inset", true, "Select Outer", "Select the new inset faces");
+}
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 57d3f7406ca..3f1c8ced5d2 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -35,7 +35,8 @@
#include "MEM_guardedalloc.h"
-#include "BLI_blenlib.h"
+#include "BLI_listbase.h"
+#include "BLI_string.h"
#include "BLI_array.h"
#include "BLI_linklist.h"
#include "BLI_math.h"
@@ -58,7 +59,6 @@
#include "WM_api.h"
#include "WM_types.h"
-#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "BKE_tessmesh.h"
#include "UI_resources.h"
@@ -66,7 +66,7 @@
#include "RNA_access.h"
#include "RNA_define.h"
-#include "mesh_intern.h"
+#include "mesh_intern.h" /* own include */
/* this code here is kindof messy. . .I might need to eventually rework it - joeedh */
diff --git a/source/blender/editors/mesh/editmesh_knife_project.c b/source/blender/editors/mesh/editmesh_knife_project.c
index c8256914884..1dae4aa51c8 100644
--- a/source/blender/editors/mesh/editmesh_knife_project.c
+++ b/source/blender/editors/mesh/editmesh_knife_project.c
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * The Original Code is Copyright (C) 2007 Blender Foundation.
+ * The Original Code is Copyright (C) 2013 Blender Foundation.
* All rights reserved.
*
*
@@ -29,17 +29,12 @@
*/
#include "DNA_curve_types.h"
-#include "DNA_scene_types.h"
#include "DNA_object_types.h"
-#include "DNA_screen_types.h"
-#include "DNA_windowmanager_types.h"
-#include "BLI_utildefines.h"
#include "BLI_math.h"
#include "BLI_linklist.h"
#include "BLI_listbase.h"
-#include "BKE_library.h"
#include "BKE_mesh.h"
#include "BKE_context.h"
#include "BKE_curve.h"
@@ -55,7 +50,7 @@
#include "ED_screen.h"
#include "ED_view3d.h"
-#include "mesh_intern.h"
+#include "mesh_intern.h" /* own include */
static LinkNode *knifeproject_poly_from_object(ARegion *ar, Scene *scene, Object *ob, LinkNode *polys)
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index ee1c274b154..62cb1840808 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -29,12 +29,11 @@
*/
#include "DNA_object_types.h"
-#include "DNA_scene_types.h"
#include "MEM_guardedalloc.h"
#include "BLI_array.h"
-#include "BLI_blenlib.h"
+#include "BLI_string.h"
#include "BLI_math.h"
#include "BLF_translation.h"
@@ -58,7 +57,8 @@
#include "WM_api.h"
#include "WM_types.h"
-#include "mesh_intern.h"
+#include "mesh_intern.h" /* own include */
+
/* ringsel operator */
diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c
index 0ea02f371f0..23920e7424e 100644
--- a/source/blender/editors/mesh/editmesh_rip.c
+++ b/source/blender/editors/mesh/editmesh_rip.c
@@ -50,7 +50,7 @@
#include "ED_transform.h"
#include "ED_view3d.h"
-#include "mesh_intern.h"
+#include "mesh_intern.h" /* own include */
/**
* helper to find edge for edge_rip,
@@ -1049,7 +1049,7 @@ void MESH_OT_rip(wmOperatorType *ot)
/* api callbacks */
ot->invoke = edbm_rip_invoke;
- ot->poll = EM_view3d_poll;
+ ot->poll = EDBM_view3d_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index c89a5558c9a..0bdd7093976 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -31,7 +31,7 @@
#include "MEM_guardedalloc.h"
-#include "BLI_blenlib.h"
+#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_rand.h"
#include "BLI_array.h"
@@ -42,7 +42,6 @@
#include "BKE_displist.h"
#include "BKE_report.h"
#include "BKE_paint.h"
-#include "BKE_mesh.h"
#include "BKE_tessmesh.h"
#include "IMB_imbuf_types.h"
@@ -61,17 +60,16 @@
#include "BIF_gl.h"
-#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "GPU_extensions.h"
-#include "mesh_intern.h"
-
#include "UI_resources.h"
+#include "mesh_intern.h" /* own include */
+
/* ****************************** MIRROR **************** */
void EDBM_select_mirrored(Object *UNUSED(obedit), BMEditMesh *em, bool extend)
@@ -738,7 +736,6 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
EDBM_update_generic(em, false, false);
- /* we succeeded */
return OPERATOR_FINISHED;
}
@@ -780,7 +777,6 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
EDBM_update_generic(em, false, false);
- /* we succeeded */
return OPERATOR_FINISHED;
}
@@ -825,7 +821,6 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
EDBM_update_generic(em, false, false);
- /* we succeeded */
return OPERATOR_FINISHED;
}
@@ -1259,6 +1254,82 @@ void MESH_OT_edgering_select(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "ring", 1, "Select Ring", "Select ring");
}
+/* ******************** (de)select all operator **************** */
+static int edbm_select_all_exec(bContext *C, wmOperator *op)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(obedit);
+ const int action = RNA_enum_get(op->ptr, "action");
+
+ switch (action) {
+ case SEL_TOGGLE:
+ EDBM_select_toggle_all(em);
+ break;
+ case SEL_SELECT:
+ EDBM_flag_enable_all(em, BM_ELEM_SELECT);
+ break;
+ case SEL_DESELECT:
+ EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+ break;
+ case SEL_INVERT:
+ EDBM_select_swap(em);
+ EDBM_selectmode_flush(em);
+ break;
+ }
+
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
+
+ return OPERATOR_FINISHED;
+}
+
+void MESH_OT_select_all(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "(De)select All";
+ ot->idname = "MESH_OT_select_all";
+ ot->description = "(De)select all vertices, edges or faces";
+
+ /* api callbacks */
+ ot->exec = edbm_select_all_exec;
+ ot->poll = ED_operator_editmesh;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ WM_operator_properties_select_all(ot);
+}
+
+static int edbm_faces_select_interior_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(obedit);
+
+ if (EDBM_select_interior_faces(em)) {
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
+
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+
+}
+
+void MESH_OT_select_interior_faces(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Select Interior Faces";
+ ot->idname = "MESH_OT_select_interior_faces";
+ ot->description = "Select faces where all edges have more than 2 face users";
+
+ /* api callbacks */
+ ot->exec = edbm_faces_select_interior_exec;
+ ot->poll = ED_operator_editmesh;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
/* ******************* generic tag_shortest_path and helpers ****************** */
static float step_cost_3_v3(const float v1[3], const float v2[3], const float v3[3])
@@ -2267,6 +2338,9 @@ int EDBM_select_interior_faces(BMEditMesh *em)
return change;
}
+
+/************************ Select Linked Operator *************************/
+
static void linked_limit_default(bContext *C, wmOperator *op)
{
if (!RNA_struct_property_is_set(op->ptr, "limit")) {
@@ -2279,6 +2353,106 @@ static void linked_limit_default(bContext *C, wmOperator *op)
}
}
+static int edbm_select_linked_exec(bContext *C, wmOperator *op)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(obedit);
+ BMesh *bm = em->bm;
+ BMIter iter;
+ BMVert *v;
+ BMEdge *e;
+ BMWalker walker;
+
+ int limit;
+
+ linked_limit_default(C, op);
+
+ limit = RNA_boolean_get(op->ptr, "limit");
+
+ if (em->selectmode == SCE_SELECT_FACE) {
+ BMFace *efa;
+
+ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+ BM_elem_flag_set(efa, BM_ELEM_TAG, (BM_elem_flag_test(efa, BM_ELEM_SELECT) &&
+ !BM_elem_flag_test(efa, BM_ELEM_HIDDEN)));
+ }
+
+ if (limit) {
+ /* grr, shouldn't need to alloc BMO flags here */
+ BM_mesh_elem_toolflags_ensure(bm);
+ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
+ /* BMESH_TODO, don't use 'BM_ELEM_SELECT' here, its a HFLAG only! */
+ BMO_elem_flag_set(bm, e, BM_ELEM_SELECT, !BM_elem_flag_test(e, BM_ELEM_SEAM));
+ }
+ }
+
+ BMW_init(&walker, bm, BMW_ISLAND,
+ BMW_MASK_NOP, limit ? BM_ELEM_SELECT : BMW_MASK_NOP, BMW_MASK_NOP,
+ BMW_FLAG_TEST_HIDDEN,
+ BMW_NIL_LAY);
+
+ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+ if (BM_elem_flag_test(efa, BM_ELEM_TAG)) {
+ for (efa = BMW_begin(&walker, efa); efa; efa = BMW_step(&walker)) {
+ BM_face_select_set(bm, efa, true);
+ }
+ }
+ }
+ BMW_end(&walker);
+
+ if (limit) {
+ BM_mesh_elem_toolflags_clear(bm);
+ }
+ }
+ else {
+ BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
+ BM_elem_flag_enable(v, BM_ELEM_TAG);
+ }
+ else {
+ BM_elem_flag_disable(v, BM_ELEM_TAG);
+ }
+ }
+
+ BMW_init(&walker, em->bm, BMW_SHELL,
+ BMW_MASK_NOP, BMW_MASK_NOP, BMW_MASK_NOP,
+ BMW_FLAG_TEST_HIDDEN,
+ BMW_NIL_LAY);
+
+ BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
+ if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
+ for (e = BMW_begin(&walker, v); e; e = BMW_step(&walker)) {
+ BM_edge_select_set(em->bm, e, true);
+ }
+ }
+ }
+ BMW_end(&walker);
+
+ EDBM_selectmode_flush(em);
+ }
+
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
+
+ return OPERATOR_FINISHED;
+}
+
+void MESH_OT_select_linked(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Select Linked All";
+ ot->idname = "MESH_OT_select_linked";
+ ot->description = "Select all vertices linked to the active mesh";
+
+ /* api callbacks */
+ ot->exec = edbm_select_linked_exec;
+ ot->poll = ED_operator_editmesh;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ RNA_def_boolean(ot->srna, "limit", 0, "Limit by Seams", "");
+}
+
static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Object *obedit = CTX_data_edit_object(C);
@@ -2394,104 +2568,160 @@ void MESH_OT_select_linked_pick(wmOperatorType *ot)
}
-static int edbm_select_linked_exec(bContext *C, wmOperator *op)
+static int edbm_select_face_by_sides_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);
BMEditMesh *em = BMEdit_FromObject(obedit);
- BMesh *bm = em->bm;
+ BMFace *efa;
BMIter iter;
- BMVert *v;
- BMEdge *e;
- BMWalker walker;
-
- int limit;
+ const int numverts = RNA_int_get(op->ptr, "number");
+ const int type = RNA_enum_get(op->ptr, "type");
- linked_limit_default(C, op);
+ if (!RNA_boolean_get(op->ptr, "extend"))
+ EDBM_flag_disable_all(em, BM_ELEM_SELECT);
- limit = RNA_boolean_get(op->ptr, "limit");
+ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (em->selectmode == SCE_SELECT_FACE) {
- BMFace *efa;
+ int select;
- BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- BM_elem_flag_set(efa, BM_ELEM_TAG, (BM_elem_flag_test(efa, BM_ELEM_SELECT) &&
- !BM_elem_flag_test(efa, BM_ELEM_HIDDEN)));
+ switch (type) {
+ case 0:
+ select = (efa->len < numverts);
+ break;
+ case 1:
+ select = (efa->len == numverts);
+ break;
+ case 2:
+ select = (efa->len > numverts);
+ break;
+ case 3:
+ select = (efa->len != numverts);
+ break;
+ default:
+ BLI_assert(0);
+ select = false;
+ break;
}
- if (limit) {
- /* grr, shouldn't need to alloc BMO flags here */
- BM_mesh_elem_toolflags_ensure(bm);
- BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
- /* BMESH_TODO, don't use 'BM_ELEM_SELECT' here, its a HFLAG only! */
- BMO_elem_flag_set(bm, e, BM_ELEM_SELECT, !BM_elem_flag_test(e, BM_ELEM_SEAM));
- }
+ if (select) {
+ BM_face_select_set(em->bm, efa, true);
}
+ }
- BMW_init(&walker, bm, BMW_ISLAND,
- BMW_MASK_NOP, limit ? BM_ELEM_SELECT : BMW_MASK_NOP, BMW_MASK_NOP,
- BMW_FLAG_TEST_HIDDEN,
- BMW_NIL_LAY);
+ EDBM_selectmode_flush(em);
- BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(efa, BM_ELEM_TAG)) {
- for (efa = BMW_begin(&walker, efa); efa; efa = BMW_step(&walker)) {
- BM_face_select_set(bm, efa, true);
- }
- }
- }
- BMW_end(&walker);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ return OPERATOR_FINISHED;
+}
- if (limit) {
- BM_mesh_elem_toolflags_clear(bm);
+void MESH_OT_select_face_by_sides(wmOperatorType *ot)
+{
+ static const EnumPropertyItem type_items[] = {
+ {0, "LESS", 0, "Less Than", ""},
+ {1, "EQUAL", 0, "Equal To", ""},
+ {2, "GREATER", 0, "Greater Than", ""},
+ {3, "NOTEQUAL", 0, "Not Equal To", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ /* identifiers */
+ ot->name = "Select Faces by Sides";
+ ot->description = "Select vertices or faces by the number of polygon sides";
+ ot->idname = "MESH_OT_select_face_by_sides";
+
+ /* api callbacks */
+ ot->exec = edbm_select_face_by_sides_exec;
+ ot->poll = ED_operator_editmesh;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_int(ot->srna, "number", 4, 3, INT_MAX, "Number of Vertices", "", 3, INT_MAX);
+ RNA_def_enum(ot->srna, "type", type_items, 1, "Type", "Type of comparison to make");
+ RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend the selection");
+}
+
+
+static int edbm_select_loose_verts_exec(bContext *C, wmOperator *op)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(obedit);
+ BMVert *eve;
+ BMEdge *eed;
+ BMIter iter;
+
+ if (!RNA_boolean_get(op->ptr, "extend"))
+ EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+
+ BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
+ if (!eve->e) {
+ BM_vert_select_set(em->bm, eve, true);
}
}
- else {
- BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
- BM_elem_flag_enable(v, BM_ELEM_TAG);
- }
- else {
- BM_elem_flag_disable(v, BM_ELEM_TAG);
- }
+
+ BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
+ if (!eed->l) {
+ BM_edge_select_set(em->bm, eed, true);
}
+ }
- BMW_init(&walker, em->bm, BMW_SHELL,
- BMW_MASK_NOP, BMW_MASK_NOP, BMW_MASK_NOP,
- BMW_FLAG_TEST_HIDDEN,
- BMW_NIL_LAY);
+ EDBM_selectmode_flush(em);
- BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
- for (e = BMW_begin(&walker, v); e; e = BMW_step(&walker)) {
- BM_edge_select_set(em->bm, e, true);
- }
- }
- }
- BMW_end(&walker);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ return OPERATOR_FINISHED;
+}
+
+void MESH_OT_select_loose_verts(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Select Loose Vertices/Edges";
+ ot->description = "Select vertices with no edges nor faces, and edges with no faces";
+ ot->idname = "MESH_OT_select_loose_verts";
+
+ /* api callbacks */
+ ot->exec = edbm_select_loose_verts_exec;
+ ot->poll = ED_operator_editmesh;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* props */
+ RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
+}
+
+
+static int edbm_select_mirror_exec(bContext *C, wmOperator *op)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(obedit);
+ bool extend = RNA_boolean_get(op->ptr, "extend");
+
+ if (em->bm->totvert && em->bm->totvertsel) {
+ EDBM_select_mirrored(obedit, em, extend);
EDBM_selectmode_flush(em);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
-
return OPERATOR_FINISHED;
}
-void MESH_OT_select_linked(wmOperatorType *ot)
+void MESH_OT_select_mirror(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Select Linked All";
- ot->idname = "MESH_OT_select_linked";
- ot->description = "Select all vertices linked to the active mesh";
-
+ ot->name = "Select Mirror";
+ ot->description = "Select mesh items at mirrored locations";
+ ot->idname = "MESH_OT_select_mirror";
+
/* api callbacks */
- ot->exec = edbm_select_linked_exec;
+ ot->exec = edbm_select_mirror_exec;
ot->poll = ED_operator_editmesh;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- RNA_def_boolean(ot->srna, "limit", 0, "Limit by Seams", "");
+
+ /* props */
+ RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the existing selection");
}
/* ******************** **************** */
@@ -2756,15 +2986,6 @@ void em_setup_viewcontext(bContext *C, ViewContext *vc)
}
}
-/* poll call for mesh operators requiring a view3d context */
-int EM_view3d_poll(bContext *C)
-{
- if (ED_operator_editmesh(C) && ED_operator_view3d_active(C))
- return 1;
-
- return 0;
-}
-
static int edbm_select_sharp_edges_exec(bContext *C, wmOperator *op)
{
@@ -3075,6 +3296,91 @@ void MESH_OT_select_ungrouped(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
}
+
+/* BMESH_TODO - some way to select on an arbitrary axis */
+static int edbm_select_axis_exec(bContext *C, wmOperator *op)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(obedit);
+ BMEditSelection *ese = em->bm->selected.last;
+ const int axis = RNA_enum_get(op->ptr, "axis");
+ const int mode = RNA_enum_get(op->ptr, "mode"); /* -1 == aligned, 0 == neg, 1 == pos */
+
+ if (ese == NULL || ese->htype != BM_VERT) {
+ BKE_report(op->reports, RPT_WARNING, "This operator requires an active vertex (last selected)");
+ return OPERATOR_CANCELLED;
+ }
+ else {
+ BMVert *ev, *act_vert = (BMVert *)ese->ele;
+ BMIter iter;
+ float value = act_vert->co[axis];
+ float limit = CTX_data_tool_settings(C)->doublimit; // XXX
+
+ if (mode == 0)
+ value -= limit;
+ else if (mode == 1)
+ value += limit;
+
+ BM_ITER_MESH (ev, &iter, em->bm, BM_VERTS_OF_MESH) {
+ if (!BM_elem_flag_test(ev, BM_ELEM_HIDDEN)) {
+ switch (mode) {
+ case -1: /* aligned */
+ if (fabsf(ev->co[axis] - value) < limit)
+ BM_vert_select_set(em->bm, ev, true);
+ break;
+ case 0: /* neg */
+ if (ev->co[axis] > value)
+ BM_vert_select_set(em->bm, ev, true);
+ break;
+ case 1: /* pos */
+ if (ev->co[axis] < value)
+ BM_vert_select_set(em->bm, ev, true);
+ break;
+ }
+ }
+ }
+ }
+
+ EDBM_selectmode_flush(em);
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
+
+ return OPERATOR_FINISHED;
+}
+
+void MESH_OT_select_axis(wmOperatorType *ot)
+{
+ static EnumPropertyItem axis_mode_items[] = {
+ {0, "POSITIVE", 0, "Positive Axis", ""},
+ {1, "NEGATIVE", 0, "Negative Axis", ""},
+ {-1, "ALIGNED", 0, "Aligned Axis", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ static EnumPropertyItem axis_items_xyz[] = {
+ {0, "X_AXIS", 0, "X Axis", ""},
+ {1, "Y_AXIS", 0, "Y Axis", ""},
+ {2, "Z_AXIS", 0, "Z Axis", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ /* identifiers */
+ ot->name = "Select Axis";
+ ot->description = "Select all data in the mesh on a single axis";
+ ot->idname = "MESH_OT_select_axis";
+
+ /* api callbacks */
+ ot->exec = edbm_select_axis_exec;
+ ot->poll = ED_operator_editmesh;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_enum(ot->srna, "mode", axis_mode_items, 0, "Axis Mode", "Axis side to use when selecting");
+ RNA_def_enum(ot->srna, "axis", axis_items_xyz, 0, "Axis", "Select the axis to compare each vertex on");
+}
+
+
static int edbm_select_next_loop_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *obedit = CTX_data_edit_object(C);
@@ -3371,3 +3677,118 @@ void MESH_OT_loop_to_region(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "select_bigger", 0, "Select Bigger", "Select bigger regions instead of smaller ones");
}
+
+
+/************************ Vertex Path Operator *************************/
+
+typedef struct PathNode {
+ /* int u; */ /* UNUSED */
+ /* int visited; */ /* UNUSED */
+ ListBase edges;
+} PathNode;
+
+typedef struct PathEdge {
+ struct PathEdge *next, *prev;
+ int v;
+ float w;
+} PathEdge;
+
+static int edbm_select_vertex_path_exec(bContext *C, wmOperator *op)
+{
+ Object *ob = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(ob);
+ BMOperator bmop;
+ BMIter iter;
+ BMVert *eve = NULL, *svert = NULL, *evert = NULL;
+ BMEditSelection *sv, *ev;
+
+ /* get the type from RNA */
+ const int type = RNA_enum_get(op->ptr, "type");
+
+ /* first try to find vertices in edit selection */
+ sv = em->bm->selected.last;
+ if (sv != NULL) {
+ ev = sv->prev;
+
+ if (ev && (sv->htype == BM_VERT) && (ev->htype == BM_VERT)) {
+ svert = (BMVert *)sv->ele;
+ evert = (BMVert *)ev->ele;
+ }
+ }
+
+ /* if those are not found, because vertices where selected by e.g.
+ * border or circle select, find two selected vertices */
+ if (svert == NULL) {
+ 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))
+ continue;
+
+ if (svert == NULL) {
+ svert = eve;
+ }
+ else if (evert == NULL) {
+ evert = eve;
+ }
+ else {
+ /* more than two vertices are selected,
+ * show warning message and cancel operator */
+ svert = evert = NULL;
+ break;
+ }
+ }
+ }
+
+ if (svert == NULL || evert == NULL) {
+ BKE_report(op->reports, RPT_WARNING, "Path selection requires two vertices to be selected");
+ return OPERATOR_CANCELLED;
+ }
+
+ /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */
+ EDBM_op_init(em, &bmop, op,
+ "shortest_path vert_start=%e vert_end=%e type=%i",
+ svert, evert, type);
+
+ /* execute the operator */
+ BMO_op_exec(em->bm, &bmop);
+
+ /* DO NOT clear the existing selection */
+ /* EDBM_flag_disable_all(em, BM_ELEM_SELECT); */
+
+ /* select the output */
+ BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "verts.out", BM_VERT, BM_ELEM_SELECT, true);
+
+ /* finish the operator */
+ if (!EDBM_op_finish(em, &bmop, op, true)) {
+ return OPERATOR_CANCELLED;
+ }
+
+ EDBM_selectmode_flush(em);
+
+ EDBM_update_generic(em, false, false);
+
+ return OPERATOR_FINISHED;
+}
+
+void MESH_OT_select_vertex_path(wmOperatorType *ot)
+{
+ static const EnumPropertyItem type_items[] = {
+ {VPATH_SELECT_EDGE_LENGTH, "EDGE_LENGTH", 0, "Edge Length", NULL},
+ {VPATH_SELECT_TOPOLOGICAL, "TOPOLOGICAL", 0, "Topological", NULL},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ /* identifiers */
+ ot->name = "Select Vertex Path";
+ ot->idname = "MESH_OT_select_vertex_path";
+ ot->description = "Selected vertex path between two vertices";
+
+ /* api callbacks */
+ ot->exec = edbm_select_vertex_path_exec;
+ ot->poll = ED_operator_editmesh;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_enum(ot->srna, "type", type_items, VPATH_SELECT_EDGE_LENGTH, "Type", "Method to compute distance");
+}
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 3feb8f921dc..c4763e75327 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -36,19 +36,15 @@
#include "DNA_mesh_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
-#include "DNA_scene_types.h"
-#include "BLI_blenlib.h"
+#include "BLI_listbase.h"
#include "BLI_noise.h"
#include "BLI_math.h"
#include "BLI_rand.h"
-#include "BLF_translation.h"
-
#include "BKE_material.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
-#include "BKE_object.h"
#include "BKE_report.h"
#include "BKE_texture.h"
#include "BKE_main.h"
@@ -62,7 +58,6 @@
#include "WM_types.h"
#include "ED_mesh.h"
-#include "ED_numinput.h"
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_transform.h"
@@ -74,24 +69,10 @@
#include "UI_interface.h"
#include "UI_resources.h"
-#include "mesh_intern.h"
+#include "mesh_intern.h" /* own include */
#define USE_FACE_CREATE_SEL_EXTEND
-#define MVAL_PIXEL_MARGIN 5.0f
-
-/* allow accumulated normals to form a new direction but don't
- * accept direct opposite directions else they will cancel each other out */
-static void add_normal_aligned(float nor[3], const float add[3])
-{
- if (dot_v3v3(nor, add) < -0.9999f) {
- sub_v3_v3(nor, add);
- }
- else {
- add_v3_v3(nor, add);
- }
-}
-
static int edbm_subdivide_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);
@@ -228,735 +209,6 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em)
}
-/* individual face extrude */
-/* will use vertex normals for extrusion directions, so *nor is unaffected */
-static short edbm_extrude_discrete_faces(BMEditMesh *em, wmOperator *op, const char hflag, float *UNUSED(nor))
-{
- BMOIter siter;
- BMIter liter;
- BMFace *f;
- BMLoop *l;
- BMOperator bmop;
-
- EDBM_op_init(em, &bmop, op, "extrude_discrete_faces faces=%hf", hflag);
-
- /* deselect original verts */
- EDBM_flag_disable_all(em, BM_ELEM_SELECT);
-
- BMO_op_exec(em->bm, &bmop);
-
- BMO_ITER (f, &siter, bmop.slots_out, "faces.out", BM_FACE) {
- BM_face_select_set(em->bm, f, true);
-
- /* set face vertex normals to face normal */
- BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
- copy_v3_v3(l->v->no, f->no);
- }
- }
-
- if (!EDBM_op_finish(em, &bmop, op, true)) {
- return 0;
- }
-
- return 's'; /* s is shrink/fatten */
-}
-
-/* extrudes individual edges */
-static short edbm_extrude_edges_indiv(BMEditMesh *em, wmOperator *op, const char hflag, float *UNUSED(nor))
-{
- BMOperator bmop;
-
- EDBM_op_init(em, &bmop, op, "extrude_edge_only edges=%he", hflag);
-
- /* deselect original verts */
- EDBM_flag_disable_all(em, BM_ELEM_SELECT);
-
- BMO_op_exec(em->bm, &bmop);
- BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_VERT | BM_EDGE, BM_ELEM_SELECT, true);
-
- if (!EDBM_op_finish(em, &bmop, op, true)) {
- return 0;
- }
-
- return 'n'; /* n is normal grab */
-}
-
-/* extrudes individual vertices */
-static short edbm_extrude_verts_indiv(BMEditMesh *em, wmOperator *op, const char hflag, float *UNUSED(nor))
-{
- BMOperator bmop;
-
- EDBM_op_init(em, &bmop, op, "extrude_vert_indiv verts=%hv", hflag);
-
- /* deselect original verts */
- BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_in, "verts", BM_VERT, BM_ELEM_SELECT, true);
-
- BMO_op_exec(em->bm, &bmop);
- BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "verts.out", BM_VERT, BM_ELEM_SELECT, true);
-
- if (!EDBM_op_finish(em, &bmop, op, true)) {
- return 0;
- }
-
- return 'g'; /* g is grab */
-}
-
-static short edbm_extrude_edge(Object *obedit, BMEditMesh *em, const char hflag, float nor[3])
-{
- BMesh *bm = em->bm;
- BMIter iter;
- BMOIter siter;
- BMOperator extop;
- BMEdge *edge;
- BMFace *f;
- ModifierData *md;
- BMElem *ele;
- BMOpSlot *slot_edges_exclude;
-
- BMO_op_init(bm, &extop, BMO_FLAG_DEFAULTS, "extrude_face_region");
- BMO_slot_buffer_from_enabled_hflag(bm, &extop, extop.slots_in, "geom", BM_VERT | BM_EDGE | BM_FACE, hflag);
-
- slot_edges_exclude = BMO_slot_get(extop.slots_in, "edges_exclude");
-
- /* If a mirror modifier with clipping is on, we need to adjust some
- * of the cases above to handle edges on the line of symmetry.
- */
- md = obedit->modifiers.first;
- for (; md; md = md->next) {
- if ((md->type == eModifierType_Mirror) && (md->mode & eModifierMode_Realtime)) {
- MirrorModifierData *mmd = (MirrorModifierData *) md;
-
- if (mmd->flag & MOD_MIR_CLIPPING) {
- float mtx[4][4];
- if (mmd->mirror_ob) {
- float imtx[4][4];
- invert_m4_m4(imtx, mmd->mirror_ob->obmat);
- mult_m4_m4m4(mtx, imtx, obedit->obmat);
- }
-
- BM_ITER_MESH (edge, &iter, bm, BM_EDGES_OF_MESH) {
- if (BM_elem_flag_test(edge, hflag) &&
- BM_edge_is_boundary(edge) &&
- BM_elem_flag_test(edge->l->f, hflag))
- {
- float co1[3], co2[3];
-
- copy_v3_v3(co1, edge->v1->co);
- copy_v3_v3(co2, edge->v2->co);
-
- if (mmd->mirror_ob) {
- mul_v3_m4v3(co1, mtx, co1);
- mul_v3_m4v3(co2, mtx, co2);
- }
-
- if (mmd->flag & MOD_MIR_AXIS_X) {
- if ((fabsf(co1[0]) < mmd->tolerance) &&
- (fabsf(co2[0]) < mmd->tolerance))
- {
- BMO_slot_map_empty_insert(&extop, slot_edges_exclude, edge);
- }
- }
- if (mmd->flag & MOD_MIR_AXIS_Y) {
- if ((fabsf(co1[1]) < mmd->tolerance) &&
- (fabsf(co2[1]) < mmd->tolerance))
- {
- BMO_slot_map_empty_insert(&extop, slot_edges_exclude, edge);
- }
- }
- if (mmd->flag & MOD_MIR_AXIS_Z) {
- if ((fabsf(co1[2]) < mmd->tolerance) &&
- (fabsf(co2[2]) < mmd->tolerance))
- {
- BMO_slot_map_empty_insert(&extop, slot_edges_exclude, edge);
- }
- }
- }
- }
- }
- }
- }
-
- EDBM_flag_disable_all(em, BM_ELEM_SELECT);
-
- BMO_op_exec(bm, &extop);
-
- zero_v3(nor);
-
- BMO_ITER (ele, &siter, extop.slots_out, "geom.out", BM_ALL) {
- BM_elem_select_set(bm, ele, true);
-
- if (ele->head.htype == BM_FACE) {
- f = (BMFace *)ele;
- add_normal_aligned(nor, f->no);
- }
- }
-
- normalize_v3(nor);
-
- BMO_op_finish(bm, &extop);
-
- /* grab / normal constraint */
- return is_zero_v3(nor) ? 'g' : 'n';
-}
-
-static short edbm_extrude_vert(Object *obedit, BMEditMesh *em, const char hflag, float nor[3])
-{
- BMIter iter;
- BMEdge *eed;
-
- /* ensure vert flags are consistent for edge selections */
- BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
- if (BM_elem_flag_test(eed, hflag)) {
- if (hflag & BM_ELEM_SELECT) {
- BM_vert_select_set(em->bm, eed->v1, true);
- BM_vert_select_set(em->bm, eed->v2, true);
- }
-
- BM_elem_flag_enable(eed->v1, hflag & ~BM_ELEM_SELECT);
- BM_elem_flag_enable(eed->v2, hflag & ~BM_ELEM_SELECT);
- }
- else {
- if (BM_elem_flag_test(eed->v1, hflag) && BM_elem_flag_test(eed->v2, hflag)) {
- if (hflag & BM_ELEM_SELECT) {
- BM_edge_select_set(em->bm, eed, true);
- }
-
- BM_elem_flag_enable(eed, hflag & ~BM_ELEM_SELECT);
- }
- }
- }
-
- return edbm_extrude_edge(obedit, em, hflag, nor);
-}
-
-static int edbm_extrude_repeat_exec(bContext *C, wmOperator *op)
-{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BMEdit_FromObject(obedit);
- RegionView3D *rv3d = CTX_wm_region_view3d(C);
-
- const int steps = RNA_int_get(op->ptr, "steps");
-
- const float offs = RNA_float_get(op->ptr, "offset");
- float dvec[3], tmat[3][3], bmat[3][3], nor[3] = {0.0, 0.0, 0.0};
- short a;
-
- /* dvec */
- normalize_v3_v3(dvec, rv3d->persinv[2]);
- mul_v3_fl(dvec, offs);
-
- /* base correction */
- copy_m3_m4(bmat, obedit->obmat);
- invert_m3_m3(tmat, bmat);
- mul_m3_v3(tmat, dvec);
-
- for (a = 0; a < steps; a++) {
- edbm_extrude_edge(obedit, em, BM_ELEM_SELECT, nor);
- //BMO_op_callf(em->bm, BMO_FLAG_DEFAULTS, "extrude_face_region geom=%hef", BM_ELEM_SELECT);
- BMO_op_callf(em->bm, BMO_FLAG_DEFAULTS,
- "translate vec=%v verts=%hv",
- (float *)dvec, BM_ELEM_SELECT);
- //extrudeflag(obedit, em, SELECT, nor);
- //translateflag(em, SELECT, dvec);
- }
-
- EDBM_mesh_normals_update(em);
-
- EDBM_update_generic(em, true, true);
-
- return OPERATOR_FINISHED;
-}
-
-void MESH_OT_extrude_repeat(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Extrude Repeat Mesh";
- ot->description = "Extrude selected vertices, edges or faces repeatedly";
- ot->idname = "MESH_OT_extrude_repeat";
-
- /* api callbacks */
- ot->exec = edbm_extrude_repeat_exec;
- ot->poll = ED_operator_editmesh_view3d;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* props */
- RNA_def_float(ot->srna, "offset", 2.0f, 0.0f, FLT_MAX, "Offset", "", 0.0f, 100.0f);
- RNA_def_int(ot->srna, "steps", 10, 0, INT_MAX, "Steps", "", 0, 180);
-}
-
-/* generic extern called extruder */
-static int edbm_extrude_mesh(Scene *scene, Object *obedit, BMEditMesh *em, wmOperator *op, float *norin)
-{
- short nr, transmode = 0;
- float stacknor[3] = {0.0f, 0.0f, 0.0f};
- float *nor = norin ? norin : stacknor;
-
- zero_v3(nor);
-
- /* XXX If those popup menus were to be enabled again, please get rid of this "menu string" syntax! */
- if (em->selectmode & SCE_SELECT_VERTEX) {
- if (em->bm->totvertsel == 0) nr = 0;
- else if (em->bm->totvertsel == 1) nr = 4;
- else if (em->bm->totedgesel == 0) nr = 4;
- else if (em->bm->totfacesel == 0)
- nr = 3; /* pupmenu("Extrude %t|Only Edges %x3|Only Vertices %x4"); */
- else if (em->bm->totfacesel == 1)
- nr = 1; /* pupmenu("Extrude %t|Region %x1|Only Edges% x3|Only Vertices %x4"); */
- else
- nr = 1; /* pupmenu("Extrude %t|Region %x1|Individual Faces %x2|Only Edges %x3|Only Vertices %x4"); */
- }
- else if (em->selectmode & SCE_SELECT_EDGE) {
- if (em->bm->totedgesel == 0) nr = 0;
-
- nr = 1;
-#if 0
- else if (em->totedgesel == 1) nr = 3;
- else if (em->totfacesel == 0) nr = 3;
- else if (em->totfacesel == 1)
- nr = 1; /* pupmenu("Extrude %t|Region %x1|Only Edges %x3"); */
- else
- nr = 1; /* pupmenu("Extrude %t|Region %x1|Individual Faces %x2|Only Edges %x3"); */
-#endif
- }
- else {
- if (em->bm->totfacesel == 0) nr = 0;
- else if (em->bm->totfacesel == 1) nr = 1;
- else
- nr = 1; /* pupmenu("Extrude %t|Region %x1|Individual Faces %x2"); */
- }
-
- if (nr < 1) return 'g';
-
- if (nr == 1 && (em->selectmode & SCE_SELECT_VERTEX))
- transmode = edbm_extrude_vert(obedit, em, BM_ELEM_SELECT, nor);
- else if (nr == 1) transmode = edbm_extrude_edge(obedit, em, BM_ELEM_SELECT, nor);
- else if (nr == 4) transmode = edbm_extrude_verts_indiv(em, op, BM_ELEM_SELECT, nor);
- else if (nr == 3) transmode = edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT, nor);
- else transmode = edbm_extrude_discrete_faces(em, op, BM_ELEM_SELECT, nor);
-
- if (transmode == 0) {
- BKE_report(op->reports, RPT_ERROR, "Not a valid selection for extrude");
- }
- else {
-
- /* We need to force immediate calculation here because
- * transform may use derived objects (which are now stale).
- *
- * This shouldn't be necessary, derived queries should be
- * automatically building this data if invalid. Or something.
- */
-// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
- BKE_object_handle_update(scene, obedit);
-
- /* individual faces? */
-// BIF_TransformSetUndo("Extrude");
- if (nr == 2) {
-// initTransform(TFM_SHRINKFATTEN, CTX_NO_PET|CTX_NO_MIRROR);
-// Transform();
- }
- else {
-// initTransform(TFM_TRANSLATION, CTX_NO_PET|CTX_NO_MIRROR);
- if (transmode == 'n') {
- mul_m4_v3(obedit->obmat, nor);
- sub_v3_v3v3(nor, nor, obedit->obmat[3]);
-// BIF_setSingleAxisConstraint(nor, "along normal");
- }
-// Transform();
- }
- }
-
- return transmode;
-}
-
-/* extrude without transform */
-static int edbm_extrude_region_exec(bContext *C, wmOperator *op)
-{
- Scene *scene = CTX_data_scene(C);
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BMEdit_FromObject(obedit);
-
- edbm_extrude_mesh(scene, obedit, em, op, NULL);
-
- /* This normally happens when pushing undo but modal operators
- * like this one don't push undo data until after modal mode is
- * done.*/
- EDBM_mesh_normals_update(em);
-
- EDBM_update_generic(em, true, true);
-
- return OPERATOR_FINISHED;
-}
-
-void MESH_OT_extrude_region(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Extrude Region";
- ot->idname = "MESH_OT_extrude_region";
- ot->description = "Extrude region of faces";
-
- /* api callbacks */
- //ot->invoke = mesh_extrude_region_invoke;
- ot->exec = edbm_extrude_region_exec;
- ot->poll = ED_operator_editmesh;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
-}
-
-static int edbm_extrude_verts_exec(bContext *C, wmOperator *op)
-{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BMEdit_FromObject(obedit);
- float nor[3];
-
- edbm_extrude_verts_indiv(em, op, BM_ELEM_SELECT, nor);
-
- EDBM_update_generic(em, true, true);
-
- return OPERATOR_FINISHED;
-}
-
-void MESH_OT_extrude_verts_indiv(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Extrude Only Vertices";
- ot->idname = "MESH_OT_extrude_verts_indiv";
- ot->description = "Extrude individual vertices only";
-
- /* api callbacks */
- ot->exec = edbm_extrude_verts_exec;
- ot->poll = ED_operator_editmesh;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* to give to transform */
- RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
-}
-
-static int edbm_extrude_edges_exec(bContext *C, wmOperator *op)
-{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BMEdit_FromObject(obedit);
- float nor[3];
-
- edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT, nor);
-
- EDBM_update_generic(em, true, true);
-
- return OPERATOR_FINISHED;
-}
-
-void MESH_OT_extrude_edges_indiv(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Extrude Only Edges";
- ot->idname = "MESH_OT_extrude_edges_indiv";
- ot->description = "Extrude individual edges only";
-
- /* api callbacks */
- ot->exec = edbm_extrude_edges_exec;
- ot->poll = ED_operator_editmesh;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* to give to transform */
- RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
-}
-
-static int edbm_extrude_faces_exec(bContext *C, wmOperator *op)
-{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BMEdit_FromObject(obedit);
- float nor[3];
-
- edbm_extrude_discrete_faces(em, op, BM_ELEM_SELECT, nor);
-
- EDBM_update_generic(em, true, true);
-
- return OPERATOR_FINISHED;
-}
-
-void MESH_OT_extrude_faces_indiv(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Extrude Individual Faces";
- ot->idname = "MESH_OT_extrude_faces_indiv";
- ot->description = "Extrude individual faces only";
-
- /* api callbacks */
- ot->exec = edbm_extrude_faces_exec;
- ot->poll = ED_operator_editmesh;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
-}
-
-/* ******************** (de)select all operator **************** */
-
-static int edbm_select_all_exec(bContext *C, wmOperator *op)
-{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BMEdit_FromObject(obedit);
- const int action = RNA_enum_get(op->ptr, "action");
-
- switch (action) {
- case SEL_TOGGLE:
- EDBM_select_toggle_all(em);
- break;
- case SEL_SELECT:
- EDBM_flag_enable_all(em, BM_ELEM_SELECT);
- break;
- case SEL_DESELECT:
- EDBM_flag_disable_all(em, BM_ELEM_SELECT);
- break;
- case SEL_INVERT:
- EDBM_select_swap(em);
- EDBM_selectmode_flush(em);
- break;
- }
-
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
-
- return OPERATOR_FINISHED;
-}
-
-void MESH_OT_select_all(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "(De)select All";
- ot->idname = "MESH_OT_select_all";
- ot->description = "(De)select all vertices, edges or faces";
-
- /* api callbacks */
- ot->exec = edbm_select_all_exec;
- ot->poll = ED_operator_editmesh;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- WM_operator_properties_select_all(ot);
-}
-
-static int edbm_faces_select_interior_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BMEdit_FromObject(obedit);
-
- if (EDBM_select_interior_faces(em)) {
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
-
- return OPERATOR_FINISHED;
- }
- else {
- return OPERATOR_CANCELLED;
- }
-
-}
-
-void MESH_OT_select_interior_faces(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Select Interior Faces";
- ot->idname = "MESH_OT_select_interior_faces";
- ot->description = "Select faces where all edges have more than 2 face users";
-
- /* api callbacks */
- ot->exec = edbm_faces_select_interior_exec;
- ot->poll = ED_operator_editmesh;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-/* *************** add-click-mesh (extrude) operator ************** */
-static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const wmEvent *event)
-{
- ViewContext vc;
- BMVert *v1;
- BMIter iter;
- float min[3], max[3];
- bool done = false;
- bool use_proj;
-
- em_setup_viewcontext(C, &vc);
-
- ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d);
-
-
- use_proj = ((vc.scene->toolsettings->snap_flag & SCE_SNAP) &&
- (vc.scene->toolsettings->snap_mode == SCE_SNAP_MODE_FACE));
-
- INIT_MINMAX(min, max);
-
- BM_ITER_MESH (v1, &iter, vc.em->bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(v1, BM_ELEM_SELECT)) {
- minmax_v3v3_v3(min, max, v1->co);
- done = true;
- }
- }
-
- /* call extrude? */
- if (done) {
- const bool rot_src = RNA_boolean_get(op->ptr, "rotate_source");
- BMEdge *eed;
- float vec[3], cent[3], mat[3][3];
- float nor[3] = {0.0, 0.0, 0.0};
-
- /* 2D normal calc */
- const float mval_f[2] = {(float)event->mval[0],
- (float)event->mval[1]};
-
- /* check for edges that are half selected, use for rotation */
- done = false;
- BM_ITER_MESH (eed, &iter, vc.em->bm, BM_EDGES_OF_MESH) {
- if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
- float co1[2], co2[2];
-
- if ((ED_view3d_project_float_object(vc.ar, eed->v1->co, co1, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) &&
- (ED_view3d_project_float_object(vc.ar, eed->v2->co, co2, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK))
- {
- /* 2D rotate by 90d while adding.
- * (x, y) = (y, -x)
- *
- * accumulate the screenspace normal in 2D,
- * with screenspace edge length weighting the result. */
- if (line_point_side_v2(co1, co2, mval_f) >= 0.0f) {
- nor[0] += (co1[1] - co2[1]);
- nor[1] += -(co1[0] - co2[0]);
- }
- else {
- nor[0] += (co2[1] - co1[1]);
- nor[1] += -(co2[0] - co1[0]);
- }
- done = true;
- }
- }
- }
-
- if (done) {
- float view_vec[3], cross[3];
-
- /* convert the 2D nomal into 3D */
- mul_mat3_m4_v3(vc.rv3d->viewinv, nor); /* worldspace */
- mul_mat3_m4_v3(vc.obedit->imat, nor); /* local space */
-
- /* correct the normal to be aligned on the view plane */
- copy_v3_v3(view_vec, vc.rv3d->viewinv[2]);
- mul_mat3_m4_v3(vc.obedit->imat, view_vec);
- cross_v3_v3v3(cross, nor, view_vec);
- cross_v3_v3v3(nor, view_vec, cross);
- normalize_v3(nor);
- }
-
- /* center */
- mid_v3_v3v3(cent, min, max);
- copy_v3_v3(min, cent);
-
- mul_m4_v3(vc.obedit->obmat, min); /* view space */
- ED_view3d_win_to_3d_int(vc.ar, min, event->mval, min);
- mul_m4_v3(vc.obedit->imat, min); // back in object space
-
- sub_v3_v3(min, cent);
-
- /* calculate rotation */
- unit_m3(mat);
- if (done) {
- float angle;
-
- normalize_v3_v3(vec, min);
-
- angle = angle_normalized_v3v3(vec, nor);
-
- if (angle != 0.0f) {
- float axis[3];
-
- cross_v3_v3v3(axis, nor, vec);
-
- /* halve the rotation if its applied twice */
- if (rot_src) {
- angle *= 0.5f;
- }
-
- axis_angle_to_mat3(mat, axis, angle);
- }
- }
-
- if (rot_src) {
- EDBM_op_callf(vc.em, op, "rotate verts=%hv cent=%v matrix=%m3",
- BM_ELEM_SELECT, cent, mat);
-
- /* also project the source, for retopo workflow */
- if (use_proj)
- EMBM_project_snap_verts(C, vc.ar, vc.em);
- }
-
- edbm_extrude_edge(vc.obedit, vc.em, BM_ELEM_SELECT, nor);
- EDBM_op_callf(vc.em, op, "rotate verts=%hv cent=%v matrix=%m3",
- BM_ELEM_SELECT, cent, mat);
- EDBM_op_callf(vc.em, op, "translate verts=%hv vec=%v",
- BM_ELEM_SELECT, min);
- }
- else {
- const float *curs = give_cursor(vc.scene, vc.v3d);
- BMOperator bmop;
- BMOIter oiter;
-
- copy_v3_v3(min, curs);
- ED_view3d_win_to_3d_int(vc.ar, min, event->mval, min);
-
- invert_m4_m4(vc.obedit->imat, vc.obedit->obmat);
- mul_m4_v3(vc.obedit->imat, min); // back in object space
-
- EDBM_op_init(vc.em, &bmop, op, "create_vert co=%v", min);
- BMO_op_exec(vc.em->bm, &bmop);
-
- BMO_ITER (v1, &oiter, bmop.slots_out, "vert.out", BM_VERT) {
- BM_vert_select_set(vc.em->bm, v1, true);
- }
-
- if (!EDBM_op_finish(vc.em, &bmop, op, true)) {
- return OPERATOR_CANCELLED;
- }
- }
-
- if (use_proj)
- EMBM_project_snap_verts(C, vc.ar, vc.em);
-
- /* This normally happens when pushing undo but modal operators
- * like this one don't push undo data until after modal mode is
- * done. */
- EDBM_mesh_normals_update(vc.em);
-
- EDBM_update_generic(vc.em, true, true);
-
- return OPERATOR_FINISHED;
-}
-
-void MESH_OT_dupli_extrude_cursor(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Duplicate or Extrude at 3D Cursor";
- ot->idname = "MESH_OT_dupli_extrude_cursor";
- ot->description = "Duplicate and extrude selected vertices, edges or faces towards the mouse cursor";
-
- /* api callbacks */
- ot->invoke = edbm_dupli_extrude_cursor_invoke;
- ot->poll = ED_operator_editmesh;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- RNA_def_boolean(ot->srna, "rotate_source", 1, "Rotate Source", "Rotate initial selection giving better shape");
-}
-
/* Note, these values must match delete_mesh() event values */
static EnumPropertyItem prop_mesh_delete_types[] = {
{0, "VERT", 0, "Vertices", ""},
@@ -2013,7 +1265,6 @@ static int edbm_rotate_uvs_exec(bContext *C, wmOperator *op)
EDBM_update_generic(em, false, false);
- /* we succeeded */
return OPERATOR_FINISHED;
}
@@ -2036,7 +1287,6 @@ static int edbm_reverse_uvs_exec(bContext *C, wmOperator *op)
EDBM_update_generic(em, false, false);
- /* we succeeded */
return OPERATOR_FINISHED;
}
@@ -2063,7 +1313,6 @@ static int edbm_rotate_colors_exec(bContext *C, wmOperator *op)
/* dependencies graph and notification stuff */
EDBM_update_generic(em, false, false);
- /* we succeeded */
return OPERATOR_FINISHED;
}
@@ -2087,7 +1336,6 @@ static int edbm_reverse_colors_exec(bContext *C, wmOperator *op)
EDBM_update_generic(em, false, false);
- /* we succeeded */
return OPERATOR_FINISHED;
}
@@ -2109,7 +1357,6 @@ void MESH_OT_uvs_rotate(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "use_ccw", false, "Counter Clockwise", "");
}
-//void MESH_OT_uvs_mirror(wmOperatorType *ot)
void MESH_OT_uvs_reverse(wmOperatorType *ot)
{
/* identifiers */
@@ -2427,123 +1674,6 @@ void MESH_OT_remove_doubles(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "use_unselected", 0, "Unselected", "Merge selected to other unselected vertices");
}
-/************************ Vertex Path Operator *************************/
-
-typedef struct PathNode {
- /* int u; */ /* UNUSED */
- /* int visited; */ /* UNUSED */
- ListBase edges;
-} PathNode;
-
-typedef struct PathEdge {
- struct PathEdge *next, *prev;
- int v;
- float w;
-} PathEdge;
-
-
-
-static int edbm_select_vertex_path_exec(bContext *C, wmOperator *op)
-{
- Object *ob = CTX_data_edit_object(C);
- BMEditMesh *em = BMEdit_FromObject(ob);
- BMOperator bmop;
- BMIter iter;
- BMVert *eve = NULL, *svert = NULL, *evert = NULL;
- BMEditSelection *sv, *ev;
-
- /* get the type from RNA */
- const int type = RNA_enum_get(op->ptr, "type");
-
- /* first try to find vertices in edit selection */
- sv = em->bm->selected.last;
- if (sv != NULL) {
- ev = sv->prev;
-
- if (ev && (sv->htype == BM_VERT) && (ev->htype == BM_VERT)) {
- svert = (BMVert *)sv->ele;
- evert = (BMVert *)ev->ele;
- }
- }
-
- /* if those are not found, because vertices where selected by e.g.
- * border or circle select, find two selected vertices */
- if (svert == NULL) {
- 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))
- continue;
-
- if (svert == NULL) {
- svert = eve;
- }
- else if (evert == NULL) {
- evert = eve;
- }
- else {
- /* more than two vertices are selected,
- * show warning message and cancel operator */
- svert = evert = NULL;
- break;
- }
- }
- }
-
- if (svert == NULL || evert == NULL) {
- BKE_report(op->reports, RPT_WARNING, "Path selection requires two vertices to be selected");
- return OPERATOR_CANCELLED;
- }
-
- /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */
- EDBM_op_init(em, &bmop, op,
- "shortest_path vert_start=%e vert_end=%e type=%i",
- svert, evert, type);
-
- /* execute the operator */
- BMO_op_exec(em->bm, &bmop);
-
- /* DO NOT clear the existing selection */
- /* EDBM_flag_disable_all(em, BM_ELEM_SELECT); */
-
- /* select the output */
- BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "verts.out", BM_VERT, BM_ELEM_SELECT, true);
-
- /* finish the operator */
- if (!EDBM_op_finish(em, &bmop, op, true)) {
- return OPERATOR_CANCELLED;
- }
-
- EDBM_selectmode_flush(em);
-
- EDBM_update_generic(em, false, false);
-
- /* we succeeded */
- return OPERATOR_FINISHED;
-}
-
-void MESH_OT_select_vertex_path(wmOperatorType *ot)
-{
- static const EnumPropertyItem type_items[] = {
- {VPATH_SELECT_EDGE_LENGTH, "EDGE_LENGTH", 0, "Edge Length", NULL},
- {VPATH_SELECT_TOPOLOGICAL, "TOPOLOGICAL", 0, "Topological", NULL},
- {0, NULL, 0, NULL, NULL}
- };
-
- /* identifiers */
- ot->name = "Select Vertex Path";
- ot->idname = "MESH_OT_select_vertex_path";
- ot->description = "Selected vertex path between two vertices";
-
- /* api callbacks */
- ot->exec = edbm_select_vertex_path_exec;
- ot->poll = ED_operator_editmesh;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
- RNA_def_enum(ot->srna, "type", type_items, VPATH_SELECT_EDGE_LENGTH, "Type", "Method to compute distance");
-}
-/********************** Rip Operator *************************/
/************************ Shape Operators *************************/
@@ -2739,89 +1869,6 @@ void MESH_OT_blend_from_shape(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "add", 1, "Add", "Add rather than blend between shapes");
}
-/* BMESH_TODO - some way to select on an arbitrary axis */
-static int edbm_select_axis_exec(bContext *C, wmOperator *op)
-{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BMEdit_FromObject(obedit);
- BMEditSelection *ese = em->bm->selected.last;
- const int axis = RNA_enum_get(op->ptr, "axis");
- const int mode = RNA_enum_get(op->ptr, "mode"); /* -1 == aligned, 0 == neg, 1 == pos */
-
- if (ese == NULL || ese->htype != BM_VERT) {
- BKE_report(op->reports, RPT_WARNING, "This operator requires an active vertex (last selected)");
- return OPERATOR_CANCELLED;
- }
- else {
- BMVert *ev, *act_vert = (BMVert *)ese->ele;
- BMIter iter;
- float value = act_vert->co[axis];
- float limit = CTX_data_tool_settings(C)->doublimit; // XXX
-
- if (mode == 0)
- value -= limit;
- else if (mode == 1)
- value += limit;
-
- BM_ITER_MESH (ev, &iter, em->bm, BM_VERTS_OF_MESH) {
- if (!BM_elem_flag_test(ev, BM_ELEM_HIDDEN)) {
- switch (mode) {
- case -1: /* aligned */
- if (fabsf(ev->co[axis] - value) < limit)
- BM_vert_select_set(em->bm, ev, true);
- break;
- case 0: /* neg */
- if (ev->co[axis] > value)
- BM_vert_select_set(em->bm, ev, true);
- break;
- case 1: /* pos */
- if (ev->co[axis] < value)
- BM_vert_select_set(em->bm, ev, true);
- break;
- }
- }
- }
- }
-
- EDBM_selectmode_flush(em);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-
- return OPERATOR_FINISHED;
-}
-
-void MESH_OT_select_axis(wmOperatorType *ot)
-{
- static EnumPropertyItem axis_mode_items[] = {
- {0, "POSITIVE", 0, "Positive Axis", ""},
- {1, "NEGATIVE", 0, "Negative Axis", ""},
- {-1, "ALIGNED", 0, "Aligned Axis", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- static EnumPropertyItem axis_items_xyz[] = {
- {0, "X_AXIS", 0, "X Axis", ""},
- {1, "Y_AXIS", 0, "Y Axis", ""},
- {2, "Z_AXIS", 0, "Z Axis", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- /* identifiers */
- ot->name = "Select Axis";
- ot->description = "Select all data in the mesh on a single axis";
- ot->idname = "MESH_OT_select_axis";
-
- /* api callbacks */
- ot->exec = edbm_select_axis_exec;
- ot->poll = ED_operator_editmesh;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
- RNA_def_enum(ot->srna, "mode", axis_mode_items, 0, "Axis Mode", "Axis side to use when selecting");
- RNA_def_enum(ot->srna, "axis", axis_items_xyz, 0, "Axis", "Select the axis to compare each vertex on");
-}
-
static int edbm_solidify_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);
@@ -3196,7 +2243,7 @@ void MESH_OT_knife_cut(wmOperatorType *ot)
ot->modal = WM_gesture_lines_modal;
ot->exec = edbm_knife_cut_exec;
- ot->poll = EM_view3d_poll;
+ ot->poll = EDBM_view3d_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -3841,366 +2888,6 @@ void MESH_OT_split(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-
-static int edbm_spin_exec(bContext *C, wmOperator *op)
-{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BMEdit_FromObject(obedit);
- BMesh *bm = em->bm;
- BMOperator spinop;
- float cent[3], axis[3], imat[3][3];
- float d[3] = {0.0f, 0.0f, 0.0f};
- int steps, dupli;
- float angle;
-
- RNA_float_get_array(op->ptr, "center", cent);
- RNA_float_get_array(op->ptr, "axis", axis);
- steps = RNA_int_get(op->ptr, "steps");
- angle = RNA_float_get(op->ptr, "angle");
- //if (ts->editbutflag & B_CLOCKWISE)
- angle = -angle;
- dupli = RNA_boolean_get(op->ptr, "dupli");
-
- /* undo object transformation */
- copy_m3_m4(imat, obedit->imat);
- sub_v3_v3(cent, obedit->obmat[3]);
- mul_m3_v3(imat, cent);
- mul_m3_v3(imat, axis);
-
- if (!EDBM_op_init(em, &spinop, op,
- "spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i angle=%f use_duplicate=%b",
- BM_ELEM_SELECT, cent, axis, d, steps, angle, dupli))
- {
- return OPERATOR_CANCELLED;
- }
- BMO_op_exec(bm, &spinop);
- EDBM_flag_disable_all(em, BM_ELEM_SELECT);
- BMO_slot_buffer_hflag_enable(bm, spinop.slots_out, "geom_last.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true);
- if (!EDBM_op_finish(em, &spinop, op, true)) {
- return OPERATOR_CANCELLED;
- }
-
- EDBM_update_generic(em, true, true);
-
- return OPERATOR_FINISHED;
-}
-
-/* get center and axis, in global coords */
-static int edbm_spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
- Scene *scene = CTX_data_scene(C);
- View3D *v3d = CTX_wm_view3d(C);
- RegionView3D *rv3d = ED_view3d_context_rv3d(C);
-
- RNA_float_set_array(op->ptr, "center", give_cursor(scene, v3d));
- RNA_float_set_array(op->ptr, "axis", rv3d->viewinv[2]);
-
- return edbm_spin_exec(C, op);
-}
-
-void MESH_OT_spin(wmOperatorType *ot)
-{
- PropertyRNA *prop;
-
- /* identifiers */
- ot->name = "Spin";
- ot->description = "Extrude selected vertices in a circle around the cursor in indicated viewport";
- ot->idname = "MESH_OT_spin";
-
- /* api callbacks */
- ot->invoke = edbm_spin_invoke;
- ot->exec = edbm_spin_exec;
- ot->poll = EM_view3d_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* props */
- RNA_def_int(ot->srna, "steps", 9, 0, INT_MAX, "Steps", "Steps", 0, INT_MAX);
- RNA_def_boolean(ot->srna, "dupli", 0, "Dupli", "Make Duplicates");
- prop = RNA_def_float(ot->srna, "angle", DEG2RADF(90.0f), -FLT_MAX, FLT_MAX, "Angle", "Angle", DEG2RADF(-360.0f), DEG2RADF(360.0f));
- RNA_def_property_subtype(prop, PROP_ANGLE);
-
- RNA_def_float_vector(ot->srna, "center", 3, NULL, -FLT_MAX, FLT_MAX, "Center", "Center in global view space", -FLT_MAX, FLT_MAX);
- RNA_def_float_vector(ot->srna, "axis", 3, NULL, -FLT_MAX, FLT_MAX, "Axis", "Axis in global view space", -1.0f, 1.0f);
-
-}
-
-static int edbm_screw_exec(bContext *C, wmOperator *op)
-{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BMEdit_FromObject(obedit);
- BMesh *bm = em->bm;
- BMEdge *eed;
- BMVert *eve, *v1, *v2;
- BMIter iter, eiter;
- BMOperator spinop;
- float dvec[3], nor[3], cent[3], axis[3];
- float imat[3][3];
- int steps, turns;
- int valence;
-
-
- turns = RNA_int_get(op->ptr, "turns");
- steps = RNA_int_get(op->ptr, "steps");
- RNA_float_get_array(op->ptr, "center", cent);
- RNA_float_get_array(op->ptr, "axis", axis);
-
- /* undo object transformation */
- copy_m3_m4(imat, obedit->imat);
- sub_v3_v3(cent, obedit->obmat[3]);
- mul_m3_v3(imat, cent);
- mul_m3_v3(imat, axis);
-
-
- /* find two vertices with valence count == 1, more or less is wrong */
- v1 = NULL;
- v2 = NULL;
-
- BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
- valence = 0;
- BM_ITER_ELEM (eed, &eiter, eve, BM_EDGES_OF_VERT) {
- if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
- valence++;
- }
- }
-
- if (valence == 1) {
- if (v1 == NULL) {
- v1 = eve;
- }
- else if (v2 == NULL) {
- v2 = eve;
- }
- else {
- v1 = NULL;
- break;
- }
- }
- }
-
- if (v1 == NULL || v2 == NULL) {
- BKE_report(op->reports, RPT_ERROR, "You have to select a string of connected vertices too");
- return OPERATOR_CANCELLED;
- }
-
- /* calculate dvec */
- sub_v3_v3v3(dvec, v1->co, v2->co);
- mul_v3_fl(dvec, 1.0f / steps);
-
- if (dot_v3v3(nor, dvec) > 0.000f)
- negate_v3(dvec);
-
- if (!EDBM_op_init(em, &spinop, op,
- "spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i angle=%f use_duplicate=%b",
- BM_ELEM_SELECT, cent, axis, dvec, turns * steps, DEG2RADF(360.0f * turns), false))
- {
- return OPERATOR_CANCELLED;
- }
- BMO_op_exec(bm, &spinop);
- EDBM_flag_disable_all(em, BM_ELEM_SELECT);
- BMO_slot_buffer_hflag_enable(bm, spinop.slots_out, "geom_last.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true);
- if (!EDBM_op_finish(em, &spinop, op, true)) {
- return OPERATOR_CANCELLED;
- }
-
- EDBM_update_generic(em, true, true);
-
- return OPERATOR_FINISHED;
-}
-
-/* get center and axis, in global coords */
-static int edbm_screw_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
- Scene *scene = CTX_data_scene(C);
- View3D *v3d = CTX_wm_view3d(C);
- RegionView3D *rv3d = ED_view3d_context_rv3d(C);
-
- RNA_float_set_array(op->ptr, "center", give_cursor(scene, v3d));
- RNA_float_set_array(op->ptr, "axis", rv3d->viewinv[1]);
-
- return edbm_screw_exec(C, op);
-}
-
-void MESH_OT_screw(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Screw";
- ot->description = "Extrude selected vertices in screw-shaped rotation around the cursor in indicated viewport";
- ot->idname = "MESH_OT_screw";
-
- /* api callbacks */
- ot->invoke = edbm_screw_invoke;
- ot->exec = edbm_screw_exec;
- ot->poll = EM_view3d_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* props */
- RNA_def_int(ot->srna, "steps", 9, 1, INT_MAX, "Steps", "Steps", 3, 256);
- RNA_def_int(ot->srna, "turns", 1, 1, INT_MAX, "Turns", "Turns", 1, 256);
-
- RNA_def_float_vector(ot->srna, "center", 3, NULL, -FLT_MAX, FLT_MAX,
- "Center", "Center in global view space", -FLT_MAX, FLT_MAX);
- RNA_def_float_vector(ot->srna, "axis", 3, NULL, -FLT_MAX, FLT_MAX,
- "Axis", "Axis in global view space", -1.0f, 1.0f);
-}
-
-static int edbm_select_face_by_sides_exec(bContext *C, wmOperator *op)
-{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BMEdit_FromObject(obedit);
- BMFace *efa;
- BMIter iter;
- const int numverts = RNA_int_get(op->ptr, "number");
- const int type = RNA_enum_get(op->ptr, "type");
-
- if (!RNA_boolean_get(op->ptr, "extend"))
- EDBM_flag_disable_all(em, BM_ELEM_SELECT);
-
- BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
-
- int select;
-
- switch (type) {
- case 0:
- select = (efa->len < numverts);
- break;
- case 1:
- select = (efa->len == numverts);
- break;
- case 2:
- select = (efa->len > numverts);
- break;
- case 3:
- select = (efa->len != numverts);
- break;
- default:
- BLI_assert(0);
- select = false;
- break;
- }
-
- if (select) {
- BM_face_select_set(em->bm, efa, true);
- }
- }
-
- EDBM_selectmode_flush(em);
-
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
- return OPERATOR_FINISHED;
-}
-
-void MESH_OT_select_face_by_sides(wmOperatorType *ot)
-{
- static const EnumPropertyItem type_items[] = {
- {0, "LESS", 0, "Less Than", ""},
- {1, "EQUAL", 0, "Equal To", ""},
- {2, "GREATER", 0, "Greater Than", ""},
- {3, "NOTEQUAL", 0, "Not Equal To", ""},
- {0, NULL, 0, NULL, NULL}
- };
-
- /* identifiers */
- ot->name = "Select Faces by Sides";
- ot->description = "Select vertices or faces by the number of polygon sides";
- ot->idname = "MESH_OT_select_face_by_sides";
-
- /* api callbacks */
- ot->exec = edbm_select_face_by_sides_exec;
- ot->poll = ED_operator_editmesh;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
- RNA_def_int(ot->srna, "number", 4, 3, INT_MAX, "Number of Vertices", "", 3, INT_MAX);
- RNA_def_enum(ot->srna, "type", type_items, 1, "Type", "Type of comparison to make");
- RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend the selection");
-}
-
-static int edbm_select_loose_verts_exec(bContext *C, wmOperator *op)
-{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BMEdit_FromObject(obedit);
- BMVert *eve;
- BMEdge *eed;
- BMIter iter;
-
- if (!RNA_boolean_get(op->ptr, "extend"))
- EDBM_flag_disable_all(em, BM_ELEM_SELECT);
-
- BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
- if (!eve->e) {
- BM_vert_select_set(em->bm, eve, true);
- }
- }
-
- BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
- if (!eed->l) {
- BM_edge_select_set(em->bm, eed, true);
- }
- }
-
- EDBM_selectmode_flush(em);
-
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
- return OPERATOR_FINISHED;
-}
-
-void MESH_OT_select_loose_verts(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Select Loose Vertices/Edges";
- ot->description = "Select vertices with no edges nor faces, and edges with no faces";
- ot->idname = "MESH_OT_select_loose_verts";
-
- /* api callbacks */
- ot->exec = edbm_select_loose_verts_exec;
- ot->poll = ED_operator_editmesh;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* props */
- RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
-}
-
-static int edbm_select_mirror_exec(bContext *C, wmOperator *op)
-{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BMEdit_FromObject(obedit);
- bool extend = RNA_boolean_get(op->ptr, "extend");
-
- if (em->bm->totvert && em->bm->totvertsel) {
- EDBM_select_mirrored(obedit, em, extend);
- EDBM_selectmode_flush(em);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
- }
-
- return OPERATOR_FINISHED;
-}
-
-void MESH_OT_select_mirror(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Select Mirror";
- ot->description = "Select mesh items at mirrored locations";
- ot->idname = "MESH_OT_select_mirror";
-
- /* api callbacks */
- ot->exec = edbm_select_mirror_exec;
- ot->poll = ED_operator_editmesh;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* props */
- RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the existing selection");
-}
-
/******************************************************************************
* qsort routines.
* Now unified, for vertices/edges/faces. */
@@ -4853,320 +3540,6 @@ void MESH_OT_noise(wmOperatorType *ot)
RNA_def_float(ot->srna, "factor", 0.1f, -FLT_MAX, FLT_MAX, "Factor", "", 0.0f, 1.0f);
}
-typedef struct {
- BMEditMesh *em;
- BMBackup mesh_backup;
- int mcenter[2];
- float initial_length;
- float pixel_size; /* use when mouse input is interpreted as spatial distance */
- int is_modal;
- NumInput num_input;
- float shift_factor; /* The current factor when shift is pressed. Negative when shift not active. */
-} BevelData;
-
-#define HEADER_LENGTH 180
-
-static void edbm_bevel_update_header(wmOperator *op, bContext *C)
-{
- const char *str = IFACE_("Confirm: Enter/LClick, Cancel: (Esc/RMB), Offset: %s, Segments: %d");
-
- char msg[HEADER_LENGTH];
- ScrArea *sa = CTX_wm_area(C);
-
- if (sa) {
- char offset_str[NUM_STR_REP_LEN];
- BLI_snprintf(offset_str, NUM_STR_REP_LEN, "%f", RNA_float_get(op->ptr, "offset"));
- BLI_snprintf(msg, HEADER_LENGTH, str,
- offset_str,
- RNA_int_get(op->ptr, "segments")
- );
-
- ED_area_headerprint(sa, msg);
- }
-}
-
-static int edbm_bevel_init(bContext *C, wmOperator *op, int is_modal)
-{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BMEdit_FromObject(obedit);
- BevelData *opdata;
-
- if (em == NULL) {
- return 0;
- }
-
- op->customdata = opdata = MEM_mallocN(sizeof(BevelData), "beveldata_mesh_operator");
-
- opdata->em = em;
- opdata->is_modal = is_modal;
- opdata->shift_factor = -1.0f;
-
- initNumInput(&opdata->num_input);
- opdata->num_input.flag = NUM_NO_NEGATIVE;
-
- /* avoid the cost of allocating a bm copy */
- if (is_modal)
- opdata->mesh_backup = EDBM_redo_state_store(em);
-
- return 1;
-}
-
-static int edbm_bevel_calc(wmOperator *op)
-{
- BevelData *opdata = op->customdata;
- BMEditMesh *em = opdata->em;
- BMOperator bmop;
- const float offset = RNA_float_get(op->ptr, "offset");
- const int segments = RNA_int_get(op->ptr, "segments");
- const bool vertex_only = RNA_boolean_get(op->ptr, "vertex_only");
-
- /* revert to original mesh */
- if (opdata->is_modal) {
- EDBM_redo_state_restore(opdata->mesh_backup, em, false);
- }
-
- if (!EDBM_op_init(em, &bmop, op,
- "bevel geom=%hev offset=%f segments=%i vertex_only=%b",
- BM_ELEM_SELECT, offset, segments, vertex_only))
- {
- return 0;
- }
-
- BMO_op_exec(em->bm, &bmop);
-
- if (offset != 0.0f) {
- /* not essential, but we may have some loose geometry that
- * won't get bevel'd and better not leave it selected */
- EDBM_flag_disable_all(em, BM_ELEM_SELECT);
- BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true);
- }
-
- /* no need to de-select existing geometry */
- if (!EDBM_op_finish(em, &bmop, op, true))
- return 0;
-
- EDBM_mesh_normals_update(opdata->em);
-
- EDBM_update_generic(opdata->em, true, true);
-
- return 1;
-}
-
-static void edbm_bevel_exit(bContext *C, wmOperator *op)
-{
- BevelData *opdata = op->customdata;
-
- ScrArea *sa = CTX_wm_area(C);
-
- if (sa) {
- ED_area_headerprint(sa, NULL);
- }
-
- if (opdata->is_modal) {
- EDBM_redo_state_free(&opdata->mesh_backup, NULL, false);
- }
- MEM_freeN(opdata);
- op->customdata = NULL;
-}
-
-static int edbm_bevel_cancel(bContext *C, wmOperator *op)
-{
- BevelData *opdata = op->customdata;
- if (opdata->is_modal) {
- EDBM_redo_state_free(&opdata->mesh_backup, opdata->em, true);
- EDBM_update_generic(opdata->em, false, true);
- }
-
- edbm_bevel_exit(C, op);
-
- /* need to force redisplay or we may still view the modified result */
- ED_region_tag_redraw(CTX_wm_region(C));
- return OPERATOR_CANCELLED;
-}
-
-/* bevel! yay!!*/
-static int edbm_bevel_exec(bContext *C, wmOperator *op)
-{
- if (!edbm_bevel_init(C, op, false)) {
- edbm_bevel_exit(C, op);
- return OPERATOR_CANCELLED;
- }
-
- if (!edbm_bevel_calc(op)) {
- edbm_bevel_cancel(C, op);
- return OPERATOR_CANCELLED;
- }
-
- edbm_bevel_exit(C, op);
-
- return OPERATOR_FINISHED;
-}
-
-static int edbm_bevel_invoke(bContext *C, wmOperator *op, const wmEvent *event)
-{
- /* TODO make modal keymap (see fly mode) */
- RegionView3D *rv3d = CTX_wm_region_view3d(C);
- BevelData *opdata;
- float mlen[2];
- float center_3d[3];
-
- if (!edbm_bevel_init(C, op, true)) {
- return OPERATOR_CANCELLED;
- }
-
- opdata = op->customdata;
-
- /* initialize mouse values */
- if (!calculateTransformCenter(C, V3D_CENTROID, center_3d, opdata->mcenter)) {
- /* in this case the tool will likely do nothing,
- * ideally this will never happen and should be checked for above */
- opdata->mcenter[0] = opdata->mcenter[1] = 0;
- }
- mlen[0] = opdata->mcenter[0] - event->mval[0];
- mlen[1] = opdata->mcenter[1] - event->mval[1];
- opdata->initial_length = len_v2(mlen);
- opdata->pixel_size = rv3d ? ED_view3d_pixel_size(rv3d, center_3d) : 1.0f;
-
- edbm_bevel_update_header(op, C);
-
- if (!edbm_bevel_calc(op)) {
- edbm_bevel_cancel(C, op);
- return OPERATOR_CANCELLED;
- }
-
- WM_event_add_modal_handler(C, op);
-
- return OPERATOR_RUNNING_MODAL;
-}
-
-static float edbm_bevel_mval_factor(wmOperator *op, const wmEvent *event)
-{
- BevelData *opdata = op->customdata;
- int use_dist = true;
- float mdiff[2];
- float factor;
-
- mdiff[0] = opdata->mcenter[0] - event->mval[0];
- mdiff[1] = opdata->mcenter[1] - event->mval[1];
-
- if (use_dist) {
- factor = ((len_v2(mdiff) - MVAL_PIXEL_MARGIN) - opdata->initial_length) * opdata->pixel_size;
- }
- else {
- factor = (len_v2(mdiff) - MVAL_PIXEL_MARGIN) / opdata->initial_length;
- factor = factor - 1.0f; /* a different kind of buffer where nothing happens */
- }
-
- /* Fake shift-transform... */
- if (event->shift) {
- if (opdata->shift_factor < 0.0f) {
- opdata->shift_factor = RNA_float_get(op->ptr, "offset");
- }
- factor = (factor - opdata->shift_factor) * 0.1f + opdata->shift_factor;
- }
- else if (opdata->shift_factor >= 0.0f)
- opdata->shift_factor = -1.0f;
-
- /* clamp differently based on distance/factor */
- if (use_dist) {
- if (factor < 0.0f) factor = 0.0f;
- }
- else {
- CLAMP(factor, 0.0f, 1.0f);
- }
-
- return factor;
-}
-
-static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
-{
- BevelData *opdata = op->customdata;
- int segments = RNA_int_get(op->ptr, "segments");
-
- if (event->val == KM_PRESS) {
- /* Try to handle numeric inputs... */
-
- if (handleNumInput(&opdata->num_input, event)) {
- float value = RNA_float_get(op->ptr, "offset");
- applyNumInput(&opdata->num_input, &value);
- RNA_float_set(op->ptr, "offset", value);
- edbm_bevel_calc(op);
- edbm_bevel_update_header(op, C);
- return OPERATOR_RUNNING_MODAL;
- }
- }
-
- switch (event->type) {
- case ESCKEY:
- case RIGHTMOUSE:
- edbm_bevel_cancel(C, op);
- return OPERATOR_CANCELLED;
-
- case MOUSEMOVE:
- if (!hasNumInput(&opdata->num_input)) {
- const float factor = edbm_bevel_mval_factor(op, event);
- RNA_float_set(op->ptr, "offset", factor);
-
- edbm_bevel_calc(op);
- edbm_bevel_update_header(op, C);
- }
- break;
-
- case LEFTMOUSE:
- case PADENTER:
- case RETKEY:
- edbm_bevel_calc(op);
- edbm_bevel_exit(C, op);
- return OPERATOR_FINISHED;
-
- case WHEELUPMOUSE: /* change number of segments */
- case PAGEUPKEY:
- if (event->val == KM_RELEASE)
- break;
-
- segments++;
- RNA_int_set(op->ptr, "segments", segments);
- edbm_bevel_calc(op);
- edbm_bevel_update_header(op, C);
- break;
-
- case WHEELDOWNMOUSE: /* change number of segments */
- case PAGEDOWNKEY:
- if (event->val == KM_RELEASE)
- break;
-
- segments = max_ii(segments - 1, 1);
- RNA_int_set(op->ptr, "segments", segments);
- edbm_bevel_calc(op);
- edbm_bevel_update_header(op, C);
- break;
- }
-
- return OPERATOR_RUNNING_MODAL;
-}
-
-void MESH_OT_bevel(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Bevel";
- ot->description = "Edge Bevel";
- ot->idname = "MESH_OT_bevel";
-
- /* api callbacks */
- ot->exec = edbm_bevel_exec;
- ot->invoke = edbm_bevel_invoke;
- ot->modal = edbm_bevel_modal;
- ot->cancel = edbm_bevel_cancel;
- ot->poll = ED_operator_editmesh;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_POINTER | OPTYPE_BLOCKING;
-
- RNA_def_float(ot->srna, "offset", 0.0f, -FLT_MAX, FLT_MAX, "Offset", "", 0.0f, 1.0f);
- RNA_def_int(ot->srna, "segments", 1, 1, 50, "Segments", "Segments for curved edge", 1, 8);
- RNA_def_boolean(ot->srna, "vertex_only", false, "Vertex only", "Bevel only vertices");
-}
-
static int edbm_bridge_edge_loops_exec(bContext *C, wmOperator *op)
{
BMOperator bmop;
@@ -5217,382 +3590,6 @@ void MESH_OT_bridge_edge_loops(wmOperatorType *ot)
RNA_def_float(ot->srna, "merge_factor", 0.5f, 0.0f, 1.0f, "Merge Factor", "", 0.0f, 1.0f);
}
-typedef struct {
- float old_thickness;
- float old_depth;
- int mcenter[2];
- int modify_depth;
- float initial_length;
- float pixel_size; /* use when mouse input is interpreted as spatial distance */
- int is_modal;
- int shift;
- float shift_amount;
- BMBackup backup;
- BMEditMesh *em;
- NumInput num_input;
-} InsetData;
-
-static void edbm_inset_update_header(wmOperator *op, bContext *C)
-{
- InsetData *opdata = op->customdata;
-
- const char *str = IFACE_("Confirm: Enter/LClick, Cancel: (Esc/RClick), Thickness: %s, "
- "Depth (Ctrl to tweak): %s (%s), Outset (O): (%s), Boundary (B): (%s)");
-
- char msg[HEADER_LENGTH];
- ScrArea *sa = CTX_wm_area(C);
-
- if (sa) {
- char flts_str[NUM_STR_REP_LEN * 2];
- if (hasNumInput(&opdata->num_input))
- outputNumInput(&opdata->num_input, flts_str);
- else {
- BLI_snprintf(flts_str, NUM_STR_REP_LEN, "%f", RNA_float_get(op->ptr, "thickness"));
- BLI_snprintf(flts_str + NUM_STR_REP_LEN, NUM_STR_REP_LEN, "%f", RNA_float_get(op->ptr, "depth"));
- }
- BLI_snprintf(msg, HEADER_LENGTH, str,
- flts_str,
- flts_str + NUM_STR_REP_LEN,
- opdata->modify_depth ? IFACE_("On") : IFACE_("Off"),
- RNA_boolean_get(op->ptr, "use_outset") ? IFACE_("On") : IFACE_("Off"),
- RNA_boolean_get(op->ptr, "use_boundary") ? IFACE_("On") : IFACE_("Off")
- );
-
- ED_area_headerprint(sa, msg);
- }
-}
-
-
-static int edbm_inset_init(bContext *C, wmOperator *op, int is_modal)
-{
- InsetData *opdata;
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BMEdit_FromObject(obedit);
-
- op->customdata = opdata = MEM_mallocN(sizeof(InsetData), "inset_operator_data");
-
- opdata->old_thickness = 0.01;
- opdata->old_depth = 0.0;
- opdata->modify_depth = false;
- opdata->shift = false;
- opdata->shift_amount = 0.0f;
- opdata->is_modal = is_modal;
- opdata->em = em;
-
- initNumInput(&opdata->num_input);
- opdata->num_input.idx_max = 1; /* Two elements. */
-
- if (is_modal)
- opdata->backup = EDBM_redo_state_store(em);
-
- return 1;
-}
-
-static void edbm_inset_exit(bContext *C, wmOperator *op)
-{
- InsetData *opdata;
- ScrArea *sa = CTX_wm_area(C);
-
- opdata = op->customdata;
-
- if (opdata->is_modal)
- EDBM_redo_state_free(&opdata->backup, NULL, false);
-
- if (sa) {
- ED_area_headerprint(sa, NULL);
- }
- MEM_freeN(op->customdata);
-}
-
-static int edbm_inset_cancel(bContext *C, wmOperator *op)
-{
- InsetData *opdata;
-
- opdata = op->customdata;
- if (opdata->is_modal) {
- EDBM_redo_state_free(&opdata->backup, opdata->em, true);
- EDBM_update_generic(opdata->em, false, true);
- }
-
- edbm_inset_exit(C, op);
-
- /* need to force redisplay or we may still view the modified result */
- ED_region_tag_redraw(CTX_wm_region(C));
- return OPERATOR_CANCELLED;
-}
-
-static int edbm_inset_calc(wmOperator *op)
-{
- InsetData *opdata;
- BMEditMesh *em;
- BMOperator bmop;
-
- const bool use_boundary = RNA_boolean_get(op->ptr, "use_boundary");
- const bool use_even_offset = RNA_boolean_get(op->ptr, "use_even_offset");
- const bool use_relative_offset = RNA_boolean_get(op->ptr, "use_relative_offset");
- const float thickness = RNA_float_get(op->ptr, "thickness");
- const float depth = RNA_float_get(op->ptr, "depth");
- const bool use_outset = RNA_boolean_get(op->ptr, "use_outset");
- const bool use_select_inset = RNA_boolean_get(op->ptr, "use_select_inset"); /* not passed onto the BMO */
-
- opdata = op->customdata;
- em = opdata->em;
-
- if (opdata->is_modal) {
- EDBM_redo_state_restore(opdata->backup, em, false);
- }
-
- EDBM_op_init(em, &bmop, op,
- "inset faces=%hf use_boundary=%b use_even_offset=%b use_relative_offset=%b "
- "thickness=%f depth=%f use_outset=%b",
- BM_ELEM_SELECT, use_boundary, use_even_offset, use_relative_offset,
- thickness, depth, use_outset);
-
- BMO_op_exec(em->bm, &bmop);
-
- if (use_select_inset) {
- /* deselect original faces/verts */
- EDBM_flag_disable_all(em, BM_ELEM_SELECT);
- BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true);
- }
- else {
- BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE, BM_ELEM_SELECT, false);
- BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, false);
- /* re-select faces so the verts and edges get selected too */
- BM_mesh_elem_hflag_enable_test(em->bm, BM_FACE, BM_ELEM_SELECT, true, BM_ELEM_SELECT);
- }
-
- if (!EDBM_op_finish(em, &bmop, op, true)) {
- return 0;
- }
- else {
- EDBM_update_generic(em, true, true);
- return 1;
- }
-}
-
-static int edbm_inset_exec(bContext *C, wmOperator *op)
-{
- edbm_inset_init(C, op, false);
-
- if (!edbm_inset_calc(op)) {
- edbm_inset_exit(C, op);
- return OPERATOR_CANCELLED;
- }
-
- edbm_inset_exit(C, op);
- return OPERATOR_FINISHED;
-}
-
-static int edbm_inset_invoke(bContext *C, wmOperator *op, const wmEvent *event)
-{
- RegionView3D *rv3d = CTX_wm_region_view3d(C);
- InsetData *opdata;
- float mlen[2];
- float center_3d[3];
-
- edbm_inset_init(C, op, true);
-
- opdata = op->customdata;
-
- /* initialize mouse values */
- if (!calculateTransformCenter(C, V3D_CENTROID, center_3d, opdata->mcenter)) {
- /* in this case the tool will likely do nothing,
- * ideally this will never happen and should be checked for above */
- opdata->mcenter[0] = opdata->mcenter[1] = 0;
- }
- mlen[0] = opdata->mcenter[0] - event->mval[0];
- mlen[1] = opdata->mcenter[1] - event->mval[1];
- opdata->initial_length = len_v2(mlen);
- opdata->pixel_size = rv3d ? ED_view3d_pixel_size(rv3d, center_3d) : 1.0f;
-
- edbm_inset_calc(op);
-
- edbm_inset_update_header(op, C);
-
- WM_event_add_modal_handler(C, op);
- return OPERATOR_RUNNING_MODAL;
-}
-
-static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event)
-{
- InsetData *opdata = op->customdata;
-
- if (event->val == KM_PRESS) {
- /* Try to handle numeric inputs... */
-
- if (handleNumInput(&opdata->num_input, event)) {
- float amounts[2] = {RNA_float_get(op->ptr, "thickness"),
- RNA_float_get(op->ptr, "depth")};
- applyNumInput(&opdata->num_input, amounts);
- amounts[0] = max_ff(amounts[0], 0.0f);
- RNA_float_set(op->ptr, "thickness", amounts[0]);
- RNA_float_set(op->ptr, "depth", amounts[1]);
-
- if (edbm_inset_calc(op)) {
- edbm_inset_update_header(op, C);
- return OPERATOR_RUNNING_MODAL;
- }
- else {
- edbm_inset_cancel(C, op);
- return OPERATOR_CANCELLED;
- }
- }
- }
-
- switch (event->type) {
- case ESCKEY:
- case RIGHTMOUSE:
- edbm_inset_cancel(C, op);
- return OPERATOR_CANCELLED;
-
- case MOUSEMOVE:
- if (!hasNumInput(&opdata->num_input)) {
- float mdiff[2];
- float amount;
-
- mdiff[0] = opdata->mcenter[0] - event->mval[0];
- mdiff[1] = opdata->mcenter[1] - event->mval[1];
-
- if (opdata->modify_depth)
- amount = opdata->old_depth + ((len_v2(mdiff) - opdata->initial_length) * opdata->pixel_size);
- else
- amount = opdata->old_thickness - ((len_v2(mdiff) - opdata->initial_length) * opdata->pixel_size);
-
- /* Fake shift-transform... */
- if (opdata->shift)
- amount = (amount - opdata->shift_amount) * 0.1f + opdata->shift_amount;
-
- 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))
- edbm_inset_update_header(op, C);
- else {
- edbm_inset_cancel(C, op);
- return OPERATOR_CANCELLED;
- }
- }
- break;
-
- case LEFTMOUSE:
- case PADENTER:
- case RETKEY:
- edbm_inset_calc(op);
- edbm_inset_exit(C, op);
- return OPERATOR_FINISHED;
-
- case LEFTSHIFTKEY:
- case RIGHTSHIFTKEY:
- if (event->val == KM_PRESS) {
- if (opdata->modify_depth)
- opdata->shift_amount = RNA_float_get(op->ptr, "depth");
- else
- opdata->shift_amount = RNA_float_get(op->ptr, "thickness");
- opdata->shift = true;
- }
- else {
- opdata->shift_amount = 0.0f;
- opdata->shift = false;
- }
- break;
-
- case LEFTCTRLKEY:
- case RIGHTCTRLKEY:
- {
- float mlen[2];
-
- mlen[0] = opdata->mcenter[0] - event->mval[0];
- mlen[1] = opdata->mcenter[1] - event->mval[1];
-
- if (event->val == KM_PRESS) {
- opdata->old_thickness = RNA_float_get(op->ptr, "thickness");
- 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)
- opdata->shift_amount = opdata->old_depth;
- opdata->modify_depth = false;
- }
- opdata->initial_length = len_v2(mlen);
-
- edbm_inset_update_header(op, C);
- break;
- }
-
- case OKEY:
- if (event->val == KM_PRESS) {
- const bool use_outset = RNA_boolean_get(op->ptr, "use_outset");
- RNA_boolean_set(op->ptr, "use_outset", !use_outset);
- if (edbm_inset_calc(op)) {
- edbm_inset_update_header(op, C);
- }
- else {
- edbm_inset_cancel(C, op);
- return OPERATOR_CANCELLED;
- }
- }
- break;
- case BKEY:
- if (event->val == KM_PRESS) {
- const bool use_boundary = RNA_boolean_get(op->ptr, "use_boundary");
- RNA_boolean_set(op->ptr, "use_boundary", !use_boundary);
- if (edbm_inset_calc(op)) {
- edbm_inset_update_header(op, C);
- }
- else {
- edbm_inset_cancel(C, op);
- return OPERATOR_CANCELLED;
- }
- }
- break;
- }
-
- return OPERATOR_RUNNING_MODAL;
-}
-
-
-void MESH_OT_inset(wmOperatorType *ot)
-{
- PropertyRNA *prop;
-
- /* identifiers */
- ot->name = "Inset Faces";
- ot->idname = "MESH_OT_inset";
- ot->description = "Inset new faces into selected faces";
-
- /* api callbacks */
- ot->invoke = edbm_inset_invoke;
- ot->modal = edbm_inset_modal;
- ot->exec = edbm_inset_exec;
- ot->cancel = edbm_inset_cancel;
- ot->poll = ED_operator_editmesh;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_POINTER | OPTYPE_BLOCKING;
-
- /* properties */
- RNA_def_boolean(ot->srna, "use_boundary", true, "Boundary", "Inset face boundaries");
- RNA_def_boolean(ot->srna, "use_even_offset", true, "Offset Even", "Scale the offset to give more even thickness");
- RNA_def_boolean(ot->srna, "use_relative_offset", false, "Offset Relative", "Scale the offset by surrounding geometry");
-
- prop = RNA_def_float(ot->srna, "thickness", 0.01f, 0.0f, FLT_MAX, "Thickness", "", 0.0f, 10.0f);
- /* use 1 rather then 10 for max else dragging the button moves too far */
- RNA_def_property_ui_range(prop, 0.0, 1.0, 0.01, 4);
- prop = RNA_def_float(ot->srna, "depth", 0.0f, -FLT_MAX, FLT_MAX, "Depth", "", -10.0f, 10.0f);
- RNA_def_property_ui_range(prop, -10.0f, 10.0f, 0.01, 4);
-
- RNA_def_boolean(ot->srna, "use_outset", false, "Outset", "Outset rather than inset");
- RNA_def_boolean(ot->srna, "use_select_inset", true, "Select Outer", "Select the new inset faces");
-}
-
static int edbm_wireframe_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index cb15fdef880..9020e133b33 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -33,7 +33,6 @@
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
-#include "DNA_scene_types.h"
#include "BLI_math.h"
@@ -51,10 +50,10 @@
#include "WM_types.h"
#include "ED_mesh.h"
+#include "ED_screen.h"
#include "ED_util.h"
-
-#include "mesh_intern.h"
+#include "mesh_intern.h" /* own include */
/* mesh backup implementation. This would greatly benefit from some sort of binary diffing
* just as the undo stack would. So leaving this as an interface for further work */
@@ -1367,3 +1366,12 @@ void EDBM_update_generic(BMEditMesh *em, const bool do_tessface, const bool is_d
BLI_assert(EDBM_index_arrays_check(em) == true);
}
}
+
+/* poll call for mesh operators requiring a view3d context */
+int EDBM_view3d_poll(bContext *C)
+{
+ if (ED_operator_editmesh(C) && ED_operator_view3d_active(C))
+ return 1;
+
+ return 0;
+}
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index 20633aa0c87..cbaa80718ee 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -61,7 +61,7 @@
#include "ED_uvedit.h"
#include "ED_view3d.h"
-#include "mesh_intern.h"
+#include "mesh_intern.h" /* own include */
static CustomData *mesh_customdata_get_type(Mesh *me, const char htype, int *r_tot)
diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h
index 2013335dac6..996ee9fc549 100644
--- a/source/blender/editors/mesh/mesh_intern.h
+++ b/source/blender/editors/mesh/mesh_intern.h
@@ -29,7 +29,6 @@
* \ingroup edmesh
*/
-
/* Internal for editmesh_xxxx.c functions */
#ifndef __MESH_INTERN_H__
@@ -50,21 +49,18 @@ struct wmOperator;
struct wmOperatorType;
struct LinkNode;
-/* ******************** editmesh_utils.c */
+/* *** editmesh_utils.c *** */
/*
* ok: the EDBM module is for editmode bmesh stuff. in contrast, the
* BMEdit module is for code shared with blenkernel that concerns
- * the BMEditMesh structure.
- */
+ * the BMEditMesh structure. */
-/*calls a bmesh op, reporting errors to the user, etc*/
+/* Calls a bmesh op, reporting errors to the user, etc */
bool EDBM_op_callf(struct BMEditMesh *em, struct wmOperator *op, const char *fmt, ...);
-
bool EDBM_op_call_and_selectf(struct BMEditMesh *em, struct wmOperator *op,
const char *selectslot, const char *fmt, ...);
-
-/* same as above, but doesn't report errors.*/
+/* Same as above, but doesn't report errors.*/
bool EDBM_op_call_silentf(struct BMEditMesh *em, const char *fmt, ...);
/* these next two functions are the split version of EDBM_op_callf, so you can
@@ -74,17 +70,16 @@ bool EDBM_op_call_silentf(struct BMEditMesh *em, const char *fmt, ...);
* execute the operator with BM_Exec_Op */
bool EDBM_op_init(struct BMEditMesh *em, struct BMOperator *bmop,
struct wmOperator *op, const char *fmt, ...);
-/*cleans up after a bmesh operator*/
+/* Cleans up after a bmesh operator */
bool EDBM_op_finish(struct BMEditMesh *em, struct BMOperator *bmop,
struct wmOperator *op, const bool do_report);
void EDBM_stats_update(struct BMEditMesh *em);
-/* ******************** editface.c */
+int EDBM_view3d_poll(struct bContext *C);
-void MESH_OT_separate(struct wmOperatorType *ot);
-/* ******************* editmesh_add.c */
+/* *** editmesh_add.c *** */
void MESH_OT_primitive_plane_add(struct wmOperatorType *ot);
void MESH_OT_primitive_cube_add(struct wmOperatorType *ot);
void MESH_OT_primitive_circle_add(struct wmOperatorType *ot);
@@ -95,95 +90,121 @@ void MESH_OT_primitive_monkey_add(struct wmOperatorType *ot);
void MESH_OT_primitive_uv_sphere_add(struct wmOperatorType *ot);
void MESH_OT_primitive_ico_sphere_add(struct wmOperatorType *ot);
-void MESH_OT_edge_face_add(struct wmOperatorType *ot);
+
+/* *** editmesh_bevel.c *** */
+void MESH_OT_bevel(struct wmOperatorType *ot);
+
+
+/* *** editmesh_extrude.c *** */
+void MESH_OT_extrude_repeat(struct wmOperatorType *ot);
+void MESH_OT_extrude_region(struct wmOperatorType *ot);
+void MESH_OT_extrude_verts_indiv(struct wmOperatorType *ot);
+void MESH_OT_extrude_edges_indiv(struct wmOperatorType *ot);
+void MESH_OT_extrude_faces_indiv(struct wmOperatorType *ot);
void MESH_OT_dupli_extrude_cursor(struct wmOperatorType *ot);
-void MESH_OT_duplicate(struct wmOperatorType *ot);
+void MESH_OT_spin(struct wmOperatorType *ot);
+void MESH_OT_screw(struct wmOperatorType *ot);
+
-extern int EM_view3d_poll(struct bContext *C);
+/* *** editmesh_inset.c *** */
+void MESH_OT_inset(struct wmOperatorType *ot);
+
+
+/* *** editmesh_knife.c *** */
+void MESH_OT_knife_tool(struct wmOperatorType *ot);
+void MESH_OT_knife_project(wmOperatorType *ot);
+void EDBM_mesh_knife(struct bContext *C, struct LinkNode *polys, bool use_tag);
struct wmKeyMap *knifetool_modal_keymap(struct wmKeyConfig *keyconf);
-/* ******************* knifetool.c */
-void MESH_OT_knife_cut(struct wmOperatorType *ot);
+/* *** editmesh_loopcut.c *** */
+void MESH_OT_loopcut(struct wmOperatorType *ot);
-/* ******************* bmesh_select.c */
+
+/* *** editmesh_rip.c *** */
+void MESH_OT_rip(struct wmOperatorType *ot);
+
+
+/* *** editmesh_select.c *** */
+void MESH_OT_select_similar(struct wmOperatorType *ot);
+void MESH_OT_select_mode(struct wmOperatorType *ot);
+void MESH_OT_loop_multi_select(struct wmOperatorType *ot);
void MESH_OT_loop_select(struct wmOperatorType *ot);
+void MESH_OT_edgering_select(struct wmOperatorType *ot);
void MESH_OT_select_all(struct wmOperatorType *ot);
void MESH_OT_select_interior_faces(struct wmOperatorType *ot);
-void MESH_OT_select_more(struct wmOperatorType *ot);
-void MESH_OT_select_less(struct wmOperatorType *ot);
-void MESH_OT_select_non_manifold(struct wmOperatorType *ot);
+void MESH_OT_select_shortest_path(struct wmOperatorType *ot);
void MESH_OT_select_linked(struct wmOperatorType *ot);
void MESH_OT_select_linked_pick(struct wmOperatorType *ot);
-void MESH_OT_hide(struct wmOperatorType *ot);
-void MESH_OT_reveal(struct wmOperatorType *ot);
void MESH_OT_select_face_by_sides(struct wmOperatorType *ot);
void MESH_OT_select_loose_verts(struct wmOperatorType *ot);
void MESH_OT_select_mirror(struct wmOperatorType *ot);
-void MESH_OT_normals_make_consistent(struct wmOperatorType *ot);
-void MESH_OT_faces_select_linked_flat(struct wmOperatorType *ot);
+void MESH_OT_select_more(struct wmOperatorType *ot);
+void MESH_OT_select_less(struct wmOperatorType *ot);
+void MESH_OT_select_nth(struct wmOperatorType *ot);
void MESH_OT_edges_select_sharp(struct wmOperatorType *ot);
-void MESH_OT_select_shortest_path(struct wmOperatorType *ot);
-void MESH_OT_select_similar(struct wmOperatorType *ot);
-void MESH_OT_select_mode(struct wmOperatorType *ot);
+void MESH_OT_faces_select_linked_flat(struct wmOperatorType *ot);
+void MESH_OT_select_non_manifold(struct wmOperatorType *ot);
void MESH_OT_select_random(struct wmOperatorType *ot);
void MESH_OT_select_ungrouped(struct wmOperatorType *ot);
-void MESH_OT_loop_multi_select(struct wmOperatorType *ot);
-void MESH_OT_mark_seam(struct wmOperatorType *ot);
-void MESH_OT_mark_sharp(struct wmOperatorType *ot);
-void MESH_OT_vertices_smooth(struct wmOperatorType *ot);
-void MESH_OT_vertices_smooth_laplacian(struct wmOperatorType *ot);
-void MESH_OT_noise(struct wmOperatorType *ot);
-void MESH_OT_flip_normals(struct wmOperatorType *ot);
-void MESH_OT_solidify(struct wmOperatorType *ot);
-void MESH_OT_select_nth(struct wmOperatorType *ot);
+void MESH_OT_select_axis(struct wmOperatorType *ot);
void MESH_OT_select_next_loop(struct wmOperatorType *ot);
+void MESH_OT_region_to_loop(struct wmOperatorType *ot);
+void MESH_OT_loop_to_region(struct wmOperatorType *ot);
+void MESH_OT_select_vertex_path(struct wmOperatorType *ot);
extern struct EnumPropertyItem *corner_type_items;
-void MESH_OT_merge(struct wmOperatorType *ot);
+
+/* *** editmesh_tools.c *** */
void MESH_OT_subdivide(struct wmOperatorType *ot);
void MESH_OT_unsubdivide(struct wmOperatorType *ot);
-void MESH_OT_remove_doubles(struct wmOperatorType *ot);
-void MESH_OT_spin(struct wmOperatorType *ot);
-void MESH_OT_screw(struct wmOperatorType *ot);
-
-void MESH_OT_fill(struct wmOperatorType *ot);
-void MESH_OT_beautify_fill(struct wmOperatorType *ot);
-void MESH_OT_quads_convert_to_tris(struct wmOperatorType *ot);
-void MESH_OT_tris_convert_to_quads(struct wmOperatorType *ot);
-void MESH_OT_dissolve(struct wmOperatorType *ot);
-void MESH_OT_dissolve_limited(struct wmOperatorType *ot);
-void MESH_OT_faces_shade_smooth(struct wmOperatorType *ot);
-void MESH_OT_faces_shade_flat(struct wmOperatorType *ot);
-void MESH_OT_split(struct wmOperatorType *ot);
-void MESH_OT_extrude_repeat(struct wmOperatorType *ot);
-void MESH_OT_edge_rotate(struct wmOperatorType *ot);
-void MESH_OT_select_vertex_path(struct wmOperatorType *ot);
-void MESH_OT_loop_to_region(struct wmOperatorType *ot);
-void MESH_OT_region_to_loop(struct wmOperatorType *ot);
-void MESH_OT_select_axis(struct wmOperatorType *ot);
-
+void MESH_OT_normals_make_consistent(struct wmOperatorType *ot);
+void MESH_OT_vertices_smooth(struct wmOperatorType *ot);
+void MESH_OT_vertices_smooth_laplacian(struct wmOperatorType *ot);
+void MESH_OT_vert_connect(struct wmOperatorType *ot);
+void MESH_OT_edge_split(struct wmOperatorType *ot);
+void MESH_OT_bridge_edge_loops(struct wmOperatorType *ot);
+void MESH_OT_wireframe(struct wmOperatorType *ot);
+void MESH_OT_convex_hull(struct wmOperatorType *ot);
+void MESH_OT_symmetrize(struct wmOperatorType *ot);
+void MESH_OT_shape_propagate_to_all(struct wmOperatorType *ot);
+void MESH_OT_blend_from_shape(struct wmOperatorType *ot);
+void MESH_OT_sort_elements(struct wmOperatorType *ot);
void MESH_OT_uvs_rotate(struct wmOperatorType *ot);
-//void MESH_OT_uvs_mirror(struct wmOperatorType *ot);
void MESH_OT_uvs_reverse(struct wmOperatorType *ot);
void MESH_OT_colors_rotate(struct wmOperatorType *ot);
-//void MESH_OT_colors_mirror(struct wmOperatorType *ot);
-
void MESH_OT_colors_reverse(struct wmOperatorType *ot);
-
void MESH_OT_delete(struct wmOperatorType *ot);
void MESH_OT_edge_collapse(struct wmOperatorType *ot);
void MESH_OT_edge_collapse_loop(struct wmOperatorType *ot);
-void MESH_OT_rip(struct wmOperatorType *ot);
-
-void MESH_OT_shape_propagate_to_all(struct wmOperatorType *ot);
-void MESH_OT_blend_from_shape(struct wmOperatorType *ot);
-void MESH_OT_sort_elements(struct wmOperatorType *ot);
+void MESH_OT_faces_shade_smooth(struct wmOperatorType *ot);
+void MESH_OT_faces_shade_flat(struct wmOperatorType *ot);
+void MESH_OT_split(struct wmOperatorType *ot);
+void MESH_OT_edge_rotate(struct wmOperatorType *ot);
+void MESH_OT_hide(struct wmOperatorType *ot);
+void MESH_OT_reveal(struct wmOperatorType *ot);
+void MESH_OT_mark_seam(struct wmOperatorType *ot);
+void MESH_OT_mark_sharp(struct wmOperatorType *ot);
+void MESH_OT_noise(struct wmOperatorType *ot);
+void MESH_OT_flip_normals(struct wmOperatorType *ot);
+void MESH_OT_solidify(struct wmOperatorType *ot);
+void MESH_OT_knife_cut(struct wmOperatorType *ot);
+void MESH_OT_separate(struct wmOperatorType *ot);
+void MESH_OT_fill(struct wmOperatorType *ot);
+void MESH_OT_beautify_fill(struct wmOperatorType *ot);
+void MESH_OT_quads_convert_to_tris(struct wmOperatorType *ot);
+void MESH_OT_tris_convert_to_quads(struct wmOperatorType *ot);
+void MESH_OT_dissolve(struct wmOperatorType *ot);
+void MESH_OT_dissolve_limited(struct wmOperatorType *ot);
+void MESH_OT_edge_face_add(struct wmOperatorType *ot);
+void MESH_OT_duplicate(struct wmOperatorType *ot);
+void MESH_OT_merge(struct wmOperatorType *ot);
+void MESH_OT_remove_doubles(struct wmOperatorType *ot);
-/* ******************* mesh_data.c */
+/* *** mesh_data.c *** */
void MESH_OT_uv_texture_add(struct wmOperatorType *ot);
void MESH_OT_uv_texture_remove(struct wmOperatorType *ot);
void MESH_OT_vertex_color_add(struct wmOperatorType *ot);
@@ -191,40 +212,15 @@ void MESH_OT_vertex_color_remove(struct wmOperatorType *ot);
/* no create_mask yet */
void MESH_OT_customdata_clear_mask(struct wmOperatorType *ot);
void MESH_OT_customdata_clear_skin(struct wmOperatorType *ot);
-
void MESH_OT_drop_named_image(struct wmOperatorType *ot);
-/* ************* bmesh_tools.c ***********/
-void MESH_OT_vert_connect(struct wmOperatorType *ot);
-void MESH_OT_edge_split(struct wmOperatorType *ot);
-void MESH_OT_extrude_region(struct wmOperatorType *ot);
-void MESH_OT_extrude_verts_indiv(struct wmOperatorType *ot);
-void MESH_OT_extrude_edges_indiv(struct wmOperatorType *ot);
-void MESH_OT_extrude_faces_indiv(struct wmOperatorType *ot);
-
-void MESH_OT_edgering_select(struct wmOperatorType *ot);
-void MESH_OT_loopcut(struct wmOperatorType *ot);
-
-void MESH_OT_knife_tool(struct wmOperatorType *ot);
-void MESH_OT_knife_project(wmOperatorType *ot);
-
-void MESH_OT_bevel(struct wmOperatorType *ot);
-void MESH_OT_bridge_edge_loops(struct wmOperatorType *ot);
-void MESH_OT_inset(struct wmOperatorType *ot);
-void MESH_OT_wireframe(struct wmOperatorType *ot);
-
-void MESH_OT_convex_hull(struct wmOperatorType *ot);
-
-void MESH_OT_symmetrize(struct wmOperatorType *ot);
-
-/* ******************* mesh_navmesh.c */
+/* *** mesh_navmesh.c *** */
void MESH_OT_navmesh_make(struct wmOperatorType *ot);
void MESH_OT_navmesh_face_copy(struct wmOperatorType *ot);
void MESH_OT_navmesh_face_add(struct wmOperatorType *ot);
void MESH_OT_navmesh_reset(struct wmOperatorType *ot);
void MESH_OT_navmesh_clear(struct wmOperatorType *ot);
-void EDBM_mesh_knife(struct bContext *C, struct LinkNode *polys, bool use_tag);
#endif /* __MESH_INTERN_H__ */
diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c
index 2111b6f3409..e6c36274687 100644
--- a/source/blender/editors/mesh/mesh_navmesh.c
+++ b/source/blender/editors/mesh/mesh_navmesh.c
@@ -52,9 +52,10 @@
#include "WM_api.h"
#include "WM_types.h"
-#include "mesh_intern.h"
#include "recast-capi.h"
+#include "mesh_intern.h" /* own include */
+
static void createVertsTrisData(bContext *C, LinkNode *obs,
int *nverts_r, float **verts_r, int *ntris_r, int **tris_r, unsigned int *r_lay)
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index 8a22a553387..a79923a4fdb 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -28,13 +28,8 @@
* \ingroup edmesh
*/
-
-
-
-
#include "BLI_math.h"
-
#include "RNA_access.h"
#include "WM_api.h"
@@ -44,8 +39,7 @@
#include "ED_mesh.h"
#include "ED_screen.h"
-
-#include "mesh_intern.h"
+#include "mesh_intern.h" /* own include */
/**************************** registration **********************************/
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 562bc4a8e02..b34f43cd082 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -60,7 +60,6 @@
#include "BKE_tessmesh.h"
#include "BKE_multires.h"
-
#include "ED_mesh.h"
#include "ED_object.h"
#include "ED_view3d.h"