Commit: 2b9ae89ad8ddcd250402bb0ef071529297626771 Author: Falk David Date: Sat Jul 25 17:15:56 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB2b9ae89ad8ddcd250402bb0ef071529297626771
GPencil: WIP delete curve point =================================================================== M source/blender/blenkernel/BKE_gpencil.h M source/blender/blenkernel/intern/gpencil.c M source/blender/editors/gpencil/annotate_paint.c M source/blender/editors/gpencil/editaction_gpencil.c M source/blender/editors/gpencil/gpencil_data.c M source/blender/editors/gpencil/gpencil_edit.c M source/blender/editors/gpencil/gpencil_interpolate.c M source/blender/editors/gpencil/gpencil_sculpt_paint.c M source/blender/editors/gpencil/gpencil_utils.c M source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c M source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c M source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c =================================================================== diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h index 9259729695d..678937aea34 100644 --- a/source/blender/blenkernel/BKE_gpencil.h +++ b/source/blender/blenkernel/BKE_gpencil.h @@ -115,7 +115,9 @@ struct bGPDframe *BKE_gpencil_frame_duplicate(const struct bGPDframe *gpf_src); struct bGPDlayer *BKE_gpencil_layer_duplicate(const struct bGPDlayer *gpl_src); void BKE_gpencil_frame_copy_strokes(struct bGPDframe *gpf_src, struct bGPDframe *gpf_dst); struct bGPDcurve *BKE_gpencil_stroke_curve_duplicate(struct bGPDcurve *gpc_src); -struct bGPDstroke *BKE_gpencil_stroke_duplicate(struct bGPDstroke *gps_src, const bool dup_points); +struct bGPDstroke *BKE_gpencil_stroke_duplicate(struct bGPDstroke *gps_src, + const bool dup_points, + const bool dup_curve); struct bGPdata *BKE_gpencil_copy(struct Main *bmain, const struct bGPdata *gpd); diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 8d73ad44071..36e20d256ac 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -731,9 +731,10 @@ bGPDcurve *BKE_gpencil_stroke_curve_duplicate(bGPDcurve *gpc_src) * Make a copy of a given grease-pencil stroke. * \param gps_src: Source grease pencil strokes. * \param dup_points: Duplicate points data. + * \param dup_curve: Duplicate curve data. * \return Pointer to new stroke. */ -bGPDstroke *BKE_gpencil_stroke_duplicate(bGPDstroke *gps_src, const bool dup_points) +bGPDstroke *BKE_gpencil_stroke_duplicate(bGPDstroke *gps_src, const bool dup_points, const bool dup_curve) { bGPDstroke *gps_dst = NULL; @@ -753,7 +754,7 @@ bGPDstroke *BKE_gpencil_stroke_duplicate(bGPDstroke *gps_src, const bool dup_poi } } - if (gps_src->editcurve != NULL) { + if (dup_curve && gps_src->editcurve != NULL) { gps_dst->editcurve = BKE_gpencil_stroke_curve_duplicate(gps_src->editcurve); } @@ -784,7 +785,7 @@ bGPDframe *BKE_gpencil_frame_duplicate(const bGPDframe *gpf_src) BLI_listbase_clear(&gpf_dst->strokes); LISTBASE_FOREACH (bGPDstroke *, gps_src, &gpf_src->strokes) { /* make copy of source stroke */ - gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true); + gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true, true); BLI_addtail(&gpf_dst->strokes, gps_dst); } @@ -809,7 +810,7 @@ void BKE_gpencil_frame_copy_strokes(bGPDframe *gpf_src, struct bGPDframe *gpf_ds BLI_listbase_clear(&gpf_dst->strokes); LISTBASE_FOREACH (bGPDstroke *, gps_src, &gpf_src->strokes) { /* make copy of source stroke */ - gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true); + gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true, true); BLI_addtail(&gpf_dst->strokes, gps_dst); } } diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index b9a63dfcf9a..b7645bc4432 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -910,7 +910,7 @@ static void annotation_stroke_newfrombuffer(tGPsdata *p) int totarrowpoints = runtime.arrow_end_style; /* Setting up arrow stroke. */ - bGPDstroke *e_arrow_gps = BKE_gpencil_stroke_duplicate(gps, false); + bGPDstroke *e_arrow_gps = BKE_gpencil_stroke_duplicate(gps, false, false); annotation_stroke_arrow_allocate(e_arrow_gps, totarrowpoints); /* Set pointer to first non-initialized point. */ @@ -931,7 +931,7 @@ static void annotation_stroke_newfrombuffer(tGPsdata *p) int totarrowpoints = runtime.arrow_start_style; /* Setting up arrow stroke. */ - bGPDstroke *s_arrow_gps = BKE_gpencil_stroke_duplicate(gps, false); + bGPDstroke *s_arrow_gps = BKE_gpencil_stroke_duplicate(gps, false, false); annotation_stroke_arrow_allocate(s_arrow_gps, totarrowpoints); /* Set pointer to first non-initialized point. */ diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c index 752b8a74f4f..afb92ca7742 100644 --- a/source/blender/editors/gpencil/editaction_gpencil.c +++ b/source/blender/editors/gpencil/editaction_gpencil.c @@ -486,7 +486,7 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode) */ for (gps = gpfs->strokes.first; gps; gps = gps->next) { /* make a copy of stroke, then of its points array */ - gpsn = BKE_gpencil_stroke_duplicate(gps, true); + gpsn = BKE_gpencil_stroke_duplicate(gps, true, true); /* append stroke to frame */ BLI_addtail(&gpf->strokes, gpsn); diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index d3fc3aced97..20f27a59250 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -580,7 +580,7 @@ static int gpencil_layer_duplicate_object_exec(bContext *C, wmOperator *op) LISTBASE_FOREACH (bGPDstroke *, gps_src, &gpf_src->strokes) { /* Make copy of source stroke. */ - bGPDstroke *gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true); + bGPDstroke *gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true, true); /* Check if material is in destination object, * otherwise add the slot with the material. */ diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 7f10c04ec47..962aeb692bf 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -860,7 +860,7 @@ static void gpencil_duplicate_points(bGPdata *gpd, bGPDstroke *gpsd; /* make a stupid copy first of the entire stroke (to get the flags too) */ - gpsd = BKE_gpencil_stroke_duplicate((bGPDstroke *)gps, false); + gpsd = BKE_gpencil_stroke_duplicate((bGPDstroke *)gps, false, true); /* saves original layer name */ BLI_strncpy(gpsd->runtime.tmp_layerinfo, layername, sizeof(gpsd->runtime.tmp_layerinfo)); @@ -944,7 +944,7 @@ static int gpencil_duplicate_exec(bContext *C, wmOperator *op) bGPDstroke *gpsd; /* make direct copies of the stroke and its points */ - gpsd = BKE_gpencil_stroke_duplicate(gps, true); + gpsd = BKE_gpencil_stroke_duplicate(gps, true, true); BLI_strncpy( gpsd->runtime.tmp_layerinfo, gpl->info, sizeof(gpsd->runtime.tmp_layerinfo)); @@ -1066,7 +1066,7 @@ static void gpencil_add_move_points(bGPdata *gpd, bGPDframe *gpf, bGPDstroke *gp pt = &gps->points[i]; if (pt->flag == GP_SPOINT_SELECT) { /* duplicate original stroke data */ - bGPDstroke *gps_new = BKE_gpencil_stroke_duplicate(gps, false); + bGPDstroke *gps_new = BKE_gpencil_stroke_duplicate(gps, false, true); gps_new->prev = gps_new->next = NULL; /* add new points array */ @@ -1420,7 +1420,7 @@ static int gpencil_strokes_copy_exec(bContext *C, wmOperator *op) bGPDstroke *gpsd; /* make direct copies of the stroke and its points */ - gpsd = BKE_gpencil_stroke_duplicate(gps, false); + gpsd = BKE_gpencil_stroke_duplicate(gps, false, true); /* saves original layer name */ BLI_strncpy( @@ -1615,7 +1615,7 @@ static int gpencil_strokes_paste_exec(bContext *C, wmOperator *op) gpf = BKE_gpencil_layer_frame_get(gpl, CFRA, GP_GETFRAME_ADD_NEW); if (gpf) { /* Create new stroke */ - bGPDstroke *new_stroke = BKE_gpencil_stroke_duplicate(gps, true); + bGPDstroke *new_stroke = BKE_gpencil_stroke_duplicate(gps, true, true); new_stroke->runtime.tmp_layerinfo[0] = '\0'; new_stroke->next = new_stroke->prev = NULL; @@ -2479,7 +2479,7 @@ static void gpencil_stroke_join_islands(bGPdata *gpd, const int totpoints = gps_first->totpoints + gps_last->totpoints; /* create new stroke */ - bGPDstroke *join_stroke = BKE_gpencil_stroke_duplicate(gps_first, false); + bGPDstroke *join_stroke = BKE_gpencil_stroke_duplicate(gps_first, false, true); join_stroke->points = MEM_callocN(sizeof(bGPDspoint) * totpoints, __func__); join_stroke->totpoints = totpoints; @@ -2625,7 +2625,7 @@ void gpencil_stroke_delete_tagged_points(bGPdata *gpd, /* Create each new stroke... */ for (idx = 0; idx < num_islands; idx++) { tGPDeleteIsland *island = &islands[idx]; - new_stroke = BKE_gpencil_stroke_duplicate(gps, false); + new_stroke = BKE_gpencil_stroke_duplicate(gps, false, true); /* if cyclic and first stroke, save to join later */ if ((is_cyclic) && (gps_first == NULL)) { @@ -2720,16 +2720,62 @@ void gpencil_stroke_delete_tagged_points(bGPdata *gpd, BKE_gpencil_free_stroke(gps); } -void gpencil_stroke_delete_tagged_points(bGPdata *gpd, - bGPDframe *gpf, - bGPDstroke *gps, - bGPDstroke *next_stroke, - bGPDcurve *gpc, - int tag_flags, - bool select, - int limit) +void gpencil_curve_delete_tagged_points(bGPdata *gpd, + bGPDframe *gpf, + bGPDstroke *gps, + bGPDstroke *next_stroke, + bGPDcurve *gpc, + int tag_flags, + bool select, + int limit) { - return NULL; + if (gpc == NULL) { + return; + } + const bool is_cyclic = gps->flag & GP_STROKE_CYCLIC; + + int idx_start = 0; + int idx_end = 0; + bool prev_selected = gpc->curve_points[0].flag & tag_flags; + for (int i = 1; i < gpc->tot_curve_points; i++) { + @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs