diff options
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_paint.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_paint.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 73a94f066e3..79dda480a0a 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -54,6 +54,7 @@ #include "BKE_deform.h" #include "BKE_global.h" #include "BKE_gpencil.h" +#include "BKE_gpencil_curve.h" #include "BKE_gpencil_geom.h" #include "BKE_layer.h" #include "BKE_main.h" @@ -834,7 +835,7 @@ static short gpencil_stroke_addpoint(tGPsdata *p, /* color strength */ if (brush_settings->flag & GP_BRUSH_USE_STRENGTH_PRESSURE) { pt->strength *= BKE_curvemapping_evaluateF(brush_settings->curve_strength, 0, pressure); - CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f); + CLAMP(pt->strength, MIN2(GPENCIL_STRENGTH_MIN, brush_settings->draw_strength), 1.0f); } /* Set vertex colors for buffer. */ @@ -918,6 +919,19 @@ static short gpencil_stroke_addpoint(tGPsdata *p, return GP_STROKEADD_INVALID; } +static void gpencil_stroke_unselect(bGPdata *gpd, bGPDstroke *gps) +{ + gps->flag &= ~GP_STROKE_SELECT; + BKE_gpencil_stroke_select_index_reset(gps); + for (int i = 0; i < gps->totpoints; i++) { + gps->points[i].flag &= ~GP_SPOINT_SELECT; + } + /* Update the selection from the stroke to the curve. */ + if (gps->editcurve) { + BKE_gpencil_editcurve_stroke_sync_selection(gpd, gps, gps->editcurve); + } +} + /* make a new stroke from the buffer data */ static void gpencil_stroke_newfrombuffer(tGPsdata *p) { @@ -928,6 +942,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p) tGPspoint *ptc; MDeformVert *dvert = NULL; Brush *brush = p->brush; + BrushGpencilSettings *brush_settings = brush->gpencil_settings; ToolSettings *ts = p->scene->toolsettings; Depsgraph *depsgraph = p->depsgraph; Object *obact = (Object *)p->ownerPtr.data; @@ -1016,7 +1031,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p) /* copy pressure and time */ pt->pressure = ptc->pressure; pt->strength = ptc->strength; - CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f); + CLAMP(pt->strength, MIN2(GPENCIL_STRENGTH_MIN, brush_settings->draw_strength), 1.0f); copy_v4_v4(pt->vert_color, ptc->vert_color); pt->time = ptc->time; /* Apply the vertex color to point. */ @@ -1050,7 +1065,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p) /* copy pressure and time */ pt->pressure = ptc->pressure; pt->strength = ptc->strength; - CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f); + CLAMP(pt->strength, MIN2(GPENCIL_STRENGTH_MIN, brush_settings->draw_strength), 1.0f); pt->time = ptc->time; /* Apply the vertex color to point. */ ED_gpencil_point_vertex_color_set(ts, brush, pt, ptc); @@ -1175,7 +1190,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p) /* copy pressure and time */ pt->pressure = ptc->pressure; pt->strength = ptc->strength; - CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f); + CLAMP(pt->strength, MIN2(GPENCIL_STRENGTH_MIN, brush_settings->draw_strength), 1.0f); copy_v4_v4(pt->vert_color, ptc->vert_color); pt->time = ptc->time; pt->uv_fac = ptc->uv_fac; @@ -1300,7 +1315,12 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p) ctrl2, GPENCIL_MINIMUM_JOIN_DIST, &pt_index); + if (gps_target != NULL) { + /* Unselect all points of source and destination strokes. This is required to avoid + * a change in the resolution of the original strokes during the join. */ + gpencil_stroke_unselect(gpd, gps); + gpencil_stroke_unselect(gpd, gps_target); gps = ED_gpencil_stroke_join_and_trim(p->gpd, p->gpf, gps, gps_target, pt_index); } else { |