Fix T93074: Gpencil cutter not using flat caps in middle cuts
When cut an stroke using the option Flat Caps, the falt was not done if the cut was done in the middle of the stroke. Now the flat is applied to the segments created and also some cleanup of the code done.
This commit is contained in:
parent
c2c65cc4bf
commit
c3472cb11c
Notes:
blender-bot
2023-02-14 06:49:57 +01:00
Referenced by issue #88449: Blender LTS: Maintenance Task 2.93 Referenced by issue #88449, Blender LTS: Maintenance Task 2.93 Referenced by issue #93074, "Flat Caps" on Cutter tool not working if cut is made in the middle of the stroke
|
@ -128,8 +128,9 @@ struct bGPDstroke *BKE_gpencil_stroke_delete_tagged_points(struct bGPdata *gpd,
|
|||
struct bGPDstroke *gps,
|
||||
struct bGPDstroke *next_stroke,
|
||||
int tag_flags,
|
||||
bool select,
|
||||
int limit);
|
||||
const bool select,
|
||||
const bool flat_cap,
|
||||
const int limit);
|
||||
void BKE_gpencil_curve_delete_tagged_points(struct bGPdata *gpd,
|
||||
struct bGPDframe *gpf,
|
||||
struct bGPDstroke *gps,
|
||||
|
|
|
@ -3122,8 +3122,9 @@ bGPDstroke *BKE_gpencil_stroke_delete_tagged_points(bGPdata *gpd,
|
|||
bGPDstroke *gps,
|
||||
bGPDstroke *next_stroke,
|
||||
int tag_flags,
|
||||
bool select,
|
||||
int limit)
|
||||
const bool select,
|
||||
const bool flat_cap,
|
||||
const int limit)
|
||||
{
|
||||
tGPDeleteIsland *islands = (tGPDeleteIsland *)MEM_callocN(
|
||||
sizeof(tGPDeleteIsland) * (gps->totpoints + 1) / 2, "gp_point_islands");
|
||||
|
@ -3171,6 +3172,9 @@ bGPDstroke *BKE_gpencil_stroke_delete_tagged_points(bGPdata *gpd,
|
|||
for (idx = 0; idx < num_islands; idx++) {
|
||||
tGPDeleteIsland *island = &islands[idx];
|
||||
new_stroke = BKE_gpencil_stroke_duplicate(gps, false, true);
|
||||
if (flat_cap) {
|
||||
new_stroke->caps[1 - (idx % 2)] = GP_STROKE_CAP_FLAT;
|
||||
}
|
||||
|
||||
/* if cyclic and first stroke, save to join later */
|
||||
if ((is_cyclic) && (gps_first == nullptr)) {
|
||||
|
|
|
@ -1195,7 +1195,7 @@ static void annotation_stroke_eraser_dostroke(tGPsdata *p,
|
|||
/* Second Pass: Remove any points that are tagged */
|
||||
if (do_cull) {
|
||||
BKE_gpencil_stroke_delete_tagged_points(
|
||||
p->gpd, gpf, gps, gps->next, GP_SPOINT_TAG, false, 0);
|
||||
p->gpd, gpf, gps, gps->next, GP_SPOINT_TAG, false, false, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1834,7 +1834,7 @@ static int image_to_gpencil_exec(bContext *C, wmOperator *op)
|
|||
/* Delete any selected point. */
|
||||
LISTBASE_FOREACH_MUTABLE (bGPDstroke *, gps, &gpf->strokes) {
|
||||
BKE_gpencil_stroke_delete_tagged_points(
|
||||
gpd, gpf, gps, gps->next, GP_SPOINT_SELECT, false, 0);
|
||||
gpd, gpf, gps, gps->next, GP_SPOINT_SELECT, false, false, 0);
|
||||
}
|
||||
|
||||
BKE_reportf(op->reports, RPT_INFO, "Object created");
|
||||
|
|
|
@ -2635,7 +2635,7 @@ static int gpencil_delete_selected_points(bContext *C)
|
|||
else {
|
||||
/* delete unwanted points by splitting stroke into several smaller ones */
|
||||
BKE_gpencil_stroke_delete_tagged_points(
|
||||
gpd, gpf, gps, gps->next, GP_SPOINT_SELECT, false, 0);
|
||||
gpd, gpf, gps, gps->next, GP_SPOINT_SELECT, false, false, 0);
|
||||
}
|
||||
|
||||
changed = true;
|
||||
|
@ -4656,11 +4656,11 @@ static int gpencil_stroke_separate_exec(bContext *C, wmOperator *op)
|
|||
|
||||
/* delete selected points from destination stroke */
|
||||
BKE_gpencil_stroke_delete_tagged_points(
|
||||
gpd_dst, gpf_dst, gps_dst, NULL, GP_SPOINT_SELECT, false, 0);
|
||||
gpd_dst, gpf_dst, gps_dst, NULL, GP_SPOINT_SELECT, false, false, 0);
|
||||
|
||||
/* delete selected points from origin stroke */
|
||||
BKE_gpencil_stroke_delete_tagged_points(
|
||||
gpd_src, gpf, gps, gps->next, GP_SPOINT_SELECT, false, 0);
|
||||
gpd_src, gpf, gps, gps->next, GP_SPOINT_SELECT, false, false, 0);
|
||||
}
|
||||
}
|
||||
/* selected strokes mode */
|
||||
|
@ -4839,11 +4839,11 @@ static int gpencil_stroke_split_exec(bContext *C, wmOperator *op)
|
|||
|
||||
/* delete selected points from destination stroke */
|
||||
BKE_gpencil_stroke_delete_tagged_points(
|
||||
gpd, gpf, gps_dst, NULL, GP_SPOINT_SELECT, true, 0);
|
||||
gpd, gpf, gps_dst, NULL, GP_SPOINT_SELECT, true, false, 0);
|
||||
|
||||
/* delete selected points from origin stroke */
|
||||
BKE_gpencil_stroke_delete_tagged_points(
|
||||
gpd, gpf, gps, gps->next, GP_SPOINT_SELECT, false, 0);
|
||||
gpd, gpf, gps, gps->next, GP_SPOINT_SELECT, false, false, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5039,7 +5039,7 @@ static void gpencil_cutter_dissolve(bGPdata *gpd,
|
|||
}
|
||||
|
||||
BKE_gpencil_stroke_delete_tagged_points(
|
||||
gpd, hit_layer->actframe, hit_stroke, gpsn, GP_SPOINT_TAG, false, 1);
|
||||
gpd, hit_layer->actframe, hit_stroke, gpsn, GP_SPOINT_TAG, false, flat_caps, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -182,7 +182,8 @@ static void gpencil_dissolve_points(bContext *C)
|
|||
}
|
||||
|
||||
LISTBASE_FOREACH_MUTABLE (bGPDstroke *, gps, &gpf->strokes) {
|
||||
BKE_gpencil_stroke_delete_tagged_points(gpd, gpf, gps, gps->next, GP_SPOINT_TAG, false, 0);
|
||||
BKE_gpencil_stroke_delete_tagged_points(
|
||||
gpd, gpf, gps, gps->next, GP_SPOINT_TAG, false, false, 0);
|
||||
}
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
|
|
@ -1699,7 +1699,7 @@ static void gpencil_stroke_eraser_dostroke(tGPsdata *p,
|
|||
}
|
||||
|
||||
BKE_gpencil_stroke_delete_tagged_points(
|
||||
p->gpd, gpf, gps, gps->next, GP_SPOINT_TAG, false, 0);
|
||||
p->gpd, gpf, gps, gps->next, GP_SPOINT_TAG, false, false, 0);
|
||||
}
|
||||
gpencil_update_cache(p->gpd);
|
||||
}
|
||||
|
|
|
@ -3372,7 +3372,7 @@ bGPDstroke *ED_gpencil_stroke_join_and_trim(
|
|||
}
|
||||
/* Remove tagged points to trim stroke. */
|
||||
gps_final = BKE_gpencil_stroke_delete_tagged_points(
|
||||
gpd, gpf, gps_dst, gps_dst->next, GP_SPOINT_TAG, false, 0);
|
||||
gpd, gpf, gps_dst, gps_dst->next, GP_SPOINT_TAG, false, false, 0);
|
||||
}
|
||||
|
||||
/* Join both strokes. */
|
||||
|
|
Loading…
Reference in New Issue