Commit: 57b50982f1c8155351e003e426639845b688df09 Author: Falk David Date: Wed May 26 16:42:54 2021 +0200 Branches: temp-gpencil-bezier-stroke-type https://developer.blender.org/rB57b50982f1c8155351e003e426639845b688df09
Merge branch 'master' into temp-gpencil-bezier-stroke-type =================================================================== =================================================================== diff --cc release/scripts/startup/bl_ui/space_view3d.py index bbbde2b24b2,ae18fc4fb76..3f5292b30c4 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@@ -7689,12 -7627,7 +7627,8 @@@ classes = VIEW3D_MT_weight_gpencil, VIEW3D_MT_gpencil_animation, VIEW3D_MT_gpencil_simplify, - VIEW3D_MT_gpencil_append_active_layer, - VIEW3D_MT_gpencil_append_all_layers, - VIEW3D_MT_gpencil_append_active_material, - VIEW3D_MT_gpencil_append_all_materials, VIEW3D_MT_gpencil_autoweights, + VIEW3D_PT_gpencil_curve_fit, VIEW3D_MT_gpencil_edit_context_menu, VIEW3D_MT_edit_curve, VIEW3D_MT_edit_curve_ctrlpoints, diff --cc source/blender/editors/gpencil/CMakeLists.txt index 6441a14b807,bff7310e9f7..83ba519c4c7 --- a/source/blender/editors/gpencil/CMakeLists.txt +++ b/source/blender/editors/gpencil/CMakeLists.txt @@@ -41,8 -41,8 +41,9 @@@ set(SR gpencil_add_monkey.c gpencil_add_stroke.c gpencil_armature.c + gpencil_bake_animation.c gpencil_convert.c + gpencil_curve_draw.c gpencil_data.c gpencil_edit.c gpencil_edit_curve.c diff --cc source/blender/editors/gpencil/gpencil_edit.c index c90d255c413,e65afa1abff..170bbc687d1 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@@ -4693,12 -4538,15 +4693,15 @@@ static int gpencil_stroke_separate_exec bGPdata *gpd_dst = NULL; bGPDlayer *gpl_dst = NULL; bGPDframe *gpf_dst = NULL; - bGPDspoint *pt; Material *ma = NULL; - int i, idx; + int idx; eGP_SeparateModes mode = RNA_enum_get(op->ptr, "mode"); + const bool keep_ends = RNA_boolean_get(op->ptr, "keep_ends"); + const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd_src); + const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd_src); + /* sanity checks */ if (ELEM(NULL, gpd_src)) { return OPERATOR_CANCELLED; @@@ -4757,199 -4613,67 +4775,206 @@@ 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); - } + - /* 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); ++ } ++ + /* add layer if not created before */ + if (gpl_dst == NULL) { + gpl_dst = BKE_gpencil_layer_addnew(gpd_dst, gpl->info, false); + } + + /* 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 @@ 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