[Bf-blender-cvs] [c3a63776bef] temp-gpencil-bezier-stroke-type: Merge branch 'master' into temp-gpencil-bezier-stroke-type
Falk David
noreply at git.blender.org
Fri Jun 18 14:51:47 CEST 2021
Commit: c3a63776befcb435a87dcc15cf03898eb0f8e34e
Author: Falk David
Date: Fri Jun 18 14:51:38 2021 +0200
Branches: temp-gpencil-bezier-stroke-type
https://developer.blender.org/rBc3a63776befcb435a87dcc15cf03898eb0f8e34e
Merge branch 'master' into temp-gpencil-bezier-stroke-type
===================================================================
===================================================================
diff --cc source/blender/editors/gpencil/gpencil_edit.c
index 6e0d779a17a,3da75a665a2..4d79bc0946c
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@@ -4774,201 -4613,72 +4774,206 @@@ static int gpencil_stroke_separate_exec
if (ED_gpencil_stroke_material_editable(ob, gpl, gps) == false) {
continue;
}
+
/* Separate selected strokes. */
- if (gps->flag & GP_STROKE_SELECT) {
- /* add layer if not created before */
- if (gpl_dst == NULL) {
- gpl_dst = BKE_gpencil_layer_addnew(gpd_dst, gpl->info, false, false);
- gpl_dst->line_change = gpl->line_change;
- copy_v4_v4(gpl_dst->tintcolor, gpl->tintcolor);
- gpl_dst->opacity = gpl->opacity;
- gpl_dst->blend_mode = gpl->blend_mode;
- gpl_dst->vertex_paint_opacity = gpl->vertex_paint_opacity;
- }
- /* add frame if not created before */
- if (gpf_dst == NULL) {
- gpf_dst = BKE_gpencil_layer_frame_get(gpl_dst, gpf->framenum, GP_GETFRAME_ADD_NEW);
- }
+ /* add layer if not created before */
+ if (gpl_dst == NULL) {
+ gpl_dst = BKE_gpencil_layer_addnew(gpd_dst, gpl->info, false, false);
++ gpl_dst->line_change = gpl->line_change;
++ copy_v4_v4(gpl_dst->tintcolor, gpl->tintcolor);
++ gpl_dst->opacity = gpl->opacity;
++ gpl_dst->blend_mode = gpl->blend_mode;
++ gpl_dst->vertex_paint_opacity = gpl->vertex_paint_opacity;
+ }
+
+ /* add frame if not created before */
+ if (gpf_dst == NULL) {
+ gpf_dst = BKE_gpencil_layer_frame_get(gpl_dst, gpf->framenum, GP_GETFRAME_ADD_NEW);
+ }
+
+ /* add duplicate materials */
+
+ /* XXX same material can be in multiple slots. */
+ ma = BKE_gpencil_material(ob, gps->mat_nr + 1);
+
+ idx = BKE_gpencil_object_material_ensure(bmain, ob_dst, ma);
+
+ /* selected points mode */
+ if (mode == GP_SEPARATE_POINT) {
+ /* make copy of source stroke */
+ bGPDstroke *gps_dst = BKE_gpencil_stroke_duplicate(gps, true, true);
- /* add duplicate materials */
+ /* Reassign material. */
+ gps_dst->mat_nr = idx;
- /* XXX same material can be in multiple slots. */
- ma = BKE_gpencil_material(ob, gps->mat_nr + 1);
+ /* link to destination frame */
+ BLI_addtail(&gpf_dst->strokes, gps_dst);
- idx = BKE_gpencil_object_material_ensure(bmain, ob_dst, ma);
+ if (GPENCIL_STROKE_TYPE_BEZIER(gps)) {
+ bGPDcurve *gpc_src = gps->editcurve;
+ bGPDcurve *gpc_dst = gps_dst->editcurve;
- /* selected points mode */
- if (mode == GP_SEPARATE_POINT) {
- if (is_curve_edit) {
- BKE_report(op->reports, RPT_ERROR, "Not implemented!");
+ /* Flip the selection */
+ for (int i = 0; i < gpc_dst->tot_curve_points; i++) {
+ bGPDcurve_point *cpt = &gpc_dst->curve_points[i];
+ BezTriple *bezt = &cpt->bezt;
+ if (cpt->flag & GP_CURVE_POINT_SELECT) {
+ cpt->flag &= ~GP_CURVE_POINT_SELECT;
+ BEZT_DESEL_ALL(bezt);
+ }
+ else {
+ cpt->flag |= GP_CURVE_POINT_SELECT;
+ BEZT_SEL_ALL(bezt);
+ }
+ }
+
+ if (keep_ends) {
+ /* Shrink the selection in the original stroke to keep the connecting points. */
+ int tot_selected = 0, num_deselected = 0;
+
+ bool prev_sel = false;
+ int i;
+ for (i = 0; i < gpc_src->tot_curve_points; i++) {
+ bGPDcurve_point *gpc_pt = &gpc_src->curve_points[i];
+ BezTriple *bezt = &gpc_pt->bezt;
+ if (gpc_pt->flag & GP_CURVE_POINT_SELECT) {
+ /* shrink if previous wasn't selected */
+ if (prev_sel == false) {
+ gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
+ BEZT_DESEL_ALL(bezt);
+ num_deselected++;
+ }
+ prev_sel = true;
+ tot_selected++;
+ }
+ else {
+ /* mark previous as being unselected - and hence, is trigger for shrinking */
+ prev_sel = false;
+ }
+ }
+
+ /* Second Pass: Go in reverse order, doing the same as before (except in opposite
+ * order)
+ * - This pass covers the "before" edges of selection islands
+ */
+ prev_sel = false;
+ for (i = gpc_src->tot_curve_points - 1; i > 0; i--) {
+ bGPDcurve_point *gpc_pt = &gpc_src->curve_points[i];
+ BezTriple *bezt = &gpc_pt->bezt;
+ if (gpc_pt->flag & GP_CURVE_POINT_SELECT) {
+ /* shrink if previous wasn't selected */
+ if (prev_sel == false) {
+ gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
+ BEZT_DESEL_ALL(bezt);
+ num_deselected++;
+ }
+ prev_sel = true;
+ }
+ else {
+ /* mark previous as being unselected - and hence, is trigger for shrinking */
+ prev_sel = false;
+ }
+ }
+
+ /* Deselect curve if all points are deselected. */
+ if (tot_selected - num_deselected == 0) {
+ gpc_src->flag &= ~GP_CURVE_SELECT;
+ }
}
- else {
- /* make copy of source stroke */
- bGPDstroke *gps_dst = BKE_gpencil_stroke_duplicate(gps, true, true);
- /* Reassign material. */
- gps_dst->mat_nr = idx;
+ BKE_gpencil_curve_delete_tagged_points(
+ gpd_dst, gpf_dst, gps_dst, NULL, gpc_dst, GP_CURVE_POINT_SELECT);
+
+ BKE_gpencil_curve_delete_tagged_points(
+ gpd_src, gpf, gps, gps->next, gpc_src, GP_CURVE_POINT_SELECT);
+ }
+ else {
- /* link to destination frame */
- BLI_addtail(&gpf_dst->strokes, gps_dst);
+ /* Invert selection status of all points in destination stroke */
+ for (int i = 0; i < gps_dst->totpoints; i++) {
+ bGPDspoint *pt = &gps_dst->points[i];
+ pt->flag ^= GP_SPOINT_SELECT;
+ }
- /* Invert selection status of all points in destination stroke */
- for (i = 0, pt = gps_dst->points; i < gps_dst->totpoints; i++, pt++) {
- pt->flag ^= GP_SPOINT_SELECT;
+ if (keep_ends) {
+ bGPDspoint *pt;
+ int i, tot_selected = 0, num_deselected = 0;
+ bool prev_sel;
+
+ /* First Pass: Go in forward order, shrinking selection
+ * if previous was not selected (pre changes).
+ * - This pass covers the "after" edges of selection islands
+ */
+ prev_sel = false;
+ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
+ if (pt->flag & GP_SPOINT_SELECT) {
+ /* shrink if previous wasn't selected */
+ if (prev_sel == false) {
+ pt->flag &= ~GP_SPOINT_SELECT;
+ num_deselected++;
+ }
+ prev_sel = true;
+ tot_selected++;
+ }
+ else {
+ /* mark previous as being unselected - and hence, is trigger for shrinking */
+ prev_sel = false;
+ }
}
- /* delete selected points from destination stroke */
- BKE_gpencil_stroke_delete_tagged_points(
- gpd_dst, gpf_dst, gps_dst, NULL, GP_SPOINT_SELECT, false, 0);
+ /* Second Pass: Go in reverse order, doing the same as before (except in opposite
+ * order)
+ * - This pass covers the "before" edges of selection islands
+ */
+ prev_sel = false;
+ for (pt -= 1; i > 0; i--, pt--) {
+ if (pt->flag & GP_SPOINT_SELECT) {
+ /* shrink if previous wasn't selected */
+ if (prev_sel == false) {
+ pt->flag &= ~GP_SPOINT_SELECT;
+ num_deselected++;
+ }
+ prev_sel = true;
+ }
+ else {
+ /* mark previous as being unselected - and hence, is trigger for shrinking */
+ prev_sel = false;
+ }
+ }
- /* delete selected points from origin stroke */
- BKE_gpencil_stroke_delete_tagged_points(
- gpd_src, gpf, gps, gps->next, GP_SPOINT_SELECT, false, 0);
+ /* Deselect stroke if all points are deselected. */
+ if (tot_selected - num_deselected == 0) {
+ gps-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list