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:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2013-04-01 17:47:19 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2013-04-01 17:47:19 +0400
commit5524ed9ba2d60331abed47c9df0bc2fcf330b36b (patch)
treee8380010f140f022b77236af171d97083a294006 /source/blender/editors
parent1360bb6fb0bf0c5c14235c47bf1399accbcecc6f (diff)
parent689f3aa174ff795044a4dab719edf60b7b1f5bd3 (diff)
Merged changes in the trunk up to revision 55700.
Conflicts resolved: source/blender/editors/mesh/mesh_intern.h
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c8
-rw-r--r--source/blender/editors/animation/anim_markers.c47
-rw-r--r--source/blender/editors/armature/reeb.c4
-rw-r--r--source/blender/editors/include/ED_anim_api.h2
-rw-r--r--source/blender/editors/include/ED_clip.h7
-rw-r--r--source/blender/editors/include/ED_mesh.h2
-rw-r--r--source/blender/editors/include/ED_types.h2
-rw-r--r--source/blender/editors/include/UI_resources.h1
-rw-r--r--source/blender/editors/interface/interface_draw.c36
-rw-r--r--source/blender/editors/interface/resources.c3
-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.h188
-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
-rw-r--r--source/blender/editors/object/object_constraint.c4
-rw-r--r--source/blender/editors/physics/dynamicpaint_ops.c2
-rw-r--r--source/blender/editors/physics/particle_edit.c6
-rw-r--r--source/blender/editors/physics/physics_fluid.c2
-rw-r--r--source/blender/editors/render/render_internal.c2
-rw-r--r--source/blender/editors/screen/glutil.c9
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c151
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c14
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_2d.c16
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h9
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c196
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c19
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c28
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c13
-rw-r--r--source/blender/editors/space_buttons/buttons_ops.c3
-rw-r--r--source/blender/editors/space_clip/clip_draw.c113
-rw-r--r--source/blender/editors/space_clip/clip_editor.c161
-rw-r--r--source/blender/editors/space_clip/space_clip.c3
-rw-r--r--source/blender/editors/space_node/drawnode.c47
-rw-r--r--source/blender/editors/space_node/node_edit.c4
-rw-r--r--source/blender/editors/space_node/node_select.c7
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c21
-rw-r--r--source/blender/editors/space_view3d/drawobject.c100
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c2
-rw-r--r--source/blender/editors/transform/transform_manipulator.c5
-rw-r--r--source/blender/editors/transform/transform_ops.c4
56 files changed, 3022 insertions, 2607 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 2dae78ce5eb..4b0a99889b3 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -3368,13 +3368,13 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann
break;
case ACHANNEL_SETTING_EXPAND: /* expanded triangle */
- //icon = ((enabled)? ICON_TRIA_DOWN : ICON_TRIA_RIGHT);
+ //icon = ((enabled) ? ICON_TRIA_DOWN : ICON_TRIA_RIGHT);
icon = ICON_TRIA_RIGHT;
tooltip = TIP_("Make channels grouped under this channel visible");
break;
case ACHANNEL_SETTING_SOLO: /* NLA Tracks only */
- //icon = ((enabled)? ICON_LAYER_ACTIVE : ICON_LAYER_USED);
+ //icon = ((enabled) ? ICON_LAYER_ACTIVE : ICON_LAYER_USED);
icon = ICON_LAYER_USED;
tooltip = TIP_("NLA Track is the only one evaluated for the AnimData block it belongs to");
break;
@@ -3383,13 +3383,13 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann
case ACHANNEL_SETTING_PROTECT: /* protected lock */
// TODO: what about when there's no protect needed?
- //icon = ((enabled)? ICON_LOCKED : ICON_UNLOCKED);
+ //icon = ((enabled) ? ICON_LOCKED : ICON_UNLOCKED);
icon = ICON_UNLOCKED;
tooltip = TIP_("Editability of keyframes for this channel");
break;
case ACHANNEL_SETTING_MUTE: /* muted speaker */
- //icon = ((enabled)? ICON_MUTE_IPO_ON : ICON_MUTE_IPO_OFF);
+ //icon = ((enabled) ? ICON_MUTE_IPO_ON : ICON_MUTE_IPO_OFF);
icon = ICON_MUTE_IPO_OFF;
if (ale->type == ALE_FCURVE)
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 205f67cf96a..b4bbb14245d 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -1017,24 +1017,35 @@ static void MARKER_OT_duplicate(wmOperatorType *ot)
/* ************************** selection ************************************/
/* select/deselect TimeMarker at current frame */
-static void select_timeline_marker_frame(ListBase *markers, int frame, unsigned char shift)
+static void select_timeline_marker_frame(ListBase *markers, int frame, bool extend)
{
- TimeMarker *marker;
- int select = 0;
-
+ TimeMarker *marker, *marker_first = NULL;
+
+ /* support for selection cycling */
for (marker = markers->first; marker; marker = marker->next) {
- /* if Shift is not set, then deselect Markers */
- if (!shift) marker->flag &= ~SELECT;
-
- /* this way a not-shift select will allways give 1 selected marker */
- if ((marker->frame == frame) && (!select)) {
- if (marker->flag & SELECT)
- marker->flag &= ~SELECT;
- else
- marker->flag |= SELECT;
- select = 1;
+ if (marker->frame == frame) {
+ if (marker->flag & SELECT) {
+ marker_first = marker->next;
+ break;
+ }
+ }
+ }
+
+ /* if extend is not set, then deselect markers */
+ if (extend == false) {
+ for (marker = markers->first; marker; marker = marker->next) {
+ marker->flag &= ~SELECT;
+ }
+ }
+
+ LISTBASE_CIRCULAR_FORWARD_BEGIN (markers, marker, marker_first) {
+ /* this way a not-extend select will allways give 1 selected marker */
+ if (marker->frame == frame) {
+ marker->flag ^= SELECT;
+ break;
}
}
+ LISTBASE_CIRCULAR_FORWARD_END (markers, marker, marker_first);
}
static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool camera)
@@ -1121,6 +1132,8 @@ static int ed_marker_select_invoke_wrapper(bContext *C, wmOperator *op, const wm
static void MARKER_OT_select(wmOperatorType *ot)
{
+ PropertyRNA *prop;
+
/* identifiers */
ot->name = "Select Time Marker";
ot->description = "Select time marker(s)";
@@ -1133,9 +1146,11 @@ static void MARKER_OT_select(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection");
+ prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
#ifdef DURIAN_CAMERA_SWITCH
- RNA_def_boolean(ot->srna, "camera", 0, "Camera", "Select the camera");
+ prop = RNA_def_boolean(ot->srna, "camera", 0, "Camera", "Select the camera");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
#endif
}
diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c
index d04938fd59b..649ef90f7ba 100644
--- a/source/blender/editors/armature/reeb.c
+++ b/source/blender/editors/armature/reeb.c
@@ -52,9 +52,11 @@ static ReebGraph *FILTERED_RG = NULL;
* SIGGRAPH 2007
*
* */
-
+
+#if 0
#define DEBUG_REEB
#define DEBUG_REEB_NODE
+#endif
/* place-holders! */
typedef struct EditEdge {
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index b8ad40b2bd9..f698f9b0b11 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -409,7 +409,7 @@ typedef struct bAnimChannelType {
* with type being sizeof(ptr_data) which should be fine for runtime use...
* - assume that setting has been checked to be valid for current context
*/
- void *(*setting_ptr)(bAnimListElem * ale, int setting, short *type);
+ void *(*setting_ptr)(bAnimListElem *ale, int setting, short *type);
} bAnimChannelType;
/* ------------------------ Drawing API -------------------------- */
diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h
index 28727c913cb..541956136bd 100644
--- a/source/blender/editors/include/ED_clip.h
+++ b/source/blender/editors/include/ED_clip.h
@@ -39,6 +39,7 @@ struct Main;
struct Mask;
struct MovieClip;
struct SpaceClip;
+struct Scene;
/* ** clip_editor.c ** */
@@ -81,12 +82,6 @@ void ED_space_clip_set_clip(struct bContext *C, struct bScreen *screen, struct S
struct Mask *ED_space_clip_get_mask(struct SpaceClip *sc);
void ED_space_clip_set_mask(struct bContext *C, struct SpaceClip *sc, struct Mask *mask);
-/* textures buffer */
-int ED_space_clip_texture_buffer_supported(struct SpaceClip *sc);
-int ED_space_clip_load_movieclip_buffer(struct SpaceClip *sc, struct ImBuf *ibuf, const unsigned char *display_buffer);
-void ED_space_clip_unload_movieclip_buffer(struct SpaceClip *sc);
-void ED_space_clip_free_texture_buffer(struct SpaceClip *sc);
-
/* ** clip_ops.c ** */
void ED_operatormacros_clip(void);
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/include/ED_types.h b/source/blender/editors/include/ED_types.h
index 5908dbf3a1d..fac4c02e8ed 100644
--- a/source/blender/editors/include/ED_types.h
+++ b/source/blender/editors/include/ED_types.h
@@ -40,7 +40,7 @@
/* proposal = put scene pointers on function calls? */
// #define BASACT (scene->basact)
-// #define OBACT (BASACT? BASACT->object: NULL)
+// #define OBACT (BASACT ? BASACT->object : NULL)
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index 050e9c81f2a..63741ee08ba 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -185,6 +185,7 @@ enum {
TH_EDGE_CREASE,
TH_DRAWEXTRA_EDGELEN,
+ TH_DRAWEXTRA_EDGEANG,
TH_DRAWEXTRA_FACEAREA,
TH_DRAWEXTRA_FACEANG,
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 7fc5c21f052..b9b877c1fb6 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -61,6 +61,15 @@
/* own include */
#include "interface_intern.h"
+/* only for bug workaround [#34346] */
+#if !defined(WIN32) && !defined(__APPLE__)
+# define GPU_OSS_BUG_WOKAROUND
+#endif
+
+#ifdef GPU_OSS_BUG_WOKAROUND
+# include "GPU_extensions.h"
+#endif
+
static int roundboxtype = UI_CNR_ALL;
void uiSetRoundBox(int type)
@@ -1236,6 +1245,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect)
void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect)
{
+ static int use_displist = -1;
static GLuint displist = 0;
int a, old[8];
GLfloat diff[4], diffn[4] = {1.0f, 1.0f, 1.0f, 1.0f};
@@ -1285,20 +1295,30 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect)
glScalef(size, size, size);
- if (displist == 0) {
- GLUquadricObj *qobj;
-
- displist = glGenLists(1);
- glNewList(displist, GL_COMPILE_AND_EXECUTE);
+#ifdef GPU_OSS_BUG_WOKAROUND
+ if (use_displist == -1) {
+ use_displist = !GPU_type_matches(GPU_DEVICE_ANY, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE);
+ }
+#endif
+
+ if (displist == 0 || use_displist == 0) {
+ GLUquadricObj *qobj;
+
+ if (use_displist) {
+ displist = glGenLists(1);
+ glNewList(displist, GL_COMPILE_AND_EXECUTE);
+ }
qobj = gluNewQuadric();
- gluQuadricDrawStyle(qobj, GLU_FILL);
+ gluQuadricDrawStyle(qobj, GLU_FILL);
glShadeModel(GL_SMOOTH);
gluSphere(qobj, 100.0, 32, 24);
glShadeModel(GL_FLAT);
- gluDeleteQuadric(qobj);
+ gluDeleteQuadric(qobj);
- glEndList();
+ if (use_displist) {
+ glEndList();
+ }
}
else {
glCallList(displist);
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 288b8b43e82..b4246fe5b9c 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -309,6 +309,8 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
cp = &ts->facedot_size; break;
case TH_DRAWEXTRA_EDGELEN:
cp = ts->extra_edge_len; break;
+ case TH_DRAWEXTRA_EDGEANG:
+ cp = ts->extra_edge_angle; break;
case TH_DRAWEXTRA_FACEAREA:
cp = ts->extra_face_area; break;
case TH_DRAWEXTRA_FACEANG:
@@ -772,6 +774,7 @@ void ui_theme_init_default(void)
btheme->tv3d.facedot_size = 4;
rgba_char_args_set(btheme->tv3d.extra_edge_len, 32, 0, 0, 255);
+ rgba_char_args_set(btheme->tv3d.extra_edge_angle, 32, 32, 0, 255);
rgba_char_args_set(btheme->tv3d.extra_face_area, 0, 32, 0, 255);
rgba_char_args_set(btheme->tv3d.extra_face_angle, 0, 0, 128, 255);
diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt
index a76872d6e30..1aadac015dd 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 9474c051cee..3dfa2fa5c6c 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)
@@ -744,7 +742,6 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
EDBM_update_generic(em, false, false);
- /* we succeeded */
return OPERATOR_FINISHED;
}
@@ -786,7 +783,6 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
EDBM_update_generic(em, false, false);
- /* we succeeded */
return OPERATOR_FINISHED;
}
@@ -831,7 +827,6 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
EDBM_update_generic(em, false, false);
- /* we succeeded */
return OPERATOR_FINISHED;
}
@@ -1269,6 +1264,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])
@@ -2307,6 +2378,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")) {
@@ -2319,6 +2393,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);
@@ -2434,104 +2608,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");
}
/* ******************** **************** */
@@ -2796,15 +3026,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)
{
@@ -3115,6 +3336,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);
@@ -3411,3 +3717,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 f05df06ffa2..5befcd7b5f2 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -37,19 +37,15 @@
#include "DNA_meshdata_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"
@@ -63,7 +59,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"
@@ -75,24 +70,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);
@@ -229,735 +210,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", ""},
@@ -2014,7 +1266,6 @@ static int edbm_rotate_uvs_exec(bContext *C, wmOperator *op)
EDBM_update_generic(em, false, false);
- /* we succeeded */
return OPERATOR_FINISHED;
}
@@ -2037,7 +1288,6 @@ static int edbm_reverse_uvs_exec(bContext *C, wmOperator *op)
EDBM_update_generic(em, false, false);
- /* we succeeded */
return OPERATOR_FINISHED;
}
@@ -2064,7 +1314,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;
}
@@ -2088,7 +1337,6 @@ static int edbm_reverse_colors_exec(bContext *C, wmOperator *op)
EDBM_update_generic(em, false, false);
- /* we succeeded */
return OPERATOR_FINISHED;
}
@@ -2110,7 +1358,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 */
@@ -2428,123 +1675,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 *************************/
@@ -2740,89 +1870,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);
@@ -3197,7 +2244,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;
@@ -3842,366 +2889,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. */
@@ -4854,320 +3541,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;
@@ -5218,382 +3591,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 89a320ca928..4a0bbbb8dbf 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,101 +90,125 @@ 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);
+
+
+/* *** editmesh_rip.c *** */
+void MESH_OT_rip(struct wmOperatorType *ot);
-/* ******************* bmesh_select.c */
+
+/* *** 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);
-#ifdef WITH_FREESTYLE
-void MESH_OT_mark_freestyle_edge(struct wmOperatorType *ot);
-#endif
-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_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);
-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);
#ifdef WITH_FREESTYLE
+void MESH_OT_mark_freestyle_edge(struct wmOperatorType *ot);
void MESH_OT_mark_freestyle_face(struct wmOperatorType *ot);
#endif
-/* ******************* 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);
@@ -197,40 +216,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 42a139d7961..a17b0f5551b 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"
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 9b61fa44955..3e66c4ca110 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -604,7 +604,7 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int
list = &pchan->constraints;
else {
//if (G.debug & G_DEBUG)
- //printf("edit_constraint_property_get: No active bone for object '%s'\n", (ob)? ob->id.name + 2 : "<None>");
+ //printf("edit_constraint_property_get: No active bone for object '%s'\n", (ob) ? ob->id.name + 2 : "<None>");
return NULL;
}
}
@@ -616,7 +616,7 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int
con = BKE_constraints_findByName(list, constraint_name);
//if (G.debug & G_DEBUG)
- //printf("constraint found = %p, %s\n", (void *)con, (con)?con->name:"<Not found>");
+ //printf("constraint found = %p, %s\n", (void *)con, (con) ? con->name : "<Not found>");
if (con && (type != 0) && (con->type != type))
con = NULL;
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c
index 05c3af40a29..9634acd701a 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -394,7 +394,7 @@ static int dynamicPaint_initBake(struct bContext *C, struct wmOperator *op)
/* Format time string */
char time_str[30];
double time = PIL_check_seconds_timer() - timer;
- BLI_timestr(time, time_str);
+ BLI_timestr(time, time_str, sizeof(time_str));
/* Show bake info */
BKE_reportf(op->reports, RPT_INFO, "Bake complete! (%s)", time_str);
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index e972b7d6620..f00295a9033 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -2287,13 +2287,13 @@ static void subdivide_particle(PEData *data, int pa_index)
nekey++;
if (ekey->flag & PEK_SELECT && (ekey+1)->flag & PEK_SELECT) {
- nkey->time= (key->time + (key+1)->time)*0.5f;
- state.time= (endtime != 0.0f)? nkey->time/endtime: 0.0f;
+ nkey->time = (key->time + (key + 1)->time) * 0.5f;
+ state.time = (endtime != 0.0f) ? nkey->time / endtime: 0.0f;
psys_get_particle_on_path(&sim, pa_index, &state, 0);
copy_v3_v3(nkey->co, state.co);
nekey->co= nkey->co;
- nekey->time= &nkey->time;
+ nekey->time = &nkey->time;
nekey->flag |= PEK_SELECT;
if (!(psys->flag & PSYS_GLOBAL_HAIR))
nekey->flag |= PEK_USE_WCO;
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index df723b06259..8fe3eb66c67 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -528,7 +528,7 @@ static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length)
if ( ELEM(fsmesh.type, OB_FLUIDSIM_FLUID, OB_FLUIDSIM_INFLOW)) {
fsmesh.channelInitialVel = fobj->InitialVelocity;
- fsmesh.localInivelCoords = ((fluidmd->fss->typeFlags & OB_FSINFLOW_LOCALCOORD)?1:0);
+ fsmesh.localInivelCoords = ((fluidmd->fss->typeFlags & OB_FSINFLOW_LOCALCOORD) ? 1 : 0);
}
if (fluidmd->fss->typeFlags & OB_FSBND_NOSLIP)
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index 1268d577f44..365ac02d15b 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -311,7 +311,7 @@ static void make_renderinfo_string(RenderStats *rs, Scene *scene, char *str)
spos += sprintf(spos, IFACE_("Blur %d "), rs->curblur);
}
- BLI_timestr(rs->lastframetime, info_time_str);
+ BLI_timestr(rs->lastframetime, info_time_str, sizeof(info_time_str));
spos += sprintf(spos, IFACE_("Time:%s "), info_time_str);
if (rs->curfsa)
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index 8501b53afae..89315e041de 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -519,6 +519,15 @@ void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format,
nsubparts_x = (img_w + (offset_x - 1)) / (offset_x);
nsubparts_y = (img_h + (offset_y - 1)) / (offset_y);
+ if (format == GL_FLOAT) {
+ /* need to set internal format to higher range float */
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, tex_w, tex_h, 0, GL_RGBA, GL_FLOAT, NULL);
+ }
+ else {
+ /* switch to 8bit RGBA for byte buffer */
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, tex_w, tex_h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ }
+
for (subpart_y = 0; subpart_y < nsubparts_y; subpart_y++) {
for (subpart_x = 0; subpart_x < nsubparts_x; subpart_x++) {
int remainder_x = img_w - subpart_x * offset_x;
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 8d9cbbbcf11..a27ef91df24 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -85,7 +85,8 @@ static int same_snap(Snapshot *snap, Brush *brush, ViewContext *vc)
return (((mtex->tex) &&
equals_v3v3(mtex->ofs, snap->ofs) &&
equals_v3v3(mtex->size, snap->size) &&
- mtex->rot == snap->rot) &&
+ (brush->mtex.brush_map_mode == MTEX_MAP_MODE_STENCIL ||
+ mtex->rot == snap->rot)) &&
/* make brush smaller shouldn't cause a resample */
((mtex->brush_map_mode == MTEX_MAP_MODE_VIEW &&
@@ -117,7 +118,7 @@ static void make_snap(Snapshot *snap, Brush *brush, ViewContext *vc)
snap->winy = vc->ar->winy;
}
-static int load_tex(Brush *br, ViewContext *vc)
+static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col)
{
static GLuint overlay_texture = 0;
static int init = 0;
@@ -125,12 +126,15 @@ static int load_tex(Brush *br, ViewContext *vc)
static int curve_changed_timestamp = -1;
static Snapshot snap;
static int old_size = -1;
+ static int old_zoom = -1;
+ static bool old_col = -1;
GLubyte *buffer = NULL;
int size;
int j;
int refresh;
+ GLenum format = col ? GL_RGBA : GL_ALPHA;
if (br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED && !br->mtex.tex) return 0;
@@ -141,10 +145,17 @@ static int load_tex(Brush *br, ViewContext *vc)
br->mtex.tex->preview->changed_timestamp[0] != tex_changed_timestamp)) ||
!br->curve ||
br->curve->changed_timestamp != curve_changed_timestamp ||
+ old_zoom != zoom ||
+ old_col != col ||
!same_snap(&snap, br, vc);
if (refresh) {
struct ImagePool *pool = NULL;
+ /* stencil is rotated later */
+ const float rotation = (br->mtex.brush_map_mode != MTEX_MAP_MODE_STENCIL) ?
+ -br->mtex.rot : 0;
+
+ float radius = BKE_brush_size_get(vc->scene, br) * zoom;
if (br->mtex.tex && br->mtex.tex->preview)
tex_changed_timestamp = br->mtex.tex->preview->changed_timestamp[0];
@@ -152,6 +163,7 @@ static int load_tex(Brush *br, ViewContext *vc)
if (br->curve)
curve_changed_timestamp = br->curve->changed_timestamp;
+ old_zoom = zoom;
make_snap(&snap, br, vc);
if (br->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW) {
@@ -182,8 +194,10 @@ static int load_tex(Brush *br, ViewContext *vc)
old_size = size;
}
-
- buffer = MEM_mallocN(sizeof(GLubyte) * size * size, "load_tex");
+ if (col)
+ buffer = MEM_mallocN(sizeof(GLubyte) * size * size * 4, "load_tex");
+ else
+ buffer = MEM_mallocN(sizeof(GLubyte) * size * size, "load_tex");
if (br->mtex.tex)
pool = BKE_image_pool_new();
@@ -198,11 +212,8 @@ static int load_tex(Brush *br, ViewContext *vc)
// largely duplicated from tex_strength
- const float rotation = -br->mtex.rot;
- float radius = BKE_brush_size_get(vc->scene, br);
int index = j * size + i;
float x;
- float avg;
x = (float)i / size;
y = (float)j / size;
@@ -221,7 +232,7 @@ static int load_tex(Brush *br, ViewContext *vc)
len = sqrtf(x * x + y * y);
- if ((br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED) || len <= 1) {
+ if (ELEM(br->mtex.brush_map_mode, MTEX_MAP_MODE_TILED, MTEX_MAP_MODE_STENCIL) || len <= 1) {
/* it is probably worth optimizing for those cases where
* the texture is not rotated by skipping the calls to
* atan2, sqrtf, sin, and cos. */
@@ -238,17 +249,41 @@ static int load_tex(Brush *br, ViewContext *vc)
x += br->mtex.ofs[0];
y += br->mtex.ofs[1];
- avg = br->mtex.tex ? paint_get_tex_pixel(br, x, y, pool) : 1;
+ if (col) {
+ float rgba[4];
- avg += br->texture_sample_bias;
+ if (br->mtex.tex)
+ paint_get_tex_pixel_col(&br->mtex, x, y, rgba, pool);
- if (br->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW)
- avg *= BKE_brush_curve_strength(br, len, 1); /* Falloff curve */
+ if (br->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW)
+ mul_v4_fl(rgba, BKE_brush_curve_strength(br, len, 1)); /* Falloff curve */
+
+ buffer[index * 4] = rgba[0] * 255;
+ buffer[index * 4 + 1] = rgba[1] * 255;
+ buffer[index * 4 + 2] = rgba[2] * 255;
+ buffer[index * 4 + 3] = rgba[3] * 255;
+ }
+ else {
+ float avg = br->mtex.tex ? paint_get_tex_pixel(&br->mtex, x, y, pool) : 1;
- buffer[index] = 255 - (GLubyte)(255 * avg);
+ avg += br->texture_sample_bias;
+
+ if (br->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW)
+ avg *= BKE_brush_curve_strength(br, len, 1); /* Falloff curve */
+
+ buffer[index] = 255 - (GLubyte)(255 * avg);
+ }
}
else {
- buffer[index] = 0;
+ if (col) {
+ buffer[index * 4] = 0;
+ buffer[index * 4 + 1] = 0;
+ buffer[index * 4 + 2] = 0;
+ buffer[index * 4 + 3] = 0;
+ }
+ else {
+ buffer[index] = 0;
+ }
}
}
}
@@ -266,16 +301,18 @@ static int load_tex(Brush *br, ViewContext *vc)
glBindTexture(GL_TEXTURE_2D, overlay_texture);
if (refresh) {
- if (!init) {
- glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, size, size, 0, GL_ALPHA, GL_UNSIGNED_BYTE, buffer);
+ if (!init || (old_col != col)) {
+ glTexImage2D(GL_TEXTURE_2D, 0, format, size, size, 0, format, GL_UNSIGNED_BYTE, buffer);
init = 1;
}
else {
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, size, size, GL_ALPHA, GL_UNSIGNED_BYTE, buffer);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, size, size, format, GL_UNSIGNED_BYTE, buffer);
}
if (buffer)
MEM_freeN(buffer);
+
+ old_col = col;
}
glEnable(GL_TEXTURE_2D);
@@ -382,17 +419,20 @@ static int sculpt_get_brush_geometry(bContext *C, ViewContext *vc,
* have on brush strength */
/* TODO: sculpt only for now */
static void paint_draw_alpha_overlay(UnifiedPaintSettings *ups, Brush *brush,
- ViewContext *vc, int x, int y)
+ ViewContext *vc, int x, int y, float zoom, PaintMode mode)
{
rctf quad;
-
+ bool col;
/* check for overlay mode */
- if (!(brush->flag & BRUSH_TEXTURE_OVERLAY) ||
- !(ELEM(brush->mtex.brush_map_mode, MTEX_MAP_MODE_VIEW, MTEX_MAP_MODE_TILED)))
+
+ if (!((brush->mtex.brush_map_mode == MTEX_MAP_MODE_STENCIL && brush->mtex.tex) ||
+ ((brush->flag & BRUSH_TEXTURE_OVERLAY) &&
+ ELEM(brush->mtex.brush_map_mode, MTEX_MAP_MODE_VIEW, MTEX_MAP_MODE_TILED))))
{
return;
}
+ col = ELEM3(mode, PAINT_TEXTURE_PROJECTIVE, PAINT_TEXTURE_2D, PAINT_VERTEX) ? true: false;
/* save lots of GL state
* TODO: check on whether all of these are needed? */
glPushAttrib(GL_COLOR_BUFFER_BIT |
@@ -406,7 +446,7 @@ static void paint_draw_alpha_overlay(UnifiedPaintSettings *ups, Brush *brush,
GL_VIEWPORT_BIT |
GL_TEXTURE_BIT);
- if (load_tex(brush, vc)) {
+ if (load_tex(brush, vc, zoom, col)) {
glEnable(GL_BLEND);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
@@ -439,25 +479,43 @@ static void paint_draw_alpha_overlay(UnifiedPaintSettings *ups, Brush *brush,
quad.ymax = aim[1] + ups->anchored_size;
}
else {
- const int radius = BKE_brush_size_get(vc->scene, brush);
+ const int radius = BKE_brush_size_get(vc->scene, brush) * zoom;
quad.xmin = x - radius;
quad.ymin = y - radius;
quad.xmax = x + radius;
quad.ymax = y + radius;
}
}
- else {
+ else if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_TILED) {
quad.xmin = 0;
quad.ymin = 0;
quad.xmax = BLI_rcti_size_x(&vc->ar->winrct);
quad.ymax = BLI_rcti_size_y(&vc->ar->winrct);
}
+ else if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_STENCIL) {
+ quad.xmin = -brush->stencil_dimension[0];
+ quad.ymin = -brush->stencil_dimension[1];
+ quad.xmax = brush->stencil_dimension[0];
+ quad.ymax = brush->stencil_dimension[1];
+
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glTranslatef(brush->stencil_pos[0], brush->stencil_pos[1], 0);
+ glRotatef(RAD2DEGF(brush->mtex.rot), 0, 0, 1);
+ glMatrixMode(GL_TEXTURE);
+ }
- /* set quad color */
- glColor4f(U.sculpt_paint_overlay_col[0],
- U.sculpt_paint_overlay_col[1],
- U.sculpt_paint_overlay_col[2],
- brush->texture_overlay_alpha / 100.0f);
+ /* set quad color. Colored overlay does not get blending */
+ if (col)
+ glColor4f(1.0,
+ 1.0,
+ 1.0,
+ brush->texture_overlay_alpha / 100.0f);
+ else
+ glColor4f(U.sculpt_paint_overlay_col[0],
+ U.sculpt_paint_overlay_col[1],
+ U.sculpt_paint_overlay_col[2],
+ brush->texture_overlay_alpha / 100.0f);
/* draw textured quad */
glBegin(GL_QUADS);
@@ -472,6 +530,11 @@ static void paint_draw_alpha_overlay(UnifiedPaintSettings *ups, Brush *brush,
glEnd();
glPopMatrix();
+
+ if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_STENCIL) {
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ }
}
glPopAttrib();
@@ -516,17 +579,12 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
Paint *paint = paint_get_active_from_context(C);
Brush *brush = paint_brush(paint);
ViewContext vc;
+ PaintMode mode;
float final_radius;
float translation[2];
float outline_alpha, *outline_col;
+ float zoomx, zoomy;
- /* set various defaults */
- translation[0] = x;
- translation[1] = y;
- outline_alpha = 0.5;
- outline_col = brush->add_col;
- final_radius = BKE_brush_size_get(scene, brush);
-
/* check that brush drawing is enabled */
if (!(paint->flags & PAINT_SHOW_BRUSH))
return;
@@ -535,12 +593,25 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
* mouse over too, not just during a stroke */
view3d_set_viewcontext(C, &vc);
+ get_imapaint_zoom(C, &zoomx, &zoomy);
+ zoomx = max_ff(zoomx, zoomy);
+ mode = paintmode_get_active_from_context(C);
+
+ /* set various defaults */
+ translation[0] = x;
+ translation[1] = y;
+ outline_alpha = 0.5;
+ outline_col = brush->add_col;
+ final_radius = BKE_brush_size_get(scene, brush) * zoomx;
+
if (brush->flag & BRUSH_RAKE)
/* here, translation contains the mouse coordinates. */
paint_calculate_rake_rotation(ups, translation);
+ else if (!(brush->flag & BRUSH_ANCHORED))
+ ups->brush_rotation = 0.0;
/* draw overlay */
- paint_draw_alpha_overlay(ups, brush, &vc, x, y);
+ paint_draw_alpha_overlay(ups, brush, &vc, x, y, zoomx, mode);
/* TODO: as sculpt and other paint modes are unified, this
* special mode of drawing will go away */
@@ -611,3 +682,9 @@ void paint_cursor_start(bContext *C, int (*poll)(bContext *C))
if (p && !p->paint_cursor)
p->paint_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), poll, paint_draw_cursor, NULL);
}
+
+void paint_cursor_start_explicit(Paint *p, wmWindowManager *wm, int (*poll)(bContext *C))
+{
+ if (p && !p->paint_cursor)
+ p->paint_cursor = WM_paint_cursor_activate(wm, poll, paint_draw_cursor, NULL);
+}
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 4478d68d3be..a47f364ac67 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -442,7 +442,7 @@ static void paint_redraw(const bContext *C, PaintOperation *pop, int final)
}
}
-static PaintOperation * texture_paint_init(bContext *C, wmOperator *op, const wmEvent *event)
+static PaintOperation *texture_paint_init(bContext *C, wmOperator *op, const wmEvent *event)
{
Scene *scene = CTX_data_scene(C);
ToolSettings *settings = scene->toolsettings;
@@ -721,8 +721,7 @@ static void toggle_paint_cursor(bContext *C, int enable)
settings->imapaint.paintcursor = NULL;
}
else if (enable)
- settings->imapaint.paintcursor =
- WM_paint_cursor_activate(wm, image_paint_poll, brush_drawcursor_texpaint_uvsculpt, NULL);
+ paint_cursor_start(C, image_paint_poll);
}
/* enable the paint cursor if it isn't already.
@@ -746,11 +745,7 @@ void ED_space_image_paint_update(wmWindowManager *wm, ToolSettings *settings)
if (enabled) {
BKE_paint_init(&imapaint->paint, PAINT_CURSOR_TEXTURE_PAINT);
- if (!imapaint->paintcursor) {
- imapaint->paintcursor =
- WM_paint_cursor_activate(wm, image_paint_poll,
- brush_drawcursor_texpaint_uvsculpt, NULL);
- }
+ paint_cursor_start_explicit(&imapaint->paint, wm, image_paint_poll);
}
}
@@ -882,8 +877,7 @@ static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event
static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
switch (event->type) {
- case LEFTMOUSE:
- case RIGHTMOUSE: // XXX hardcoded
+ case SKEY: // XXX hardcoded
return OPERATOR_FINISHED;
case MOUSEMOVE:
RNA_int_set_array(op->ptr, "location", event->mval);
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index a45209de643..6032a7a4c22 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -87,11 +87,8 @@ BLI_INLINE unsigned char f_to_char(const float val)
#define IMAPAINT_FLOAT_RGB_COPY(a, b) copy_v3_v3(a, b)
typedef struct BrushPainterCache {
- short enabled;
-
int size; /* size override, if 0 uses 2*BKE_brush_size_get(brush) */
short flt; /* need float imbuf? */
- short texonly; /* no alpha, color or fallof, only texture in imbuf */
int lastsize;
float lastalpha;
@@ -157,11 +154,9 @@ static BrushPainter *brush_painter_2d_new(Scene *scene, Brush *brush)
}
-static void brush_painter_2d_require_imbuf(BrushPainter *painter, short flt, short texonly, int size)
+static void brush_painter_2d_require_imbuf(BrushPainter *painter, short flt, int size)
{
- if ((painter->cache.flt != flt) || (painter->cache.size != size) ||
- ((painter->cache.texonly != texonly) && texonly))
- {
+ if ((painter->cache.flt != flt) || (painter->cache.size != size)) {
if (painter->cache.ibuf) IMB_freeImBuf(painter->cache.ibuf);
if (painter->cache.maskibuf) IMB_freeImBuf(painter->cache.maskibuf);
painter->cache.ibuf = painter->cache.maskibuf = NULL;
@@ -176,8 +171,6 @@ static void brush_painter_2d_require_imbuf(BrushPainter *painter, short flt, sho
painter->cache.size = size;
painter->cache.flt = flt;
- painter->cache.texonly = texonly;
- painter->cache.enabled = 1;
}
static void brush_painter_2d_free(BrushPainter *painter)
@@ -738,10 +731,9 @@ int paint_2d_stroke(void *ps, const int prev_mval[2], const int mval[2], int era
/* OCIO_TODO: float buffers are now always linear, so always use color correction
* this should probably be changed when texture painting color space is supported
*/
- brush_painter_2d_require_imbuf(painter, ((ibuf->rect_float) ? 1 : 0), 0, 0);
+ brush_painter_2d_require_imbuf(painter, ((ibuf->rect_float) ? 1 : 0), 0);
- if (painter->cache.enabled)
- brush_painter_2d_refresh_cache(painter, newuv, is_data == false);
+ brush_painter_2d_refresh_cache(painter, newuv, is_data == false);
if (paint_2d_op(s, painter->cache.ibuf, olduv, newuv)) {
imapaint_image_update(s->sima, s->image, ibuf, false);
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 5dcfa181fa2..a2101305b4b 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -4160,7 +4160,7 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int
/* disable for 3d mapping also because painting on mirrored mesh can create "stripes" */
ps->do_masking = (brush->flag & BRUSH_AIRBRUSH || brush->mtex.brush_map_mode != MTEX_MAP_MODE_TILED) ? false : true;
ps->is_texbrush = (brush->mtex.tex && brush->imagepaint_tool == PAINT_TOOL_DRAW) ? true : false;
- ps->is_maskbrush = (brush->flag & BRUSH_USE_MASK && brush->mask_mtex.tex) ? true : false;
+ ps->is_maskbrush = (brush->mask_mtex.tex) ? true : false;
}
else {
/* brush may be NULL*/
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index 88c18602c89..8b1de32f1ea 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -39,8 +39,10 @@ struct Brush;
struct ImagePool;
struct ListBase;
struct Mesh;
+struct MTex;
struct Object;
struct PaintStroke;
+struct Paint;
struct PointerRNA;
struct rcti;
struct Scene;
@@ -51,6 +53,7 @@ struct wmEvent;
struct wmOperator;
struct wmOperatorType;
struct ImagePaintState;
+struct wmWindowManager;
enum PaintMode;
/* paint_stroke.c */
@@ -79,6 +82,7 @@ void *paint_stroke_mode_data(struct PaintStroke *stroke);
void paint_stroke_set_mode_data(struct PaintStroke *stroke, void *mode_data);
int paint_poll(struct bContext *C);
void paint_cursor_start(struct bContext *C, int (*poll)(struct bContext *C));
+void paint_cursor_start_explicit(struct Paint *p, struct wmWindowManager *wm, int (*poll)(struct bContext *C));
/* paint_vertex.c */
int weight_paint_poll(struct bContext *C);
@@ -176,7 +180,8 @@ void paint_calc_redraw_planes(float planes[4][4],
void projectf(struct bglMats *mats, const float v[3], float p[2]);
float paint_calc_object_space_radius(struct ViewContext *vc, const float center[3], float pixel_radius);
-float paint_get_tex_pixel(struct Brush *br, float u, float v, struct ImagePool *pool);
+float paint_get_tex_pixel(struct MTex *mtex, float u, float v, struct ImagePool *pool);
+void paint_get_tex_pixel_col(struct MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool);
int imapaint_pick_face(struct ViewContext *vc, const int mval[2], unsigned int *index, unsigned int totface);
void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, const int xy[2], float uv[2]);
void brush_drawcursor_texpaint_uvsculpt(struct bContext *C, int x, int y, void *customdata);
@@ -201,7 +206,7 @@ int facemask_paint_poll(struct bContext *C);
typedef enum BrushStrokeMode {
BRUSH_STROKE_NORMAL,
BRUSH_STROKE_INVERT,
- BRUSH_STROKE_SMOOTH,
+ BRUSH_STROKE_SMOOTH
} BrushStrokeMode;
/* paint_undo.c */
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 120d0a3b10a..cd9523f8ff6 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -28,6 +28,7 @@
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
+#include "BLI_math_vector.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
@@ -307,11 +308,7 @@ static int brush_select_exec(bContext *C, wmOperator *op)
Object *ob = CTX_data_active_object(C);
if (ob) {
/* select current paint mode */
- paint_mode = ob->mode &
- (OB_MODE_SCULPT |
- OB_MODE_VERTEX_PAINT |
- OB_MODE_WEIGHT_PAINT |
- OB_MODE_TEXTURE_PAINT);
+ paint_mode = ob->mode & OB_MODE_ALL_PAINT;
}
else {
return OPERATOR_CANCELLED;
@@ -448,6 +445,171 @@ static void BRUSH_OT_uv_sculpt_tool_set(wmOperatorType *ot)
ot->prop = RNA_def_enum(ot->srna, "tool", uv_sculpt_tool_items, 0, "Tool", "");
}
+/***** Stencil Control *****/
+
+enum {
+STENCIL_TRANSLATE,
+STENCIL_SCALE,
+STENCIL_ROTATE
+} StencilControlMode;
+
+typedef struct {
+ int init_mouse[2];
+ int init_spos[2];
+ int init_sdim[2];
+ float init_rot;
+ float init_angle;
+ float lenorig;
+ int mode;
+ Brush *br;
+} StencilControlData;
+
+static int stencil_control_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ Paint *paint = paint_get_active_from_context(C);
+ Brush *br = paint->brush;
+ int mdiff[2];
+
+ StencilControlData *scd = MEM_mallocN(sizeof(StencilControlData), "stencil_control");
+
+ copy_v2_v2_int(scd->init_mouse, event->mval);
+ copy_v2_v2_int(scd->init_sdim, br->stencil_dimension);
+ copy_v2_v2_int(scd->init_spos, br->stencil_pos);
+ sub_v2_v2v2_int(mdiff, event->mval, br->stencil_pos);
+ scd->lenorig = sqrtf(mdiff[0] * mdiff[0] + mdiff[1] * mdiff[1]);
+ scd->br = br;
+ scd->init_rot = br->mtex.rot;
+ scd->init_angle = atan2(mdiff[1], mdiff[0]);
+ scd->mode = RNA_enum_get(op->ptr, "mode");
+
+ op->customdata = scd;
+ WM_event_add_modal_handler(C, op);
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+
+static int stencil_control_cancel(bContext *UNUSED(C), wmOperator *op)
+{
+ StencilControlData *scd = op->customdata;
+ Brush *br = scd->br;
+
+ copy_v2_v2_int(br->stencil_dimension, scd->init_sdim);
+ copy_v2_v2_int(br->stencil_pos, scd->init_spos);
+ br->mtex.rot = scd->init_rot;
+ MEM_freeN(op->customdata);
+ return OPERATOR_CANCELLED;
+}
+
+static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ StencilControlData *scd = op->customdata;
+
+ switch (event->type) {
+ case MOUSEMOVE:
+ {
+ int mdiff[2];
+ switch (scd->mode) {
+ case STENCIL_TRANSLATE:
+ sub_v2_v2v2_int(mdiff, event->mval, scd->init_mouse);
+ add_v2_v2v2_int(scd->br->stencil_pos, scd->init_spos,
+ mdiff);
+ break;
+ case STENCIL_SCALE:
+ {
+ float len, factor;
+ sub_v2_v2v2_int(mdiff, event->mval, scd->br->stencil_pos);
+ len = sqrtf(mdiff[0] * mdiff[0] + mdiff[1] * mdiff[1]);
+ factor = len/scd->lenorig;
+ mdiff[0] = factor * scd->init_sdim[0];
+ mdiff[1] = factor * scd->init_sdim[1];
+ copy_v2_v2_int(scd->br->stencil_dimension, mdiff);
+ break;
+ }
+ case STENCIL_ROTATE:
+ {
+ float angle;
+ sub_v2_v2v2_int(mdiff, event->mval, scd->br->stencil_pos);
+ angle = atan2(mdiff[1], mdiff[0]);
+ angle = scd->init_rot + angle - scd->init_angle;
+ if (angle < 0.0f)
+ angle += (float)(2 * M_PI);
+ if (angle > (float)(2 * M_PI))
+ angle -= (float)(2 * M_PI);
+ scd->br->mtex.rot = angle;
+ break;
+ }
+ }
+ }
+ break;
+ /* XXX hardcoded! */
+ case RIGHTMOUSE:
+ if (event->val == KM_RELEASE) {
+ MEM_freeN(op->customdata);
+ WM_event_add_notifier(C, NC_WINDOW, NULL);
+ return OPERATOR_FINISHED;
+ }
+ case ESCKEY:
+ if (event->val == KM_PRESS) {
+ stencil_control_cancel(C, op);
+ WM_event_add_notifier(C, NC_WINDOW, NULL);
+ return OPERATOR_CANCELLED;
+ }
+ default:
+ break;
+ }
+
+ ED_region_tag_redraw(CTX_wm_region(C));
+
+ return OPERATOR_RUNNING_MODAL;
+}
+
+static int stencil_control_poll(bContext *C)
+{
+ Paint *paint = paint_get_active_from_context(C);
+ Brush *br = paint->brush;
+
+ return br->mtex.brush_map_mode == MTEX_MAP_MODE_STENCIL;
+}
+
+static void BRUSH_OT_stencil_control(wmOperatorType *ot)
+{
+ static EnumPropertyItem stencil_control_items[] = {
+ {STENCIL_TRANSLATE, "TRANSLATION", 0, "Transation", ""},
+ {STENCIL_SCALE, "SCALE", 0, "Scale", ""},
+ {STENCIL_ROTATE, "ROTATION", 0, "Rotation", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+ /* identifiers */
+ ot->name = "Stencil Brush Control";
+ ot->description = "Control the stencil brush";
+ ot->idname = "BRUSH_OT_stencil_control";
+
+ /* api callbacks */
+ ot->invoke = stencil_control_invoke;
+ ot->modal = stencil_control_modal;
+ ot->cancel = stencil_control_cancel;
+ ot->poll = stencil_control_poll;
+
+ /* flags */
+ ot->flag = 0;
+
+ RNA_def_enum(ot->srna, "mode", stencil_control_items, 0, "Tool", "");
+}
+
+static void ed_keymap_stencil(wmKeyMap *keymap)
+{
+ wmKeyMapItem *kmi;
+
+ kmi = WM_keymap_add_item(keymap, "BRUSH_OT_stencil_control", RIGHTMOUSE, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "mode", STENCIL_TRANSLATE);
+ kmi = WM_keymap_add_item(keymap, "BRUSH_OT_stencil_control", RIGHTMOUSE, KM_PRESS, KM_SHIFT, 0);
+ RNA_enum_set(kmi->ptr, "mode", STENCIL_SCALE);
+ kmi = WM_keymap_add_item(keymap, "BRUSH_OT_stencil_control", RIGHTMOUSE, KM_PRESS, KM_CTRL, 0);
+ RNA_enum_set(kmi->ptr, "mode", STENCIL_ROTATE);
+
+}
+
/**************************** registration **********************************/
void ED_operatortypes_paint(void)
@@ -457,6 +619,7 @@ void ED_operatortypes_paint(void)
WM_operatortype_append(BRUSH_OT_scale_size);
WM_operatortype_append(BRUSH_OT_curve_preset);
WM_operatortype_append(BRUSH_OT_reset);
+ WM_operatortype_append(BRUSH_OT_stencil_control);
/* note, particle uses a different system, can be added with existing operators in wm.py */
WM_operatortype_append(PAINT_OT_brush_select);
@@ -671,6 +834,8 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
ed_keymap_paint_brush_size(keymap, "tool_settings.sculpt.brush.size");
ed_keymap_paint_brush_radial_control(keymap, "sculpt", RC_ROTATION);
+ ed_keymap_stencil(keymap);
+
keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_DRAW, DKEY, 0);
keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_SMOOTH, SKEY, 0);
keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_PINCH, PKEY, 0);
@@ -687,7 +852,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
/* */
kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", AKEY, KM_PRESS, 0, 0);
- RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush.stroke_method");
+ RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush.sculpt_stroke_method");
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", SKEY, KM_PRESS, KM_SHIFT, 0);
RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush.use_smooth_stroke");
@@ -700,7 +865,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
keymap->poll = vertex_paint_mode_poll;
WM_keymap_verify_item(keymap, "PAINT_OT_vertex_paint", LEFTMOUSE, KM_PRESS, 0, 0);
- WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "PAINT_OT_sample_color", SKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap,
"PAINT_OT_vertex_color_set", KKEY, KM_PRESS, KM_SHIFT, 0);
@@ -709,6 +874,8 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
ed_keymap_paint_brush_size(keymap, "tool_settings.vertex_paint.brush.size");
ed_keymap_paint_brush_radial_control(keymap, "vertex_paint", RC_COLOR | RC_ROTATION);
+ ed_keymap_stencil(keymap);
+
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */
RNA_string_set(kmi->ptr, "data_path", "vertex_paint_object.data.use_paint_mask");
@@ -718,6 +885,9 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", RKEY, KM_PRESS, 0, 0);
RNA_string_set(kmi->ptr, "data_path", "tool_settings.vertex_paint.brush.texture_angle_source_random");
+ kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", AKEY, KM_PRESS, 0, 0);
+ RNA_string_set(kmi->ptr, "data_path", "tool_settings.vertex_paint.brush.stroke_method");
+
/* Weight Paint mode */
keymap = WM_keymap_find(keyconf, "Weight Paint", 0, 0);
keymap->poll = weight_paint_mode_poll;
@@ -738,6 +908,11 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
ed_keymap_paint_brush_size(keymap, "tool_settings.weight_paint.brush.size");
ed_keymap_paint_brush_radial_control(keymap, "weight_paint", 0);
+ ed_keymap_stencil(keymap);
+
+ kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", AKEY, KM_PRESS, 0, 0);
+ RNA_string_set(kmi->ptr, "data_path", "tool_settings.vertex_paint.brush.stroke_method");
+
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* face mask toggle */
RNA_string_set(kmi->ptr, "data_path", "weight_paint_object.data.use_paint_mask");
@@ -770,12 +945,14 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_image_paint", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "mode", BRUSH_STROKE_NORMAL);
RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_image_paint", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "mode", BRUSH_STROKE_INVERT);
WM_keymap_add_item(keymap, "PAINT_OT_grab_clone", RIGHTMOUSE, KM_PRESS, 0, 0);
- WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "PAINT_OT_sample_color", SKEY, KM_PRESS, 0, 0);
ed_keymap_paint_brush_switch(keymap, "image_paint");
ed_keymap_paint_brush_size(keymap, "tool_settings.image_paint.brush.size");
ed_keymap_paint_brush_radial_control(keymap, "image_paint", RC_COLOR | RC_ZOOM | RC_ROTATION);
+ ed_keymap_stencil(keymap);
+
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */
RNA_string_set(kmi->ptr, "data_path", "image_paint_object.data.use_paint_mask");
@@ -785,6 +962,9 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", RKEY, KM_PRESS, 0, 0);
RNA_string_set(kmi->ptr, "data_path", "tool_settings.image_paint.brush.texture_angle_source_random");
+ kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", AKEY, KM_PRESS, 0, 0);
+ RNA_string_set(kmi->ptr, "data_path", "tool_settings.image_paint.brush.stroke_method");
+
/* face-mask mode */
keymap = WM_keymap_find(keyconf, "Face Mask", 0, 0);
keymap->poll = facemask_paint_poll;
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index ca48524096a..1c0830a8158 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -174,10 +174,7 @@ static void paint_brush_update(bContext *C, Brush *brush, PaintMode mode,
ups->pixel_radius *= stroke->cached_pressure;
}
- if (!(brush->flag & BRUSH_ANCHORED ||
- ELEM4(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK,
- SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE)))
- {
+ if (paint_supports_dynamic_tex_coords(brush, mode)) {
if (((brush->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW) ||
(brush->mtex.brush_map_mode == MTEX_MAP_MODE_RANDOM)) &&
!(brush->flag & BRUSH_RAKE))
@@ -188,7 +185,7 @@ static void paint_brush_update(bContext *C, Brush *brush, PaintMode mode,
ups->brush_rotation = 0.0f;
}
- if ((brush->mtex.brush_map_mode == MTEX_MAP_MODE_RANDOM))
+ if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_RANDOM)
BKE_brush_randomize_texture_coordinates(ups);
else
copy_v2_v2(ups->tex_mouse, mouse);
@@ -281,9 +278,7 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, const wmEve
paint_brush_update(C, brush, mode, stroke, mouse_in, pressure);
- /* TODO: as sculpt and other paint modes are unified, this
- * separation will go away */
- if (paint_supports_jitter(mode)) {
+ {
float delta[2];
float factor = stroke->zoom_2d;
@@ -301,9 +296,6 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, const wmEve
add_v2_v2v2(mouse_out, mouse_in, delta);
}
}
- else {
- copy_v2_v2(mouse_out, mouse_in);
- }
/* TODO: can remove the if statement once all modes have this */
if (stroke->get_location)
@@ -528,11 +520,6 @@ bool paint_supports_dynamic_tex_coords(Brush *br, PaintMode mode)
return true;
}
-bool paint_supports_jitter(PaintMode mode)
-{
- return ELEM3(mode, PAINT_SCULPT, PAINT_TEXTURE_PROJECTIVE, PAINT_TEXTURE_2D);
-}
-
#define PAINT_STROKE_MODAL_CANCEL 1
/* called in paint_ops.c, on each regeneration of keymaps */
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 5e88c7b5730..47e20bcc5fb 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -43,6 +43,8 @@
#include "BLI_utildefines.h"
#include "BLI_rect.h"
+#include "BLF_translation.h"
+
#include "BKE_brush.h"
#include "BKE_context.h"
#include "BKE_DerivedMesh.h"
@@ -57,6 +59,7 @@
#include "BIF_glutil.h"
#include "RE_shader_ext.h"
+#include "RE_render_ext.h"
#include "ED_view3d.h"
#include "ED_screen.h"
@@ -174,13 +177,13 @@ float paint_calc_object_space_radius(ViewContext *vc, const float center[3],
return len_v3(delta) / scale;
}
-float paint_get_tex_pixel(Brush *br, float u, float v, struct ImagePool *pool)
+float paint_get_tex_pixel(MTex *mtex, float u, float v, struct ImagePool *pool)
{
TexResult texres = {0};
float co[3] = {u, v, 0.0f};
int hasrgb;
- hasrgb = multitex_ext(br->mtex.tex, co, NULL, NULL, 0, &texres, pool);
+ hasrgb = multitex_ext(mtex->tex, co, NULL, NULL, 0, &texres, pool);
if (hasrgb & TEX_RGB)
texres.tin = rgb_to_grayscale(&texres.tr) * texres.ta;
@@ -188,6 +191,23 @@ float paint_get_tex_pixel(Brush *br, float u, float v, struct ImagePool *pool)
return texres.tin;
}
+void paint_get_tex_pixel_col(MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool)
+{
+ float co[3] = {u, v, 0.0f};
+ int hasrgb;
+ float intensity;
+
+ hasrgb = externtex(mtex, co, &intensity,
+ rgba, rgba + 1, rgba + 2, rgba + 3, 0, pool);
+
+ if (!hasrgb) {
+ rgba[0] = intensity;
+ rgba[1] = intensity;
+ rgba[2] = intensity;
+ rgba[3] = 1.0f;
+ }
+}
+
/* 3D Paint */
static void imapaint_project(Object *ob, float model[4][4], float proj[4][4], const float co[3], float pco[4])
@@ -375,6 +395,7 @@ static int brush_curve_preset_poll(bContext *C)
void BRUSH_OT_curve_preset(wmOperatorType *ot)
{
+ PropertyRNA *prop;
static EnumPropertyItem prop_shape_items[] = {
{CURVE_PRESET_SHARP, "SHARP", 0, "Sharp", ""},
{CURVE_PRESET_SMOOTH, "SMOOTH", 0, "Smooth", ""},
@@ -391,7 +412,8 @@ void BRUSH_OT_curve_preset(wmOperatorType *ot)
ot->exec = brush_curve_preset_exec;
ot->poll = brush_curve_preset_poll;
- RNA_def_enum(ot->srna, "shape", prop_shape_items, CURVE_PRESET_SMOOTH, "Mode", "");
+ prop = RNA_def_enum(ot->srna, "shape", prop_shape_items, CURVE_PRESET_SMOOTH, "Mode", "");
+ RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 197231124fc..2eca3f94e95 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -866,6 +866,7 @@ static float calc_vp_strength_col_dl(VPaint *vp, ViewContext *vc, const float co
{
float delta[2];
float dist_squared;
+ float factor = 1.0;
sub_v2_v2v2(delta, mval, co_ss);
dist_squared = dot_v2v2(delta, delta); /* len squared */
@@ -880,8 +881,9 @@ static float calc_vp_strength_col_dl(VPaint *vp, ViewContext *vc, const float co
const float co_ss_3d[3] = {co_ss[0], co_ss[1], 0.0f}; /* we need a 3rd empty value */
BKE_brush_sample_tex_3D(vc->scene, brush, co_ss_3d, rgba, 0, NULL);
}
+ factor = rgba[3];
}
- return BKE_brush_curve_strength_clamp(brush, dist, brush_size_pressure);
+ return factor * BKE_brush_curve_strength_clamp(brush, dist, brush_size_pressure);
}
}
if (rgba)
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 20b8f90df8b..5edd14cd8e3 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -968,7 +968,7 @@ static float tex_strength(SculptSession *ss, Brush *br,
x += br->mtex.ofs[0];
y += br->mtex.ofs[1];
- avg = paint_get_tex_pixel(br, x, y, ss->tex_pool);
+ avg = paint_get_tex_pixel(&br->mtex, x, y, ss->tex_pool);
avg += br->texture_sample_bias;
}
@@ -3220,8 +3220,15 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob)
PBVHNode **nodes;
float (*vertCos)[3] = NULL;
- if (ss->kb)
- vertCos = MEM_callocN(sizeof(*vertCos) * me->totvert, "flushStrokeDeofrm keyVerts");
+ if (ss->kb) {
+ vertCos = MEM_mallocN(sizeof(*vertCos) * me->totvert, "flushStrokeDeofrm keyVerts");
+
+ /* mesh could have isolated verts which wouldn't be in BVH,
+ * to deal with this we copy old coordinates over new ones
+ * and then update coordinates for all vertices from BVH
+ */
+ memcpy(vertCos, ss->orig_cos, 3 * sizeof(float) * me->totvert);
+ }
BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index dcc61cfa544..cf277957e70 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -120,6 +120,8 @@ static int file_browse_exec(bContext *C, wmOperator *op)
BLI_path_abs(path, id ? ID_BLEND_PATH(G.main, id) : G.main->name);
if (BLI_is_dir(path)) {
+ /* do this first so '//' isnt converted to '//\' on windows */
+ BLI_add_slash(path);
if (is_relative) {
BLI_strncpy(path, str, FILE_MAX);
BLI_path_rel(path, G.main->name);
@@ -129,7 +131,6 @@ static int file_browse_exec(bContext *C, wmOperator *op)
else {
str = MEM_reallocN(str, strlen(str) + 2);
}
- BLI_add_slash(str);
}
else {
char * const lslash = (char *)BLI_last_slash(str);
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index 2d3dc9127c3..cbca2f0c46e 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -248,6 +248,53 @@ static void draw_movieclip_notes(SpaceClip *sc, ARegion *ar)
ED_region_info_draw(ar, str, block, 0.6f);
}
+static void draw_movieclip_buffer_glsl(SpaceClip *sc, ImBuf *ibuf, int x, int y,
+ float zoomx, float zoomy)
+{
+ MovieClip *clip = ED_space_clip_get_clip(sc);
+ int filter = GL_LINEAR;
+
+ glPushMatrix();
+ glTranslatef(x, y, 0.0f);
+ glScalef(zoomx, zoomy, 1.0f);
+
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+ glColor4f(1.0, 1.0, 1.0, 1.0);
+
+ /* non-scaled proxy shouldn;t use diltering */
+ if ((clip->flag & MCLIP_USE_PROXY) == 0 ||
+ ELEM(sc->user.render_size, MCLIP_PROXY_RENDER_SIZE_FULL, MCLIP_PROXY_RENDER_SIZE_100))
+ {
+ filter = GL_NEAREST;
+ }
+
+ glaDrawPixelsTex(0, 0, ibuf->x, ibuf->y, GL_FLOAT, filter, ibuf->rect_float);
+
+ glPopMatrix();
+}
+
+static void draw_movieclip_buffer_fallback(const bContext *C, ImBuf *ibuf, int x, int y,
+ int width, int height, float zoomx, float zoomy)
+{
+ unsigned char *display_buffer;
+ void *cache_handle;
+
+ display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
+
+ if (display_buffer) {
+ /* set zoom */
+ glPixelZoom(zoomx * width / ibuf->x, zoomy * height / ibuf->y);
+
+ glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer);
+
+ /* reset zoom */
+ glPixelZoom(1.0f, 1.0f);
+ }
+
+ IMB_display_buffer_release(cache_handle);
+}
+
static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar, ImBuf *ibuf,
int width, int height, float zoomx, float zoomy)
{
@@ -261,62 +308,32 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar,
glRectf(x, y, x + zoomx * width, y + zoomy * height);
}
else {
- unsigned char *display_buffer;
- void *cache_handle;
-
- display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
-
- if (display_buffer) {
- int need_fallback = 1;
-
- /* checkerboard for case alpha */
- if (ibuf->planes == 32) {
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- fdrawcheckerboard(x, y, x + zoomx * ibuf->x, y + zoomy * ibuf->y);
- }
+ bool need_fallback = true;
- if (ED_space_clip_texture_buffer_supported(sc)) {
- if (ED_space_clip_load_movieclip_buffer(sc, ibuf, display_buffer)) {
- glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+ /* checkerboard for case alpha */
+ if (ibuf->planes == 32) {
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glPushMatrix();
- glTranslatef(x, y, 0.0f);
- glScalef(zoomx, zoomy, 1.0f);
-
- glBegin(GL_QUADS);
- glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);
- glTexCoord2f(1.0f, 0.0f); glVertex2f(width, 0.0f);
- glTexCoord2f(1.0f, 1.0f); glVertex2f(width, height);
- glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, height);
- glEnd();
-
- glPopMatrix();
-
- ED_space_clip_unload_movieclip_buffer(sc);
-
- need_fallback = 0;
- }
- }
+ fdrawcheckerboard(x, y, x + zoomx * ibuf->x, y + zoomy * ibuf->y);
+ }
- /* if texture buffers aren't efficiently supported or texture is too large to
- * be binder fallback to simple draw pixels solution */
- if (need_fallback) {
- /* set zoom */
- glPixelZoom(zoomx * width / ibuf->x, zoomy * height / ibuf->y);
+ /* GLSL display transform for byte buffers is not supported yet */
+ if (ibuf->rect_float && IMB_coloemanagement_setup_glsl_draw_from_ctx(C)) {
+ draw_movieclip_buffer_glsl(sc, ibuf, x, y, zoomx, zoomy);
- glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer);
+ IMB_coloemanagement_finish_glsl_draw();
- /* reset zoom */
- glPixelZoom(1.0f, 1.0f);
- }
+ need_fallback = false;
+ }
- if (ibuf->planes == 32)
- glDisable(GL_BLEND);
+ /* if GLSL display failed, fallback to regular glaDrawPixelsAuto method */
+ if (need_fallback) {
+ draw_movieclip_buffer_fallback(C, ibuf, x, y, width, height, zoomx, zoomy);
}
- IMB_display_buffer_release(cache_handle);
+ if (ibuf->planes == 32)
+ glDisable(GL_BLEND);
}
}
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index b00cc564a99..d297d0485e3 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -62,15 +62,13 @@
#include "GPU_extensions.h"
+#include "IMB_colormanagement.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
#include "ED_screen.h"
#include "ED_clip.h"
-#include "BIF_gl.h"
-#include "BIF_glutil.h"
-
#include "WM_api.h"
#include "WM_types.h"
@@ -580,163 +578,6 @@ void ED_space_clip_set_mask(bContext *C, SpaceClip *sc, Mask *mask)
}
}
-/* OpenGL draw context */
-
-typedef struct SpaceClipDrawContext {
- int support_checked, buffers_supported;
-
- GLuint texture; /* OGL texture ID */
- short texture_allocated; /* flag if texture was allocated by glGenTextures */
- struct ImBuf *texture_ibuf; /* image buffer for which texture was created */
- const unsigned char *display_buffer; /* display buffer for which texture was created */
- int image_width, image_height; /* image width and height for which texture was created */
- unsigned last_texture; /* ID of previously used texture, so it'll be restored after clip drawing */
-
- /* fields to check if cache is still valid */
- int framenr, start_frame, frame_offset;
- short render_size, render_flag;
-
- char colorspace[64];
-} SpaceClipDrawContext;
-
-int ED_space_clip_texture_buffer_supported(SpaceClip *sc)
-{
- SpaceClipDrawContext *context = sc->draw_context;
-
- if (!context) {
- context = MEM_callocN(sizeof(SpaceClipDrawContext), "SpaceClipDrawContext");
- sc->draw_context = context;
- }
-
- if (!context->support_checked) {
- context->support_checked = TRUE;
- if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY)) {
- context->buffers_supported = FALSE;
- }
- else {
- context->buffers_supported = GPU_non_power_of_two_support();
- }
- }
-
- return context->buffers_supported;
-}
-
-int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf, const unsigned char *display_buffer)
-{
- SpaceClipDrawContext *context = sc->draw_context;
- MovieClip *clip = ED_space_clip_get_clip(sc);
- int need_rebind = 0;
-
- context->last_texture = glaGetOneInteger(GL_TEXTURE_2D);
-
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
- /* image texture need to be rebinded if displaying another image buffer
- * assuming displaying happens of footage frames only on which painting doesn't happen.
- * so not changed image buffer pointer means unchanged image content */
- need_rebind |= context->texture_ibuf != ibuf;
- need_rebind |= context->display_buffer != display_buffer;
- need_rebind |= context->framenr != sc->user.framenr;
- need_rebind |= context->render_size != sc->user.render_size;
- need_rebind |= context->render_flag != sc->user.render_flag;
- need_rebind |= context->start_frame != clip->start_frame;
- need_rebind |= context->frame_offset != clip->frame_offset;
-
- if (!need_rebind) {
- /* OCIO_TODO: not entirely nice, but currently it seems to be easiest way
- * to deal with changing input color space settings
- * pointer-based check could fail due to new buffers could be
- * be allocated on on old memory
- */
- need_rebind = strcmp(context->colorspace, clip->colorspace_settings.name) != 0;
- }
-
- if (need_rebind) {
- int width = ibuf->x, height = ibuf->y;
- int need_recreate = 0;
-
- if (width > GL_MAX_TEXTURE_SIZE || height > GL_MAX_TEXTURE_SIZE)
- return 0;
-
- /* if image resolution changed (e.g. switched to proxy display) texture need to be recreated */
- need_recreate = context->image_width != ibuf->x || context->image_height != ibuf->y;
-
- if (context->texture_ibuf && need_recreate) {
- glDeleteTextures(1, &context->texture);
- context->texture_allocated = 0;
- }
-
- if (need_recreate || !context->texture_allocated) {
- /* texture doesn't exist yet or need to be re-allocated because of changed dimensions */
- int filter = GL_LINEAR;
-
- /* non-scaled proxy shouldn;t use diltering */
- if ((clip->flag & MCLIP_USE_PROXY) == 0 ||
- ELEM(sc->user.render_size, MCLIP_PROXY_RENDER_SIZE_FULL, MCLIP_PROXY_RENDER_SIZE_100))
- {
- filter = GL_NEAREST;
- }
-
- glGenTextures(1, &context->texture);
- glBindTexture(GL_TEXTURE_2D, context->texture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
- }
- else {
- /* if texture doesn't need to be reallocated itself, just bind it so
- * loading of image will happen to a proper texture */
- glBindTexture(GL_TEXTURE_2D, context->texture);
- }
-
- if (display_buffer)
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
-
- /* store settings */
- context->texture_allocated = 1;
- context->display_buffer = display_buffer;
- context->texture_ibuf = ibuf;
- context->image_width = ibuf->x;
- context->image_height = ibuf->y;
- context->framenr = sc->user.framenr;
- context->render_size = sc->user.render_size;
- context->render_flag = sc->user.render_flag;
- context->start_frame = clip->start_frame;
- context->frame_offset = clip->frame_offset;
-
- BLI_strncpy(context->colorspace, clip->colorspace_settings.name, sizeof(context->colorspace));
- }
- else {
- /* displaying exactly the same image which was loaded t oa texture,
- * just bint texture in this case */
- glBindTexture(GL_TEXTURE_2D, context->texture);
- }
-
- glEnable(GL_TEXTURE_2D);
-
- return TRUE;
-}
-
-void ED_space_clip_unload_movieclip_buffer(SpaceClip *sc)
-{
- SpaceClipDrawContext *context = sc->draw_context;
-
- glBindTexture(GL_TEXTURE_2D, context->last_texture);
- glDisable(GL_TEXTURE_2D);
-}
-
-void ED_space_clip_free_texture_buffer(SpaceClip *sc)
-{
- SpaceClipDrawContext *context = sc->draw_context;
-
- if (context) {
- glDeleteTextures(1, &context->texture);
-
- MEM_freeN(context);
- }
-}
-
/* ******** pre-fetching functions ******** */
typedef struct PrefetchJob {
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index ced19020034..64b643f8a58 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -327,8 +327,6 @@ static void clip_free(SpaceLink *sl)
if (sc->scopes.track_search)
IMB_freeImBuf(sc->scopes.track_search);
-
- ED_space_clip_free_texture_buffer(sc);
}
/* spacetype; init callback */
@@ -348,7 +346,6 @@ static SpaceLink *clip_duplicate(SpaceLink *sl)
scn->scopes.track_search = NULL;
scn->scopes.track_preview = NULL;
scn->scopes.ok = FALSE;
- scn->draw_context = NULL;
return (SpaceLink *)scn;
}
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index a413eb47140..5e5b2ece8c9 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -2872,10 +2872,57 @@ static void std_node_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr,
}
}
+static void std_node_socket_interface_draw(bContext *UNUSED(C), uiLayout *layout, PointerRNA *ptr)
+{
+ bNodeSocket *sock = ptr->data;
+ int type = sock->typeinfo->type;
+ /*int subtype = sock->typeinfo->subtype;*/
+
+ switch (type) {
+ case SOCK_FLOAT: {
+ uiLayout *row;
+ uiItemR(layout, ptr, "default_value", 0, NULL, 0);
+ row = uiLayoutRow(layout, true);
+ uiItemR(row, ptr, "min_value", 0, "min", 0);
+ uiItemR(row, ptr, "max_value", 0, "max", 0);
+ break;
+ }
+ case SOCK_INT: {
+ uiLayout *row;
+ uiItemR(layout, ptr, "default_value", 0, NULL, 0);
+ row = uiLayoutRow(layout, true);
+ uiItemR(row, ptr, "min_value", 0, "min", 0);
+ uiItemR(row, ptr, "max_value", 0, "max", 0);
+ break;
+ }
+ case SOCK_BOOLEAN: {
+ uiItemR(layout, ptr, "default_value", 0, NULL, 0);
+ break;
+ }
+ case SOCK_VECTOR: {
+ uiLayout *row;
+ uiItemR(layout, ptr, "default_value", UI_ITEM_R_EXPAND, NULL, 0);
+ row = uiLayoutRow(layout, true);
+ uiItemR(row, ptr, "min_value", 0, "min", 0);
+ uiItemR(row, ptr, "max_value", 0, "max", 0);
+ break;
+ }
+ case SOCK_RGBA: {
+ uiItemR(layout, ptr, "default_value", 0, NULL, 0);
+ break;
+ }
+ case SOCK_STRING: {
+ uiItemR(layout, ptr, "default_value", 0, NULL, 0);
+ break;
+ }
+ }
+}
+
void ED_init_standard_node_socket_type(bNodeSocketType *stype)
{
stype->draw = std_node_socket_draw;
stype->draw_color = std_node_socket_draw_color;
+ stype->interface_draw = std_node_socket_interface_draw;
stype->interface_draw_color = std_node_socket_interface_draw_color;
}
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index c74c160080c..cba807a436f 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -115,7 +115,7 @@ static void compo_tag_output_nodes(bNodeTree *nodetree, int recalc_flags)
if (recalc_flags & COM_RECALC_COMPOSITE)
node->flag |= NODE_DO_OUTPUT_RECALC;
}
- else if (node->type == CMP_NODE_VIEWER) {
+ else if (node->type == CMP_NODE_VIEWER || node->type == CMP_NODE_SPLITVIEWER) {
if (recalc_flags & COM_RECALC_VIEWER)
node->flag |= NODE_DO_OUTPUT_RECALC;
}
@@ -2364,7 +2364,7 @@ static int node_shader_script_update_exec(bContext *C, wmOperator *op)
RE_engine_free(engine);
- return (found)? OPERATOR_FINISHED: OPERATOR_CANCELLED;
+ return (found) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
void NODE_OT_shader_script_update(wmOperatorType *ot)
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index cdb89a66867..62537fb713f 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -823,9 +823,10 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op)
/* is note outside view? */
if (active->totr.xmax < ar->v2d.cur.xmin || active->totr.xmin > ar->v2d.cur.xmax ||
- active->totr.ymax < ar->v2d.cur.ymin || active->totr.ymin > ar->v2d.cur.ymax)
- space_node_view_flag(C, snode, CTX_wm_region(C), NODE_SELECT);
-
+ active->totr.ymax < ar->v2d.cur.ymin || active->totr.ymin > ar->v2d.cur.ymax)
+ {
+ space_node_view_flag(C, snode, CTX_wm_region(C), NODE_SELECT);
+ }
}
if (node_array)
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 1a4d461c3c1..3c2c715efc2 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -1050,6 +1050,17 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
/* setting up the view - actual drawing starts here */
UI_view2d_view_ortho(v2d);
+ /* only draw alpha for main buffer */
+ if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
+ if (sseq->flag & SEQ_USE_ALPHA) {
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ fdrawcheckerboard(v2d->tot.xmin, v2d->tot.ymin, v2d->tot.xmax, v2d->tot.ymax);
+ glColor4f(1.0, 1.0, 1.0, 1.0);
+ }
+ }
+
last_texid = glaGetOneInteger(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_2D);
glGenTextures(1, (GLuint *)&texid);
@@ -1061,14 +1072,6 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
- /* only draw alpha for main buffer */
- if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
- if (sseq->flag & SEQ_USE_ALPHA) {
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- }
- }
-
glBegin(GL_QUADS);
if (draw_overlay) {
@@ -1100,7 +1103,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
glEnd();
glBindTexture(GL_TEXTURE_2D, last_texid);
glDisable(GL_TEXTURE_2D);
- if (sseq->flag & SEQ_USE_ALPHA)
+ if (sseq->mainb == SEQ_DRAW_IMG_IMBUF && sseq->flag & SEQ_USE_ALPHA)
glDisable(GL_BLEND);
glDeleteTextures(1, &texid);
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 8eae1571933..265fef0f59b 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -37,6 +37,7 @@
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
+#include "DNA_rigidbody_types.h"
#include "DNA_scene_types.h"
#include "DNA_smoke_types.h"
#include "DNA_world_types.h"
@@ -2660,9 +2661,9 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS
unsigned char col[4] = {0, 0, 0, 255}; /* color of the text to draw */
float area; /* area of the face */
float grid = unit->system ? unit->scale_length : v3d->grid;
- const int do_split = unit->flag & USER_UNIT_OPT_SPLIT;
- const int do_global = v3d->flag & V3D_GLOBAL_STATS;
- const int do_moving = G.moving;
+ const bool do_split = (unit->flag & USER_UNIT_OPT_SPLIT) != 0;
+ const bool do_global = (v3d->flag & V3D_GLOBAL_STATS) != 0;
+ const bool do_moving = G.moving;
BMIter iter;
int i;
@@ -2703,7 +2704,7 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS
unit->system, B_UNIT_LENGTH, do_split, false);
}
else {
- sprintf(numstr, conv_float, len_v3v3(v1, v2));
+ BLI_snprintf(numstr, sizeof(numstr), conv_float, len_v3v3(v1, v2));
}
view3d_cached_text_draw_add(vmid, numstr, 0, txt_flag, col);
@@ -2711,6 +2712,57 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS
}
}
+ if (me->drawflag & ME_DRAWEXTRA_EDGEANG) {
+ const bool is_rad = (unit->system_rotation == USER_UNIT_ROT_RADIANS);
+ BMEdge *eed;
+
+ UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGEANG, col);
+
+ // invert_m4_m4(ob->imat, ob->obmat); // this is already called
+
+ eed = BM_iter_new(&iter, em->bm, BM_EDGES_OF_MESH, NULL);
+ for (; eed; eed = BM_iter_step(&iter)) {
+ BMLoop *l_a, *l_b;
+ if (BM_edge_loop_pair(eed, &l_a, &l_b)) {
+ /* draw selected edges, or edges next to selected verts while draging */
+ if (BM_elem_flag_test(eed, BM_ELEM_SELECT) ||
+ (do_moving && (BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) ||
+ BM_elem_flag_test(eed->v2, BM_ELEM_SELECT) ||
+ /* special case, this is useful to show when vertes connected to this edge via a
+ * face are being transformed */
+ BM_elem_flag_test(l_a->next->next->v, BM_ELEM_SELECT) ||
+ BM_elem_flag_test(l_a->prev->v, BM_ELEM_SELECT) ||
+ BM_elem_flag_test(l_b->next->next->v, BM_ELEM_SELECT) ||
+ BM_elem_flag_test(l_b->prev->v, BM_ELEM_SELECT)
+ )))
+ {
+ float angle;
+ copy_v3_v3(v1, eed->v1->co);
+ copy_v3_v3(v2, eed->v2->co);
+
+ mid_v3_v3v3(vmid, v1, v2);
+
+ if (do_global) {
+ float no_a[3];
+ float no_b[3];
+ copy_v3_v3(no_a, l_a->f->no);
+ copy_v3_v3(no_b, l_b->f->no);
+ mul_mat3_m4_v3(ob->imat, no_a);
+ mul_mat3_m4_v3(ob->imat, no_b);
+ angle = angle_v3v3(no_a, no_b);
+ }
+ else {
+ angle = angle_normalized_v3v3(l_a->f->no, l_b->f->no);
+ }
+
+ BLI_snprintf(numstr, sizeof(numstr), "%.3f", is_rad ? angle : RAD2DEGF(angle));
+
+ view3d_cached_text_draw_add(vmid, numstr, 0, txt_flag, col);
+ }
+ }
+ }
+ }
+
if (me->drawflag & ME_DRAWEXTRA_FACEAREA) {
/* would be nice to use BM_face_calc_area, but that is for 2d faces
* so instead add up tessellation triangle areas */
@@ -2773,7 +2825,7 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS
if (me->drawflag & ME_DRAWEXTRA_FACEANG) {
BMFace *efa;
- int is_rad = unit->system_rotation == USER_UNIT_ROT_RADIANS;
+ const bool is_rad = (unit->system_rotation == USER_UNIT_ROT_RADIANS);
UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col);
@@ -2846,7 +2898,7 @@ static void draw_em_indices(BMEditMesh *em)
UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col);
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
- sprintf(numstr, "%d", i);
+ BLI_snprintf(numstr, sizeof(numstr), "%d", i);
view3d_cached_text_draw_add(v->co, numstr, 0, txt_flag, col);
}
i++;
@@ -2858,7 +2910,7 @@ static void draw_em_indices(BMEditMesh *em)
UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGELEN, col);
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
if (BM_elem_flag_test(e, BM_ELEM_SELECT)) {
- sprintf(numstr, "%d", i);
+ BLI_snprintf(numstr, sizeof(numstr), "%d", i);
mid_v3_v3v3(pos, e->v1->co, e->v2->co);
view3d_cached_text_draw_add(pos, numstr, 0, txt_flag, col);
}
@@ -2872,7 +2924,7 @@ static void draw_em_indices(BMEditMesh *em)
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
BM_face_calc_center_mean(f, pos);
- sprintf(numstr, "%d", i);
+ BLI_snprintf(numstr, sizeof(numstr), "%d", i);
view3d_cached_text_draw_add(pos, numstr, 0, txt_flag, col);
}
i++;
@@ -3091,7 +3143,10 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d,
draw_dm_vert_normals(em, scene, ob, cageDM);
}
- if ((me->drawflag & (ME_DRAWEXTRA_EDGELEN | ME_DRAWEXTRA_FACEAREA | ME_DRAWEXTRA_FACEANG)) &&
+ if ((me->drawflag & (ME_DRAWEXTRA_EDGELEN |
+ ME_DRAWEXTRA_FACEAREA |
+ ME_DRAWEXTRA_FACEANG |
+ ME_DRAWEXTRA_EDGEANG)) &&
!(v3d->flag2 & V3D_RENDER_OVERRIDE))
{
draw_em_measure_stats(v3d, ob, em, &scene->unit);
@@ -3148,7 +3203,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
eWireDrawMode draw_wire = OBDRAW_WIRE_OFF;
int /* totvert,*/ totedge, totface;
DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask);
- const short is_obact = (ob == OBACT);
+ const bool is_obact = (ob == OBACT);
int draw_flags = (is_obact && paint_facesel_test(ob)) ? DRAW_FACE_SELECT : 0;
if (!dm)
@@ -4485,15 +4540,15 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
if (part->draw & PART_DRAW_NUM) {
if (a < totpart && (part->draw & PART_DRAW_HEALTH) && (part->phystype == PART_PHYS_BOIDS)) {
- sprintf(val_pos, "%d:%.2f", a, pa_health);
+ BLI_snprintf(val_pos, sizeof(numstr), "%d:%.2f", a, pa_health);
}
else {
- sprintf(val_pos, "%d", a);
+ BLI_snprintf(val_pos, sizeof(numstr), "%d", a);
}
}
else {
if (a < totpart && (part->draw & PART_DRAW_HEALTH) && (part->phystype == PART_PHYS_BOIDS)) {
- sprintf(val_pos, "%.2f", pa_health);
+ BLI_snprintf(val_pos, sizeof(numstr), "%.2f", pa_health);
}
}
@@ -6368,7 +6423,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
short dtx;
char dt;
short zbufoff = 0;
- const short is_obact = (ob == OBACT);
+ const bool is_obact = (ob == OBACT);
/* only once set now, will be removed too, should become a global standard */
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -6992,6 +7047,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
/* not for sets, duplicators or picking */
if (dflag == 0 && (v3d->flag & V3D_HIDE_HELPLINES) == 0 && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
ListBase *list;
+ RigidBodyCon *rbc = ob ? ob->rigidbody_constraint : NULL;
/* draw hook center and offset line */
if (ob != scene->obedit) draw_hooks(ob);
@@ -7077,6 +7133,22 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
BKE_constraints_clear_evalob(cob);
}
+ /* draw rigid body constraint lines */
+ if (rbc) {
+ UI_ThemeColor(TH_WIRE);
+ setlinestyle(3);
+ glBegin(GL_LINES);
+ if (rbc->ob1) {
+ glVertex3fv(ob->obmat[3]);
+ glVertex3fv(rbc->ob1->obmat[3]);
+ }
+ if (rbc->ob2) {
+ glVertex3fv(ob->obmat[3]);
+ glVertex3fv(rbc->ob2->obmat[3]);
+ }
+ glEnd();
+ setlinestyle(0);
+ }
}
free_old_images();
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 66047b6e8f4..b6d46f82e6a 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -1831,7 +1831,7 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
* glaDrawPixelsSafe in some cases, which will end up in misssing
* alpha transparency for the background image (sergey)
*/
- glaDrawPixelsTex(x1, y1, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_NEAREST, ibuf->rect);
+ glaDrawPixelsTex(x1, y1, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_LINEAR, ibuf->rect);
glPixelZoom(1.0, 1.0);
glPixelTransferf(GL_ALPHA_SCALE, 1.0f);
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index bea1f9da057..41a3418ada9 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -948,7 +948,6 @@ static void postOrtho(int ortho)
static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, int drawflags, int combo)
{
- GLUquadricObj *qobj;
double plane[4];
float matt[4][4];
float size, unitmat[4][4];
@@ -968,9 +967,6 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
glDisable(GL_DEPTH_TEST);
unit_m4(unitmat);
- qobj = gluNewQuadric();
- gluQuadricDrawStyle(qobj, GLU_FILL);
-
/* prepare for screen aligned draw */
size = len_v3(rv3d->twmat[0]);
glPushMatrix();
@@ -1195,7 +1191,6 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
/* restore */
glLoadMatrixf(rv3d->viewmat);
- gluDeleteQuadric(qobj);
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
}
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index 60b0c655691..bdfd9df6246 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -446,7 +446,9 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
if (flags & P_PROPORTIONAL) {
RNA_def_enum(ot->srna, "proportional", proportional_editing_items, 0, "Proportional Editing", "");
- RNA_def_enum(ot->srna, "proportional_edit_falloff", proportional_falloff_items, 0, "Proportional Editing Falloff", "Falloff type for proportional editing mode");
+ prop = RNA_def_enum(ot->srna, "proportional_edit_falloff", proportional_falloff_items, 0,
+ "Proportional Editing Falloff", "Falloff type for proportional editing mode");
+ RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */
RNA_def_float(ot->srna, "proportional_size", 1, 0.00001f, FLT_MAX, "Proportional Size", "", 0.001, 100);
}