GPv3: Draw Tool: Stabilize Stroke setting
This adds the "Stabilize Stroke" setting to GPv3. It also makes it possible to hold "shift" to activate the stabilize option temporarily like in GPv2. Pull Request: https://projects.blender.org/blender/blender/pulls/122556
This commit is contained in:
@@ -139,6 +139,12 @@ static GreasePencilStrokeOperation *get_stroke_operation(bContext &C, wmOperator
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static bool stroke_test_start(bContext *C, wmOperator *op, const float mouse[2])
|
||||
{
|
||||
UNUSED_VARS(C, op, mouse);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void stroke_update_step(bContext *C,
|
||||
wmOperator *op,
|
||||
PaintStroke *stroke,
|
||||
@@ -194,12 +200,6 @@ static bool grease_pencil_brush_stroke_poll(bContext *C)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool stroke_test_start(bContext *C, wmOperator *op, const float mouse[2])
|
||||
{
|
||||
UNUSED_VARS(C, op, mouse);
|
||||
return true;
|
||||
}
|
||||
|
||||
static int grease_pencil_brush_stroke_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
int return_value = ed::greasepencil::grease_pencil_draw_operator_invoke(C, op);
|
||||
|
||||
@@ -1557,8 +1557,7 @@ static void grease_pencil_brush_cursor_draw(PaintCursorContext *pcontext)
|
||||
* - Fixed size, or
|
||||
* - Brush size (i.e. stroke thickness)
|
||||
*/
|
||||
if ((gp_style) && ((brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE) == 0) &&
|
||||
((brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE_TEMP) == 0) &&
|
||||
if ((gp_style) && ((brush->flag & BRUSH_SMOOTH_STROKE) == 0) &&
|
||||
(brush->gpencil_tool == GPAINT_TOOL_DRAW))
|
||||
{
|
||||
|
||||
@@ -1571,6 +1570,11 @@ static void grease_pencil_brush_cursor_draw(PaintCursorContext *pcontext)
|
||||
color = use_vertex_color_stroke ? float3(brush->rgb) : float4(gp_style->stroke_rgba).xyz();
|
||||
}
|
||||
}
|
||||
|
||||
if ((brush->flag & BRUSH_SMOOTH_STROKE) != 0) {
|
||||
const float scale = 1.0f / 255.0f;
|
||||
color = scale * float3(paint->paint_cursor_col);
|
||||
}
|
||||
}
|
||||
else if (pcontext->mode == PaintMode::WeightGPencil) {
|
||||
copy_v3_v3(color, brush->add_col);
|
||||
@@ -1585,25 +1589,6 @@ static void grease_pencil_brush_cursor_draw(PaintCursorContext *pcontext)
|
||||
const float3 darkcolor = color * 0.40f;
|
||||
immUniformColor4f(darkcolor[0], darkcolor[1], darkcolor[2], 0.8f);
|
||||
imm_draw_circle_wire_2d(pcontext->pos, x, y, pcontext->pixel_radius + 1, 32);
|
||||
|
||||
/* Draw line for lazy mouse */
|
||||
/* TODO: No stabilize mode yet. */
|
||||
// if ((last_mouse_position) &&
|
||||
// (pcontext->xbrush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE_TEMP))
|
||||
// {
|
||||
// GPU_line_smooth(true);
|
||||
// GPU_blend(GPU_BLEND_ALPHA);
|
||||
|
||||
// copy_v3_v3(color, pcontext->brush->add_col);
|
||||
// immUniformColor4f(color[0], color[1], color[2], 0.8f);
|
||||
|
||||
// immBegin(GPU_PRIM_LINES, 2);
|
||||
// immVertex2f(pos, x, y);
|
||||
// immVertex2f(pos,
|
||||
// last_mouse_position[0] + pcontext->region->winrct.xmin,
|
||||
// last_mouse_position[1] + pcontext->region->winrct.ymin);
|
||||
// immEnd();
|
||||
// }
|
||||
}
|
||||
|
||||
static void paint_draw_2D_view_brush_cursor(PaintCursorContext *pcontext)
|
||||
|
||||
@@ -98,7 +98,7 @@ bool paint_supports_dynamic_size(const Brush &br, PaintMode mode);
|
||||
* Return true if the brush size can change during paint (normally used for pressure).
|
||||
*/
|
||||
bool paint_supports_dynamic_tex_coords(const Brush &br, PaintMode mode);
|
||||
bool paint_supports_smooth_stroke(const Brush &br, PaintMode mode);
|
||||
bool paint_supports_smooth_stroke(PaintStroke *stroke, const Brush &br, PaintMode mode);
|
||||
bool paint_supports_texture(PaintMode mode);
|
||||
|
||||
/**
|
||||
|
||||
@@ -631,7 +631,7 @@ static bool paint_smooth_stroke(PaintStroke *stroke,
|
||||
float r_mouse[2],
|
||||
float *r_pressure)
|
||||
{
|
||||
if (paint_supports_smooth_stroke(*stroke->brush, mode)) {
|
||||
if (paint_supports_smooth_stroke(stroke, *stroke->brush, mode)) {
|
||||
float radius = stroke->brush->smooth_stroke_radius * stroke->zoom_2d;
|
||||
float u = stroke->brush->smooth_stroke_factor;
|
||||
|
||||
@@ -1090,17 +1090,24 @@ bool paint_supports_dynamic_size(const Brush &br, PaintMode mode)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool paint_supports_smooth_stroke(const Brush &br, PaintMode mode)
|
||||
bool paint_supports_smooth_stroke(PaintStroke *stroke, const Brush &brush, PaintMode mode)
|
||||
{
|
||||
if (!(br.flag & BRUSH_SMOOTH_STROKE) ||
|
||||
(br.flag & (BRUSH_ANCHORED | BRUSH_DRAG_DOT | BRUSH_LINE)))
|
||||
/* The grease pencil draw tool needs to enable this when the `stroke_mode` is set to
|
||||
* `BRUSH_STROKE_SMOOTH`. */
|
||||
if (mode == PaintMode::GPencil && eBrushGPaintTool(brush.gpencil_tool) == GPAINT_TOOL_DRAW &&
|
||||
stroke->stroke_mode == BRUSH_STROKE_SMOOTH)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!(brush.flag & BRUSH_SMOOTH_STROKE) ||
|
||||
(brush.flag & (BRUSH_ANCHORED | BRUSH_DRAG_DOT | BRUSH_LINE)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case PaintMode::Sculpt:
|
||||
if (sculpt_is_grab_tool(br)) {
|
||||
if (sculpt_is_grab_tool(brush)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@@ -1488,7 +1495,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event, PaintS
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
if (paint_supports_smooth_stroke(*br, mode)) {
|
||||
if (paint_supports_smooth_stroke(stroke, *br, mode)) {
|
||||
stroke->stroke_cursor = WM_paint_cursor_activate(
|
||||
SPACE_TYPE_ANY, RGN_TYPE_ANY, paint_brush_tool_poll, paint_draw_smooth_cursor, stroke);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user