[Bf-blender-cvs] [aa5e3aaf472] greasepencil-experimental: GP: Paint: Speedline Guides
Charlie Jolly
noreply at git.blender.org
Sun Jan 6 00:08:37 CET 2019
Commit: aa5e3aaf472da1534192e497bdace18e9a3477fb
Author: Charlie Jolly
Date: Sat Jan 5 23:08:16 2019 +0000
Branches: greasepencil-experimental
https://developer.blender.org/rBaa5e3aaf472da1534192e497bdace18e9a3477fb
GP: Paint: Speedline Guides
+ OKEY sets current reference point including 3dcursor
+ Tidy logic in draw utils (suggested by Antonioya)
+ New operator GPENCIL_OT_guide_rotate to set angle from UI
+ Tidy up UI panel with alternative to flip option
+ Angle for snap and parallel lines is now separate
Known Issues:
Some missing UI updates. Probably missing a notification somewhere.
===================================================================
M release/scripts/startup/bl_ui/space_view3d.py
M source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M source/blender/editors/gpencil/gpencil_intern.h
M source/blender/editors/gpencil/gpencil_ops.c
M source/blender/editors/gpencil/gpencil_paint.c
M source/blender/makesdna/DNA_scene_types.h
M source/blender/makesrna/intern/rna_sculpt_paint.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index a7fbe41dc25..41fbe71587f 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -5343,6 +5343,7 @@ class VIEW3D_PT_gpencil_guide(Panel):
@staticmethod
def draw(self, context):
+ from math import pi
settings = context.tool_settings.gpencil_sculpt
layout = self.layout
@@ -5353,21 +5354,25 @@ class VIEW3D_PT_gpencil_guide(Panel):
col = col.column()
col.active = settings.use_speed_guide
+
col.prop(settings, "guide_type", expand=True)
- col.prop(settings, "use_snapping")
-
- row = col.row(align=True)
- row.active = settings.guide_type in {'PARALLEL', 'RADIAL'}
- row.prop(settings, "guide_angle")
-
- row = col.row(align=True)
- row.active = settings.use_snapping
- row.prop(settings, "guide_spacing")
+
+ if settings.guide_type in {'PARALLEL'}:
+ col.prop(settings, "guide_angle")
+ row = col.row(align=True)
+ op = row.operator("gpencil.guide_rotate", text="0", emboss=True)
+ op.increment = False
+ op.angle = 0.0
+ row.operator("gpencil.guide_rotate", text="+90", emboss=True).angle = pi * 0.5
+ row.operator("gpencil.guide_rotate", text="+45", emboss=True).angle = pi * 0.25
+
+ col.prop(settings, "use_snapping")
+ if settings.use_snapping:
+ col.prop(settings, "guide_spacing")
+ col.prop(settings, "guide_angle_snap")
col.prop(settings, "use_cursor")
if not settings.use_cursor:
- row = col.row(align=True)
- col = row.column()
col.prop(settings, "guide_origin")
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 0458e78bdc2..c6edac7b763 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -1242,14 +1242,14 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data, void *vedata, T
}
}
- /* control points */
- if ((overlay) && ((gpd->runtime.tot_cp_points > 0) ||
- (ts->gp_sculpt.use_speed_guide && (draw_ctx->object_mode == OB_MODE_PAINT_GPENCIL))) &&
- ((gpd->runtime.sbuffer_sflag & GP_STROKE_ERASER) == 0) &&
- ((v3d->gizmo_flag & V3D_GIZMO_HIDE) == 0) &&
- ((v3d->gizmo_flag & V3D_GIZMO_HIDE_TOOL) == 0))
- {
+ /* control points for primitives and speed guide */
+ const bool is_cppoint = (gpd->runtime.tot_cp_points > 0);
+ const bool is_speed_guide = (ts->gp_sculpt.use_speed_guide && (draw_ctx->object_mode == OB_MODE_PAINT_GPENCIL));
+ const bool is_show_gizmo = (((v3d->gizmo_flag & V3D_GIZMO_HIDE) == 0) && ((v3d->gizmo_flag & V3D_GIZMO_HIDE_TOOL) == 0));
+ if ((overlay) && (is_cppoint || is_speed_guide) && (is_show_gizmo) &&
+ ((gpd->runtime.sbuffer_sflag & GP_STROKE_ERASER) == 0))
+ {
DRWShadingGroup *shgrp = DRW_shgroup_create(
e_data->gpencil_edit_point_sh, psl->drawing_pass);
const float *viewport_size = DRW_viewport_size_get();
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index b4b45a465d6..e583e3d1f48 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -293,6 +293,10 @@ void GPENCIL_OT_annotate(struct wmOperatorType *ot);
void GPENCIL_OT_draw(struct wmOperatorType *ot);
void GPENCIL_OT_fill(struct wmOperatorType *ot);
+/* Guides ----------------------- */
+
+void GPENCIL_OT_guide_rotate(struct wmOperatorType *ot);
+
/* Paint Modes for operator */
typedef enum eGPencil_PaintModes {
GP_PAINTMODE_DRAW = 0,
diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c
index 83667214c9b..8493244998d 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -228,6 +228,10 @@ void ED_operatortypes_gpencil(void)
WM_operatortype_append(GPENCIL_OT_draw);
WM_operatortype_append(GPENCIL_OT_fill);
+ /* Guides ----------------------- */
+
+ WM_operatortype_append(GPENCIL_OT_guide_rotate);
+
/* Editing (Strokes) ------------ */
WM_operatortype_append(GPENCIL_OT_editmode_toggle);
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 5c4c2625639..fc174866f46 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -192,7 +192,6 @@ typedef struct tGPsdata {
short keymodifier; /* key used for invoking the operator */
short shift; /* shift modifier flag */
- char use_cursor; /* reference point for guides */
float totpixlen; /* size in pixels for uv calculation */
@@ -2579,7 +2578,10 @@ static void gp_origin_set(wmOperator *op, const int mval[2])
float point[3];
copy_v2fl_v2i(origin, mval);
gp_stroke_convertcoords(p, origin, point, NULL);
- copy_v3_v3(ts->gp_sculpt.guide_origin, point);
+ if (ts->gp_sculpt.use_cursor)
+ copy_v3_v3(p->scene->cursor.location, point);
+ else
+ copy_v3_v3(ts->gp_sculpt.guide_origin, point);
}
/* get reference point - buffer coords to screen coords */
@@ -2587,13 +2589,11 @@ static void gp_origin_get(wmOperator *op, float origin[2])
{
tGPsdata *p = op->customdata;
ToolSettings *ts = p->scene->toolsettings;
-
float location[3];
if (ts->gp_sculpt.use_cursor)
copy_v3_v3(location, p->scene->cursor.location);
else
copy_v3_v3(location, ts->gp_sculpt.guide_origin);
-
GP_SpaceConversion *gsc = &p->gsc;
gp_point_3d_to_xy(gsc, p->gpd->runtime.sbuffer_sflag, location, origin);
}
@@ -2703,10 +2703,10 @@ static void gpencil_draw_apply_event(bContext *C, wmOperator *op, const wmEvent
/* special exception for grid snapping
* it requires direction which needs at least two points
*/
- if ((p->paintmode != GP_PAINTMODE_ERASER)
- && ts->gp_sculpt.use_speed_guide
- && ts->gp_sculpt.use_snapping
- && (ts->gp_sculpt.guide_type == GP_GUIDE_GRID)) {
+ if (!ELEM(p->paintmode, GP_PAINTMODE_ERASER, GP_PAINTMODE_SET_CP) &&
+ ts->gp_sculpt.use_speed_guide &&
+ ts->gp_sculpt.use_snapping &&
+ (ts->gp_sculpt.guide_type == GP_GUIDE_GRID)) {
p->flags |= GP_PAINTFLAG_REQ_VECTOR;
}
}
@@ -2756,15 +2756,15 @@ static void gpencil_draw_apply_event(bContext *C, wmOperator *op, const wmEvent
float origin[2];
gp_origin_get(op, origin);
if (ts->gp_sculpt.use_snapping
- && (ts->gp_sculpt.guide_angle > 0.0f)) {
+ && (ts->gp_sculpt.guide_angle_snap > 0.0f)) {
float xy[2];
sub_v2_v2v2(xy, p->mvali, origin);
float angle = atan2f(xy[1], xy[0]);
angle += (M_PI * 2.0f);
/* half angle used so stroke aligns with mouse */
- float half = ts->gp_sculpt.guide_angle * 0.5f;
- angle = fmodf(angle + half, ts->gp_sculpt.guide_angle);
+ float half = ts->gp_sculpt.guide_angle_snap * 0.5f;
+ angle = fmodf(angle + half, ts->gp_sculpt.guide_angle_snap);
angle -= half;
float point[2];
@@ -2939,38 +2939,49 @@ static int gpencil_draw_exec(bContext *C, wmOperator *op)
/* handle events for guides */
static void gpencil_guide_event_handling(bContext *C, wmOperator *op, const wmEvent *event, tGPsdata *p)
{
+ bool add_notifier = false;
ToolSettings *ts = p->scene->toolsettings;
+
/* Enter or exit set center point mode */
- if ((event->type == OKEY) && (event->val == KM_PRESS)) {
+ if ((event->type == OKEY) && (event->val == KM_RELEASE)) {
if (p->paintmode == GP_PAINTMODE_DRAW) {
+ add_notifier = true;
p->paintmode = GP_PAINTMODE_SET_CP;
- p->use_cursor = ts->gp_sculpt.use_cursor;
- ED_gpencil_toggle_brush_cursor(C, false, NULL);
+ ED_gpencil_toggle_brush_cursor(C, false, NULL);
}
}
/* Freehand mode, turn off speed guide */
else if ((event->type == VKEY) && (event->val == KM_PRESS)) {
ts->gp_sculpt.use_speed_guide = false;
- WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
+ add_notifier = true;
}
/* Alternate or flip direction */
else if ((event->type == MKEY) && (event->val == KM_PRESS)) {
- copy_v2_v2(p->mvali, p->mval);
if (ts->gp_sculpt.guide_type == GP_GUIDE_CIRCULAR) {
+ add_notifier = true;
ts->gp_sculpt.guide_type = GP_GUIDE_RADIAL;
}
else if (ts->gp_sculpt.guide_type == GP_GUIDE_RADIAL) {
+ add_notifier = true;
ts->gp_sculpt.guide_type = GP_GUIDE_CIRCULAR;
}
else if (ts->gp_sculpt.guide_type == GP_GUIDE_PARALLEL) {
+ add_notifier = true;
ts->gp_sculpt.guide_angle += M_PI_2;
- ts->gp_sculpt.guide_angle = angle_wrap_rad(ts->gp_sculpt.guide_angle);
+ ts->gp_sculpt.guide_angle = angle_compat_rad(ts->gp_sculpt.guide_angle, M_PI);
+ }
+ else {
+ add_notifier = false;
+ }
+
+ if (add_notifier) {
+ copy_v2_v2(p->mvali, p->mval);
}
}
/* Line guides */
else if ((event->type == LKEY) && (event->val == KM_PRESS)) {
- ts->gp_sculpt.use_speed_guide = true;
- WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
+ add_notifier = true;
+ ts->gp_sculpt.use_speed_guide = true;
copy_v2_v2(p->mvali, p->mval);
if (event->ctrl) {
ts->gp_sculpt.guide_angle = 0.0f;
@@ -2986,8 +2997,8 @@ static void gpencil_guide_event_handling(bContext *C, wmOperator *op, const wmEv
}
/* Point guide */
else if ((event->type == CKEY) && (event->val == KM_PRESS)) {
+ add_notifier = true;
ts->gp_sculpt.use_speed_guide = true;
- WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
copy_v2_v2(p->mvali, p->mval);
if (ts->gp_sculpt.guide_type == GP_GUIDE_CIRCULAR) {
ts->gp_sculpt.guide_type = GP_GUIDE_RADIAL;
@@ -3001,6 +3012,7 @@ static void gpencil_guide_event_handling(bContext *C, wmOperator *op, const wmEv
}
/* Change line angle xxx maybe use LEFTBRACKETKEY & RIGHTBRACKETKEY */
else if (ELEM(event->type, JKEY, KKEY) && (event->val == KM_PRESS)) {
+ add_notifier = true;
float angle = ts->
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list