diff options
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_sculpt_paint.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_sculpt_paint.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c b/source/blender/editors/gpencil/gpencil_sculpt_paint.c index efd0f86df03..9ea4f176585 100644 --- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c +++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c @@ -54,6 +54,7 @@ #include "BKE_context.h" #include "BKE_deform.h" #include "BKE_gpencil.h" +#include "BKE_gpencil_curve.h" #include "BKE_gpencil_geom.h" #include "BKE_gpencil_modifier.h" #include "BKE_main.h" @@ -96,6 +97,8 @@ typedef struct tGP_BrushEditData { ScrArea *area; ARegion *region; + ToolSettings *ts; + /* Current GPencil datablock */ bGPdata *gpd; @@ -291,7 +294,7 @@ static void gpencil_recalc_geometry_tag(bGPDstroke *gps) } /* Recalc any stroke tagged. */ -static void gpencil_update_geometry(bGPdata *gpd) +static void gpencil_update_geometry(bGPdata *gpd, ToolSettings *ts) { if (gpd == NULL) { return; @@ -305,7 +308,11 @@ static void gpencil_update_geometry(bGPdata *gpd) LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) { if (gps->flag & GP_STROKE_TAG) { - BKE_gpencil_stroke_geometry_update(gpd, gps); + BKE_gpencil_stroke_refit_curve(gps, + ts->gpencil_curve_fit_threshold, + ts->gpencil_curve_fit_corner_angle, + GP_GEO_UPDATE_CURVE_REFIT_ALL); + BKE_gpencil_stroke_geometry_update(gpd, gps, GP_GEO_UPDATE_POLYLINE_REGENERATE_ALL); gps->flag &= ~GP_STROKE_TAG; } } @@ -1161,6 +1168,7 @@ static bool gpencil_sculpt_brush_init(bContext *C, wmOperator *op) gso->bmain = CTX_data_main(C); /* store state */ gso->settings = gpencil_sculpt_get_settings(scene); + gso->ts = ts; /* Random generator, only init once. */ uint rng_seed = (uint)(PIL_check_seconds_timer_i() & UINT_MAX); @@ -1304,7 +1312,7 @@ static void gpencil_sculpt_brush_exit(bContext *C, wmOperator *op) gso->brush->gpencil_settings->sculpt_flag &= ~GP_SCULPT_FLAG_TMP_INVERT; /* Update geometry data for tagged strokes. */ - gpencil_update_geometry(gso->gpd); + gpencil_update_geometry(gso->gpd, gso->ts); /* free operator data */ MEM_freeN(gso); @@ -1449,6 +1457,7 @@ static bool gpencil_sculpt_brush_do_stroke(tGP_BrushEditData *gso, bool include_last = false; bool changed = false; float rot_eval = 0.0f; + const bool is_curve = GPENCIL_STROKE_TYPE_BEZIER(gps_active); if (gps->totpoints == 1) { bGPDspoint pt_temp; @@ -1465,6 +1474,9 @@ static bool gpencil_sculpt_brush_do_stroke(tGP_BrushEditData *gso, if (len_v2v2_int(mval_i, pc1) <= radius) { /* apply operation to this point */ if (pt_active != NULL) { + if (is_curve) { + pt_active->flag |= GP_SPOINT_TAG; + } rot_eval = gpencil_sculpt_rotation_eval_get(gso, gps, pt, 0); changed = apply(gso, gps_active, rot_eval, 0, radius, pc1); } @@ -1508,7 +1520,7 @@ static bool gpencil_sculpt_brush_do_stroke(tGP_BrushEditData *gso, /* To each point individually... */ pt = &gps->points[i]; - if ((pt->runtime.pt_orig == NULL) && (tool != GPSCULPT_TOOL_GRAB)) { + if (!is_curve && (pt->runtime.pt_orig == NULL) && (tool != GPSCULPT_TOOL_GRAB)) { continue; } pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt; @@ -1517,8 +1529,14 @@ static bool gpencil_sculpt_brush_do_stroke(tGP_BrushEditData *gso, ((pt_active->flag & GP_SPOINT_SELECT) == 0)) { continue; } + index = (pt->runtime.pt_orig) ? pt->runtime.idx_orig : i; if ((pt_active != NULL) && (index < gps_active->totpoints)) { + if (is_curve) { + /* Tag points that will be transformed for curve update. */ + pt_active->flag |= GP_SPOINT_TAG; + } + rot_eval = gpencil_sculpt_rotation_eval_get(gso, gps, pt, i); ok = apply(gso, gps_active, rot_eval, index, radius, pc1); } @@ -1690,7 +1708,7 @@ static bool gpencil_sculpt_brush_do_frame(bContext *C, MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps->mat_nr + 1); /* Update active frame now, only if material has fill. */ if (gp_style->flag & GP_MATERIAL_FILL_SHOW) { - BKE_gpencil_stroke_geometry_update(gpd, gps_active); + BKE_gpencil_stroke_geometry_update(gpd, gps_active, GP_GEO_UPDATE_DEFAULT); } else { gpencil_recalc_geometry_tag(gps_active); |