[Bf-blender-cvs] [9a82fcb51d6] soc-2020-greasepencil-curve: Merge branch 'soc-2020-greasepencil-curve' of git.blender.org:blender into soc-2020-greasepencil-curve
Commit: 9a82fcb51d6b8835204378dfc181b67f50749e9e Author: Falk David Date: Mon Aug 24 16:43:29 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB9a82fcb51d6b8835204378dfc181b67f50749e9e Merge branch 'soc-2020-greasepencil-curve' of git.blender.org:blender into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [274c8ae9e27] soc-2020-greasepencil-curve: GPencil: Handle strokes with one or two points
Commit: 274c8ae9e27a7ba5290c72c72cbc2fcdb6d7b056 Author: Falk David Date: Mon Aug 24 15:23:36 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB274c8ae9e27a7ba5290c72c72cbc2fcdb6d7b056 GPencil: Handle strokes with one or two points Generating the curve for a stroke with one or two strokes could crash because it was not handled properly. === M source/blender/blenkernel/BKE_gpencil_curve.h M source/blender/blenkernel/intern/gpencil_curve.c M source/blender/editors/gpencil/gpencil_edit.c M source/blender/editors/gpencil/gpencil_edit_curve.c M source/blender/editors/gpencil/gpencil_select.c M source/blender/editors/gpencil/gpencil_utils.c === diff --git a/source/blender/blenkernel/BKE_gpencil_curve.h b/source/blender/blenkernel/BKE_gpencil_curve.h index 3c52b67dfdc..e8c4139384f 100644 --- a/source/blender/blenkernel/BKE_gpencil_curve.h +++ b/source/blender/blenkernel/BKE_gpencil_curve.h @@ -44,10 +44,11 @@ void BKE_gpencil_convert_curve(struct Main *bmain, struct bGPDcurve *BKE_gpencil_stroke_editcurve_generate(struct bGPDstroke *gps, const float error_threshold, -const float corner_angle); -void BKE_gpencil_stroke_editcurve_update(struct bGPDstroke *gps, - const float error_threshold, - const float corner_angle); +const float corner_angle, +const float stroke_radius); +void BKE_gpencil_stroke_editcurve_update(struct bGPdata *gpd, + struct bGPDlayer *gpl, + struct bGPDstroke *gps); void BKE_gpencil_editcurve_stroke_sync_selection(struct bGPDstroke *gps, struct bGPDcurve *gpc); void BKE_gpencil_stroke_editcurve_sync_selection(struct bGPDstroke *gps, struct bGPDcurve *gpc); void BKE_gpencil_strokes_selected_update_editcurve(struct bGPdata *gpd); diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index 0ae6fb6a267..0b4a438c67d 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -563,26 +563,25 @@ void BKE_gpencil_convert_curve(Main *bmain, /** \name Editcurve kernel functions * \{ */ -/** - * Creates a bGPDcurve by doing a cubic curve fitting on the grease pencil stroke points. - */ -bGPDcurve *BKE_gpencil_stroke_editcurve_generate(bGPDstroke *gps, - const float error_threshold, - const float corner_angle) +static bGPDcurve *gpencil_stroke_editcurve_generate_edgecases(bGPDstroke *gps, + const float stroke_radius) { - if (gps->totpoints < 1) { -return NULL; - } - else if (gps->totpoints == 1) { + BLI_assert(gps->totpoints < 3); + + if (gps->totpoints == 1) { bGPDcurve *editcurve = BKE_gpencil_stroke_editcurve_new(1); bGPDspoint *pt = >points[0]; bGPDcurve_point *cpt = >curve_points[0]; BezTriple *bezt = >bezt; +/* Handles are twice as long as the radius of the point. */ +float offset = (pt->pressure * stroke_radius) * 2.0f; + float tmp_vec[3]; for (int j = 0; j < 3; j++) { copy_v3_v3(tmp_vec, >x); - tmp_vec[0] += (j - 1); + /* Move handles along the x-axis away from the control point */ + tmp_vec[0] += (float)(j - 1) * offset; copy_v3_v3(bezt->vec[j], tmp_vec); } @@ -591,13 +590,63 @@ bGPDcurve *BKE_gpencil_stroke_editcurve_generate(bGPDstroke *gps, copy_v4_v4(cpt->vert_color, pt->vert_color); /* default handle type */ -bezt->h1 = HD_ALIGN; -bezt->h2 = HD_ALIGN; +bezt->h1 = HD_FREE; +bezt->h2 = HD_FREE; cpt->point_index = 0; return editcurve; } + if (gps->totpoints == 2) { +bGPDcurve *editcurve = BKE_gpencil_stroke_editcurve_new(2); +bGPDspoint *first_pt = >points[0]; +bGPDspoint *last_pt = >points[1]; + +float length = len_v3v3(_pt->x, _pt->x); +float offset = length / 3; +float dir[3]; +sub_v3_v3v3(dir, _pt->x, _pt->x); + +for (int i = 0; i < 2; i++) { + bGPDspoint *pt = >points[i]; + bGPDcurve_point *cpt = >curve_points[i]; + BezTriple *bezt = >bezt; + + float tmp_vec[3]; + for (int j = 0; j < 3; j++) { +copy_v3_v3(tmp_vec, dir); +normalize_v3_length(tmp_vec, (float)(j - 1) * offset); +add_v3_v3v3(bezt->vec[j]
[Bf-blender-cvs] [3b23ce9992d] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: 3b23ce9992db12f2042a326923ef25db16f062a6 Author: Falk David Date: Mon Aug 24 16:43:21 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB3b23ce9992db12f2042a326923ef25db16f062a6 Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [23f725e78cb] soc-2020-greasepencil-curve: GPencil: Rename parameters
Commit: 23f725e78cbe631283e31792574f0932361a19a8 Author: Falk David Date: Mon Aug 24 16:42:41 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB23f725e78cbe631283e31792574f0932361a19a8 GPencil: Rename parameters === M release/scripts/startup/bl_ui/space_view3d.py M source/blender/blenkernel/intern/gpencil.c M source/blender/blenkernel/intern/gpencil_curve.c M source/blender/blenkernel/intern/gpencil_geom.c M source/blender/blenloader/intern/versioning_290.c M source/blender/makesdna/DNA_gpencil_types.h M source/blender/makesrna/intern/rna_gpencil.c === diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 05aac191c2e..e52d8592fc9 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -6959,7 +6959,7 @@ class VIEW3D_PT_gpencil_curve_edit(Panel): col = layout.column(align=True) col.prop(gpd, "edit_curve_resolution") col.prop(gpd, "curve_edit_threshold") -col.prop(gpd, "curve_corner_angle") +col.prop(gpd, "curve_edit_corner_angle") col.prop(gpd, "use_adaptive_curve_resolution") diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index d6b2a358f63..1bf7429cbdb 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -541,7 +541,7 @@ bGPdata *BKE_gpencil_data_addnew(Main *bmain, const char name[]) gpd->pixfactor = GP_DEFAULT_PIX_FACTOR; - gpd->editcurve_resolution = GP_DEFAULT_CURVE_RESOLUTION; + gpd->curve_edit_resolution = GP_DEFAULT_CURVE_RESOLUTION; gpd->curve_edit_threshold = GP_DEFAULT_CURVE_ERROR; /* use adaptive curve resolution by default */ gpd->flag |= GP_DATA_CURVE_ADAPTIVE_RESOLUTION; diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index 0b4a438c67d..76901f91e34 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -767,7 +767,7 @@ void BKE_gpencil_stroke_editcurve_update(bGPdata *gpd, bGPDlayer *gpl, bGPDstrok float stroke_radius = ((gps->thickness + gpl->line_change) / defaultpixsize) / 2.0f; bGPDcurve *editcurve = BKE_gpencil_stroke_editcurve_generate( - gps, gpd->curve_edit_threshold, gpd->curve_corner_angle, stroke_radius); + gps, gpd->curve_edit_threshold, gpd->curve_edit_corner_angle, stroke_radius); if (editcurve == NULL) { return; } diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c index 691b713cc57..646a77f2638 100644 --- a/source/blender/blenkernel/intern/gpencil_geom.c +++ b/source/blender/blenkernel/intern/gpencil_geom.c @@ -1284,7 +1284,7 @@ void BKE_gpencil_stroke_geometry_update(bGPdata *gpd, bGPDstroke *gps) if (gps->flag & GP_STROKE_NEEDS_CURVE_UPDATE) { bool is_adaptive = gpd->flag & GP_DATA_CURVE_ADAPTIVE_RESOLUTION; BKE_gpencil_stroke_update_geometry_from_editcurve( -gps, gpd->editcurve_resolution, is_adaptive); +gps, gpd->curve_edit_resolution, is_adaptive); gps->flag &= ~GP_STROKE_NEEDS_CURVE_UPDATE; } } diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index 7e614180028..e79fc186503 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -519,9 +519,9 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Keep this block, even when empty. */ /* Init grease pencil default curve resolution. */ -if (!DNA_struct_elem_find(fd->filesdna, "bGPdata", "int", "editcurve_resolution")) { +if (!DNA_struct_elem_find(fd->filesdna, "bGPdata", "int", "curve_edit_resolution")) { LISTBASE_FOREACH (bGPdata *, gpd, >gpencils) { -gpd->editcurve_resolution = GP_DEFAULT_CURVE_RESOLUTION; +gpd->curve_edit_resolution = GP_DEFAULT_CURVE_RESOLUTION; gpd->flag |= GP_DATA_CURVE_ADAPTIVE_RESOLUTION; } } diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h index 3554a1d5851..60d7c5f482f 100644 --- a/source/blender/makesdna/DNA_gpencil_types.h +++ b/source/blender/makesdna/DNA_gpencil_types.h @@ -39,7 +39,7 @@ struct Curve; #define GP_DEFAULT_CURVE_RESOLUTION 32 #define GP_DEFAULT_CURVE_ERROR 0.1f -#define GP_DEFAULT_CURVE_CORNER_ANGLE 1.57079632679489661923 /* pi
[Bf-blender-cvs] [ec36b042808] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: ec36b0428081b585ba58dd485609a1b8cfb8204d Author: Falk David Date: Mon Aug 24 12:34:46 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBec36b0428081b585ba58dd485609a1b8cfb8204d Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [3633a6197e8] soc-2020-greasepencil-curve: GPencil: Fix transform memory issue
Commit: 3633a6197e8a8ca5888e7e613d2f5a6b665bf823 Author: Falk David Date: Fri Aug 21 14:25:10 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB3633a6197e8a8ca5888e7e613d2f5a6b665bf823 GPencil: Fix transform memory issue === M source/blender/editors/transform/transform_convert_gpencil.c === diff --git a/source/blender/editors/transform/transform_convert_gpencil.c b/source/blender/editors/transform/transform_convert_gpencil.c index 5e692798303..0a742ec4470 100644 --- a/source/blender/editors/transform/transform_convert_gpencil.c +++ b/source/blender/editors/transform/transform_convert_gpencil.c @@ -122,7 +122,7 @@ static void createTransGPencil_curves(bContext *C, tc->data_len = 0; /* Number of selected curve points */ - int tot_curve_points = 0, tot_sel_curve_points = 0, tot_points = 0, tot_sel_points = 0; + uint32_t tot_curve_points = 0, tot_sel_curve_points = 0, tot_points = 0, tot_sel_points = 0; LISTBASE_FOREACH (bGPDlayer *, gpl, >layers) { /* Only editable and visible layers are considered. */ if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) { @@ -185,6 +185,11 @@ static void createTransGPencil_curves(bContext *C, } } + if (((is_prop_edit && !is_prop_edit_connected) ? tot_curve_points : tot_sel_points) == 0) { +tc->data_len = 0; +return; + } + int data_len_pt = 0; if (is_prop_edit) { @@ -288,9 +293,10 @@ static void createTransGPencil_curves(bContext *C, const short sel_flag = get_bezt_sel_triple_flag(bezt, handles_visible); /* Iterate over bezier triple */ for (int j = 0; j < 3; j++) { -bool is_ctrl_point = j == 1; -bezt_use |= sel_flag & (1 << j); -if (is_prop_edit || bezt_use) { +bool is_ctrl_point = (j == 1); +bool sel = sel_flag & (1 << j); + +if (is_prop_edit || sel) { copy_v3_v3(td->iloc, bezt->vec[j]); td->loc = bezt->vec[j]; bool rotate_around_ctrl = !handles_visible || @@ -353,6 +359,8 @@ static void createTransGPencil_curves(bContext *C, td++; tail++; } + +bezt_use |= sel; } /* Update the handle types so transformation is possible */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [062595b6f97] soc-2020-greasepencil-curve: GPencil: Report operators that are not implemented
Commit: 062595b6f9706cc89d0d903ddd6ca4f512ee2b4b Author: Falk David Date: Fri Aug 21 15:37:26 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB062595b6f9706cc89d0d903ddd6ca4f512ee2b4b GPencil: Report operators that are not implemented === M source/blender/editors/gpencil/gpencil_edit.c === diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index b0b35ab5465..5f845a85fa6 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -930,7 +930,7 @@ static int gpencil_duplicate_exec(bContext *C, wmOperator *op) bool changed = false; if (is_curve_edit) { -/* TODO: handle copy in curve edit mode */ +BKE_report(op->reports, RPT_ERROR, "Not implemented!"); } else { /* for each visible (and editable) layer's selected strokes, @@ -1501,7 +1501,7 @@ static int gpencil_strokes_copy_exec(bContext *C, wmOperator *op) ED_gpencil_strokes_copybuf_free(); if (is_curve_edit) { -/* TODO: do curve copy */ +BKE_report(op->reports, RPT_ERROR, "Not implemented!"); } else { /* for each visible (and editable) layer's selected strokes, @@ -1698,7 +1698,7 @@ static int gpencil_strokes_paste_exec(bContext *C, wmOperator *op) new_colors = gpencil_copybuf_validate_colormap(C); if (is_curve_edit) { -/* TODO: do curve paste */ +BKE_report(op->reports, RPT_ERROR, "Not implemented!"); } else { /* Copy over the strokes from the buffer (and adjust the colors) */ @@ -3278,7 +3278,7 @@ static int gpencil_snap_to_cursor(bContext *C, wmOperator *op) bool changed = false; if (is_curve_edit) { -/* TODO: snap curve to cursor */ +BKE_report(op->reports, RPT_ERROR, "Not implemented!"); } else { LISTBASE_FOREACH (bGPDlayer *, gpl, >layers) { @@ -3432,7 +3432,7 @@ static bool gpencil_stroke_points_centroid(Depsgraph *depsgraph, return changed; } -static int gpencil_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op)) +static int gpencil_snap_cursor_to_sel(bContext *C, wmOperator *op) { Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *obact = CTX_data_active_object(C); @@ -3451,7 +3451,7 @@ static int gpencil_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op)) bool changed = false; if (is_curve_edit) { -/* TODO: */ +BKE_report(op->reports, RPT_ERROR, "Not implemented!"); } else { changed = gpencil_stroke_points_centroid(depsgraph, C, obact, gpd, centroid, min, max, ); @@ -4123,7 +4123,7 @@ void GPENCIL_OT_stroke_join(wmOperatorType *ot) /** \name Stroke Flip Operator * \{ */ -static int gpencil_stroke_flip_exec(bContext *C, wmOperator *UNUSED(op)) +static int gpencil_stroke_flip_exec(bContext *C, wmOperator *op) { bGPdata *gpd = ED_gpencil_data_get_active(C); Object *ob = CTX_data_active_object(C); @@ -4154,7 +4154,7 @@ static int gpencil_stroke_flip_exec(bContext *C, wmOperator *UNUSED(op)) } if (is_curve_edit) { - /* TODO: flip curve */ + BKE_report(op->reports, RPT_ERROR, "Not implemented!"); } else { /* flip stroke */ @@ -4213,18 +4213,19 @@ static int gpencil_strokes_reproject_exec(bContext *C, wmOperator *op) sctx = ED_transform_snap_object_context_create_view3d(scene, 0, region, CTX_wm_view3d(C)); bool changed = false; - if (is_curve_edit) { -/* TODO: reproject curve */ - } - else { -/* Init space conversion stuff. */ -GP_SpaceConversion gsc = {NULL}; -gpencil_point_conversion_init(C, ); -int cfra_prv = INT_MIN; + /* Init space conversion stuff. */ + GP_SpaceConversion gsc = {NULL}; + gpencil_point_conversion_init(C, ); + int cfra_prv = INT_MIN; -/* Go through each editable + selected stroke, adjusting each of its points one by one... */ -GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) { - if (gps->flag & GP_STROKE_SELECT) { + /* Go through each editable + selected stroke, adjusting each of its points one by one... */ + GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) { +bool curve_select = false; +if (is_curve_edit && gps->editcurve != NULL) { + curve_select = gps->editcurve->flag & GP_CURVE_SELECT; +} + +if (gps->flag & GP_STROKE_SELECT || curve_select) { /* update frame to get the new location of objects */ if ((mode == GP_REPROJECT_SURFACE) && (cfra_prv != gpf_->framenum)) { @@ -4233,13 +4234,22 @@ static int gpencil_strokes_reproject_exec(bContext *C, wmOperator *op) BKE_scene_graph_update_for_newframe(depsgraph); } -ED_gpencil_stroke_reproject
[Bf-blender-cvs] [4474b7c9399] soc-2020-greasepencil-curve: GPencil: Remove unessesary curve edit mode test
Commit: 4474b7c9399c56c756c9db1c3ce66144ff1905d0 Author: Falk David Date: Fri Aug 21 14:26:48 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB4474b7c9399c56c756c9db1c3ce66144ff1905d0 GPencil: Remove unessesary curve edit mode test === M source/blender/editors/gpencil/gpencil_data.c === diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 6b2f547b6a6..c8721a49055 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -3485,7 +3485,6 @@ static int gpencil_set_active_material_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_active_object(C); bGPdata *gpd = ED_gpencil_data_get_active(C); - const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd); /* Sanity checks. */ if (gpd == NULL) { @@ -3494,21 +3493,16 @@ static int gpencil_set_active_material_exec(bContext *C, wmOperator *op) } bool changed = false; - if (is_curve_edit) { -/* TODO: set curve stroke material */ - } - else { -/* Loop all selected strokes. */ -GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) { - if (gps->flag & GP_STROKE_SELECT) { -/* Change Active material. */ -ob->actcol = gps->mat_nr + 1; -changed = true; -break; - } + /* Loop all selected strokes. */ + GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) { +if (gps->flag & GP_STROKE_SELECT) { + /* Change Active material. */ + ob->actcol = gps->mat_nr + 1; + changed = true; + break; } -GP_EDITABLE_STROKES_END(gpstroke_iter); } + GP_EDITABLE_STROKES_END(gpstroke_iter); /* notifiers */ if (changed) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e0985ffcc15] soc-2020-greasepencil-curve: GPencil: Draw transform gizmo curve edit
Commit: e0985ffcc153f0a66f50e013d096009000ca6411 Author: Falk David Date: Fri Aug 21 14:25:46 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBe0985ffcc153f0a66f50e013d096009000ca6411 GPencil: Draw transform gizmo curve edit === M source/blender/editors/transform/transform_gizmo_3d.c === diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c index 14ef5e87534..51601151b87 100644 --- a/source/blender/editors/transform/transform_gizmo_3d.c +++ b/source/blender/editors/transform/transform_gizmo_3d.c @@ -649,6 +649,7 @@ int ED_transform_calc_gizmo_stats(const bContext *C, Object *ob = OBACT(view_layer); bGPdata *gpd = CTX_data_gpencil_data(C); const bool is_gp_edit = GPENCIL_ANY_MODE(gpd); + const bool is_curve_edit = GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd); int a, totsel = 0; const int pivot_point = scene->toolsettings->transform_pivot_point; @@ -707,16 +708,39 @@ int ED_transform_calc_gizmo_stats(const bContext *C, continue; } - /* we're only interested in selected points here... */ - if (gps->flag & GP_STROKE_SELECT) { -bGPDspoint *pt; -int i; + if (is_curve_edit) { +if (gps->editcurve == NULL) { + continue; +} -/* Change selection status of all points, then make the stroke match */ -for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { - if (pt->flag & GP_SPOINT_SELECT) { -calc_tw_center_with_matrix(tbounds, >x, use_mat_local, diff_mat); -totsel++; +bGPDcurve *gpc = gps->editcurve; +if (gpc->flag & GP_CURVE_SELECT) { + for (uint32_t i = 0; i < gpc->tot_curve_points; i++) { +bGPDcurve_point *gpc_pt = >curve_points[i]; +BezTriple *bezt = _pt->bezt; +if (gpc_pt->flag & GP_CURVE_POINT_SELECT) { + for (uint32_t j = 0; j < 3; j++) { +if (BEZT_ISSEL_IDX(bezt, j)) { + calc_tw_center_with_matrix(tbounds, bezt->vec[j], use_mat_local, diff_mat); + totsel++; +} + } +} + } +} + } + else { +/* we're only interested in selected points here... */ +if (gps->flag & GP_STROKE_SELECT) { + bGPDspoint *pt; + int i; + + /* Change selection status of all points, then make the stroke match */ + for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { +if (pt->flag & GP_SPOINT_SELECT) { + calc_tw_center_with_matrix(tbounds, >x, use_mat_local, diff_mat); + totsel++; +} } } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [1e5f65c91bf] soc-2020-greasepencil-curve: GPencil: Fix handle lines display
Commit: 1e5f65c91bf797d980b909425df4f732d8e28bb3 Author: Falk David Date: Fri Aug 21 11:56:09 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB1e5f65c91bf797d980b909425df4f732d8e28bb3 GPencil: Fix handle lines display === M source/blender/draw/engines/overlay/shaders/edit_curve_handle_geom.glsl === diff --git a/source/blender/draw/engines/overlay/shaders/edit_curve_handle_geom.glsl b/source/blender/draw/engines/overlay/shaders/edit_curve_handle_geom.glsl index 9311542a79e..442f69aec7e 100644 --- a/source/blender/draw/engines/overlay/shaders/edit_curve_handle_geom.glsl +++ b/source/blender/draw/engines/overlay/shaders/edit_curve_handle_geom.glsl @@ -53,6 +53,9 @@ void main() bool edge_selected = (((vertFlag[1] | vertFlag[0]) & VERT_SELECTED) != 0); bool handle_selected = (showCurveHandles && (((vertFlag[1] | vertFlag[0]) & VERT_SELECTED_BEZT_HANDLE) != 0)); + /* It reuses freestyle flag because the flag is 8 bits and all are already used and this + * flag is not used in this context. */ + bool is_gpencil = ((vertFlag[1] & EDGE_FREESTYLE) != 0); /* If handle type is only selected and the edge is not selected, don't show. */ if ((curveHandleDisplay != CURVE_HANDLE_ALL) && (!handle_selected)) { @@ -61,6 +64,9 @@ void main() if ((!is_u_segment) && (color_id <= 4)) { return; } +if (is_gpencil) { + return; +} } vec4 inner_color; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [9a89bb4d597] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: 9a89bb4d59731258bb68e149f3e62afdb97c539b Author: Falk David Date: Fri Aug 21 11:04:13 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB9a89bb4d59731258bb68e149f3e62afdb97c539b Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [30014b0616f] soc-2020-greasepencil-curve: GSoC Editing Grease Pencil Strokes Using Curves
Commit: 30014b0616f6837a60a9765cb9a9395cc252603d Author: Falk David Date: Thu Aug 20 10:11:53 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB30014b0616f6837a60a9765cb9a9395cc252603d GSoC Editing Grease Pencil Strokes Using Curves This patch includes all the changes made in the soc-2020-greasepencil-curve branch. Major changes: * Add a new "sub-mode" to grease pencil edit mode called "curve edit mode". * Grease pencil stroke data structure has a pointer to a grease pencil curve. It will be saved with the stroke to the blend file. * Most edit mode operators have been changed to work in curve edit mode. * Transformation code has been adjusted to work for grease pencil curves. * New source file added (gpencil_edit_curve.c) for operators exclusive to curve edit mode. Differential Revision: https://developer.blender.org/D8660 === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2cace77aa16] soc-2020-greasepencil-curve: GPencil: Make parameters const
Commit: 2cace77aa16c566f96023af32fb1682f41f747eb Author: Falk David Date: Fri Aug 21 10:46:35 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB2cace77aa16c566f96023af32fb1682f41f747eb GPencil: Make parameters const === M source/blender/blenkernel/BKE_gpencil.h M source/blender/blenkernel/BKE_gpencil_curve.h M source/blender/blenkernel/intern/gpencil.c M source/blender/blenkernel/intern/gpencil_curve.c === diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h index 429ddf4e551..4ec8609831b 100644 --- a/source/blender/blenkernel/BKE_gpencil.h +++ b/source/blender/blenkernel/BKE_gpencil.h @@ -167,7 +167,7 @@ struct bGPDstroke *BKE_gpencil_stroke_add_existing_style(struct bGPDframe *gpf, int totpoints, short thickness); -struct bGPDcurve *BKE_gpencil_stroke_editcurve_new(int tot_curve_points); +struct bGPDcurve *BKE_gpencil_stroke_editcurve_new(const int tot_curve_points); /* Stroke and Fill - Alpha Visibility Threshold */ #define GPENCIL_ALPHA_OPACITY_THRESH 0.001f diff --git a/source/blender/blenkernel/BKE_gpencil_curve.h b/source/blender/blenkernel/BKE_gpencil_curve.h index 0f6d2f37d29..3c52b67dfdc 100644 --- a/source/blender/blenkernel/BKE_gpencil_curve.h +++ b/source/blender/blenkernel/BKE_gpencil_curve.h @@ -43,18 +43,18 @@ void BKE_gpencil_convert_curve(struct Main *bmain, const float sample); struct bGPDcurve *BKE_gpencil_stroke_editcurve_generate(struct bGPDstroke *gps, -float error_threshold, -float corner_angle); +const float error_threshold, +const float corner_angle); void BKE_gpencil_stroke_editcurve_update(struct bGPDstroke *gps, - float error_threshold, - float corner_angle); + const float error_threshold, + const float corner_angle); void BKE_gpencil_editcurve_stroke_sync_selection(struct bGPDstroke *gps, struct bGPDcurve *gpc); void BKE_gpencil_stroke_editcurve_sync_selection(struct bGPDstroke *gps, struct bGPDcurve *gpc); void BKE_gpencil_strokes_selected_update_editcurve(struct bGPdata *gpd); void BKE_gpencil_strokes_selected_sync_selection_editcurve(struct bGPdata *gpd); void BKE_gpencil_stroke_update_geometry_from_editcurve(struct bGPDstroke *gps, const uint resolution, - bool is_adaptive); + const bool is_adaptive); void BKE_gpencil_editcurve_recalculate_handles(struct bGPDstroke *gps); void BKE_gpencil_editcurve_subdivide(struct bGPDstroke *gps, const int cuts); diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index da6b3808802..d6b2a358f63 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -687,7 +687,7 @@ bGPDstroke *BKE_gpencil_stroke_add_existing_style( return gps; } -bGPDcurve *BKE_gpencil_stroke_editcurve_new(int tot_curve_points) +bGPDcurve *BKE_gpencil_stroke_editcurve_new(const int tot_curve_points) { bGPDcurve *new_gp_curve = (bGPDcurve *)MEM_callocN(sizeof(bGPDcurve), __func__); new_gp_curve->tot_curve_points = tot_curve_points; diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index d8bfa6b1d95..0ae6fb6a267 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -567,8 +567,8 @@ void BKE_gpencil_convert_curve(Main *bmain, * Creates a bGPDcurve by doing a cubic curve fitting on the grease pencil stroke points. */ bGPDcurve *BKE_gpencil_stroke_editcurve_generate(bGPDstroke *gps, - float error_threshold, - float corner_angle) + const float error_threshold, + const float corner_angle) { if (gps->totpoints < 1) { return NULL; @@ -705,8 +705,8 @@ bGPDcurve *BKE_gpencil_stroke_editcurve_generate(bGPDstroke *gps, * Updates the editcurve for a stroke. Frees the old curve if one exists and generates a new one. */ void BKE_gpencil_stroke_editcurve_update(bGPDst
[Bf-blender-cvs] [2758e560a05] soc-2020-greasepencil-curve: GPencil: Recalc transform only in curve edit mode
Commit: 2758e560a05f27da92becbc4ce1f3703067f5f01 Author: Falk David Date: Fri Aug 21 11:03:40 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB2758e560a05f27da92becbc4ce1f3703067f5f01 GPencil: Recalc transform only in curve edit mode When changing the opacity or thickness, only reaclculate stroke if in curve edit mode. === M source/blender/editors/transform/transform_mode_gpopacity.c M source/blender/editors/transform/transform_mode_gpshrinkfatten.c === diff --git a/source/blender/editors/transform/transform_mode_gpopacity.c b/source/blender/editors/transform/transform_mode_gpopacity.c index fdc0bdd3900..0d698f2d039 100644 --- a/source/blender/editors/transform/transform_mode_gpopacity.c +++ b/source/blender/editors/transform/transform_mode_gpopacity.c @@ -29,6 +29,8 @@ #include "BKE_context.h" #include "BKE_unit.h" +#include "DNA_gpencil_types.h" + #include "ED_screen.h" #include "UI_interface.h" @@ -70,8 +72,16 @@ static void applyGPOpacity(TransInfo *t, const int UNUSED(mval[2])) BLI_snprintf(str, sizeof(str), TIP_("Opacity: %3f"), ratio); } + bool recalc = false; FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; +bGPdata *gpd = td->ob->data; +const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd); +/* Only recalculate data when in curve edit mode. */ +if (is_curve_edit) { + recalc = true; +} + for (i = 0; i < tc->data_len; i++, td++) { if (td->flag & TD_SKIP) { continue; @@ -86,8 +96,9 @@ static void applyGPOpacity(TransInfo *t, const int UNUSED(mval[2])) } } - /* GXX: This is only really needed in curve edit mode */ - recalcData(t); + if (recalc) { +recalcData(t); + } ED_area_status_text(t->area, str); } diff --git a/source/blender/editors/transform/transform_mode_gpshrinkfatten.c b/source/blender/editors/transform/transform_mode_gpshrinkfatten.c index 636461bf26d..41e6bebc838 100644 --- a/source/blender/editors/transform/transform_mode_gpshrinkfatten.c +++ b/source/blender/editors/transform/transform_mode_gpshrinkfatten.c @@ -29,6 +29,8 @@ #include "BKE_context.h" #include "BKE_unit.h" +#include "DNA_gpencil_types.h" + #include "ED_screen.h" #include "UI_interface.h" @@ -70,8 +72,16 @@ static void applyGPShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) BLI_snprintf(str, sizeof(str), TIP_("Shrink/Fatten: %3f"), ratio); } + bool recalc = false; FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; +bGPdata *gpd = td->ob->data; +const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd); +/* Only recalculate data when in curve edit mode. */ +if (is_curve_edit) { + recalc = true; +} + for (i = 0; i < tc->data_len; i++, td++) { if (td->flag & TD_SKIP) { continue; @@ -88,8 +98,9 @@ static void applyGPShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) } } - /* GXX: This is only really needed in curve edit mode */ - recalcData(t); + if (recalc) { +recalcData(t); + } ED_area_status_text(t->area, str); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4844379f3fa] soc-2020-greasepencil-curve: Merge branch 'soc-2020-greasepencil-curve' of git.blender.org:blender into soc-2020-greasepencil-curve
Commit: 4844379f3fa768990bfbfe2d338eff4e5dcd5880 Author: Falk David Date: Fri Aug 21 10:36:42 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB4844379f3fa768990bfbfe2d338eff4e5dcd5880 Merge branch 'soc-2020-greasepencil-curve' of git.blender.org:blender into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [3e4fb5b5f18] soc-2020-greasepencil-curve: GPencil: Add corner angle parameter
Commit: 3e4fb5b5f18c7cb6f8485011dab8936f76e294b2 Author: Falk David Date: Thu Aug 20 10:10:09 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB3e4fb5b5f18c7cb6f8485011dab8936f76e294b2 GPencil: Add corner angle parameter === M source/blender/blenkernel/BKE_gpencil_curve.h M source/blender/blenkernel/intern/gpencil_curve.c M source/blender/editors/gpencil/gpencil_edit.c M source/blender/editors/gpencil/gpencil_edit_curve.c M source/blender/editors/gpencil/gpencil_select.c M source/blender/editors/gpencil/gpencil_utils.c M source/blender/makesrna/intern/rna_gpencil.c === diff --git a/source/blender/blenkernel/BKE_gpencil_curve.h b/source/blender/blenkernel/BKE_gpencil_curve.h index 7709b165c11..0f6d2f37d29 100644 --- a/source/blender/blenkernel/BKE_gpencil_curve.h +++ b/source/blender/blenkernel/BKE_gpencil_curve.h @@ -45,7 +45,9 @@ void BKE_gpencil_convert_curve(struct Main *bmain, struct bGPDcurve *BKE_gpencil_stroke_editcurve_generate(struct bGPDstroke *gps, float error_threshold, float corner_angle); -void BKE_gpencil_stroke_editcurve_update(struct bGPDstroke *gps, float error_threshold, float corner_angle); +void BKE_gpencil_stroke_editcurve_update(struct bGPDstroke *gps, + float error_threshold, + float corner_angle); void BKE_gpencil_editcurve_stroke_sync_selection(struct bGPDstroke *gps, struct bGPDcurve *gpc); void BKE_gpencil_stroke_editcurve_sync_selection(struct bGPDstroke *gps, struct bGPDcurve *gpc); void BKE_gpencil_strokes_selected_update_editcurve(struct bGPdata *gpd); diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index 70a9700a1db..d8bfa6b1d95 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -566,7 +566,9 @@ void BKE_gpencil_convert_curve(Main *bmain, /** * Creates a bGPDcurve by doing a cubic curve fitting on the grease pencil stroke points. */ -bGPDcurve *BKE_gpencil_stroke_editcurve_generate(bGPDstroke *gps, float error_threshold, float corner_angle) +bGPDcurve *BKE_gpencil_stroke_editcurve_generate(bGPDstroke *gps, + float error_threshold, + float corner_angle) { if (gps->totpoints < 1) { return NULL; @@ -702,7 +704,9 @@ bGPDcurve *BKE_gpencil_stroke_editcurve_generate(bGPDstroke *gps, float error_th /** * Updates the editcurve for a stroke. Frees the old curve if one exists and generates a new one. */ -void BKE_gpencil_stroke_editcurve_update(bGPDstroke *gps, float error_threshold, float corner_angle) +void BKE_gpencil_stroke_editcurve_update(bGPDstroke *gps, + float error_threshold, + float corner_angle) { if (gps == NULL || gps->totpoints < 0) { return; @@ -1303,14 +1307,16 @@ void BKE_gpencil_strokes_selected_update_editcurve(bGPdata *gpd) /* Generate the curve if there is none or the stroke was changed */ if (gps->editcurve == NULL) { -BKE_gpencil_stroke_editcurve_update(gps, gpd->curve_edit_threshold, gpd->curve_corner_angle); +BKE_gpencil_stroke_editcurve_update( +gps, gpd->curve_edit_threshold, gpd->curve_corner_angle); /* Continue if curve could not be generated. */ if (gps->editcurve == NULL) { continue; } } else if (gps->editcurve->flag & GP_CURVE_NEEDS_STROKE_UPDATE) { -BKE_gpencil_stroke_editcurve_update(gps, gpd->curve_edit_threshold, gpd->curve_corner_angle); +BKE_gpencil_stroke_editcurve_update( +gps, gpd->curve_edit_threshold, gpd->curve_corner_angle); } /* Update the selection from the stroke to the curve. */ BKE_gpencil_editcurve_stroke_sync_selection(gps, gps->editcurve); diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index d4c77598ee8..6d2fa0dbd26 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -209,7 +209,8 @@ static int gpencil_editmode_toggle_exec(bContext *C, wmOperator *op) GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc) { if (gpc->flag & GP_CURVE_NEEDS_STROKE_UPDATE) { -BKE_gpencil_stroke_editcurve_update(gps, gpd->curve_edit_threshold, gpd->curve_corner_angle);
[Bf-blender-cvs] [632b978af94] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: 632b978af94d8d98716abc4a2340d0bc34cc2851 Author: Falk David Date: Thu Aug 20 10:11:53 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB632b978af94d8d98716abc4a2340d0bc34cc2851 Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2be3e78a7b7] soc-2020-greasepencil-curve: GPencil: Skip unused code with macro
Commit: 2be3e78a7b711a89a0cdc6035688e39469fe07dd Author: Falk David Date: Thu Aug 20 10:11:15 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB2be3e78a7b711a89a0cdc6035688e39469fe07dd GPencil: Skip unused code with macro === M source/blender/editors/gpencil/gpencil_select.c === diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index 6690695bad5..36ca15c4ca4 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -1819,13 +1819,15 @@ static bool gpencil_generic_stroke_select(bContext *C, whole = ED_gpencil_stroke_point_is_inside(gps_active, , mval, gpstroke_iter.diff_mat); } -// if (is_curve_edit && (hit || whole) && gps->editcurve == NULL) { -// BKE_gpencil_stroke_editcurve_update(gps, gpd->curve_edit_threshold, gpd->curve_corner_angle); -// BKE_gpencil_curve_sync_selection(gps); -// gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE; -// BKE_gpencil_stroke_geometry_update(gpd, gps); -// changed = true; -// } +#if 0 +if (is_curve_edit && (hit || whole) && gps->editcurve == NULL) { + BKE_gpencil_stroke_editcurve_update(gps, gpd->curve_edit_threshold, gpd->curve_corner_angle); + BKE_gpencil_curve_sync_selection(gps); + gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE; + BKE_gpencil_stroke_geometry_update(gpd, gps); + changed = true; +} +#endif /* if stroke mode expand selection. */ if ((strokemode) || (whole)) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8bd1469d86d] soc-2020-greasepencil-curve: GPencil: Add corner angle parameter
Commit: 8bd1469d86d43fe9e896ea0b487a22ea896fcd17 Author: Falk David Date: Sat Aug 15 13:10:37 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB8bd1469d86d43fe9e896ea0b487a22ea896fcd17 GPencil: Add corner angle parameter This parameter allows the user to control at what angle corners are detected and considered by the fitting algorithm. === M release/scripts/startup/bl_ui/space_view3d.py M source/blender/blenkernel/BKE_gpencil_curve.h M source/blender/blenkernel/intern/gpencil_curve.c M source/blender/editors/gpencil/gpencil_edit.c M source/blender/editors/gpencil/gpencil_edit_curve.c M source/blender/editors/gpencil/gpencil_select.c M source/blender/editors/gpencil/gpencil_utils.c M source/blender/makesdna/DNA_gpencil_types.h M source/blender/makesrna/intern/rna_gpencil.c === diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 72f0128965c..f7070c46078 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -6951,6 +6951,7 @@ class VIEW3D_PT_gpencil_curve_edit(Panel): col = layout.column(align=True) col.prop(gpd, "edit_curve_resolution") col.prop(gpd, "curve_edit_threshold") +col.prop(gpd, "curve_corner_angle") col.prop(gpd, "use_adaptive_curve_resolution") diff --git a/source/blender/blenkernel/BKE_gpencil_curve.h b/source/blender/blenkernel/BKE_gpencil_curve.h index dd41762c046..7709b165c11 100644 --- a/source/blender/blenkernel/BKE_gpencil_curve.h +++ b/source/blender/blenkernel/BKE_gpencil_curve.h @@ -43,8 +43,9 @@ void BKE_gpencil_convert_curve(struct Main *bmain, const float sample); struct bGPDcurve *BKE_gpencil_stroke_editcurve_generate(struct bGPDstroke *gps, -float error_threshold); -void BKE_gpencil_stroke_editcurve_update(struct bGPDstroke *gps, float error_threshold); +float error_threshold, +float corner_angle); +void BKE_gpencil_stroke_editcurve_update(struct bGPDstroke *gps, float error_threshold, float corner_angle); void BKE_gpencil_editcurve_stroke_sync_selection(struct bGPDstroke *gps, struct bGPDcurve *gpc); void BKE_gpencil_stroke_editcurve_sync_selection(struct bGPDstroke *gps, struct bGPDcurve *gpc); void BKE_gpencil_strokes_selected_update_editcurve(struct bGPdata *gpd); diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index 881ce019d32..b82d1552e5e 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -565,7 +565,7 @@ void BKE_gpencil_convert_curve(Main *bmain, /** * Creates a bGPDcurve by doing a cubic curve fitting on the grease pencil stroke points. */ -bGPDcurve *BKE_gpencil_stroke_editcurve_generate(bGPDstroke *gps, float error_threshold) +bGPDcurve *BKE_gpencil_stroke_editcurve_generate(bGPDstroke *gps, float error_threshold, float corner_angle) { if (gps->totpoints < 1) { return NULL; @@ -588,8 +588,8 @@ bGPDcurve *BKE_gpencil_stroke_editcurve_generate(bGPDstroke *gps, float error_th copy_v4_v4(cpt->vert_color, pt->vert_color); /* default handle type */ -bezt->h1 |= HD_ALIGN; -bezt->h2 |= HD_ALIGN; +bezt->h1 = HD_ALIGN; +bezt->h2 = HD_ALIGN; cpt->point_index = 0; @@ -620,9 +620,6 @@ bGPDcurve *BKE_gpencil_stroke_editcurve_generate(bGPDstroke *gps, float error_th calc_flag |= CURVE_FIT_CALC_CYCLIC; } - /* TODO: make this a parameter */ - float corner_angle = M_PI_2; - float *r_cubic_array = NULL; unsigned int r_cubic_array_len = 0; unsigned int *r_cubic_orig_index = NULL; @@ -666,12 +663,26 @@ bGPDcurve *BKE_gpencil_stroke_editcurve_generate(bGPDstroke *gps, float error_th mul_v4_v4fl(cpt->vert_color, _point[5], diag_length); /* default handle type */ -bezt->h1 |= HD_ALIGN; -bezt->h2 |= HD_ALIGN; +bezt->h1 = HD_ALIGN; +bezt->h2 = HD_ALIGN; cpt->point_index = r_cubic_orig_index[i]; } + if (r_corners_index_len > 0 && r_corners_index_array != NULL) { +int start = 0, end = r_corners_index_len; +if ((r_corners_index_len > 1) && (calc_flag & CURVE_FIT_CALC_CYCLIC) == 0) { + start = 1; + end = r_corners_index_len - 1; +} +for (int i = start; i < end; i++) { + bGPDcurve_point *cpt = >curve_points[r_corners_index_array[i]]; + BezTriple *bezt = >bezt; + bezt->h1 = HD_FREE; +
[Bf-blender-cvs] [b221d8d0a32] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: b221d8d0a32a74d912cc0fa204565410eee95dcf Author: Falk David Date: Fri Aug 14 15:07:07 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBb221d8d0a32a74d912cc0fa204565410eee95dcf Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [13bbdc10d8e] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: 13bbdc10d8e61db394b0056795f9f88117f03528 Author: Falk David Date: Sat Aug 15 13:12:48 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB13bbdc10d8e61db394b0056795f9f88117f03528 Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [a0152042b84] soc-2020-greasepencil-curve: GPencil: UI: Move adaptive resolution
Commit: a0152042b846887412c31df8ad4f779a2c400c1c Author: Falk David Date: Thu Aug 13 14:27:34 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBa0152042b846887412c31df8ad4f779a2c400c1c GPencil: UI: Move adaptive resolution Since the adaptive resolution modifies the behaviour of the curve resolution parameter, it makes more sense to put the checkbox underneath the curve resolution silder. === M release/scripts/startup/bl_ui/space_view3d.py === diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 7c9f632dcd2..0c4680ea6ba 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -6992,9 +6992,9 @@ class VIEW3D_PT_gpencil_curve_edit(Panel): layout = self.layout col = layout.column(align=True) -col.prop(gpd, "use_adaptive_curve_resolution") col.prop(gpd, "edit_curve_resolution") col.prop(gpd, "curve_edit_threshold") +col.prop(gpd, "use_adaptive_curve_resolution") class VIEW3D_MT_gpencil_edit_context_menu(Menu): ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4a00c694163] soc-2020-greasepencil-curve: GPencil: Fix add needed gpd reference
Commit: 4a00c694163b1dec222bcfdd34852a7c7bcb7c09 Author: Falk David Date: Sat Aug 15 13:12:09 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB4a00c694163b1dec222bcfdd34852a7c7bcb7c09 GPencil: Fix add needed gpd reference === M source/blender/blenkernel/intern/gpencil_curve.c === diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index b82d1552e5e..943c42c9593 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -305,6 +305,7 @@ static void gpencil_convert_spline(Main *bmain, bGPDframe *gpf, Nurb *nu) { + bGPdata *gpd = (bGPdata *)ob_gp->data; bool cyclic = true; /* Create Stroke. */ @@ -455,7 +456,7 @@ static void gpencil_convert_spline(Main *bmain, } if (sample > 0.0f) { -BKE_gpencil_stroke_sample(gps, sample, false); +BKE_gpencil_stroke_sample(gpd, gps, sample, false); } /* Recalc fill geometry. */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b109537df16] greasepencil-edit-curve: Merge branch 'soc-2020-greasepencil-curve' into greasepencil-edit-curve
Commit: b109537df16e037aab09b3e2ce40e9e9a58ac17d Author: Falk David Date: Thu Aug 13 10:21:29 2020 +0200 Branches: greasepencil-edit-curve https://developer.blender.org/rBb109537df16e037aab09b3e2ce40e9e9a58ac17d Merge branch 'soc-2020-greasepencil-curve' into greasepencil-edit-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c6650146eb1] soc-2020-greasepencil-curve: GPencil: Extrude middle curve points
Commit: c6650146eb1c615293b1371992270520fe262c57 Author: Falk David Date: Wed Aug 12 16:45:03 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBc6650146eb1c615293b1371992270520fe262c57 GPencil: Extrude middle curve points Previously, extruding one of the middle points of a curve would only move the point. Now it creates a new curve from the point selected. === M source/blender/editors/gpencil/gpencil_edit.c === diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 2c5d91bc9ad..82a09a63039 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -206,7 +206,8 @@ static int gpencil_editmode_toggle_exec(bContext *C, wmOperator *op) /* Recalculate editcurves for strokes where the geometry/vertex colors have changed */ if (GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd)) { -GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc) { +GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc) +{ if (gpc->flag & GP_CURVE_NEEDS_STROKE_UPDATE) { BKE_gpencil_stroke_editcurve_update(gps, gpd->curve_edit_threshold); /* Update the selection from the stroke to the curve. */ @@ -1194,6 +1195,41 @@ static void gpencil_curve_extrude_points(bGPdata *gpd, const bool first_select = gpc->curve_points[0].flag & GP_CURVE_POINT_SELECT; const bool last_select = gpc->curve_points[old_num_points - 1].flag & GP_CURVE_POINT_SELECT; + /* iterate over middle points */ + for (int i = 1; i < gpc->tot_curve_points - 1; i++) { +bGPDcurve_point *gpc_pt = >curve_points[i]; + +/* Create new stroke if selected point */ +if (gpc_pt->flag & GP_CURVE_POINT_SELECT) { + bGPDstroke *gps_new = BKE_gpencil_stroke_duplicate(gps, false, false); + gps_new->points = NULL; + gps_new->flag &= ~GP_STROKE_CYCLIC; + gps_new->prev = gps_new->next = NULL; + + gps_new->editcurve = BKE_gpencil_stroke_editcurve_new(2); + bGPDcurve *new_gpc = gps_new->editcurve; + for (int j = 0; j < new_gpc->tot_curve_points; j++) { +bGPDcurve_point *gpc_pt_new = _gpc->curve_points[j]; +memcpy(gpc_pt_new, gpc_pt, sizeof(bGPDcurve_point)); +gpc_pt_new->flag &= ~GP_CURVE_POINT_SELECT; +BEZT_DESEL_ALL(_pt_new->bezt); + } + + /* select last point */ + bGPDcurve_point *gpc_pt_last = _gpc->curve_points[1]; + gpc_pt_last->flag |= GP_CURVE_POINT_SELECT; + BEZT_SEL_ALL(_pt_last->bezt); + + BLI_insertlinkafter(>strokes, gps, gps_new); + + gps_new->flag |= GP_STROKE_NEEDS_CURVE_UPDATE; + BKE_gpencil_stroke_geometry_update(gpd, gps_new); + + gpc_pt->flag &= ~GP_CURVE_POINT_SELECT; + BEZT_DESEL_ALL(_pt->bezt); +} + } + if (first_select || last_select) { int new_num_points = old_num_points; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c934bb5f409] soc-2020-greasepencil-curve: GPencil: Refactor: Make return more explicit
Commit: c934bb5f409fef1afcb08ffecda2c6b2a08bcf56 Author: Falk David Date: Tue Aug 11 17:29:37 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBc934bb5f409fef1afcb08ffecda2c6b2a08bcf56 GPencil: Refactor: Make return more explicit === M source/blender/editors/gpencil/gpencil_vertex_paint.c === diff --git a/source/blender/editors/gpencil/gpencil_vertex_paint.c b/source/blender/editors/gpencil/gpencil_vertex_paint.c index 59b880c2a70..34731e1270c 100644 --- a/source/blender/editors/gpencil/gpencil_vertex_paint.c +++ b/source/blender/editors/gpencil/gpencil_vertex_paint.c @@ -846,7 +846,7 @@ static bool gpencil_vertexpaint_select_stroke(tGP_BrushVertexpaintData *gso, /* Check if the stroke collide with brush. */ if (!ED_gpencil_stroke_check_collision(gsc, gps, gso->mval, radius, diff_mat)) { -return saved; +return false; } if (gps->totpoints == 1) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e99ffb8dcc0] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: e99ffb8dcc0f41841efbd109450a342f931d956c Author: Falk David Date: Sat Aug 8 16:43:25 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBe99ffb8dcc0f41841efbd109450a342f931d956c Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === diff --cc source/blender/blenkernel/intern/gpencil_curve.c index 61951cb9ff3,d53e712326b..633cb755577 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@@ -55,12 -55,8 +55,12 @@@ #define COORD_FITTING_INFLUENCE 20.0f +/* */ +/** \name Convert to curve object + * \{ */ + /* Helper: Check materials with same color. */ - static int gpencil_check_same_material_color(Object *ob_gp, float color[4], Material **r_mat) + static int gpencil_check_same_material_color(Object *ob_gp, const float color[4], Material **r_mat) { Material *ma = NULL; float color_cu[4]; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [0ae02b130a7] soc-2020-greasepencil-curve: GPencil: Split transform code
Commit: 0ae02b130a78237a8850b616da99edfe8e5fc66d Author: Falk David Date: Sat Aug 8 16:39:05 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB0ae02b130a78237a8850b616da99edfe8e5fc66d GPencil: Split transform code This commit splits the grease pencil transform code, so that editcurves and strokes get handled separately. This fixes a bug where in normal edit mode, proportional editing would be very slow. The center point of the transform is also more predictable and behaves similar to bezier triples in curve objects. === M source/blender/editors/transform/transform_convert_gpencil.c M source/blender/editors/transform/transform_generics.c === diff --git a/source/blender/editors/transform/transform_convert_gpencil.c b/source/blender/editors/transform/transform_convert_gpencil.c index 8f4a44c6a34..deb6e6e27aa 100644 --- a/source/blender/editors/transform/transform_convert_gpencil.c +++ b/source/blender/editors/transform/transform_convert_gpencil.c @@ -46,27 +46,6 @@ * * \{ */ -static void createTransGPencil_curve_center_get(bGPDcurve *gpc, float r_center[3]) -{ - zero_v3(r_center); - int tot_sel = 0; - for (int i = 0; i < gpc->tot_curve_points; i++) { -bGPDcurve_point *gpc_pt = >curve_points[i]; -if (gpc_pt->flag & GP_CURVE_POINT_SELECT) { - BezTriple *bezt = _pt->bezt; - /* only allow rotation around control point for now... */ - if (bezt->f2 & SELECT) { -add_v3_v3(r_center, bezt->vec[1]); -tot_sel++; - } -} - } - - if (tot_sel > 0) { -mul_v3_fl(r_center, 1.0f / tot_sel); - } -} - static void createTransGPencil_center_get(bGPDstroke *gps, float r_center[3]) { bGPDspoint *pt; @@ -86,55 +65,190 @@ static void createTransGPencil_center_get(bGPDstroke *gps, float r_center[3]) } } -void createTransGPencil(bContext *C, TransInfo *t) +static short get_bezt_sel_triple_flag(BezTriple *bezt, const bool handles_visible) { - if (t->data_container_len == 0) { -return; - } +#define SEL_F1 (1 << 0) +#define SEL_F2 (1 << 1) +#define SEL_F3 (1 << 2) +#define SEL_ALL ((1 << 0) | (1 << 1) | (1 << 2)) - Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); - const Scene *scene = CTX_data_scene(C); - ToolSettings *ts = scene->toolsettings; - Object *obact = CTX_data_active_object(C); - bGPdata *gpd = obact->data; - BLI_assert(gpd != NULL); + short flag = 0; - TransData *td = NULL; - float mtx[3][3], smtx[3][3]; + if (handles_visible) { +flag = ((bezt->f1 & SELECT) ? SEL_F1 : 0) | ((bezt->f2 & SELECT) ? SEL_F2 : 0) | + ((bezt->f3 & SELECT) ? SEL_F3 : 0); + } + else { +if (bezt->f2 & SELECT) { + flag = SEL_ALL; +} + } - const int cfra_scene = CFRA; + /* Special case for auto & aligned handles */ + if (flag != SEL_ALL && flag & SEL_F2) { +if (ELEM(bezt->h1, HD_AUTO, HD_ALIGN) && ELEM(bezt->h2, HD_AUTO, HD_ALIGN)) { + flag = SEL_ALL; +} + } - const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); - const bool use_multiframe_falloff = (ts->gp_sculpt.flag & GP_SCULPT_SETT_FLAG_FRAME_FALLOFF) != - 0; - const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd); +#undef SEL_F1 +#undef SEL_F2 +#undef SEL_F3 + return flag; +} - const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0; - const bool is_prop_edit_connected = (t->flag & T_PROP_CONNECTED) != 0; - const bool is_scale_thickness = ((t->mode == TFM_GPENCIL_SHRINKFATTEN) || - (ts->gp_sculpt.flag & GP_SCULPT_SETT_FLAG_SCALE_THICKNESS)); +static void createTransGPencil_curves(bContext *C, + TransInfo *t, + Depsgraph *depsgraph, + ToolSettings *ts, + Object *obact, + bGPdata *gpd, + const int cfra_scene, + const bool is_multiedit, + const bool use_multiframe_falloff, + const bool is_prop_edit, + const bool is_prop_edit_connected, + const bool is_scale_thickness) +{ +#define SEL_F1 (1 << 0) +#define SEL_F2 (1 << 1) +#define SEL_F3 (1 << 2) - TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t); + View3D *v3d = t->view; + const bool handle_only_selected_visible = (v3d->overlay.handle_display == CURVE_HANDLE_SELECTED); + const bool handle_a
[Bf-blender-cvs] [acd92bfd288] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: acd92bfd2887abb0fb34c6e61ff81d90ff4bcdb2 Author: Falk David Date: Sat Aug 8 12:04:02 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBacd92bfd2887abb0fb34c6e61ff81d90ff4bcdb2 Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d6b842205f0] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: d6b842205f0c179309d7f6f862aa89046fffef82 Author: Falk David Date: Mon Aug 3 00:26:58 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBd6b842205f0c179309d7f6f862aa89046fffef82 Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c825d70811f] soc-2020-greasepencil-curve: GPencil: Implement basic extrude support
Commit: c825d70811f38202b2ec9fc945db61b104f39139 Author: Falk David Date: Mon Aug 3 00:23:30 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBc825d70811f38202b2ec9fc945db61b104f39139 GPencil: Implement basic extrude support === M source/blender/editors/gpencil/gpencil_edit.c === diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 61fe7c7e905..c4d151f674d 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -1167,6 +1167,54 @@ static void gpencil_add_move_points(bGPdata *gpd, bGPDframe *gpf, bGPDstroke *gp } } +static void gpencil_curve_extrude_points(bGPdata *gpd, + bGPDframe *gpf, + bGPDstroke *gps, + bGPDcurve *gpc) +{ + const int old_num_points = gpc->tot_curve_points; + const bool first_select = gpc->curve_points[0].flag & GP_CURVE_POINT_SELECT; + const bool last_select = gpc->curve_points[old_num_points - 1].flag & GP_CURVE_POINT_SELECT; + + if (first_select || last_select) { +int new_num_points = old_num_points; + +if (first_select) { + new_num_points++; +} +if (last_select) { + new_num_points++; +} + +/* Grow the array */ +gpc->tot_curve_points = new_num_points; +gpc->curve_points = MEM_recallocN(gpc->curve_points, sizeof(bGPDcurve_point) * new_num_points); + +if (first_select) { + /* shift points by one */ + memmove( + >curve_points[1], >curve_points[0], sizeof(bGPDcurve_point) * old_num_points); + + bGPDcurve_point *old_first = >curve_points[1]; + + old_first->flag &= GP_CURVE_POINT_SELECT; + BEZT_DESEL_ALL(_first->bezt); +} + +if (last_select) { + bGPDcurve_point *old_last = >curve_points[gpc->tot_curve_points - 2]; + bGPDcurve_point *new_last = >curve_points[gpc->tot_curve_points - 1]; + memcpy(new_last, old_last, sizeof(bGPDcurve_point)); + + old_last->flag &= GP_CURVE_POINT_SELECT; + BEZT_DESEL_ALL(_last->bezt); +} + +gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE; +BKE_gpencil_stroke_geometry_update(gpd, gps); + } +} + static int gpencil_extrude_exec(bContext *C, wmOperator *op) { Object *obact = CTX_data_active_object(C); @@ -1181,40 +1229,46 @@ static int gpencil_extrude_exec(bContext *C, wmOperator *op) } bool changed = false; - if (is_curve_edit) { -/* TODO: do curve extude */ - } - else { -CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) { - bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe; + CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) { +bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe; - for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) { -if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) { - if (gpf == NULL) { +for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) { + if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) { +if (gpf == NULL) { + continue; +} + +for (gps = gpf->strokes.first; gps; gps = gps->next) { + /* skip strokes that are invalid for current view */ + if (ED_gpencil_stroke_can_use(C, gps) == false) { continue; } - for (gps = gpf->strokes.first; gps; gps = gps->next) { -/* skip strokes that are invalid for current view */ -if (ED_gpencil_stroke_can_use(C, gps) == false) { + if (is_curve_edit) { +if (gps->editcurve == NULL) { continue; } - +bGPDcurve *gpc = gps->editcurve; +if (gpc->flag & GP_CURVE_SELECT) { + gpencil_curve_extrude_points(gpd, gpf, gps, gpc); +} + } + else { if (gps->flag & GP_STROKE_SELECT) { gpencil_add_move_points(gpd, gpf, gps); - - changed = true; } } - /* if not multiedit, exit loop*/ - if (!is_multiedit) { -break; - } + + changed = true; +} +/* if not multiedit, exit loop*/ +if (!is_multiedit) { + break; } } } -CTX_DATA_END; } + CTX_DATA_END; if (changed) { /* updates */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [944ba1b38d0] soc-2020-greasepencil-curve: GPencil: Add snap to grid for curve points
Commit: 944ba1b38d01d6d5f578c57bf0efe519e8a79da2 Author: Falk David Date: Sat Aug 1 15:50:01 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB944ba1b38d01d6d5f578c57bf0efe519e8a79da2 GPencil: Add snap to grid for curve points === M source/blender/editors/gpencil/gpencil_edit.c === diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index c4d151f674d..57c04d3c232 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -3091,34 +3091,73 @@ static int gpencil_snap_to_grid(bContext *C, wmOperator *UNUSED(op)) const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd); bool changed = false; - if (is_curve_edit) { -/* TODO: snap curve points */ - } - else { -LISTBASE_FOREACH (bGPDlayer *, gpl, >layers) { - /* only editable and visible layers are considered */ - if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) { -bGPDframe *gpf = gpl->actframe; -float diff_mat[4][4]; + LISTBASE_FOREACH (bGPDlayer *, gpl, >layers) { +/* only editable and visible layers are considered */ +if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) { + bGPDframe *gpf = gpl->actframe; + float diff_mat[4][4]; -/* calculate difference matrix object */ -BKE_gpencil_parent_matrix_get(depsgraph, obact, gpl, diff_mat); + /* calculate difference matrix object */ + BKE_gpencil_parent_matrix_get(depsgraph, obact, gpl, diff_mat); -LISTBASE_FOREACH (bGPDstroke *, gps, >strokes) { - bGPDspoint *pt; - int i; + LISTBASE_FOREACH (bGPDstroke *, gps, >strokes) { +/* skip strokes that are invalid for current view */ +if (ED_gpencil_stroke_can_use(C, gps) == false) { + continue; +} +/* check if the color is editable */ +if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false) { + continue; +} - /* skip strokes that are invalid for current view */ - if (ED_gpencil_stroke_can_use(C, gps) == false) { +if (is_curve_edit) { + if (gps->editcurve == NULL) { continue; } - /* check if the color is editable */ - if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false) { -continue; + float inv_diff_mat[4][4]; + invert_m4_m4_safe(inv_diff_mat, diff_mat); + + bGPDcurve *gpc = gps->editcurve; + for (int i = 0; i < gpc->tot_curve_points; i++) { +bGPDcurve_point *gpc_pt = >curve_points[i]; +BezTriple *bezt = _pt->bezt; +if (gpc_pt->flag & GP_CURVE_POINT_SELECT) { + float tmp0[3], tmp1[3], tmp2[3], offset[3]; + mul_v3_m4v3(tmp0, diff_mat, bezt->vec[0]); + mul_v3_m4v3(tmp1, diff_mat, bezt->vec[1]); + mul_v3_m4v3(tmp2, diff_mat, bezt->vec[2]); + + /* calculate the offset vector */ + offset[0] = gridf * floorf(0.5f + tmp1[0] / gridf) - tmp1[0]; + offset[1] = gridf * floorf(0.5f + tmp1[1] / gridf) - tmp1[1]; + offset[2] = gridf * floorf(0.5f + tmp1[2] / gridf) - tmp1[2]; + + /* shift bezTriple */ + add_v3_v3(bezt->vec[0], offset); + add_v3_v3(bezt->vec[1], offset); + add_v3_v3(bezt->vec[2], offset); + + mul_v3_m4v3(tmp0, inv_diff_mat, bezt->vec[0]); + mul_v3_m4v3(tmp1, inv_diff_mat, bezt->vec[1]); + mul_v3_m4v3(tmp2, inv_diff_mat, bezt->vec[2]); + copy_v3_v3(bezt->vec[0], tmp0); + copy_v3_v3(bezt->vec[1], tmp1); + copy_v3_v3(bezt->vec[2], tmp2); + + changed = true; +} } + if (changed) { +BKE_gpencil_editcurve_recalculate_handles(gps); +gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE; +BKE_gpencil_stroke_geometry_update(gpd, gps); + } +} +else { // TODO: if entire stroke is selected, offset entire stroke by same amount? - for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { + for (int i = 0; i < gps->totpoints; i++) { +bGPDspoint *pt = >points[i]; /* only if point is selected */ if (pt->flag & GP_SPOINT_SELECT) { /* apply parent transformations */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [331e1639c49] soc-2020-greasepencil-curve: GPencil: Fix curve point deletion in cyclic curve
Commit: 331e1639c49989e83da3467e1d9a3dc41a197ac3 Author: Falk David Date: Thu Jul 30 14:52:29 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB331e1639c49989e83da3467e1d9a3dc41a197ac3 GPencil: Fix curve point deletion in cyclic curve === M source/blender/blenkernel/intern/gpencil_curve.c M source/blender/editors/gpencil/gpencil_edit.c === diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index 2d1fe8fccd6..96bee649844 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -988,7 +988,7 @@ void BKE_gpencil_editcurve_recalculate_handles(bGPDstroke *gps) bool changed = false; bGPDcurve *gpc = gps->editcurve; - if (gpc->tot_curve_points < 1) { + if (gpc->tot_curve_points < 2) { return; } diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 962aeb692bf..61fe7c7e905 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -2057,7 +2057,6 @@ typedef enum eGP_DissolveMode { static int gpencil_delete_selected_strokes(bContext *C) { bGPdata *gpd = ED_gpencil_data_get_active(C); - const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd); const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); bool changed = false; @@ -2720,19 +2719,22 @@ void gpencil_stroke_delete_tagged_points(bGPdata *gpd, BKE_gpencil_free_stroke(gps); } -void gpencil_curve_delete_tagged_points(bGPdata *gpd, -bGPDframe *gpf, -bGPDstroke *gps, -bGPDstroke *next_stroke, -bGPDcurve *gpc, -int tag_flags, -bool select, -int limit) +static void gpencil_curve_delete_tagged_points(bGPdata *gpd, + bGPDframe *gpf, + bGPDstroke *gps, + bGPDstroke *next_stroke, + bGPDcurve *gpc, + int tag_flags, + bool select, + int limit) { if (gpc == NULL) { return; } const bool is_cyclic = gps->flag & GP_STROKE_CYCLIC; + const int idx_last = gpc->tot_curve_points - 1; + bGPDstroke *gps_first = NULL; + bGPDstroke *gps_last = NULL; int idx_start = 0; int idx_end = 0; @@ -2742,16 +2744,35 @@ void gpencil_curve_delete_tagged_points(bGPdata *gpd, if (prev_selected == true && selected == false) { idx_start = i; } -if ((prev_selected == false && selected == true) || -(selected == false && i == gpc->tot_curve_points - 1)) { - idx_end = selected ? i - 1 : i; +/* Island ends if the current point is selected or if we reached the end of the stroke */ +if ((prev_selected == false && selected == true) || (selected == false && i == idx_last)) { + idx_end = selected ? i - 1 : i; int island_length = idx_end - idx_start + 1; + + /* If an island has only a single curve point, there is no curve segment, so skip island */ + if (island_length == 1) { +if (is_cyclic) { + if (idx_start > 0 && idx_end < idx_last) { +prev_selected = selected; +continue; + } +} +else { + prev_selected = selected; + continue; +} + } + bGPDstroke *new_stroke = BKE_gpencil_stroke_duplicate(gps, false, false); new_stroke->points = NULL; new_stroke->flag &= ~GP_STROKE_CYCLIC; new_stroke->editcurve = BKE_gpencil_stroke_editcurve_new(island_length); + if (gps_first == NULL) { +gps_first = new_stroke; + } + bGPDcurve *new_gpc = new_stroke->editcurve; memcpy(new_gpc->curve_points, gpc->curve_points + idx_start, @@ -2769,10 +2790,38 @@ void gpencil_curve_delete_tagged_points(bGPdata *gpd, else { BLI_addtail(>strokes, new_stroke); } + + gps_last = new_stroke; } prev_selected = selected; } + /* join first and last stroke if cyclic */ + if (is_cyclic && gps_first != NULL && gps_last != NULL && gps_first != gps_last) { +bGPDcurve *gpc_first = gps_first->editcurve; +bGPDcurve *gpc_last = gps_last->
[Bf-blender-cvs] [438378b59d3] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: 438378b59d37454f6124e308da8f98fb17e27f44 Author: Falk David Date: Thu Jul 30 14:53:42 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB438378b59d37454f6124e308da8f98fb17e27f44 Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === diff --cc source/blender/editors/gpencil/gpencil_interpolate.c index 2261908407f,b40211ce527..fb27aba431d --- a/source/blender/editors/gpencil/gpencil_interpolate.c +++ b/source/blender/editors/gpencil/gpencil_interpolate.c @@@ -603,7 -603,9 +603,9 @@@ static int gpencil_interpolate_modal(bC } /* make copy of source stroke, then adjust pointer to points too */ - gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true); + gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true, true); + gps_dst->flag &= ~GP_STROKE_TAG; + /* Calc geometry data. */ BKE_gpencil_stroke_geometry_update(tgpi->gpd, gps_dst); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f2e2913a583] soc-2020-greasepencil-curve: GPencil: Handle single point curve
Commit: f2e2913a5838082ba1af65cf2c551316f2a0c889 Author: Falk David Date: Tue Jul 28 11:20:57 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBf2e2913a5838082ba1af65cf2c551316f2a0c889 GPencil: Handle single point curve === M source/blender/blenkernel/intern/gpencil_curve.c === diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index 19f14e92443..2d1fe8fccd6 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -55,6 +55,10 @@ #define COORD_FITTING_INFLUENCE 20.0f +/* */ +/** \name Convert to curve object + * \{ */ + /* Helper: Check materials with same color. */ static int gpencil_check_same_material_color(Object *ob_gp, float color[4], Material **r_mat) { @@ -466,15 +470,46 @@ void BKE_gpencil_convert_curve(Main *bmain, DEG_id_tag_update(>id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE); } +/** \} */ + +/* */ +/** \name Editcurve kernel functions + * \{ */ + /** * Creates a bGPDcurve by doing a cubic curve fitting on the grease pencil stroke points. */ bGPDcurve *BKE_gpencil_stroke_editcurve_generate(bGPDstroke *gps, float error_threshold) { -#define POINT_DIM 9 if (gps->totpoints < 1) { return NULL; } + else if (gps->totpoints == 1) { +bGPDcurve *editcurve = BKE_gpencil_stroke_editcurve_new(1); +bGPDspoint *pt = >points[0]; +bGPDcurve_point *cpt = >curve_points[0]; +BezTriple *bezt = >bezt; + +float tmp_vec[3]; +for (int j = 0; j < 3; j++) { + copy_v3_v3(tmp_vec, >x); + tmp_vec[0] += (j - 1); + copy_v3_v3(bezt->vec[j], tmp_vec); +} + +cpt->pressure = pt->pressure; +cpt->strength = pt->strength; +copy_v4_v4(cpt->vert_color, pt->vert_color); + +/* default handle type */ +bezt->h1 |= HD_ALIGN; +bezt->h2 |= HD_ALIGN; + +cpt->point_index = 0; + +return editcurve; + } +#define POINT_DIM 9 float *points = MEM_callocN(sizeof(float) * gps->totpoints * POINT_DIM, __func__); float diag_length = len_v3v3(gps->boundbox_min, gps->boundbox_max); @@ -688,7 +723,7 @@ static void gpencil_interpolate_fl_from_to( float *r = point_offset; for (int i = 0; i <= it; i++) { float fac = (float)i / (float)it; -fac = 3.0f * fac * fac - 2.0f * fac * fac * fac; // smooth +fac = 3.0f * fac * fac - 2.0f * fac * fac * fac; // smooth *r = interpf(to, from, fac); r = POINTER_OFFSET(r, stride); } @@ -701,7 +736,7 @@ static void gpencil_interpolate_v4_from_to( float *r = point_offset; for (int i = 0; i <= it; i++) { float fac = (float)i / (float)it; -fac = 3.0f * fac * fac - 2.0f * fac * fac * fac; // smooth +fac = 3.0f * fac * fac - 2.0f * fac * fac * fac; // smooth interp_v4_v4v4(r, from, to, fac); r = POINTER_OFFSET(r, stride); } @@ -766,7 +801,7 @@ static float *gpencil_stroke_points_from_editcurve_adaptive_resolu( const uint num_segments = (is_cyclic) ? curve_point_array_len : curve_point_array_len - 1; int *segment_point_lengths = MEM_callocN(sizeof(int) * num_segments, __func__); - uint points_len = 0; + uint points_len = 1; for (int i = 0; i < cpt_last; i++) { bGPDcurve_point *cpt = _point_array[i]; bGPDcurve_point *cpt_next = _point_array[i + 1]; @@ -786,7 +821,6 @@ static float *gpencil_stroke_points_from_editcurve_adaptive_resolu( segment_point_lengths[cpt_last] = segment_resolu; points_len += segment_resolu; } - points_len += 1; float(*r_points)[9] = MEM_callocN((stride * points_len * (is_cyclic ? 2 : 1)), __func__); float *points_offset = _points[0][0]; @@ -873,6 +907,33 @@ void BKE_gpencil_stroke_update_geometry_from_editcurve(bGPDstroke *gps, bGPDcurve *editcurve = gps->editcurve; bGPDcurve_point *curve_point_array = editcurve->curve_points; int curve_point_array_len = editcurve->tot_curve_points; + if (curve_point_array_len == 0) { +return; + } + else if (curve_point_array_len == 1) { +bGPDcurve_point *cpt = _point_array[0]; +/* resize stroke point array */ +gps->totpoints = 1; +gps->points = MEM_recallocN(gps->points, sizeof(bGPDspoint) * gps->totpoints); +if (gps->dvert != NULL) { + gps->dvert = MEM_recallocN(gps->dvert, sizeof(MDeformVert) * gps->totpoints); +} + +bGPDspoint *pt = >points[0]; +copy_v3_v3(>x, >bezt.vec[0]); + +pt->pressure = cpt->pressure; +pt->strength = cpt->strength; + +copy_v4_v4(pt->vert_color, >vert_color); + +/* d
[Bf-blender-cvs] [1a9b0127d96] greasepencil-object: Merge branch 'greasepencil-object' of git.blender.org:blender into greasepencil-object
Commit: 1a9b0127d96ea9f3553da462173fd68c5a0a2fbd Author: Falk David Date: Tue Jul 28 21:06:42 2020 +0200 Branches: greasepencil-object https://developer.blender.org/rB1a9b0127d96ea9f3553da462173fd68c5a0a2fbd Merge branch 'greasepencil-object' of git.blender.org:blender into greasepencil-object === === diff --cc source/blender/blenkernel/intern/gpencil_geom.c index cb88fffac33,99b9134d5e0..3505a77e52f --- a/source/blender/blenkernel/intern/gpencil_geom.c +++ b/source/blender/blenkernel/intern/gpencil_geom.c @@@ -3110,87 -3108,8 +3111,89 @@@ bGPDstroke *BKE_gpencil_stroke_perimete perimeter_stroke->flag |= GP_STROKE_SELECT | GP_STROKE_CYCLIC; + BKE_gpencil_free_stroke(gps_temp); + return perimeter_stroke; } + +/** + * Calculates the perimeter of a stroke projected from the view and + * returns it as a flat 2D stroke. + * \param subdivisions: Number of subdivions for the start and end caps + * \return: bGPDstroke pointer to stroke perimeter + */ +bGPDstroke *BKE_gpencil_stroke_perimeter_from_view_2d(struct ARegion *region, + const bGPdata *gpd, + const bGPDlayer *gpl, + bGPDstroke *gps, + int subdivisions, + float diff_mat[4][4]) +{ + if (gps->totpoints == 0) { +return NULL; + } + RegionView3D *rv3d = (RegionView3D *)region->regiondata; + bGPDstroke *gps_cpy = BKE_gpencil_stroke_duplicate(gps, true); + BKE_gpencil_stroke_to_view_space(rv3d, gps_cpy, diff_mat); + + int num_perimeter_points = 0; + ListBase *perimeter_points = gpencil_stroke_perimeter_ex( + gpd, gpl, gps_cpy, subdivisions, _perimeter_points); + + if (num_perimeter_points == 0) { +return NULL; + } + + /* create new stroke */ + bGPDstroke *perimeter_stroke = BKE_gpencil_stroke_new(gps->mat_nr, num_perimeter_points, 1); + + tPerimeterPoint *curr = perimeter_points->first; + for (int i = 0; i < num_perimeter_points; i++) { +bGPDspoint *pt = _stroke->points[i]; + +// float vec4[3]; +// copy_v4_v4(); +// const float scalar = (vec4[3] != 0.0f) ? (1.0f / vec4[3]) : 0.0f; +// const float fx = ((float)region->winx / 2.0f) * (1.0f + (vec4[0] * scalar)); +// const float fy = ((float)region->winy / 2.0f) * (1.0f + (vec4[1] * scalar)); + +copy_v3_v3(>x, >x); + +/* Set pressure to zero and strength to one */ +pt->pressure = 0.0f; +pt->strength = 1.0f; + +pt->flag |= GP_SPOINT_SELECT; + +curr = curr->next; + } + + BKE_gpencil_stroke_from_view_space(rv3d, perimeter_stroke, diff_mat); + for (int i = 0; i < num_perimeter_points; i++) { +bGPDspoint *pt = _stroke->points[i]; +float parent_co[3]; +mul_v3_m4v3(parent_co, diff_mat, >x); +float screen_co[2]; +// eV3DProjTest test = (eV3DProjTest)(V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN); +eV3DProjTest test = (eV3DProjTest)(V3D_PROJ_RET_OK); +if (ED_view3d_project_float_global(region, parent_co, screen_co, test) == V3D_PROJ_RET_OK) { + if (!ELEM(V2D_IS_CLIPPED, screen_co[0], screen_co[1])) { +copy_v2_v2(>x, screen_co); +pt->z = 0.0f; + } +} + } + + /* free temp data */ + BLI_freelistN(perimeter_points); + MEM_freeN(perimeter_points); + BKE_gpencil_free_stroke(gps_cpy); + + /* triangles cache needs to be recalculated */ + BKE_gpencil_stroke_geometry_update(perimeter_stroke); + + perimeter_stroke->flag |= GP_STROKE_SELECT | GP_STROKE_CYCLIC | GP_STROKE_2DSPACE; + + return perimeter_stroke; +} /** \} */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [83854be4607] greasepencil-object: GPencil: Add 2d stroke perimeter function
Commit: 83854be46075b223f2c441beb5ddfdb30316a9d6 Author: Falk David Date: Tue Jul 28 21:06:34 2020 +0200 Branches: greasepencil-object https://developer.blender.org/rB83854be46075b223f2c441beb5ddfdb30316a9d6 GPencil: Add 2d stroke perimeter function === M source/blender/blenkernel/BKE_gpencil_geom.h M source/blender/blenkernel/intern/gpencil_geom.c === diff --git a/source/blender/blenkernel/BKE_gpencil_geom.h b/source/blender/blenkernel/BKE_gpencil_geom.h index 610b113c5d0..87fa55c201d 100644 --- a/source/blender/blenkernel/BKE_gpencil_geom.h +++ b/source/blender/blenkernel/BKE_gpencil_geom.h @@ -142,6 +142,12 @@ struct bGPDstroke *BKE_gpencil_stroke_perimeter_from_view(struct RegionView3D *r struct bGPDstroke *gps, int subdivisions, float diff_mat[4][4]); +struct bGPDstroke *BKE_gpencil_stroke_perimeter_from_view_2d(struct ARegion *region, + const struct bGPdata *gpd, + const struct bGPDlayer *gpl, + struct bGPDstroke *gps, + int subdivisions, + float diff_mat[4][4]); #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c index 5afe05ed168..cb88fffac33 100644 --- a/source/blender/blenkernel/intern/gpencil_geom.c +++ b/source/blender/blenkernel/intern/gpencil_geom.c @@ -54,6 +54,9 @@ #include "BKE_material.h" #include "BKE_object.h" +#include "UI_view2d.h" +#include "ED_view3d.h" + #include "DEG_depsgraph_query.h" /* GP Object - Boundbox Support */ @@ -3109,4 +3112,85 @@ bGPDstroke *BKE_gpencil_stroke_perimeter_from_view(struct RegionView3D *rv3d, return perimeter_stroke; } + +/** + * Calculates the perimeter of a stroke projected from the view and + * returns it as a flat 2D stroke. + * \param subdivisions: Number of subdivions for the start and end caps + * \return: bGPDstroke pointer to stroke perimeter + */ +bGPDstroke *BKE_gpencil_stroke_perimeter_from_view_2d(struct ARegion *region, + const bGPdata *gpd, + const bGPDlayer *gpl, + bGPDstroke *gps, + int subdivisions, + float diff_mat[4][4]) +{ + if (gps->totpoints == 0) { +return NULL; + } + RegionView3D *rv3d = (RegionView3D *)region->regiondata; + bGPDstroke *gps_cpy = BKE_gpencil_stroke_duplicate(gps, true); + BKE_gpencil_stroke_to_view_space(rv3d, gps_cpy, diff_mat); + + int num_perimeter_points = 0; + ListBase *perimeter_points = gpencil_stroke_perimeter_ex( + gpd, gpl, gps_cpy, subdivisions, _perimeter_points); + + if (num_perimeter_points == 0) { +return NULL; + } + + /* create new stroke */ + bGPDstroke *perimeter_stroke = BKE_gpencil_stroke_new(gps->mat_nr, num_perimeter_points, 1); + + tPerimeterPoint *curr = perimeter_points->first; + for (int i = 0; i < num_perimeter_points; i++) { +bGPDspoint *pt = _stroke->points[i]; + +// float vec4[3]; +// copy_v4_v4(); +// const float scalar = (vec4[3] != 0.0f) ? (1.0f / vec4[3]) : 0.0f; +// const float fx = ((float)region->winx / 2.0f) * (1.0f + (vec4[0] * scalar)); +// const float fy = ((float)region->winy / 2.0f) * (1.0f + (vec4[1] * scalar)); + +copy_v3_v3(>x, >x); + +/* Set pressure to zero and strength to one */ +pt->pressure = 0.0f; +pt->strength = 1.0f; + +pt->flag |= GP_SPOINT_SELECT; + +curr = curr->next; + } + + BKE_gpencil_stroke_from_view_space(rv3d, perimeter_stroke, diff_mat); + for (int i = 0; i < num_perimeter_points; i++) { +bGPDspoint *pt = _stroke->points[i]; +float parent_co[3]; +mul_v3_m4v3(parent_co, diff_mat, >x); +float screen_co[2]; +// eV3DProjTest test = (eV3DProjTest)(V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN); +eV3DProjTest test = (eV3DProjTest)(V3D_PROJ_RET_OK); +if (ED_view3d_project_float_global(region, parent_co, screen_co, test) == V3D_PROJ_RET_OK) { + if (!ELEM(V2D_IS_CLIPPED, screen_co[0], screen_co[1])) { +copy_v2_v2(>x, screen_co); +pt->z = 0.0f; + } +} + } + + /* free temp data */ + BLI_freelistN(perimeter_points); + MEM_fre
[Bf-blender-cvs] [539aef6e353] greasepencil-object: GPencil: Fix pugixml library linking on linux
Commit: 539aef6e3534c151a2fa0a652d8967f5a5fda351 Author: Falk David Date: Tue Jul 28 21:05:03 2020 +0200 Branches: greasepencil-object https://developer.blender.org/rB539aef6e3534c151a2fa0a652d8967f5a5fda351 GPencil: Fix pugixml library linking on linux === M build_files/cmake/platform/platform_unix.cmake M source/blender/io/gpencil/CMakeLists.txt === diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index 96244b65f21..7390dc69569 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -334,7 +334,7 @@ if(WITH_OPENIMAGEIO) find_package_wrapper(PugiXML) else() set(PUGIXML_INCLUDE_DIR "${OPENIMAGEIO_INCLUDE_DIR/OpenImageIO}") -set(PUGIXML_LIBRARIES "") +#set(PUGIXML_LIBRARIES "") endif() set(OPENIMAGEIO_LIBRARIES diff --git a/source/blender/io/gpencil/CMakeLists.txt b/source/blender/io/gpencil/CMakeLists.txt index 4874b7fbc12..a31f30ac590 100644 --- a/source/blender/io/gpencil/CMakeLists.txt +++ b/source/blender/io/gpencil/CMakeLists.txt @@ -54,7 +54,7 @@ set(LIB bf_blenlib bf_io_common - #${PUGIXML_LIBRARIES} + ${PUGIXML_LIBRARIES} ) list(APPEND LIB ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [0e478f2acc7] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: 0e478f2acc780df98b64cffd155ae7ae56c3d54a Author: Falk David Date: Mon Jul 27 00:23:56 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB0e478f2acc780df98b64cffd155ae7ae56c3d54a Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === diff --cc source/blender/blenkernel/intern/gpencil.c index 36e20d256ac,992efe4bdb5..e66e85ef1a7 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@@ -536,7 -536,7 +536,6 @@@ bGPdata *BKE_gpencil_data_addnew(Main * gpd->flag |= GP_DATA_VIEWALIGN; /* always enable object onion skin switch */ gpd->flag |= GP_DATA_SHOW_ONIONSKINS; - - /* GP object specific settings */ ARRAY_SET_ITEMS(gpd->line_color, 0.6f, 0.6f, 0.6f, 0.5f); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2b9ae89ad8d] soc-2020-greasepencil-curve: GPencil: WIP delete curve point
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(_dst->strokes); LISTBASE_FOREACH (bGPDstroke *, gps_src, _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(_dst->strokes, gps_dst); } @@ -809,7 +810,7 @@ void BKE_gpencil_frame_copy_strokes(bGPDframe *gpf_src, struct bGPDframe *gpf_ds BLI_listbase_clear(_dst->strokes); LISTBASE_FOREACH (bGPDstroke *, gps_src, _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(_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, fa
[Bf-blender-cvs] [8045d8b8614] soc-2020-greasepencil-curve: GPencil: WIP delete curve points
Commit: 8045d8b8614c4c91fab0e862ca5e44219c3639b6 Author: Falk David Date: Fri Jul 24 19:23:42 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB8045d8b8614c4c91fab0e862ca5e44219c3639b6 GPencil: WIP delete curve points === M source/blender/editors/gpencil/gpencil_edit.c === diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 1a2d4112034..7f10c04ec47 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -2061,49 +2061,37 @@ static int gpencil_delete_selected_strokes(bContext *C) const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); bool changed = false; - if (is_curve_edit) { -/* TODO: do curve delete */ - } - else { -CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) { - bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe; + CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) { +bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe; - for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) { -if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) { +for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) { + if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) { - if (gpf == NULL) { -continue; - } +if (gpf == NULL) { + continue; +} - /* simply delete strokes which are selected */ - LISTBASE_FOREACH_MUTABLE (bGPDstroke *, gps, >strokes) { +/* simply delete strokes which are selected */ +LISTBASE_FOREACH_MUTABLE (bGPDstroke *, gps, >strokes) { -/* skip strokes that are invalid for current view */ -if (ED_gpencil_stroke_can_use(C, gps) == false) { - continue; -} + /* skip strokes that are invalid for current view */ + if (ED_gpencil_stroke_can_use(C, gps) == false) { +continue; + } -/* free stroke if selected */ -if (gps->flag & GP_STROKE_SELECT) { - /* free stroke memory arrays, then stroke itself */ - if (gps->points) { -MEM_freeN(gps->points); - } - if (gps->dvert) { -BKE_gpencil_free_stroke_weights(gps); -MEM_freeN(gps->dvert); - } - MEM_SAFE_FREE(gps->triangles); - BLI_freelinkN(>strokes, gps); + /* free stroke if selected */ + if (gps->flag & GP_STROKE_SELECT) { +/* free stroke memory arrays, then stroke itself */ +BKE_gpencil_free_stroke(gps); +BLI_freelinkN(>strokes, gps); - changed = true; -} +changed = true; } } } } -CTX_DATA_END; } + CTX_DATA_END; if (changed) { DEG_id_tag_update(>id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); @@ -2115,7 +2103,9 @@ static int gpencil_delete_selected_strokes(bContext *C) /* --- */ -static bool gpencil_dissole_selected_curve_points(bContext *C, bGPdata *gpd, eGP_DissolveMode mode) +static bool gpencil_dissolve_selected_curve_points(bContext *C, + bGPdata *gpd, + eGP_DissolveMode mode) { bool changed = false; GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc) @@ -2169,7 +2159,6 @@ static bool gpencil_dissole_selected_curve_points(bContext *C, bGPdata *gpd, eGP /* Delete stroke */ BKE_gpencil_free_stroke(gps); BLI_freelinkN(_->strokes, gps); -DEG_id_tag_update(>id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); } else { bGPDcurve_point *new_points = MEM_callocN(sizeof(bGPDcurve_point) * num_points_remaining, @@ -2311,18 +2300,8 @@ static bool gpencil_dissolve_selected_stroke_points(bContext *C, /* if no points are left, we simply delete the entire stroke */ if (tot <= 0) { /* remove the entire stroke */ -if (gps->points) { - MEM_freeN(gps->points); -} -if (gps->dvert) { - BKE_gpencil_free_stroke_weights(gps); - MEM_freeN(gps->dvert); -} -if (gps->triangles) { - MEM_freeN(gps->triangles); -} +BKE_gpencil_free_stroke(gps); BLI_freelinkN(_->strokes, gps); -DEG_id_tag_update(>id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); } else { /*
[Bf-blender-cvs] [075276ee803] soc-2020-greasepencil-curve: GPencil: Implement curve points dissolve
Commit: 075276ee803a1bb03f694f1707868fbc7ed82850 Author: Falk David Date: Thu Jul 23 19:24:24 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB075276ee803a1bb03f694f1707868fbc7ed82850 GPencil: Implement curve points dissolve === M source/blender/editors/gpencil/gpencil_edit.c === diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index e94cf5ca634..1a2d4112034 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -2115,6 +2115,139 @@ static int gpencil_delete_selected_strokes(bContext *C) /* --- */ +static bool gpencil_dissole_selected_curve_points(bContext *C, bGPdata *gpd, eGP_DissolveMode mode) +{ + bool changed = false; + GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc) + { +if (gpc->flag & GP_CURVE_SELECT) { + int first = 0, last = 0; + int num_points_remaining = gpc->tot_curve_points; + + switch (mode) { +case GP_DISSOLVE_POINTS: + for (int i = 0; i < gpc->tot_curve_points; i++) { +bGPDcurve_point *cpt = >curve_points[i]; +if (cpt->flag & GP_CURVE_POINT_SELECT) { + num_points_remaining--; +} + } + break; +case GP_DISSOLVE_BETWEEN: + first = -1; + for (int i = 0; i < gpc->tot_curve_points; i++) { +bGPDcurve_point *cpt = >curve_points[i]; +if (cpt->flag & GP_CURVE_POINT_SELECT) { + if (first < 0) { +first = i; + } + last = i; +} + } + + for (int i = first + 1; i < last; i++) { +bGPDcurve_point *cpt = >curve_points[i]; +if ((cpt->flag & GP_CURVE_POINT_SELECT) == 0) { + num_points_remaining--; +} + } + break; +case GP_DISSOLVE_UNSELECT: + for (int i = 0; i < gpc->tot_curve_points; i++) { +bGPDcurve_point *cpt = >curve_points[i]; +if ((cpt->flag & GP_CURVE_POINT_SELECT) == 0) { + num_points_remaining--; +} + } + break; +default: + return false; + break; + } + + if (num_points_remaining < 1) { +/* Delete stroke */ +BKE_gpencil_free_stroke(gps); +BLI_freelinkN(_->strokes, gps); +DEG_id_tag_update(>id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); + } + else { +bGPDcurve_point *new_points = MEM_callocN(sizeof(bGPDcurve_point) * num_points_remaining, + __func__); + +int idx = 0; +switch (mode) { + case GP_DISSOLVE_POINTS: +for (int i = 0; i < gpc->tot_curve_points; i++) { + bGPDcurve_point *cpt = >curve_points[i]; + bGPDcurve_point *new_cpt = _points[idx]; + if ((cpt->flag & GP_CURVE_POINT_SELECT) == 0) { +*new_cpt = *cpt; +idx++; + } +} +break; + case GP_DISSOLVE_BETWEEN: +for (int i = 0; i < first; i++) { + bGPDcurve_point *cpt = >curve_points[i]; + bGPDcurve_point *new_cpt = _points[idx]; + + *new_cpt = *cpt; + idx++; +} + +for (int i = first; i < last; i++) { + bGPDcurve_point *cpt = >curve_points[i]; + bGPDcurve_point *new_cpt = _points[idx]; + if (cpt->flag & GP_CURVE_POINT_SELECT) { +*new_cpt = *cpt; +idx++; + } +} + +for (int i = last; i < gpc->tot_curve_points; i++) { + bGPDcurve_point *cpt = >curve_points[i]; + bGPDcurve_point *new_cpt = _points[idx]; + + *new_cpt = *cpt; + idx++; +} +break; + case GP_DISSOLVE_UNSELECT: +for (int i = 0; i < gpc->tot_curve_points; i++) { + bGPDcurve_point *cpt = >curve_points[i]; + bGPDcurve_point *new_cpt = _points[idx]; + if (cpt->flag & GP_CURVE_POINT_SELECT) { +*new_cpt = *cpt; +idx++; + } +} +break; + default: +return false; +break; +} + +if (gpc->curve_points != NULL) { + MEM_freeN(gpc->curve_points); +} + +gpc->curve_points = new_points; +gpc->tot_curve_points = num_points_remaining; + +BKE_gpencil_editcurve_recalculat
[Bf-blender-cvs] [b21df4d473f] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: b21df4d473fb773c34cd3a7436fbc17a2abd93d3 Author: Falk David Date: Thu Jul 23 13:59:20 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBb21df4d473fb773c34cd3a7436fbc17a2abd93d3 Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c18eb01eb64] soc-2020-greasepencil-curve: GPencil: WIP: multi-dimensional curve fitting
Commit: c18eb01eb6416f06cd3ee59e428d24b6b6d2164a Author: Falk David Date: Thu Jul 23 13:41:13 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBc18eb01eb6416f06cd3ee59e428d24b6b6d2164a GPencil: WIP: multi-dimensional curve fitting === M source/blender/blenkernel/intern/gpencil_curve.c === diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index e38c79f3a0f..982cea69901 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -53,8 +53,6 @@ #include "DEG_depsgraph_query.h" -#define POINT_DIM 3 - /* Helper: Check materials with same color. */ static int gpencil_check_same_material_color(Object *ob_gp, float color[4], Material **r_mat) { @@ -471,15 +469,26 @@ void BKE_gpencil_convert_curve(Main *bmain, */ bGPDcurve *BKE_gpencil_stroke_editcurve_generate(bGPDstroke *gps, float error_threshold) { +#define POINT_DIM 9 if (gps->totpoints < 1) { return NULL; } float *points = MEM_callocN(sizeof(float) * gps->totpoints * POINT_DIM, __func__); + float diag_length = len_v3v3(gps->boundbox_min, gps->boundbox_max); + float tmp_vec[3]; + for (int i = 0; i < gps->totpoints; i++) { bGPDspoint *pt = >points[i]; -float *to = [i * POINT_DIM]; -copy_v3_v3(to, >x); +int row = i * POINT_DIM; + +/* normalize coordinate to 0..1 */ +sub_v3_v3v3(tmp_vec, >x, gps->boundbox_min); +mul_v3_v3fl([row], tmp_vec, 1.0f / diag_length); + +points[row + 3] = pt->pressure; +points[row + 4] = pt->strength; +copy_v4_v4([row + 5], pt->vert_color); } uint calc_flag = CURVE_FIT_CALC_HIGH_QUALIY; @@ -487,40 +496,52 @@ bGPDcurve *BKE_gpencil_stroke_editcurve_generate(bGPDstroke *gps, float error_th calc_flag |= CURVE_FIT_CALC_CYCLIC; } + /* TODO: make this a parameter */ + float corner_angle = M_PI_2; + float *r_cubic_array = NULL; unsigned int r_cubic_array_len = 0; unsigned int *r_cubic_orig_index = NULL; unsigned int *r_corners_index_array = NULL; unsigned int r_corners_index_len = 0; - int r = curve_fit_cubic_to_points_fl(points, - gps->totpoints, - POINT_DIM, - error_threshold, - calc_flag, - NULL, - 0, - _cubic_array, - _cubic_array_len, - _cubic_orig_index, - _corners_index_array, - _corners_index_len); + int r = curve_fit_cubic_to_points_refit_fl(points, + gps->totpoints, + POINT_DIM, + error_threshold, + calc_flag, + NULL, + 0, + corner_angle, + _cubic_array, + _cubic_array_len, + _cubic_orig_index, + _corners_index_array, + _corners_index_len); if (r != 0 || r_cubic_array_len < 1) { return NULL; } + uint curve_point_size = 3 * POINT_DIM; + bGPDcurve *editcurve = BKE_gpencil_stroke_editcurve_new(r_cubic_array_len); for (int i = 0; i < r_cubic_array_len; i++) { bGPDcurve_point *cpt = >curve_points[i]; BezTriple *bezt = >bezt; -bGPDspoint *orig_pt = >points[r_cubic_orig_index[i]]; +float *curve_point = _cubic_array[i * curve_point_size]; + for (int j = 0; j < 3; j++) { - copy_v3_v3(bezt->vec[j], _cubic_array[i * 3 * POINT_DIM + j * 3]); + float *bez = _point[j * POINT_DIM]; + copy_v3_v3(tmp_vec, bez); + mul_v3_fl(tmp_vec, diag_length); + add_v3_v3v3(bezt->vec[j], tmp_vec, gps->boundbox_min); } -cpt->pressure = orig_pt->pressure; -cpt->strength = orig_pt->strength; -copy_v4_v4(cpt->vert_color, orig_pt->vert_color); + +float *ctrl_point = _point[1 * POINT_DIM]; +cpt->pressure = ctrl_point[3]; +cpt->strength = ctrl_point[4]; +copy_v4_v4(cpt->vert_color, _point[5]); /* default handle type */ bezt->h1 |= HD_ALIGN; @@ -540,6 +561,7 @@ bGPDcurve *BKE_gpencil_stroke_editcurve_ge
[Bf-blender-cvs] [48e52c5a5ce] soc-2020-greasepencil-curve: GPencil: use smooth interpolation
Commit: 48e52c5a5ced06b49f1fee6a8bd3f3a51838bd8a Author: Falk David Date: Thu Jul 23 13:58:49 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB48e52c5a5ced06b49f1fee6a8bd3f3a51838bd8a GPencil: use smooth interpolation For the pressure, strength and color atributes, use smooth interpolation to generate the stroke points. === M source/blender/blenkernel/intern/gpencil_curve.c === diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index f7a1133f76a..19f14e92443 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -684,11 +684,11 @@ void BKE_gpencil_stroke_editcurve_sync_selection(bGPDstroke *gps, bGPDcurve *gpc static void gpencil_interpolate_fl_from_to( float from, float to, float *point_offset, int it, int stride) { - /* linear interpolation */ + /* smooth interpolation */ float *r = point_offset; for (int i = 0; i <= it; i++) { float fac = (float)i / (float)it; -// fac = 3.0f * fac * fac - 2.0f * fac * fac * fac; // smooth +fac = 3.0f * fac * fac - 2.0f * fac * fac * fac; // smooth *r = interpf(to, from, fac); r = POINTER_OFFSET(r, stride); } @@ -697,11 +697,11 @@ static void gpencil_interpolate_fl_from_to( static void gpencil_interpolate_v4_from_to( float from[4], float to[4], float *point_offset, int it, int stride) { - /* linear interpolation */ + /* smooth interpolation */ float *r = point_offset; for (int i = 0; i <= it; i++) { float fac = (float)i / (float)it; -// fac = 3.0f * fac * fac - 2.0f * fac * fac * fac; // smooth +fac = 3.0f * fac * fac - 2.0f * fac * fac * fac; // smooth interp_v4_v4v4(r, from, to, fac); r = POINTER_OFFSET(r, stride); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2d9e869b18b] soc-2020-greasepencil-curve: GPencil: Fix coordinate influence fitting problem
Commit: 2d9e869b18b96c66072e9fa1568b1abe3e10c6b1 Author: Falk David Date: Thu Jul 23 13:36:09 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB2d9e869b18b96c66072e9fa1568b1abe3e10c6b1 GPencil: Fix coordinate influence fitting problem The coordinates had a two small influence in the curve fitting. All the values are now normalized and a factor used to make the shape of the stroke more important. === M source/blender/blenkernel/intern/gpencil_curve.c === diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index 982cea69901..f7a1133f76a 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -53,6 +53,8 @@ #include "DEG_depsgraph_query.h" +#define COORD_FITTING_INFLUENCE 20.0f + /* Helper: Check materials with same color. */ static int gpencil_check_same_material_color(Object *ob_gp, float color[4], Material **r_mat) { @@ -484,11 +486,12 @@ bGPDcurve *BKE_gpencil_stroke_editcurve_generate(bGPDstroke *gps, float error_th /* normalize coordinate to 0..1 */ sub_v3_v3v3(tmp_vec, >x, gps->boundbox_min); -mul_v3_v3fl([row], tmp_vec, 1.0f / diag_length); +mul_v3_v3fl([row], tmp_vec, COORD_FITTING_INFLUENCE / diag_length); +points[row + 3] = pt->pressure / diag_length; -points[row + 3] = pt->pressure; -points[row + 4] = pt->strength; -copy_v4_v4([row + 5], pt->vert_color); +/* strength and color are already normalized */ +points[row + 4] = pt->strength / diag_length; +mul_v4_v4fl([row + 5], pt->vert_color, 1.0f / diag_length); } uint calc_flag = CURVE_FIT_CALC_HIGH_QUALIY; @@ -533,15 +536,13 @@ bGPDcurve *BKE_gpencil_stroke_editcurve_generate(bGPDstroke *gps, float error_th for (int j = 0; j < 3; j++) { float *bez = _point[j * POINT_DIM]; - copy_v3_v3(tmp_vec, bez); - mul_v3_fl(tmp_vec, diag_length); - add_v3_v3v3(bezt->vec[j], tmp_vec, gps->boundbox_min); + madd_v3_v3v3fl(bezt->vec[j], gps->boundbox_min, bez, diag_length / COORD_FITTING_INFLUENCE); } float *ctrl_point = _point[1 * POINT_DIM]; -cpt->pressure = ctrl_point[3]; -cpt->strength = ctrl_point[4]; -copy_v4_v4(cpt->vert_color, _point[5]); +cpt->pressure = ctrl_point[3] * diag_length; +cpt->strength = ctrl_point[4] * diag_length; +mul_v4_v4fl(cpt->vert_color, _point[5], diag_length); /* default handle type */ bezt->h1 |= HD_ALIGN; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d0c9a62904b] soc-2020-greasepencil-curve: GPencil: Update defaults for curve resolution
Commit: d0c9a62904b8e31f66d0b9d7c1f2eec0e3688b50 Author: Falk David Date: Wed Jul 22 17:33:29 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBd0c9a62904b8e31f66d0b9d7c1f2eec0e3688b50 GPencil: Update defaults for curve resolution === M source/blender/blenkernel/intern/gpencil.c M source/blender/blenloader/intern/versioning_290.c M source/blender/makesdna/DNA_gpencil_types.h M source/blender/makesrna/intern/rna_gpencil.c === diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 7932be4000f..8d73ad44071 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -536,6 +536,7 @@ bGPdata *BKE_gpencil_data_addnew(Main *bmain, const char name[]) gpd->flag |= GP_DATA_VIEWALIGN; /* always enable object onion skin switch */ gpd->flag |= GP_DATA_SHOW_ONIONSKINS; + /* GP object specific settings */ ARRAY_SET_ITEMS(gpd->line_color, 0.6f, 0.6f, 0.6f, 0.5f); @@ -543,6 +544,8 @@ bGPdata *BKE_gpencil_data_addnew(Main *bmain, const char name[]) gpd->editcurve_resolution = GP_DEFAULT_CURVE_RESOLUTION; gpd->curve_edit_threshold = GP_DEFAULT_CURVE_ERROR; + /* use adaptive curve resolution by default */ + gpd->flag |= GP_DATA_CURVE_ADAPTIVE_RESOLUTION; gpd->zdepth_offset = 0.150f; diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index 76d25d744fe..807a3505db6 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -307,13 +307,14 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Init grease pencil default curve resolution. */ if (!DNA_struct_elem_find(fd->filesdna, "bGPdata", "int", "editcurve_resolution")) { - for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) { + LISTBASE_FOREACH (bGPdata *, gpd, >gpencils) { gpd->editcurve_resolution = GP_DEFAULT_CURVE_RESOLUTION; +gpd->flag |= GP_DATA_CURVE_ADAPTIVE_RESOLUTION; } } /* Init grease pencil curve editing error threshold. */ if (!DNA_struct_elem_find(fd->filesdna, "bGPdata", "float", "curve_edit_threshold")) { - for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) { + LISTBASE_FOREACH (bGPdata *, gpd, >gpencils) { gpd->curve_edit_threshold = GP_DEFAULT_CURVE_ERROR; } } diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h index adac760f8fb..914f422b600 100644 --- a/source/blender/makesdna/DNA_gpencil_types.h +++ b/source/blender/makesdna/DNA_gpencil_types.h @@ -38,8 +38,8 @@ struct Curve; #define GP_MATERIAL_BUFFER_LEN 256 -#define GP_DEFAULT_CURVE_RESOLUTION 16 -#define GP_DEFAULT_CURVE_ERROR 0.01f +#define GP_DEFAULT_CURVE_RESOLUTION 32 +#define GP_DEFAULT_CURVE_ERROR 0.1f /* * */ /* GP Stroke Points */ diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index b75d290371c..962ea90aa29 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -2376,11 +2376,12 @@ static void rna_def_gpencil_data(BlenderRNA *brna) prop = RNA_def_property(srna, "use_adaptive_curve_resolution", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_CURVE_ADAPTIVE_RESOLUTION); + RNA_def_property_boolean_default(prop, true); RNA_def_property_ui_text(prop, "Adaptive Resolution", "Set the resolution of each editcurve segment dynamically depending on " "the length of the segment. The resolution is the number of points " - "generated per unit distance. "); + "generated per unit distance"); RNA_def_property_update( prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_resolution_update"); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [fbbd03ae8a2] soc-2020-greasepencil-curve: GPencil: remove unnecessary variables
Commit: fbbd03ae8a22ccf90365f42d8d3cc68537d3d1db Author: Falk David Date: Tue Jul 21 16:02:07 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBfbbd03ae8a22ccf90365f42d8d3cc68537d3d1db GPencil: remove unnecessary variables === M source/blender/editors/gpencil/gpencil_edit_curve.c === diff --git a/source/blender/editors/gpencil/gpencil_edit_curve.c b/source/blender/editors/gpencil/gpencil_edit_curve.c index 64e5867309f..d6373e01d1e 100644 --- a/source/blender/editors/gpencil/gpencil_edit_curve.c +++ b/source/blender/editors/gpencil/gpencil_edit_curve.c @@ -156,12 +156,6 @@ static int gpencil_editcurve_set_handle_type_exec(bContext *C, wmOperator *op) if (gpc_pt->flag & GP_CURVE_POINT_SELECT) { BezTriple *bezt = _pt->bezt; -bGPDcurve_point *gpc_pt_prev = (i > 0) ? >curve_points[i - 1] : NULL; -bGPDcurve_point *gpc_pt_next = (i < gpc->tot_curve_points - 1) ? - >curve_points[i + 1] : - NULL; -BezTriple *bezt_prev = gpc_pt_prev != NULL ? _pt_prev->bezt : NULL; -BezTriple *bezt_next = gpc_pt_next != NULL ? _pt_next->bezt : NULL; if (bezt->f2 & SELECT) { bezt->h1 = handle_type; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f16a50ba946] soc-2020-greasepencil-curve: GPencil: Implement adaptive editcurve resolution
Commit: f16a50ba946ae4ddea18d4f7058fef3a359078b8 Author: Falk David Date: Wed Jul 22 16:10:25 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBf16a50ba946ae4ddea18d4f7058fef3a359078b8 GPencil: Implement adaptive editcurve resolution With adaptive curve resolution the arclength of a curve segment is used to calculate the number of points between two control points. This means that in general the stroke points are more spaced out. === M release/scripts/startup/bl_ui/space_view3d.py M source/blender/blenkernel/BKE_gpencil_curve.h M source/blender/blenkernel/intern/gpencil_curve.c M source/blender/blenkernel/intern/gpencil_geom.c M source/blender/editors/gpencil/gpencil_edit_curve.c M source/blender/editors/gpencil/gpencil_select.c M source/blender/editors/gpencil/gpencil_utils.c M source/blender/makesdna/DNA_gpencil_types.h M source/blender/makesrna/intern/rna_gpencil.c === diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 007b8c933ce..0faca0b3413 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -6990,6 +6990,7 @@ class VIEW3D_PT_gpencil_curve_edit(Panel): layout = self.layout col = layout.column(align=True) +col.prop(gpd, "use_adaptive_curve_resolution") col.prop(gpd, "edit_curve_resolution") col.prop(gpd, "curve_edit_threshold") diff --git a/source/blender/blenkernel/BKE_gpencil_curve.h b/source/blender/blenkernel/BKE_gpencil_curve.h index b066e901211..28791acc47a 100644 --- a/source/blender/blenkernel/BKE_gpencil_curve.h +++ b/source/blender/blenkernel/BKE_gpencil_curve.h @@ -50,7 +50,7 @@ void BKE_gpencil_editcurve_stroke_sync_selection(struct bGPDstroke *gps, struct void BKE_gpencil_stroke_editcurve_sync_selection(struct bGPDstroke *gps, struct bGPDcurve *gpc); void BKE_gpencil_strokes_selected_update_editcurve(struct bGPdata *gpd); void BKE_gpencil_strokes_selected_sync_selection_editcurve(struct bGPdata *gpd); -void BKE_gpencil_stroke_update_geometry_from_editcurve(struct bGPDstroke *gps); +void BKE_gpencil_stroke_update_geometry_from_editcurve(struct bGPDstroke *gps, const uint resolution, bool is_adaptive); void BKE_gpencil_editcurve_recalculate_handles(struct bGPDstroke *gps); void BKE_gpencil_editcurve_subdivide(struct bGPDstroke *gps, const int cuts); diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index eb3c78f2827..e38c79f3a0f 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -665,6 +665,7 @@ static void gpencil_interpolate_fl_from_to( float *r = point_offset; for (int i = 0; i <= it; i++) { float fac = (float)i / (float)it; +// fac = 3.0f * fac * fac - 2.0f * fac * fac * fac; // smooth *r = interpf(to, from, fac); r = POINTER_OFFSET(r, stride); } @@ -677,12 +678,27 @@ static void gpencil_interpolate_v4_from_to( float *r = point_offset; for (int i = 0; i <= it; i++) { float fac = (float)i / (float)it; +// fac = 3.0f * fac * fac - 2.0f * fac * fac * fac; // smooth interp_v4_v4v4(r, from, to, fac); r = POINTER_OFFSET(r, stride); } } -static void gpencil_calculate_stroke_points_curve_point( +static float gpencil_approximate_curve_segment_arclength(bGPDcurve_point *cpt_start, + bGPDcurve_point *cpt_end) +{ + BezTriple *bezt_start = _start->bezt; + BezTriple *bezt_end = _end->bezt; + + float chord_len = len_v3v3(bezt_start->vec[1], bezt_end->vec[1]); + float net_len = len_v3v3(bezt_start->vec[1], bezt_start->vec[2]); + net_len += len_v3v3(bezt_start->vec[2], bezt_end->vec[0]); + net_len += len_v3v3(bezt_end->vec[0], bezt_end->vec[1]); + + return (chord_len + net_len) / 2.0f; +} + +static void gpencil_calculate_stroke_points_curve_segment( bGPDcurve_point *cpt, bGPDcurve_point *cpt_next, float *points_offset, int resolu, int stride) { /* sample points on all 3 axis between two curve points */ @@ -714,51 +730,141 @@ static void gpencil_calculate_stroke_points_curve_point( stride); } -/** - * Recalculate stroke points with the editcurve of the stroke. - */ -void BKE_gpencil_stroke_update_geometry_from_editcurve(bGPDstroke *gps) +static float *gpencil_stroke_points_from_editcurve_adaptive_resolu( +bGPDcurve_point *curve_point_array, +int curve_point_array_len, +int resolution, +bool is_cyclic, +int *r_points_len) { - if (gps == NULL || gps->editcurve == NULL) { -return; + /* One stride contains: x, y, z,
[Bf-blender-cvs] [31ffbfd78f9] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: 31ffbfd78f9d85d211ed96d2591b59907395472b Author: Falk David Date: Wed Jul 22 16:11:18 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB31ffbfd78f9d85d211ed96d2591b59907395472b Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f7a1512bdff] soc-2020-greasepencil-curve: GPencil: deselct curve when deselect all
Commit: f7a1512bdff59f6e75a1b67adb67fa3630ce1e75 Author: Falk David Date: Tue Jul 21 15:57:42 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBf7a1512bdff59f6e75a1b67adb67fa3630ce1e75 GPencil: deselct curve when deselect all === M source/blender/blenkernel/intern/gpencil_curve.c === diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index ec286432927..eb3c78f2827 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -401,6 +401,7 @@ static void gpencil_editstroke_deselect_all(bGPDcurve *gpc) gpc_pt->flag &= ~GP_CURVE_POINT_SELECT; BEZT_DESEL_ALL(bezt); } + gpc->flag &= ~GP_CURVE_SELECT; } /** ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [46e0b0404ad] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: 46e0b0404ad21414f5386f90ea175d219ea3b080 Author: Falk David Date: Tue Jul 21 15:58:10 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB46e0b0404ad21414f5386f90ea175d219ea3b080 Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [5330fe4b708] soc-2020-greasepencil-curve: GPencil: Fix select more
Commit: 5330fe4b708df37c067f4050661495ce120d8338 Author: Falk David Date: Mon Jul 20 15:47:40 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB5330fe4b708df37c067f4050661495ce120d8338 GPencil: Fix select more The first control point was not being selected due to an off-by-one error. === M source/blender/editors/gpencil/gpencil_select.c === diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index c2dae9e58f6..11706c7f133 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -927,14 +927,9 @@ static int gpencil_select_more_exec(bContext *C, wmOperator *UNUSED(op)) GP_EDITABLE_STROKES_BEGIN (gp_iter, C, gpl, gps) { if (gps->editcurve != NULL && gps->flag & GP_STROKE_SELECT) { bGPDcurve *editcurve = gps->editcurve; -int i; -/* First Pass: Go in forward order, - * expanding selection if previous was selected (pre changes). - * - This pass covers the "after" edges of selection islands - */ bool prev_sel = false; -for (i = 0; i < editcurve->tot_curve_points; i++) { +for (int i = 0; i < editcurve->tot_curve_points; i++) { bGPDcurve_point *gpc_pt = >curve_points[i]; BezTriple *bezt = _pt->bezt; if (gpc_pt->flag & GP_CURVE_POINT_SELECT) { @@ -952,11 +947,8 @@ static int gpencil_select_more_exec(bContext *C, wmOperator *UNUSED(op)) } } -/* 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 = editcurve->tot_curve_points - 1; i > 0; i--) { +for (int i = editcurve->tot_curve_points - 1; i >= 0; i--) { bGPDcurve_point *gpc_pt = >curve_points[i]; BezTriple *bezt = _pt->bezt; if (gpc_pt->flag & GP_CURVE_POINT_SELECT) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [56e88ada832] soc-2020-greasepencil-curve: GPencil: Fix select fill
Commit: 56e88ada832432d9490716c28560678b52376b06 Author: Falk David Date: Mon Jul 20 15:55:18 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB56e88ada832432d9490716c28560678b52376b06 GPencil: Fix select fill The function was not working correctly, because it would select fills where one of the triangles would have a bounding box large enought that it would intersect the selction. === M source/blender/editors/gpencil/gpencil_select.c === diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index 11706c7f133..0802cbfde2a 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -1565,16 +1565,21 @@ static bool gpencil_stroke_fill_isect_rect(ARegion *region, DO_MINMAX2(pt3, tri_min, tri_max); rcti tri_bb = {tri_min[0], tri_max[0], tri_min[1], tri_max[1]}; - if (BLI_rcti_inside_rcti(, _bb) || BLI_rcti_inside_rcti(_bb, )) { + /* Case 1: triangle is entirely inside box selection */ + /* (XXX: Can this even happen with no point inside the box?) */ + if (BLI_rcti_inside_rcti(_bb, )) { hit = true; break; } + /* Case 2: rectangle intersects sides of triangle */ if (BLI_rcti_isect_segment(, pt1, pt2) || BLI_rcti_isect_segment(, pt2, pt3) || BLI_rcti_isect_segment(, pt3, pt1)) { hit = true; break; } + + /* TODO: Case 3: rectangle is inside the triangle */ } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [a98c9e3de9b] soc-2020-greasepencil-curve: GPencil: Fix curve points not deslecting
Commit: a98c9e3de9b7f0fbd490c7df8f86a71a90d4066d Author: Falk David Date: Sun Jul 19 13:40:00 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBa98c9e3de9b7f0fbd490c7df8f86a71a90d4066d GPencil: Fix curve points not deslecting === M source/blender/editors/gpencil/gpencil_select.c === diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index 54779070d1b..39e2981785b 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -165,21 +165,21 @@ static void deselect_all_selected(bContext *C) pt->flag &= ~GP_SPOINT_SELECT; } - /* deselect curve and curve points */ - if (gps->editcurve != NULL) { -bGPDcurve *gpc = gps->editcurve; -for (int j = 0; j < gpc->tot_curve_points; j++) { - bGPDcurve_point *gpc_pt = >curve_points[j]; - BezTriple *bezt = _pt->bezt; - gpc_pt->flag &= ~GP_CURVE_POINT_SELECT; - BEZT_DESEL_ALL(bezt); -} + /* deselect stroke itself too */ + gps->flag &= ~GP_STROKE_SELECT; +} -gpc->flag &= ~GP_CURVE_SELECT; +/* deselect curve and curve points */ +if (gps->editcurve != NULL) { + bGPDcurve *gpc = gps->editcurve; + for (int j = 0; j < gpc->tot_curve_points; j++) { +bGPDcurve_point *gpc_pt = >curve_points[j]; +BezTriple *bezt = _pt->bezt; +gpc_pt->flag &= ~GP_CURVE_POINT_SELECT; +BEZT_DESEL_ALL(bezt); } - /* deselect stroke itself too */ - gps->flag &= ~GP_STROKE_SELECT; + gpc->flag &= ~GP_CURVE_SELECT; } } CTX_DATA_END; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [bc90636f61a] soc-2020-greasepencil-curve: GPencil: Disable box/lasso conversion, fill select
Commit: bc90636f61af3c328cb277eac1bff07efe779773 Author: Falk David Date: Sun Jul 19 13:44:45 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBbc90636f61af3c328cb277eac1bff07efe779773 GPencil: Disable box/lasso conversion, fill select These features are currently not working correctly. Disable them for now. === M source/blender/editors/gpencil/gpencil_select.c === diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index 39e2981785b..c2dae9e58f6 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -1691,15 +1691,15 @@ static bool gpencil_generic_curve_select(bContext *C, } } -if (!hit) { - /* check if we selected the inside of a filled curve */ - MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps->mat_nr + 1); - if ((gp_style->flag & GP_MATERIAL_FILL_SHOW) == 0) { -continue; - } +// if (!hit) { +// /* check if we selected the inside of a filled curve */ +// MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps->mat_nr + 1); +// if ((gp_style->flag & GP_MATERIAL_FILL_SHOW) == 0) { +// continue; +// } - whole = gpencil_stroke_fill_isect_rect(region, gps, gps_iter.diff_mat, box); -} +// whole = gpencil_stroke_fill_isect_rect(region, gps, gps_iter.diff_mat, box); +// } /* select the entire curve */ if (strokemode || whole) { @@ -1822,14 +1822,14 @@ static bool gpencil_generic_stroke_select(bContext *C, whole = ED_gpencil_stroke_point_is_inside(gps_active, , mval, gpstroke_iter.diff_mat); } -if (is_curve_edit && (hit || whole) && gps->editcurve == NULL) { - BKE_gpencil_stroke_editcurve_update(gps, gpd->curve_edit_threshold); - BKE_gpencil_curve_sync_selection(gps); - gps->editcurve->resolution = gpd->editcurve_resolution; - gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE; - BKE_gpencil_stroke_geometry_update(gpd, gps); - changed = true; -} +// if (is_curve_edit && (hit || whole) && gps->editcurve == NULL) { +// BKE_gpencil_stroke_editcurve_update(gps, gpd->curve_edit_threshold); +// BKE_gpencil_curve_sync_selection(gps); +// gps->editcurve->resolution = gpd->editcurve_resolution; +// gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE; +// BKE_gpencil_stroke_geometry_update(gpd, gps); +// changed = true; +// } /* if stroke mode expand selection. */ if ((strokemode) || (whole)) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d7ae232dbac] soc-2020-greasepencil-curve: GPencil: deselect stroke after convert from curve
Commit: d7ae232dbacbeb038b1a7643bfca45a34a6441fa Author: Falk David Date: Sat Jul 18 22:06:16 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBd7ae232dbacbeb038b1a7643bfca45a34a6441fa GPencil: deselect stroke after convert from curve === M source/blender/blenkernel/intern/gpencil_curve.c === diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index f04e1a4bd5f..ec286432927 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -776,7 +776,11 @@ void BKE_gpencil_stroke_update_geometry_from_editcurve(bGPDstroke *gps) pt->strength = points[i][4]; copy_v4_v4(pt->vert_color, [i][5]); + +/* deselect points */ +pt->flag &= ~GP_SPOINT_SELECT; } + gps->flag &= ~GP_STROKE_SELECT; /* free temp data */ MEM_freeN(points); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [88b98dfe32b] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: 88b98dfe32bd4860c1fa1590923a5ee9a2efd1eb Author: Falk David Date: Sat Jul 18 13:06:25 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB88b98dfe32bd4860c1fa1590923a5ee9a2efd1eb Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8eedcb6f9dc] soc-2020-greasepencil-curve: GPencil: WIP: convert to curve box/lasso select
Commit: 8eedcb6f9dc7f16e46fb6771b567a83cba87ff8b Author: Falk David Date: Sat Jul 18 13:05:06 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB8eedcb6f9dc7f16e46fb6771b567a83cba87ff8b GPencil: WIP: convert to curve box/lasso select === M source/blender/editors/gpencil/gpencil_select.c === diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index 82d456892ae..54779070d1b 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -1749,6 +1749,7 @@ static bool gpencil_generic_stroke_select(bContext *C, { GP_SpaceConversion gsc = {NULL}; bool changed = false; + const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd); /* init space conversion stuff */ gpencil_point_conversion_init(C, ); @@ -1821,6 +1822,15 @@ static bool gpencil_generic_stroke_select(bContext *C, whole = ED_gpencil_stroke_point_is_inside(gps_active, , mval, gpstroke_iter.diff_mat); } +if (is_curve_edit && (hit || whole) && gps->editcurve == NULL) { + BKE_gpencil_stroke_editcurve_update(gps, gpd->curve_edit_threshold); + BKE_gpencil_curve_sync_selection(gps); + gps->editcurve->resolution = gpd->editcurve_resolution; + gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE; + BKE_gpencil_stroke_geometry_update(gpd, gps); + changed = true; +} + /* if stroke mode expand selection. */ if ((strokemode) || (whole)) { const bool is_select = BKE_gpencil_stroke_select_check(gps_active) || whole; @@ -1892,7 +1902,8 @@ static int gpencil_generic_select_exec(bContext *C, changed = gpencil_generic_curve_select( C, ob, is_inside_fn, box, user_data, strokemode, sel_op); } - else { + + if (changed == false) { changed = gpencil_generic_stroke_select( C, ob, gpd, is_inside_fn, box, user_data, strokemode, segmentmode, sel_op, scale); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [9d69d642ff1] soc-2020-greasepencil-curve: GPencil: Recalculate curve when entering editmode
Commit: 9d69d642ff17fad683840d055a9b4b8393de92da Author: Falk David Date: Fri Jul 17 13:36:14 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB9d69d642ff17fad683840d055a9b4b8393de92da GPencil: Recalculate curve when entering editmode === M source/blender/blenkernel/BKE_gpencil_curve.h M source/blender/blenkernel/intern/gpencil_curve.c M source/blender/editors/gpencil/gpencil_edit.c M source/blender/makesrna/intern/rna_gpencil.c === diff --git a/source/blender/blenkernel/BKE_gpencil_curve.h b/source/blender/blenkernel/BKE_gpencil_curve.h index 3527d678355..b066e901211 100644 --- a/source/blender/blenkernel/BKE_gpencil_curve.h +++ b/source/blender/blenkernel/BKE_gpencil_curve.h @@ -48,7 +48,8 @@ struct bGPDcurve *BKE_gpencil_stroke_editcurve_generate(struct bGPDstroke *gps, void BKE_gpencil_stroke_editcurve_update(struct bGPDstroke *gps, float error_threshold); void BKE_gpencil_editcurve_stroke_sync_selection(struct bGPDstroke *gps, struct bGPDcurve *gpc); void BKE_gpencil_stroke_editcurve_sync_selection(struct bGPDstroke *gps, struct bGPDcurve *gpc); -void BKE_gpencil_selected_strokes_editcurve_update(struct bGPdata *gpd); +void BKE_gpencil_strokes_selected_update_editcurve(struct bGPdata *gpd); +void BKE_gpencil_strokes_selected_sync_selection_editcurve(struct bGPdata *gpd); void BKE_gpencil_stroke_update_geometry_from_editcurve(struct bGPDstroke *gps); void BKE_gpencil_editcurve_recalculate_handles(struct bGPDstroke *gps); void BKE_gpencil_editcurve_subdivide(struct bGPDstroke *gps, const int cuts); diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index 3bd60746028..f04e1a4bd5f 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -991,4 +991,67 @@ void BKE_gpencil_editcurve_subdivide(bGPDstroke *gps, const int cuts) } } +void BKE_gpencil_strokes_selected_update_editcurve(bGPdata *gpd) +{ + const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); + /* For all selected strokes, update edit curve. */ + LISTBASE_FOREACH (bGPDlayer *, gpl, >layers) { +if (!BKE_gpencil_layer_is_editable(gpl)) { + continue; +} +bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe; +for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) { + if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && is_multiedit)) { +LISTBASE_FOREACH (bGPDstroke *, gps, >strokes) { + /* skip deselected stroke */ + if (!(gps->flag & GP_STROKE_SELECT)) { +continue; + } + + /* Generate the curve if there is none or the stroke was changed */ + if (gps->editcurve == NULL) { +BKE_gpencil_stroke_editcurve_update(gps, gpd->curve_edit_threshold); +/* Continue if curve could not be generated. */ +if (gps->editcurve == NULL) { + continue; +} + } + else if (gps->editcurve->flag & GP_CURVE_NEEDS_STROKE_UPDATE) { +BKE_gpencil_stroke_editcurve_update(gps, gpd->curve_edit_threshold); + } + /* Update the selection from the stroke to the curve. */ + BKE_gpencil_editcurve_stroke_sync_selection(gps, gps->editcurve); + + gps->editcurve->resolution = gpd->editcurve_resolution; + gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE; + BKE_gpencil_stroke_geometry_update(gpd, gps); +} + } +} + } +} + +void BKE_gpencil_strokes_selected_sync_selection_editcurve(bGPdata *gpd) +{ + const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); + /* Sync selection for all strokes with editcurve. */ + LISTBASE_FOREACH (bGPDlayer *, gpl, >layers) { +if (!BKE_gpencil_layer_is_editable(gpl)) { + continue; +} +bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe; +for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) { + if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && is_multiedit)) { +LISTBASE_FOREACH (bGPDstroke *, gps, >strokes) { + bGPDcurve *gpc = gps->editcurve; + if (gpc != NULL) { +/* Update the selection of every stroke that has an editcurve */ +BKE_gpencil_stroke_editcurve_sync_selection(gps, gpc); + } +} + } +} + } +} + /** \} */ diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 51cb9dea743..10857aed866 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.
[Bf-blender-cvs] [5bac474903e] soc-2020-greasepencil-curve: GPencil: Convert to curve with click select
Commit: 5bac474903e99adbed89e9b610f6905076c7ede8 Author: Falk David Date: Fri Jul 17 14:16:28 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB5bac474903e99adbed89e9b610f6905076c7ede8 GPencil: Convert to curve with click select === M source/blender/editors/gpencil/gpencil_select.c === diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index 70e8649dd94..82d456892ae 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -43,6 +43,8 @@ #include "BKE_context.h" #include "BKE_gpencil.h" +#include "BKE_gpencil_curve.h" +#include "BKE_gpencil_geom.h" #include "BKE_material.h" #include "BKE_report.h" @@ -2200,6 +2202,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op) /* select all handles if the click was on the curve but not on a handle */ if (is_curve_edit && hit_point != NULL) { whole = true; +hit_curve = hit_stroke->editcurve; } /* adjust selection behavior - for toggle option */ @@ -2225,6 +2228,14 @@ static int gpencil_select_exec(bContext *C, wmOperator *op) /* Perform selection operations... */ if (whole) { +/* Generate editcurve if it does not exist */ +if (is_curve_edit && hit_curve == NULL) { + BKE_gpencil_stroke_editcurve_update(hit_stroke, gpd->curve_edit_threshold); + hit_stroke->editcurve->resolution = gpd->editcurve_resolution; + hit_stroke->flag |= GP_STROKE_NEEDS_CURVE_UPDATE; + BKE_gpencil_stroke_geometry_update(gpd, hit_stroke); + hit_curve = hit_stroke->editcurve; +} /* select all curve points */ if (hit_curve != NULL) { for (int i = 0; i < hit_curve->tot_curve_points; i++) { @@ -2464,7 +2475,6 @@ static int gpencil_select_vertex_color_exec(bContext *C, wmOperator *op) ToolSettings *ts = CTX_data_tool_settings(C); Object *ob = CTX_data_active_object(C); bGPdata *gpd = ED_gpencil_data_get_active(C); - const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd); const float threshold = RNA_int_get(op->ptr, "threshold"); const int selectmode = gpencil_select_mode_from_vertex(ts->gpencil_selectmode_vertex); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [76dc5529893] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: 76dc552989325dffa65dc7e25dc2381abb69c4ef Author: Falk David Date: Fri Jul 17 14:17:56 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB76dc552989325dffa65dc7e25dc2381abb69c4ef Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [741cd183985] greasepencil-edit-curve: GPencil: Draw edit lines under curve handles
Commit: 741cd18398575b63b737ecb107673e3220af1ccf Author: Falk David Date: Fri Jul 17 14:17:30 2020 +0200 Branches: greasepencil-edit-curve https://developer.blender.org/rB741cd18398575b63b737ecb107673e3220af1ccf GPencil: Draw edit lines under curve handles === M source/blender/draw/engines/overlay/overlay_gpencil.c === diff --git a/source/blender/draw/engines/overlay/overlay_gpencil.c b/source/blender/draw/engines/overlay/overlay_gpencil.c index 52d05376161..7f9290a6c3a 100644 --- a/source/blender/draw/engines/overlay/overlay_gpencil.c +++ b/source/blender/draw/engines/overlay/overlay_gpencil.c @@ -142,6 +142,18 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata) DRWState state = DRW_STATE_WRITE_COLOR; DRW_PASS_CREATE(psl->edit_gpencil_curve_ps, state | pd->clipping_state); +/* Edit lines. */ +if (show_lines) { + sh = OVERLAY_shader_edit_gpencil_wire(); + pd->edit_gpencil_wires_grp = grp = DRW_shgroup_create(sh, psl->edit_gpencil_curve_ps); + DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); + DRW_shgroup_uniform_bool_copy(grp, "doMultiframe", show_multi_edit_lines); + DRW_shgroup_uniform_bool_copy(grp, "doWeightColor", is_weight_paint); + DRW_shgroup_uniform_bool_copy(grp, "hideSelect", hide_select); + DRW_shgroup_uniform_float_copy(grp, "gpEditOpacity", v3d->vertex_opacity); + DRW_shgroup_uniform_texture(grp, "weightTex", G_draw.weight_ramp); +} + sh = OVERLAY_shader_edit_curve_handle(); pd->edit_gpencil_curve_handle_grp = grp = DRW_shgroup_create(sh, psl->edit_gpencil_curve_ps); DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); @@ -154,18 +166,6 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata) DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); DRW_shgroup_uniform_bool_copy(grp, "showCurveHandles", pd->edit_curve.show_handles); DRW_shgroup_uniform_int_copy(grp, "curveHandleDisplay", pd->edit_curve.handle_display); - -/* Edit lines. */ -if (show_lines) { - sh = OVERLAY_shader_edit_gpencil_wire(); - pd->edit_gpencil_wires_grp = grp = DRW_shgroup_create(sh, psl->edit_gpencil_curve_ps); - DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); - DRW_shgroup_uniform_bool_copy(grp, "doMultiframe", show_multi_edit_lines); - DRW_shgroup_uniform_bool_copy(grp, "doWeightColor", is_weight_paint); - DRW_shgroup_uniform_bool_copy(grp, "hideSelect", hide_select); - DRW_shgroup_uniform_float_copy(grp, "gpEditOpacity", v3d->vertex_opacity); - DRW_shgroup_uniform_texture(grp, "weightTex", G_draw.weight_ramp); -} } /* control points for primitives and speed guide */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8b35bc7743f] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: 8b35bc7743fb0e81643b19e87f6f6b5b29d6e20c Author: Falk David Date: Thu Jul 16 19:42:39 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB8b35bc7743fb0e81643b19e87f6f6b5b29d6e20c Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [610a5452c11] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: 610a5452c113a8addad3d72d32b92e24b39369f3 Author: Falk David Date: Wed Jul 15 12:11:12 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB610a5452c113a8addad3d72d32b92e24b39369f3 Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [477fbf4e44d] soc-2020-greasepencil-curve: Gpencil: WIP: Update "enter curve edit mode" op
Commit: 477fbf4e44d61633e42bbab2973a0148e552ddd7 Author: Falk David Date: Wed Jul 15 12:10:33 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB477fbf4e44d61633e42bbab2973a0148e552ddd7 Gpencil: WIP: Update "enter curve edit mode" op === M source/blender/editors/gpencil/gpencil_edit_curve.c === diff --git a/source/blender/editors/gpencil/gpencil_edit_curve.c b/source/blender/editors/gpencil/gpencil_edit_curve.c index b8d2ecf2474..64e5867309f 100644 --- a/source/blender/editors/gpencil/gpencil_edit_curve.c +++ b/source/blender/editors/gpencil/gpencil_edit_curve.c @@ -70,7 +70,7 @@ static bool gpencil_curve_edit_mode_poll(bContext *C) return (gpl != NULL); } -static int gpencil_stroke_enter_editcurve_mode(bContext *C, wmOperator *op) +static int gpencil_stroke_enter_editcurve_mode_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_active_object(C); bGPdata *gpd = ob->data; @@ -90,10 +90,10 @@ static int gpencil_stroke_enter_editcurve_mode(bContext *C, wmOperator *op) if ((gps->flag & GP_STROKE_SELECT && gps->editcurve == NULL) || (gps->editcurve != NULL && gps->editcurve->flag & GP_CURVE_NEEDS_STROKE_UPDATE)) { BKE_gpencil_stroke_editcurve_update(gps, gpd->curve_edit_threshold); -if (gps->editcurve != NULL) { - gps->editcurve->resolution = gpd->editcurve_resolution; - gps->editcurve->flag |= GP_STROKE_NEEDS_CURVE_UPDATE; -} +gps->editcurve->resolution = gpd->editcurve_resolution; +/* Update the selection from the stroke to the curve. */ +BKE_gpencil_editcurve_stroke_sync_selection(gps, gps->editcurve); +gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE; BKE_gpencil_stroke_geometry_update(gpd, gps); } } @@ -101,6 +101,8 @@ static int gpencil_stroke_enter_editcurve_mode(bContext *C, wmOperator *op) } } + gpd->flag |= GP_DATA_CURVE_EDIT_MODE; + /* notifiers */ DEG_id_tag_update(>id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); @@ -118,7 +120,7 @@ void GPENCIL_OT_stroke_enter_editcurve_mode(wmOperatorType *ot) ot->description = "Called to transform a stroke into a curve"; /* api callbacks */ - ot->exec = gpencil_stroke_enter_editcurve_mode; + ot->exec = gpencil_stroke_enter_editcurve_mode_exec; ot->poll = gpencil_active_layer_poll; /* flags */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [bd71007ebda] soc-2020-greasepencil-curve: GPencil: Implement select more/less curve points
Commit: bd71007ebda79c0cadabdb83dae1c01bbd71fcfa Author: Falk David Date: Wed Jul 15 11:55:18 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBbd71007ebda79c0cadabdb83dae1c01bbd71fcfa GPencil: Implement select more/less curve points === M source/blender/editors/gpencil/gpencil_select.c === diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index 05912d45b9c..70e8649dd94 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -922,52 +922,57 @@ static int gpencil_select_more_exec(bContext *C, wmOperator *UNUSED(op)) bool changed = false; if (is_curve_edit) { -/* TODO: do curve select */ -// GP_EDITABLE_STROKES_BEGIN (gp_iter, C, gpl, gps) { -// if (gps->editcurve != NULL && gps->flag & GP_STROKE_SELECT) { -// bGPDcurve *editcurve = gps->editcurve; -// int i; - -// /* First Pass: Go in forward order, -// * expanding selection if previous was selected (pre changes). -// * - This pass covers the "after" edges of selection islands -// */ -// bool prev_sel = false; -// for (i = 0; i < editcurve->tot_curve_points; i++) { -// BezTriple *bezt = >curve_points[i].bezt; -// if (bezt->f2 & SELECT) { -// /* selected point - just set flag for next point */ -// prev_sel = true; -// } -// else { -// /* unselected point - expand selection if previous was selected... */ -// if (prev_sel) { -// BEZT_SEL_ALL(bezt); -// } -// 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 = editcurve->tot_curve_points - 1; i > 0; i--) { -// BezTriple *bezt = >curve_points[i].bezt; -// if (bezt->f2 & SELECT) { -// prev_sel = true; -// } -// else { -// /* unselected point - expand selection if previous was selected... */ -// if (prev_sel) { -// BEZT_SEL_ALL(bezt); -// } -// prev_sel = false; -// } -// } -// } -// } -// GP_EDITABLE_STROKES_END(gp_iter); +GP_EDITABLE_STROKES_BEGIN (gp_iter, C, gpl, gps) { + if (gps->editcurve != NULL && gps->flag & GP_STROKE_SELECT) { +bGPDcurve *editcurve = gps->editcurve; +int i; + +/* First Pass: Go in forward order, + * expanding selection if previous was selected (pre changes). + * - This pass covers the "after" edges of selection islands + */ +bool prev_sel = false; +for (i = 0; i < editcurve->tot_curve_points; i++) { + bGPDcurve_point *gpc_pt = >curve_points[i]; + BezTriple *bezt = _pt->bezt; + if (gpc_pt->flag & GP_CURVE_POINT_SELECT) { +/* selected point - just set flag for next point */ +prev_sel = true; + } + else { +/* unselected point - expand selection if previous was selected... */ +if (prev_sel) { + gpc_pt->flag |= GP_CURVE_POINT_SELECT; + BEZT_SEL_ALL(bezt); + changed = true; +} +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 = editcurve->tot_curve_points - 1; i > 0; i--) { + bGPDcurve_point *gpc_pt = >curve_points[i]; + BezTriple *bezt = _pt->bezt; + if (gpc_pt->flag & GP_CURVE_POINT_SELECT) { +prev_sel = true; + } + else { +/* unselected point - expand selection if previous was selected... */ +if (prev_sel) { + gpc_pt->flag |= GP_CURVE_POINT_SELECT; + BEZT_SEL_ALL(bezt); + changed = true; +} +prev_sel = false; + } +} + } +} +GP_EDITABLE_STROKES_END(gp_iter); } else { CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) { @@ -1065,49 +1070,54 @@ static int gpencil_select_less_exec(bContext *C, wmOperator *UNUSED(op)) bool changed = false; if (is_curve_edit) { -/* TODO: do curve select */ -// GP_
[Bf-blender-cvs] [95d0192308f] soc-2020-greasepencil-curve: GPencil: Implement select first/last curve point
Commit: 95d0192308f515e466a5b1447549bb69df28d35f Author: Falk David Date: Wed Jul 15 11:07:47 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB95d0192308f515e466a5b1447549bb69df28d35f GPencil: Implement select first/last curve point === M source/blender/editors/gpencil/gpencil_select.c === diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index acb4cbc1b1a..05912d45b9c 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -573,8 +573,8 @@ static bool gpencil_select_same_material(bContext *C) CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) { if (gps->flag & GP_STROKE_SELECT) { /* add instead of insert here, otherwise the uniqueness check gets skipped, -* and we get many duplicate entries... -*/ + * and we get many duplicate entries... + */ BLI_gset_add(selected_colors, >mat_nr); } } @@ -592,7 +592,7 @@ static bool gpencil_select_same_material(bContext *C) } gpc->flag |= GP_CURVE_SELECT; gps->flag |= GP_STROKE_SELECT; - + changed = true; } } @@ -710,19 +710,33 @@ static int gpencil_select_first_exec(bContext *C, wmOperator *op) const bool extend = RNA_boolean_get(op->ptr, "extend"); bool changed = false; - if (is_curve_edit) { -/* TODO: do curve select */ - } - else { -CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) { - /* skip stroke if we're only manipulating selected strokes */ - if (only_selected && !(gps->flag & GP_STROKE_SELECT)) { -continue; - } + CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) { +/* skip stroke if we're only manipulating selected strokes */ +if (only_selected && !(gps->flag & GP_STROKE_SELECT)) { + continue; +} - /* select first point */ - BLI_assert(gps->totpoints >= 1); +/* select first point */ +BLI_assert(gps->totpoints >= 1); +if (is_curve_edit) { + if (gps->editcurve != NULL) { +bGPDcurve *gpc = gps->editcurve; +gpc->curve_points[0].flag |= GP_CURVE_POINT_SELECT; +BEZT_SEL_ALL(>curve_points[0].bezt); +gpc->flag |= GP_CURVE_SELECT; +gps->flag |= GP_STROKE_SELECT; +if ((extend == false) && (gps->totpoints > 1)) { + for (int i = 1; i < gpc->tot_curve_points; i++) { +bGPDcurve_point *gpc_pt = >curve_points[i]; +gpc_pt->flag &= ~GP_CURVE_POINT_SELECT; +BEZT_DESEL_ALL(_pt->bezt); + } +} +changed = true; + } +} +else { gps->points->flag |= GP_SPOINT_SELECT; gps->flag |= GP_STROKE_SELECT; @@ -736,11 +750,10 @@ static int gpencil_select_first_exec(bContext *C, wmOperator *op) pt->flag &= ~GP_SPOINT_SELECT; } } - changed = true; } -CTX_DATA_END; } + CTX_DATA_END; if (changed) { /* updates */ @@ -787,7 +800,7 @@ void GPENCIL_OT_select_first(wmOperatorType *ot) /** \} */ /* */ -/** \name Select First +/** \name Select Last * \{ */ static int gpencil_select_last_exec(bContext *C, wmOperator *op) @@ -804,19 +817,33 @@ static int gpencil_select_last_exec(bContext *C, wmOperator *op) const bool extend = RNA_boolean_get(op->ptr, "extend"); bool changed = false; - if (is_curve_edit) { -/* TODO: do curve select */ - } - else { -CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) { - /* skip stroke if we're only manipulating selected strokes */ - if (only_selected && !(gps->flag & GP_STROKE_SELECT)) { -continue; - } + CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) { +/* skip stroke if we're only manipulating selected strokes */ +if (only_selected && !(gps->flag & GP_STROKE_SELECT)) { + continue; +} - /* select last point */ - BLI_assert(gps->totpoints >= 1); +/* select last point */ +BLI_assert(gps->totpoints >= 1); +if (is_curve_edit) { + if (gps->editcurve != NULL) { +bGPDcurve *gpc = gps->editcurve; +gpc->curve_points[gpc->tot_curve_points - 1].flag |= GP_CURVE_POINT_SELECT; +BEZT_SEL_ALL(>curve_points[gpc->tot_curve_points - 1].bezt); +gpc->flag |= GP_CURVE_SELECT; +gps->flag |= GP_STROKE_SELECT; +if ((extend == false) && (gps->totpoints > 1)) { + for (int i = 0; i &l
[Bf-blender-cvs] [fcd22007b52] soc-2020-greasepencil-curve: GPencil: Implement select grouped for curves
Commit: fcd22007b52033de52757f824ea1018e0d36b1aa Author: Falk David Date: Wed Jul 15 10:40:25 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBfcd22007b52033de52757f824ea1018e0d36b1aa GPencil: Implement select grouped for curves === M source/blender/editors/gpencil/gpencil_select.c === diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index 4aba4420c28..acb4cbc1b1a 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -500,31 +500,44 @@ static bool gpencil_select_same_layer(bContext *C) const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd); bool changed = false; - if (is_curve_edit) { -/* TODO: do curve select */ - } - else { -CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) { - bGPDframe *gpf = BKE_gpencil_layer_frame_get(gpl, CFRA, GP_GETFRAME_USE_PREV); - bGPDstroke *gps; - bool found = false; + CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) { +bGPDframe *gpf = BKE_gpencil_layer_frame_get(gpl, CFRA, GP_GETFRAME_USE_PREV); +bGPDstroke *gps; +bool found = false; - if (gpf == NULL) { -continue; +if (gpf == NULL) { + continue; +} + +/* Search for a selected stroke */ +for (gps = gpf->strokes.first; gps; gps = gps->next) { + if (ED_gpencil_stroke_can_use(C, gps)) { +if (gps->flag & GP_STROKE_SELECT) { + found = true; + break; +} } +} + +/* Select all if found */ +if (found) { + if (is_curve_edit) { +for (gps = gpf->strokes.first; gps; gps = gps->next) { + if (gps->editcurve != NULL && ED_gpencil_stroke_can_use(C, gps)) { +bGPDcurve *gpc = gps->editcurve; +for (int i = 0; i < gpc->tot_curve_points; i++) { + bGPDcurve_point *gpc_pt = >curve_points[i]; + gpc_pt->flag |= GP_CURVE_POINT_SELECT; + BEZT_SEL_ALL(_pt->bezt); +} +gpc->flag |= GP_CURVE_SELECT; +gps->flag |= GP_STROKE_SELECT; - /* Search for a selected stroke */ - for (gps = gpf->strokes.first; gps; gps = gps->next) { -if (ED_gpencil_stroke_can_use(C, gps)) { - if (gps->flag & GP_STROKE_SELECT) { -found = true; -break; +changed = true; } } } - - /* Select all if found */ - if (found) { + else { for (gps = gpf->strokes.first; gps; gps = gps->next) { if (ED_gpencil_stroke_can_use(C, gps)) { bGPDspoint *pt; @@ -541,8 +554,8 @@ static bool gpencil_select_same_layer(bContext *C) } } } -CTX_DATA_END; } + CTX_DATA_END; return changed; } @@ -556,21 +569,36 @@ static bool gpencil_select_same_material(bContext *C) GSet *selected_colors = BLI_gset_str_new("GP Selected Colors"); bool changed = false; - if (is_curve_edit) { -/* TODO: do curve select */ + + CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) { +if (gps->flag & GP_STROKE_SELECT) { + /* add instead of insert here, otherwise the uniqueness check gets skipped, +* and we get many duplicate entries... +*/ + BLI_gset_add(selected_colors, >mat_nr); +} } - else { + CTX_DATA_END; + + /* Second, select any visible stroke that uses these colors */ + if (is_curve_edit) { CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) { - if (gps->flag & GP_STROKE_SELECT) { -/* add instead of insert here, otherwise the uniqueness check gets skipped, - * and we get many duplicate entries... - */ -BLI_gset_add(selected_colors, >mat_nr); + if (gps->editcurve != NULL && BLI_gset_haskey(selected_colors, >mat_nr)) { +bGPDcurve *gpc = gps->editcurve; +for (int i = 0; i < gpc->tot_curve_points; i++) { + bGPDcurve_point *gpc_pt = >curve_points[i]; + gpc_pt->flag |= GP_CURVE_POINT_SELECT; + BEZT_SEL_ALL(_pt->bezt); +} +gpc->flag |= GP_CURVE_SELECT; +gps->flag |= GP_STROKE_SELECT; + +changed = true; } } CTX_DATA_END; - -/* Second, select any visible stroke that uses these colors */ + } + else { CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) { if (BLI_gset_haskey(selected_colors, >mat_nr)) { /* select this stroke */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d0d9490ac00] soc-2020-greasepencil-curve: GPencil: Implement select alternate curve points
Commit: d0d9490ac00967ddb3451502ca2423b0e1ec0bab Author: Falk David Date: Wed Jul 15 10:14:19 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBd0d9490ac00967ddb3451502ca2423b0e1ec0bab GPencil: Implement select alternate curve points === M source/blender/editors/gpencil/gpencil_select.c === diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index 1ce6db51cab..4aba4420c28 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -361,7 +361,43 @@ static int gpencil_select_alternate_exec(bContext *C, wmOperator *op) bool changed = false; if (is_curve_edit) { -/* TODO: do curve select */ +GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc) +{ + if ((gps->flag & GP_STROKE_SELECT) && (gps->totpoints > 1)) { +int idx = 0; +int start = 0; +if (unselect_ends) { + start = 1; +} + +for (int i = start; i < gpc->tot_curve_points; i++) { + bGPDcurve_point *gpc_pt = >curve_points[i]; + if ((idx % 2) == 0) { +gpc_pt->flag |= GP_SPOINT_SELECT; +BEZT_SEL_ALL(_pt->bezt); + } + else { +gpc_pt->flag &= ~GP_SPOINT_SELECT; +BEZT_DESEL_ALL(_pt->bezt); + } + idx++; +} + +if (unselect_ends) { + bGPDcurve_point *gpc_pt = >curve_points[0]; + gpc_pt->flag &= ~GP_SPOINT_SELECT; + BEZT_DESEL_ALL(_pt->bezt); + + gpc_pt = >curve_points[gpc->tot_curve_points - 1]; + gpc_pt->flag &= ~GP_SPOINT_SELECT; + BEZT_DESEL_ALL(_pt->bezt); +} + +BKE_gpencil_curve_sync_selection(gps); +changed = true; + } +} +GP_EDITABLE_CURVES_END(gps_iter); } else { /* select all points in selected strokes */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7e6b8f693c7] soc-2020-greasepencil-curve: GPencil: Fix compiler warnings
Commit: 7e6b8f693c7fb75faded80243831663a4f3a15d3 Author: Falk David Date: Wed Jul 15 10:08:45 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB7e6b8f693c7fb75faded80243831663a4f3a15d3 GPencil: Fix compiler warnings === M source/blender/editors/gpencil/gpencil_select.c === diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index c7d1388d799..1ce6db51cab 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -1435,15 +1435,14 @@ static bool gpencil_stroke_fill_isect_rect(ARegion *region, const float diff_mat[4][4], rcti rect) { - int min[2]; - int max[2]; - INIT_MINMAX2(min, max); + int min[2] = {-INT_MAX, -INT_MAX}; + int max[2] = {INT_MAX, INT_MAX}; int(*points2d)[2] = MEM_callocN(sizeof(int[2]) * gps->totpoints, __func__); for (int i = 0; i < gps->totpoints; i++) { bGPDspoint *pt = >points[i]; -int *pt2d = [i]; +int *pt2d = points2d[i]; int screen_co[2]; gpencil_3d_point_to_screen_space(region, diff_mat, >x, screen_co); @@ -1459,16 +1458,18 @@ static bool gpencil_stroke_fill_isect_rect(ARegion *region, for (int i = 0; i < gps->tot_triangles; i++) { bGPDtriangle *tri = >triangles[i]; int pt1[2], pt2[2], pt3[2]; - int tri_min[2], tri_max[2]; - INIT_MINMAX2(tri_min, tri_max); - copy_v2_v2_int(pt1, [tri->verts[0]]); - copy_v2_v2_int(pt2, [tri->verts[1]]); - copy_v2_v2_int(pt3, [tri->verts[2]]); + int tri_min[2] = {-INT_MAX, -INT_MAX}; + int tri_max[2] = {INT_MAX, INT_MAX}; + + copy_v2_v2_int(pt1, points2d[tri->verts[0]]); + copy_v2_v2_int(pt2, points2d[tri->verts[1]]); + copy_v2_v2_int(pt3, points2d[tri->verts[2]]); + DO_MINMAX2(pt1, tri_min, tri_max); DO_MINMAX2(pt2, tri_min, tri_max); DO_MINMAX2(pt3, tri_min, tri_max); - rcti tri_bb = {tri_min[0], tri_max[0], tri_min[1], tri_max[1]}; + rcti tri_bb = {tri_min[0], tri_max[0], tri_min[1], tri_max[1]}; if (BLI_rcti_inside_rcti(, _bb) || BLI_rcti_inside_rcti(_bb, )) { hit = true; break; @@ -1488,7 +1489,6 @@ static bool gpencil_stroke_fill_isect_rect(ARegion *region, static bool gpencil_generic_curve_select(bContext *C, Object *ob, - bGPdata *gpd, GPencilTestFn is_inside_fn, rcti box, GP_SelectUserData *user_data, @@ -1787,7 +1787,7 @@ static int gpencil_generic_select_exec(bContext *C, if (is_curve_edit) { changed = gpencil_generic_curve_select( -C, ob, gpd, is_inside_fn, box, user_data, strokemode, sel_op); +C, ob, is_inside_fn, box, user_data, strokemode, sel_op); } else { changed = gpencil_generic_stroke_select( ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [eb22e7a650a] soc-2020-greasepencil-curve: GPencil: Select fill curves
Commit: eb22e7a650a27cfd4abc49a0d7e32fa3d3ee209e Author: Falk David Date: Tue Jul 14 20:59:28 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBeb22e7a650a27cfd4abc49a0d7e32fa3d3ee209e GPencil: Select fill curves The previous algorithm used the center of the selection to check if the fill was selected. This uses the triangle data of the fill so it will be a bit slower, but results in better select behaviour. === M source/blender/editors/gpencil/gpencil_select.c === diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index d2f15f667b4..c7d1388d799 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -1430,6 +1430,62 @@ typedef bool (*GPencilTestFn)(ARegion *region, const float pt[3], GP_SelectUserData *user_data); +static bool gpencil_stroke_fill_isect_rect(ARegion *region, + bGPDstroke *gps, + const float diff_mat[4][4], + rcti rect) +{ + int min[2]; + int max[2]; + INIT_MINMAX2(min, max); + + int(*points2d)[2] = MEM_callocN(sizeof(int[2]) * gps->totpoints, __func__); + + for (int i = 0; i < gps->totpoints; i++) { +bGPDspoint *pt = >points[i]; +int *pt2d = [i]; + +int screen_co[2]; +gpencil_3d_point_to_screen_space(region, diff_mat, >x, screen_co); +DO_MINMAX2(screen_co, min, max); + +copy_v2_v2_int(pt2d, screen_co); + } + + bool hit = false; + /* check bounding box */ + rcti bb = {min[0], max[0], min[1], max[1]}; + if (BLI_rcti_isect(, , NULL)) { +for (int i = 0; i < gps->tot_triangles; i++) { + bGPDtriangle *tri = >triangles[i]; + int pt1[2], pt2[2], pt3[2]; + int tri_min[2], tri_max[2]; + INIT_MINMAX2(tri_min, tri_max); + copy_v2_v2_int(pt1, [tri->verts[0]]); + copy_v2_v2_int(pt2, [tri->verts[1]]); + copy_v2_v2_int(pt3, [tri->verts[2]]); + DO_MINMAX2(pt1, tri_min, tri_max); + DO_MINMAX2(pt2, tri_min, tri_max); + DO_MINMAX2(pt3, tri_min, tri_max); + rcti tri_bb = {tri_min[0], tri_max[0], tri_min[1], tri_max[1]}; + + if (BLI_rcti_inside_rcti(, _bb) || BLI_rcti_inside_rcti(_bb, )) { +hit = true; +break; + } + + if (BLI_rcti_isect_segment(, pt1, pt2) || BLI_rcti_isect_segment(, pt2, pt3) || + BLI_rcti_isect_segment(, pt3, pt1)) { +hit = true; +break; + } +} + } + + MEM_freeN(points2d); + return hit; +} + static bool gpencil_generic_curve_select(bContext *C, Object *ob, bGPdata *gpd, @@ -1444,37 +1500,9 @@ static bool gpencil_generic_curve_select(bContext *C, const bool handle_only_selected = (v3d->overlay.handle_display == CURVE_HANDLE_SELECTED); const bool handle_all = (v3d->overlay.handle_display == CURVE_HANDLE_ALL); - // /* deselect handles first */ - // if (SEL_OP_USE_PRE_DESELECT(sel_op)) { - // GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc) - // { - // /* deselect stroke and its points if selected */ - // if (gps->flag & GP_STROKE_SELECT) { - // if (gps->editcurve != NULL) { - // bGPDcurve *gpc = gps->editcurve; - // for (int j = 0; j < gpc->tot_curve_points; j++) { - // bGPDcurve_point *gpc_pt = >curve_points[j]; - // BezTriple *bezt = _pt->bezt; - // if (gpc_pt->flag & GP_CURVE_POINT_SELECT) { - // bezt->f1 &= ~SELECT; - // bezt->f3 &= ~SELECT; - // } - - // SET_FLAG_FROM_TEST(gpc_pt->flag, bezt->f1 || bezt->f3, GP_CURVE_POINT_SELECT); - // } - - // gpc->flag &= ~GP_CURVE_SELECT; - // } - - // /* deselect stroke itself too */ - // gps->flag &= ~GP_STROKE_SELECT; - // } - // } - // GP_EDITABLE_CURVES_END(gps_iter); - // } - bool hit = false; bool changed = false; + bool whole = false; GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc) { @@ -1566,16 +1594,13 @@ static bool gpencil_generic_curve_select(bContext *C, if ((gp_style->flag & GP_MATERIAL_FILL_SHOW) == 0) { continue; } - int mval[2]; - mval[0] = (box.xmax + box.xmin) / 2; - mval[1] = (box.ymax + box.ymin) / 2; - hit = false; + whole = gpencil_stroke_fill_isect_rect(region, gps, gps_iter.diff_mat, box); } /* select the entire curve */ -if (strokemode) { - const int sel_op_result = ED_select_op_action_deselected(sel_op, any_s
[Bf-blender-cvs] [d589d504439] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: d589d5044393d69a5dff0504a069c1870f6978b7 Author: Falk David Date: Tue Jul 14 16:53:08 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBd589d5044393d69a5dff0504a069c1870f6978b7 Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [5122c75fd62] soc-2020-greasepencil-curve: GPencil: Implement box and lasso curve select
Commit: 5122c75fd62c244473e10e3242f3312378bebca9 Author: Falk David Date: Tue Jul 14 16:52:35 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB5122c75fd62c244473e10e3242f3312378bebca9 GPencil: Implement box and lasso curve select === M source/blender/editors/gpencil/gpencil_select.c === diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index d348b849f5b..d2f15f667b4 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -128,6 +128,61 @@ static bool gpencil_select_poll(bContext *C) return false; } +static bool gpencil_3d_point_to_screen_space(ARegion *region, + const float diff_mat[4][4], + const float co[3], + int r_co[2]) +{ + float parent_co[3]; + mul_v3_m4v3(parent_co, diff_mat, co); + int screen_co[2]; + if (ED_view3d_project_int_global( + region, parent_co, screen_co, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == + V3D_PROJ_RET_OK) { +if (!ELEM(V2D_IS_CLIPPED, screen_co[0], screen_co[1])) { + copy_v2_v2_int(r_co, screen_co); + return true; +} + } + r_co[0] = V2D_IS_CLIPPED; + r_co[1] = V2D_IS_CLIPPED; + return false; +} + +/* helper to deselect all selected strokes/points */ +static void deselect_all_selected(bContext *C) +{ + CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) { +/* deselect stroke and its points if selected */ +if (gps->flag & GP_STROKE_SELECT) { + bGPDspoint *pt; + int i; + + /* deselect points */ + for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { +pt->flag &= ~GP_SPOINT_SELECT; + } + + /* deselect curve and curve points */ + if (gps->editcurve != NULL) { +bGPDcurve *gpc = gps->editcurve; +for (int j = 0; j < gpc->tot_curve_points; j++) { + bGPDcurve_point *gpc_pt = >curve_points[j]; + BezTriple *bezt = _pt->bezt; + gpc_pt->flag &= ~GP_CURVE_POINT_SELECT; + BEZT_DESEL_ALL(bezt); +} + +gpc->flag &= ~GP_CURVE_SELECT; + } + + /* deselect stroke itself too */ + gps->flag &= ~GP_STROKE_SELECT; +} + } + CTX_DATA_END; +} + /** \} */ /* */ @@ -1137,8 +1192,6 @@ static bool gpencil_stroke_do_circle_sel(bGPdata *gpd, } static bool gpencil_do_curve_circle_sel(bContext *C, -bGPdata *gpd, -bGPDlayer *gpl, bGPDstroke *gps, bGPDcurve *gpc, const int mx, @@ -1278,25 +1331,24 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op) rect.xmax = mx + radius; rect.ymax = my + radius; - GP_SpaceConversion gsc = {NULL}; - /* init space conversion stuff */ - gpencil_point_conversion_init(C, ); - if (is_curve_edit) { if (SEL_OP_USE_PRE_DESELECT(sel_op)) { ED_gpencil_select_curve_toggle_all(C, SEL_DESELECT); changed = true; } -/* TODO: do curve circle select */ GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc) { changed |= gpencil_do_curve_circle_sel( - C, gpd, gpl, gps, gpc, mx, my, radius, select, , gps_iter.diff_mat, selectmode); + C, gps, gpc, mx, my, radius, select, , gps_iter.diff_mat, selectmode); } GP_EDITABLE_CURVES_END(gps_iter); } else { +GP_SpaceConversion gsc = {NULL}; +/* init space conversion stuff */ +gpencil_point_conversion_init(C, ); + if (SEL_OP_USE_PRE_DESELECT(sel_op)) { ED_gpencil_select_toggle_all(C, SEL_DESELECT); changed = true; @@ -1365,18 +1417,203 @@ void GPENCIL_OT_select_circle(wmOperatorType *ot) * * \{ */ -typedef bool (*GPencilTestFn)(bGPDstroke *gps, - bGPDspoint *pt, - const GP_SpaceConversion *gsc, +typedef struct GP_SelectUserData { + int mx, my, radius; + /* Bounding box rect */ + rcti rect; + const int (*lasso_coords)[2]; + int lasso_coords_len; +} GP_SelectUserData; + +typedef bool (*GPencilTestFn)(ARegion *region, const float diff_mat[4][4], - void *user_data); + const float pt[3], + GP_SelectUserData *user_data); + +static bool gpencil_generic_curve_select(bContext *C, + Obje
[Bf-blender-cvs] [91b9f99f04a] soc-2020-greasepencil-curve: Clang formatting
Commit: 91b9f99f04a7f0deee56dc04c2537221f20c6e8e Author: Falk David Date: Sat Jul 11 20:43:29 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB91b9f99f04a7f0deee56dc04c2537221f20c6e8e Clang formatting === M source/blender/editors/gpencil/gpencil_data.c M source/blender/editors/gpencil/gpencil_select.c M source/blender/makesrna/intern/rna_access_internal.h === diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index e4edb83eb50..d3fc3aced97 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -1465,7 +1465,7 @@ static int gpencil_stroke_arrange_exec(bContext *C, wmOperator *op) default: BLI_assert(0); break; -changed = true; + changed = true; } } BLI_freelistN(); @@ -1659,7 +1659,7 @@ static int gpencil_material_lock_unsused_exec(bContext *C, wmOperator *UNUSED(op } } } - + if (changed) { /* updates */ DEG_id_tag_update(>id, ID_RECALC_GEOMETRY); @@ -3361,7 +3361,7 @@ static int gpencil_set_active_material_exec(bContext *C, wmOperator *op) } GP_EDITABLE_STROKES_END(gpstroke_iter); } - + /* notifiers */ if (changed) { WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index 6e7192f059c..d348b849f5b 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -1589,7 +1589,7 @@ static int gpencil_box_select_exec(bContext *C, wmOperator *op) if (is_curve_edit) { return gpencil_editcurve_box_select_exec(C, op, gpd); } - + struct GP_SelectBoxUserData data = {0}; WM_operator_properties_border_to_rcti(op, ); rcti rect = data.rect; diff --git a/source/blender/makesrna/intern/rna_access_internal.h b/source/blender/makesrna/intern/rna_access_internal.h index ecc9386ca77..7d8fff21862 100644 --- a/source/blender/makesrna/intern/rna_access_internal.h +++ b/source/blender/makesrna/intern/rna_access_internal.h @@ -30,8 +30,8 @@ struct PropertyRNAOrID; PropertyRNA *rna_ensure_property(PropertyRNA *prop); void rna_property_rna_or_id_get(PropertyRNA *prop, -PointerRNA *ptr, -PropertyRNAOrID *r_prop_rna_or_id); +PointerRNA *ptr, +PropertyRNAOrID *r_prop_rna_or_id); void rna_idproperty_touch(struct IDProperty *idprop); struct IDProperty *rna_idproperty_find(PointerRNA *ptr, const char *name); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [93acaccecba] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: 93acaccecba56827d86d5f22724391e89217569a Author: Falk David Date: Mon Jul 13 11:22:33 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB93acaccecba56827d86d5f22724391e89217569a Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8b1182d6cfb] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: 8b1182d6cfb798ab2eb3ff15c08a19851882d2ac Author: Falk David Date: Sat Jul 11 20:30:58 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB8b1182d6cfb798ab2eb3ff15c08a19851882d2ac Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b8220880148] soc-2020-greasepencil-curve: GPencil: Fix curve handles not updating
Commit: b8220880148412feab5ddcf85afd1b9f897a178f Author: Falk David Date: Sat Jul 11 17:08:24 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBb8220880148412feab5ddcf85afd1b9f897a178f GPencil: Fix curve handles not updating When the handle types of the first and last handles of a cyclic curve were changed, the handles did not update correctly. === M source/blender/editors/gpencil/gpencil_edit_curve.c === diff --git a/source/blender/editors/gpencil/gpencil_edit_curve.c b/source/blender/editors/gpencil/gpencil_edit_curve.c index fb8e608551d..b8d2ecf2474 100644 --- a/source/blender/editors/gpencil/gpencil_edit_curve.c +++ b/source/blender/editors/gpencil/gpencil_edit_curve.c @@ -164,7 +164,6 @@ static int gpencil_editcurve_set_handle_type_exec(bContext *C, wmOperator *op) if (bezt->f2 & SELECT) { bezt->h1 = handle_type; bezt->h2 = handle_type; - BKE_nurb_handle_calc(bezt, bezt_prev, bezt_next, false, 0); } else { if (bezt->f1 & SELECT) { @@ -173,13 +172,13 @@ static int gpencil_editcurve_set_handle_type_exec(bContext *C, wmOperator *op) if (bezt->f3 & SELECT) { bezt->h2 = handle_type; } - BKE_nurb_handle_calc(bezt, bezt_prev, bezt_next, false, 0); } - -gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE; -BKE_gpencil_stroke_geometry_update(gpd, gps); } } + +BKE_gpencil_editcurve_recalculate_handles(gps); +gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE; +BKE_gpencil_stroke_geometry_update(gpd, gps); } GP_EDITABLE_CURVES_END(gps_iter); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [9fa9ee61368] soc-2020-greasepencil-curve: GPencil: Implement editcurve subdivide
Commit: 9fa9ee61368860833e535a51aa789ed04fd2db72 Author: Falk David Date: Sat Jul 11 17:00:15 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB9fa9ee61368860833e535a51aa789ed04fd2db72 GPencil: Implement editcurve subdivide Implement an algorithm to subdivide an editcurve. === M source/blender/blenkernel/BKE_gpencil_curve.h M source/blender/blenkernel/intern/gpencil_curve.c M source/blender/editors/gpencil/gpencil_edit.c === diff --git a/source/blender/blenkernel/BKE_gpencil_curve.h b/source/blender/blenkernel/BKE_gpencil_curve.h index f16e8ae7acb..3527d678355 100644 --- a/source/blender/blenkernel/BKE_gpencil_curve.h +++ b/source/blender/blenkernel/BKE_gpencil_curve.h @@ -51,6 +51,7 @@ void BKE_gpencil_stroke_editcurve_sync_selection(struct bGPDstroke *gps, struct void BKE_gpencil_selected_strokes_editcurve_update(struct bGPdata *gpd); void BKE_gpencil_stroke_update_geometry_from_editcurve(struct bGPDstroke *gps); void BKE_gpencil_editcurve_recalculate_handles(struct bGPDstroke *gps); +void BKE_gpencil_editcurve_subdivide(struct bGPDstroke *gps, const int cuts); #ifdef __cplusplus } diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index 4bd3c326a09..3bd60746028 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -852,4 +852,143 @@ void BKE_gpencil_editcurve_recalculate_handles(bGPDstroke *gps) } } +/* Helper: count how many new curve points must be generated. */ +static int gpencil_editcurve_subdivide_count(bGPDcurve *gpc, bool is_cyclic) +{ + int count = 0; + for (int i = 0; i < gpc->tot_curve_points - 1; i++) { +bGPDcurve_point *cpt = >curve_points[i]; +bGPDcurve_point *cpt_next = >curve_points[i + 1]; + +if (cpt->flag & GP_CURVE_POINT_SELECT && cpt_next->flag & GP_CURVE_POINT_SELECT) { + count++; +} + } + + if (is_cyclic) { +bGPDcurve_point *cpt = >curve_points[0]; +bGPDcurve_point *cpt_next = >curve_points[gpc->tot_curve_points - 1]; + +if (cpt->flag & GP_CURVE_POINT_SELECT && cpt_next->flag & GP_CURVE_POINT_SELECT) { + count++; +} + } + + return count; +} + +static void gpencil_editcurve_subdivide_curve_segment(bGPDcurve_point *cpt_start, + bGPDcurve_point *cpt_end, + bGPDcurve_point *cpt_new) +{ + BezTriple *bezt_start = _start->bezt; + BezTriple *bezt_end = _end->bezt; + BezTriple *bezt_new = _new->bezt; + for (int axis = 0; axis < 3; axis++) { +float p0, p1, p2, p3, m0, m1, q0, q1, b; +p0 = bezt_start->vec[1][axis]; +p1 = bezt_start->vec[2][axis]; +p2 = bezt_end->vec[0][axis]; +p3 = bezt_end->vec[1][axis]; + +m0 = (p0 + p1) / 2; +q0 = (p0 + 2 * p1 + p2) / 4; +b = (p0 + 3 * p1 + 3 * p2 + p3) / 8; +q1 = (p1 + 2 * p2 + p3) / 4; +m1 = (p2 + p3) / 2; + +bezt_new->vec[0][axis] = q0; +bezt_new->vec[2][axis] = q1; +bezt_new->vec[1][axis] = b; + +bezt_start->vec[2][axis] = m0; +bezt_end->vec[0][axis] = m1; + } + + cpt_new->pressure = interpf(cpt_end->pressure, cpt_start->pressure, 0.5f); + cpt_new->strength = interpf(cpt_end->strength, cpt_start->strength, 0.5f); + interp_v4_v4v4(cpt_new->vert_color, cpt_start->vert_color, cpt_end->vert_color, 0.5f); +} + +void BKE_gpencil_editcurve_subdivide(bGPDstroke *gps, const int cuts) +{ + bGPDcurve *gpc = gps->editcurve; + if (gpc == NULL || gpc->tot_curve_points < 2) { +return; + } + bool is_cyclic = gps->flag & GP_STROKE_CYCLIC; + + /* repeat for number of cuts */ + for (int s = 0; s < cuts; s++) { +int old_tot_curve_points = gpc->tot_curve_points; +int new_num_curve_points = gpencil_editcurve_subdivide_count(gpc, is_cyclic); +if (new_num_curve_points == 0) { + break; +} +int new_tot_curve_points = old_tot_curve_points + new_num_curve_points; + +bGPDcurve_point *temp_curve_points = (bGPDcurve_point *)MEM_callocN( +sizeof(bGPDcurve_point) * new_tot_curve_points, __func__); + +bool prev_subdivided = false; +int j = 0; +for (int i = 0; i < old_tot_curve_points - 1; i++, j++) { + bGPDcurve_point *cpt = >curve_points[i]; + bGPDcurve_point *cpt_next = >curve_points[i + 1]; + + if (cpt->flag & GP_CURVE_POINT_SELECT && cpt_next->flag & GP_CURVE_POINT_SELECT) { +bGPDcurve_point *cpt_new = _curve_points[j + 1]; +gpencil_editcurve_subdivide_curve_segment(cpt, cpt_next, cpt_new); + +memcpy(_curve_points[j], cpt, sizeof(bGPDcurve_point)); +
[Bf-blender-cvs] [6b12994ccf1] soc-2020-greasepencil-curve: GPencil: Adapt box and lasso select for editcurve
Commit: 6b12994ccf119c953dc05635597016a2587b5fda Author: Falk David Date: Sat Jul 11 18:10:58 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB6b12994ccf119c953dc05635597016a2587b5fda GPencil: Adapt box and lasso select for editcurve === M source/blender/editors/gpencil/gpencil_select.c === diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index 1118ce2c10c..6e7192f059c 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -1572,8 +1572,24 @@ static bool gpencil_test_box(bGPDstroke *gps, return ((!ELEM(V2D_IS_CLIPPED, x0, y0)) && BLI_rcti_isect_pt(>rect, x0, y0)); } +static int gpencil_editcurve_box_select_exec(bContext *C, wmOperator *op, bGPdata *gpd) +{ + return OPERATOR_CANCELLED; +} + static int gpencil_box_select_exec(bContext *C, wmOperator *op) { + bGPdata *gpd = ED_gpencil_data_get_active(C); + + if (ELEM(gpd, NULL)) { +return OPERATOR_CANCELLED; + } + + const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd); + if (is_curve_edit) { +return gpencil_editcurve_box_select_exec(C, op, gpd); + } + struct GP_SelectBoxUserData data = {0}; WM_operator_properties_border_to_rcti(op, ); rcti rect = data.rect; @@ -1631,8 +1647,24 @@ static bool gpencil_test_lasso(bGPDstroke *gps, BLI_lasso_is_point_inside(data->mcoords, data->mcoords_len, x0, y0, INT_MAX)); } +static int gpencil_editcurve_lasso_select_exec(bContext *C, wmOperator *op, bGPdata *gpd) +{ + return OPERATOR_CANCELLED; +} + static int gpencil_lasso_select_exec(bContext *C, wmOperator *op) { + bGPdata *gpd = ED_gpencil_data_get_active(C); + + if (ELEM(gpd, NULL)) { +return OPERATOR_CANCELLED; + } + + const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd); + if (is_curve_edit) { +return gpencil_editcurve_lasso_select_exec(C, op, gpd); + } + struct GP_SelectLassoUserData data = {0}; data.mcoords = WM_gesture_lasso_path_to_array(C, op, _len); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2340540c44d] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: 2340540c44d70adc3a70b08a92dbcb1d1b623c7e Author: Falk David Date: Sat Jul 11 13:12:14 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB2340540c44d70adc3a70b08a92dbcb1d1b623c7e Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6fa8efd8159] soc-2020-greasepencil-curve: GPencil: Implement curve point circle select
Commit: 6fa8efd8159206da65a2d6c6da1ca71fd113da90 Author: Falk David Date: Sat Jul 11 13:11:34 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB6fa8efd8159206da65a2d6c6da1ca71fd113da90 GPencil: Implement curve point circle select === M source/blender/editors/gpencil/gpencil_select.c === diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index 0a231bee5cc..1118ce2c10c 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -405,7 +405,6 @@ typedef enum eGP_SelectGrouped { static bool gpencil_select_same_layer(bContext *C) { Scene *scene = CTX_data_scene(C); - Object *ob = CTX_data_active_object(C); bGPdata *gpd = ED_gpencil_data_get_active(C); const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd); @@ -460,7 +459,6 @@ static bool gpencil_select_same_layer(bContext *C) /* Select all strokes with same colors as selected ones */ static bool gpencil_select_same_material(bContext *C) { - Object *ob = CTX_data_active_object(C); bGPdata *gpd = ED_gpencil_data_get_active(C); const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd); /* First, build set containing all the colors of selected strokes */ @@ -1138,6 +1136,99 @@ static bool gpencil_stroke_do_circle_sel(bGPdata *gpd, return changed; } +static bool gpencil_do_curve_circle_sel(bContext *C, +bGPdata *gpd, +bGPDlayer *gpl, +bGPDstroke *gps, +bGPDcurve *gpc, +const int mx, +const int my, +const int radius, +const bool select, +rcti *rect, +const float diff_mat[4][4], +const int selectmode) +{ + ARegion *region = CTX_wm_region(C); + View3D *v3d = CTX_wm_view3d(C); + const bool only_selected = (v3d->overlay.handle_display == CURVE_HANDLE_SELECTED); + + bool hit = false; + for (int i = 0; i < gpc->tot_curve_points; i++) { +bGPDcurve_point *gpc_pt = >curve_points[i]; +BezTriple *bezt = _pt->bezt; + +if (bezt->hide == 1) { + continue; +} + +const bool handles_visible = (v3d->overlay.handle_display != CURVE_HANDLE_NONE) && + (!only_selected || BEZT_ISSEL_ANY(bezt)); + +/* if the handles are not visible only check ctrl point (vec[1])*/ +int from = (!handles_visible) ? 1 : 0; +int to = (!handles_visible) ? 2 : 3; + +for (int j = from; j < to; j++) { + float parent_co[3]; + mul_v3_m4v3(parent_co, diff_mat, bezt->vec[j]); + int screen_co[2]; + /* do 2d projection */ + if (ED_view3d_project_int_global( + region, parent_co, screen_co, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) != + V3D_PROJ_RET_OK) { +continue; + } + + /* view and bounding box test */ + if (ELEM(V2D_IS_CLIPPED, screen_co[0], screen_co[1]) && + !BLI_rcti_isect_pt(rect, screen_co[0], screen_co[1])) { +continue; + } + + /* test inside circle */ + int dist_x = screen_co[0] - mx; + int dist_y = screen_co[1] - my; + int dist = dist_x * dist_x + dist_y * dist_y; + if (dist <= radius * radius) { +hit = true; +/* change selection */ +if (select) { + gpc_pt->flag |= GP_CURVE_POINT_SELECT; + BEZT_SEL_IDX(bezt, j); +} +else { + BEZT_DESEL_IDX(bezt, j); + if (!BEZT_ISSEL_ANY(bezt)) { +gpc_pt->flag &= ~GP_CURVE_POINT_SELECT; + } +} + } +} + } + + /* select the entire curve */ + if (hit && (selectmode == GP_SELECTMODE_STROKE)) { +for (int i = 0; i < gpc->tot_curve_points; i++) { + bGPDcurve_point *gpc_pt = >curve_points[i]; + BezTriple *bezt = _pt->bezt; + + if (select) { +gpc_pt->flag |= GP_CURVE_POINT_SELECT; +BEZT_SEL_ALL(bezt); + } + else { +gpc_pt->flag &= ~GP_CURVE_POINT_SELECT; +BEZT_DESEL_ALL(bezt); + } +} + } + + BKE_gpencil_curve_sync_selection(gps); + + return hit; +} + static int gpencil_circle_select_exec(bContext *C, wmOperator *op) { bGPdata *gpd = ED_gpencil_data_get_active(C); @@ -1169,11 +1260,6 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op) const int my = RNA_int_get(op->ptr, "y"); const int radius = RNA_i
[Bf-blender-cvs] [dce8986223a] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: dce8986223ab39b18abc974eb9b6e31d245971d1 Author: Falk David Date: Fri Jul 10 16:37:37 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBdce8986223ab39b18abc974eb9b6e31d245971d1 Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6394287b1c2] soc-2020-greasepencil-curve: GPencil: Adapt edit mode operators for curve edit
Commit: 6394287b1c2ab517b77a3038b4bc6e8863c7c0cb Author: Falk David Date: Fri Jul 10 16:32:14 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB6394287b1c2ab517b77a3038b4bc6e8863c7c0cb GPencil: Adapt edit mode operators for curve edit Change the rest of the edit mode opearators (c62bc08f) so that they check if curve edit mode is active (if needed). === M source/blender/editors/gpencil/gpencil_data.c M source/blender/editors/gpencil/gpencil_edit.c === diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 40f71031dde..0666f523b67 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -1383,6 +1383,7 @@ static int gpencil_stroke_arrange_exec(bContext *C, wmOperator *op) const int direction = RNA_enum_get(op->ptr, "direction"); const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); + bool changed = false; CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) { /* temp listbase to store selected strokes */ ListBase selected = {NULL}; @@ -1441,7 +1442,7 @@ static int gpencil_stroke_arrange_exec(bContext *C, wmOperator *op) break; /* Bring Forward */ case GP_STROKE_MOVE_UP: - for (LinkData *link = selected.last; link; link = link->prev) { + LISTBASE_FOREACH_BACKWARD (LinkData *, link, ) { gps = link->data; BLI_listbase_link_move(>strokes, gps, 1); } @@ -1455,7 +1456,7 @@ static int gpencil_stroke_arrange_exec(bContext *C, wmOperator *op) break; /* Send to Back */ case GP_STROKE_MOVE_BOTTOM: - for (LinkData *link = selected.last; link; link = link->prev) { + LISTBASE_FOREACH_BACKWARD (LinkData *, link, ) { gps = link->data; BLI_remlink(>strokes, gps); BLI_addhead(>strokes, gps); @@ -1464,6 +1465,7 @@ static int gpencil_stroke_arrange_exec(bContext *C, wmOperator *op) default: BLI_assert(0); break; +changed = true; } } BLI_freelistN(); @@ -1477,9 +1479,11 @@ static int gpencil_stroke_arrange_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - /* notifiers */ - DEG_id_tag_update(>id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); - WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); + if (changed) { +/* notifiers */ +DEG_id_tag_update(>id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); +WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); + } return OPERATOR_FINISHED; } @@ -1545,6 +1549,7 @@ static int gpencil_stroke_change_color_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } + bool changed = false; /* loop all strokes */ CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) { bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe; @@ -1569,6 +1574,8 @@ static int gpencil_stroke_change_color_exec(bContext *C, wmOperator *op) /* assign new color */ gps->mat_nr = idx; + +changed = true; } } } @@ -1580,9 +1587,11 @@ static int gpencil_stroke_change_color_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - /* notifiers */ - DEG_id_tag_update(>id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); - WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); + if (changed) { +/* notifiers */ +DEG_id_tag_update(>id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); +WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); + } return OPERATOR_FINISHED; } @@ -1609,9 +1618,7 @@ void GPENCIL_OT_stroke_change_color(wmOperatorType *ot) static int gpencil_material_lock_unsused_exec(bContext *C, wmOperator *UNUSED(op)) { bGPdata *gpd = ED_gpencil_data_get_active(C); - Object *ob = CTX_data_active_object(C); - short *totcol = BKE_object_material_len_p(ob); /* sanity checks */ @@ -1628,6 +1635,7 @@ static int gpencil_material_lock_unsused_exec(bContext *C, wmOperator *UNUSED(op } } + bool changed = false; /* loop all selected strokes and unlock any color */ LISTBASE_FOREACH (bGPDlayer *, gpl, >layers) { /* only editable and visible layers are considered */ @@ -1645,19 +1653,24 @@ static int gpencil_material_lock_unsused_exec(bContext *C, wmOperator *UNUSED(op tmp_ma->gp_style->flag &= ~GP_MATERIAL_LOCKED; DEG_id_tag_update(_ma->id, ID_RECALC_COPY_ON_WRITE); } + + changed = true; } }
[Bf-blender-cvs] [596f10a0cf1] soc-2020-greasepencil-curve: GPencil: Curve mode: Set stroke select flag
Commit: 596f10a0cf14741679a4b3228662e12a0ae591ff Author: Falk David Date: Thu Jul 9 16:24:04 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB596f10a0cf14741679a4b3228662e12a0ae591ff GPencil: Curve mode: Set stroke select flag Set/unset the selection flag for a stroke, when its curve is selected. This change is needed so that operators like "change end caps" work as expected in curve edit mode. === M source/blender/blenkernel/BKE_gpencil.h M source/blender/blenkernel/intern/gpencil.c M source/blender/editors/gpencil/gpencil_select.c M source/blender/editors/gpencil/gpencil_utils.c === diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h index ffc16dbbaaf..9259729695d 100644 --- a/source/blender/blenkernel/BKE_gpencil.h +++ b/source/blender/blenkernel/BKE_gpencil.h @@ -104,7 +104,7 @@ void BKE_gpencil_batch_cache_dirty_tag(struct bGPdata *gpd); void BKE_gpencil_batch_cache_free(struct bGPdata *gpd); void BKE_gpencil_stroke_sync_selection(struct bGPDstroke *gps); -void BKE_gpencil_curve_sync_selection(struct bGPDcurve *gpc); +void BKE_gpencil_curve_sync_selection(struct bGPDstroke *gps); struct bGPDframe *BKE_gpencil_frame_addnew(struct bGPDlayer *gpl, int cframe); struct bGPDframe *BKE_gpencil_frame_addcopy(struct bGPDlayer *gpl, int cframe); diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 1b734e2e792..4d3b820304a 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -934,13 +934,16 @@ void BKE_gpencil_stroke_sync_selection(bGPDstroke *gps) } } -void BKE_gpencil_curve_sync_selection(bGPDcurve *gpc) +void BKE_gpencil_curve_sync_selection(bGPDstroke *gps) { + bGPDcurve *gpc = gps->editcurve; if (gpc == NULL) { return; } + gps->flag &= ~GP_STROKE_SELECT; gpc->flag &= ~GP_CURVE_SELECT; + bool is_selected = false; for (int i = 0; i < gpc->tot_curve_points; i++) { bGPDcurve_point *gpc_pt = >curve_points[i]; @@ -960,6 +963,7 @@ void BKE_gpencil_curve_sync_selection(bGPDcurve *gpc) if (is_selected) { gpc->flag |= GP_CURVE_SELECT; +gps->flag |= GP_STROKE_SELECT; } } diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index 6dc7228b70a..0a231bee5cc 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -1612,6 +1612,7 @@ static void deselect_all_selected(bContext *C) } gpc->flag &= ~GP_CURVE_SELECT; + gps->flag &= ~GP_STROKE_SELECT; } } CTX_DATA_END; @@ -1620,6 +1621,7 @@ static void deselect_all_selected(bContext *C) static void gpencil_select_curve_point(bContext *C, const int mval[2], const int radius_squared, + bGPDstroke **r_gps, bGPDcurve **r_gpc, bGPDcurve_point **r_pt, char *handle) @@ -1658,6 +1660,7 @@ static void gpencil_select_curve_point(bContext *C, const int pt_distance = len_manhattan_v2v2_int(mval, screen_co); if (pt_distance <= radius_squared && pt_distance < hit_distance) { + *r_gps = gps; *r_gpc = gpc; *r_pt = gpc_pt; *handle = j; @@ -1726,10 +1729,10 @@ static int gpencil_select_exec(bContext *C, wmOperator *op) if (is_curve_edit) { gpencil_select_curve_point( -C, mval, radius_squared, _curve, _curve_point, _curve_handle); +C, mval, radius_squared, _stroke, _curve, _curve_point, _curve_handle); } - if (hit_curve_point == NULL) { + if (hit_curve == NULL) { /* init space conversion stuff */ gpencil_point_conversion_init(C, ); @@ -1831,9 +1834,11 @@ static int gpencil_select_exec(bContext *C, wmOperator *op) if (deselect == false) { hit_curve->flag |= GP_CURVE_SELECT; +hit_stroke->flag |= GP_STROKE_SELECT; } else { hit_curve->flag &= ~GP_CURVE_SELECT; +hit_stroke->flag &= ~GP_STROKE_SELECT; } } else { @@ -1866,6 +1871,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op) hit_curve_point->flag |= GP_CURVE_POINT_SELECT; BEZT_SEL_IDX(_curve_point->bezt, hit_curve_handle); hit_curve->flag |= GP_CURVE_SELECT; +hit_stroke->flag |= GP_STROKE_SELECT; } else { /* we're adding selection, so selection must be true */ @@ -1898,7 +1904,7 @@
[Bf-blender-cvs] [c62bc08f45b] soc-2020-greasepencil-curve: GPencil: Adapt edit operators to curve edit mode
Commit: c62bc08f45b7714c889c147d87a3f8a145984d33 Author: Falk David Date: Tue Jul 7 17:25:50 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBc62bc08f45b7714c889c147d87a3f8a145984d33 GPencil: Adapt edit operators to curve edit mode Currently all operators do nothing in curve edit mode, but they should work normally in edit mode. This is the first step of implementing the operators in curve edit mode. === M source/blender/editors/gpencil/gpencil_data.c M source/blender/editors/gpencil/gpencil_edit.c === diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 96b0296a7de..40f71031dde 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -3324,7 +3324,7 @@ static int gpencil_set_active_material_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_active_object(C); bGPdata *gpd = ED_gpencil_data_get_active(C); - bool changed = false; + const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd); /* Sanity checks. */ if (gpd == NULL) { @@ -3332,17 +3332,23 @@ static int gpencil_set_active_material_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - /* Loop all selected strokes. */ - GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) { -if (gps->flag & GP_STROKE_SELECT) { - /* Change Active material. */ - ob->actcol = gps->mat_nr + 1; - changed = true; - break; + bool changed = false; + if (is_curve_edit) { +/* TODO: set curve stroke material */ + } + else { +/* Loop all selected strokes. */ +GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) { + if (gps->flag & GP_STROKE_SELECT) { +/* Change Active material. */ +ob->actcol = gps->mat_nr + 1; +changed = true; +break; + } } +GP_EDITABLE_STROKES_END(gpstroke_iter); } - GP_EDITABLE_STROKES_END(gpstroke_iter); - + /* notifiers */ if (changed) { WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index bcce94ca5eb..e5095ebb768 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -803,9 +803,9 @@ void GPENCIL_OT_selection_opacity_toggle(wmOperatorType *ot) /* Make copies of selected point segments in a selected stroke */ static void gpencil_duplicate_points(bGPdata *gpd, -const bGPDstroke *gps, -ListBase *new_strokes, -const char *layername) + const bGPDstroke *gps, + ListBase *new_strokes, + const char *layername) { bGPDspoint *pt; int i; @@ -884,6 +884,7 @@ static void gpencil_duplicate_points(bGPdata *gpd, static int gpencil_duplicate_exec(bContext *C, wmOperator *op) { bGPdata *gpd = ED_gpencil_data_get_active(C); + const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd); if (gpd == NULL) { BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data"); @@ -895,65 +896,74 @@ static int gpencil_duplicate_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - /* for each visible (and editable) layer's selected strokes, - * copy the strokes into a temporary buffer, then append - * once all done - */ - CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) { -ListBase new_strokes = {NULL, NULL}; -bGPDframe *gpf = gpl->actframe; -bGPDstroke *gps; - -if (gpf == NULL) { - continue; -} + bool changed = false; + if (is_curve_edit) { +/* TODO: handle copy in curve edit mode */ + } + else { +/* for each visible (and editable) layer's selected strokes, + * copy the strokes into a temporary buffer, then append + * once all done + */ +CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) { + ListBase new_strokes = {NULL, NULL}; + bGPDframe *gpf = gpl->actframe; + bGPDstroke *gps; -/* make copies of selected strokes, and deselect these once we're done */ -for (gps = gpf->strokes.first; gps; gps = gps->next) { - /* skip strokes that are invalid for current view */ - if (ED_gpencil_stroke_can_use(C, gps) == false) { + if (gpf == NULL) { continue; } - if (gps->flag & GP_STROKE_SELECT) { -if (gps->totpoints == 1) { - /* Special Case: If there's just a single point in this stroke... */ - bGPDstroke *gpsd; + /* make copies of selected strokes, and deselect
[Bf-blender-cvs] [b8087a2fa62] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: b8087a2fa6280e2b15a2392c0f706b18712e7e0b Author: Falk David Date: Tue Jul 7 17:26:25 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBb8087a2fa6280e2b15a2392c0f706b18712e7e0b Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [967c5b7da55] soc-2020-greasepencil-curve: GPencil: Adapt select operators to curve edit mode
Commit: 967c5b7da55507b8302b65a7dc813449321232c4 Author: Falk David Date: Tue Jul 7 12:27:22 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB967c5b7da55507b8302b65a7dc813449321232c4 GPencil: Adapt select operators to curve edit mode All select operators now check if curve edit mode is active. These include GPENCIL_OT_select, GPENCIL_OT_select_all, GPENCIL_OT_select_circle, GPENCIL_OT_select_box, GPENCIL_OT_select_lasso, GPENCIL_OT_select_linked, GPENCIL_OT_select_grouped, GPENCIL_OT_select_more, GPENCIL_OT_select_less, GPENCIL_OT_select_first, GPENCIL_OT_select_last, GPENCIL_OT_select_alternate and GPENCIL_OT_select_vertex_color === M source/blender/editors/gpencil/gpencil_select.c === diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index a5af22dc502..6dc7228b70a 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -151,6 +151,7 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op) { bGPdata *gpd = ED_gpencil_data_get_active(C); int action = RNA_enum_get(op->ptr, "action"); + const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd); if (gpd == NULL) { BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data"); @@ -170,7 +171,7 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op) } } - if (GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd)) { + if (is_curve_edit) { ED_gpencil_select_curve_toggle_all(C, action); } else { @@ -188,7 +189,6 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } - void GPENCIL_OT_select_all(wmOperatorType *ot) { /* identifiers */ @@ -215,6 +215,7 @@ void GPENCIL_OT_select_all(wmOperatorType *ot) static int gpencil_select_linked_exec(bContext *C, wmOperator *op) { bGPdata *gpd = ED_gpencil_data_get_active(C); + const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd); if (gpd == NULL) { BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data"); @@ -226,7 +227,7 @@ static int gpencil_select_linked_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - if (GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd)) { + if (is_curve_edit) { GP_EDITABLE_CURVES_BEGIN(gps_iter, C, gpl, gps, gpc) { if (gpc->flag & GP_CURVE_SELECT) { @@ -289,8 +290,9 @@ void GPENCIL_OT_select_linked(wmOperatorType *ot) static int gpencil_select_alternate_exec(bContext *C, wmOperator *op) { - const bool unselect_ends = RNA_boolean_get(op->ptr, "unselect_ends"); bGPdata *gpd = ED_gpencil_data_get_active(C); + const bool unselect_ends = RNA_boolean_get(op->ptr, "unselect_ends"); + const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd); if (gpd == NULL) { BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data"); @@ -302,47 +304,58 @@ static int gpencil_select_alternate_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - /* select all points in selected strokes */ - CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) { -if ((gps->flag & GP_STROKE_SELECT) && (gps->totpoints > 1)) { - bGPDspoint *pt; - int row = 0; - int start = 0; - if (unselect_ends) { -start = 1; - } + bool changed = false; + if (is_curve_edit) { +/* TODO: do curve select */ + } + else { +/* select all points in selected strokes */ +CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) { + if ((gps->flag & GP_STROKE_SELECT) && (gps->totpoints > 1)) { +bGPDspoint *pt; +int row = 0; +int start = 0; +if (unselect_ends) { + start = 1; +} - for (int i = start; i < gps->totpoints; i++) { -pt = >points[i]; -if ((row % 2) == 0) { - pt->flag |= GP_SPOINT_SELECT; +for (int i = start; i < gps->totpoints; i++) { + pt = >points[i]; + if ((row % 2) == 0) { +pt->flag |= GP_SPOINT_SELECT; + } + else { +pt->flag &= ~GP_SPOINT_SELECT; + } + row++; } -else { + +/* unselect start and end points */ +if (unselect_ends) { + pt = >points[0]; pt->flag &= ~GP_SPOINT_SELECT; -} -row++; - } - /* unselect start and end points */ - if (unselect_ends) { -pt = >points[0]; -pt->flag &= ~GP_SPOINT_SELECT; + pt = >points[gps->totpoints - 1]; + pt->flag &= ~GP_SPOINT_SELECT; +
[Bf-blender-cvs] [a0fa831bfeb] soc-2020-greasepencil-curve: GPencil: Remove error threshold as parameter
Commit: a0fa831bfeba548261319fc671324917567c4c96 Author: Falk David Date: Tue Jul 7 10:52:57 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBa0fa831bfeba548261319fc671324917567c4c96 GPencil: Remove error threshold as parameter Use the error threshold in gpd instead of the operator property. === M source/blender/editors/gpencil/gpencil_select.c M source/blender/editors/gpencil/gpencil_utils.c M source/blender/editors/include/ED_gpencil.h === diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index 94017e64632..a5af22dc502 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -128,31 +128,6 @@ static bool gpencil_select_poll(bContext *C) return false; } -static bool error_threshold_display_poll(bContext *C) -{ - CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) { -if (gps->editcurve == NULL) { - return true; -} - } - CTX_DATA_END; - return false; -} - -static void gpencil_select_ui(bContext *C, wmOperator *op) -{ - uiLayout *layout = op->layout; - PointerRNA ptr; - - Object *ob = CTX_data_active_object(C); - bGPdata *gpd = ob->data; - - if (GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd)) { // && error_threshold_display_poll(C)) { -RNA_pointer_create(NULL, op->type->srna, op->properties, ); -uiItemR(layout, , "error_threshold", 0, "Error Threshold", ICON_NONE); - } -} - /** \} */ /* */ @@ -176,7 +151,6 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op) { bGPdata *gpd = ED_gpencil_data_get_active(C); int action = RNA_enum_get(op->ptr, "action"); - float error_threshold = RNA_float_get(op->ptr, "error_threshold"); if (gpd == NULL) { BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data"); @@ -197,7 +171,7 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op) } if (GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd)) { -ED_gpencil_select_curve_toggle_all(C, action, error_threshold); +ED_gpencil_select_curve_toggle_all(C, action); } else { ED_gpencil_select_toggle_all(C, action); @@ -214,19 +188,6 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static void WM_operator_property_error_threshold(wmOperatorType *ot) -{ - PropertyRNA *prop = RNA_def_float(ot->srna, -"error_threshold", -0.1f, -FLT_MIN, -100.0f, -"Error Threshold", -"Threshold on the maximum deviation from the actual stroke", -FLT_MIN, -10.f); - RNA_def_property_ui_range(prop, FLT_MIN, 10.0f, 0.1f, 5); -} void GPENCIL_OT_select_all(wmOperatorType *ot) { @@ -242,10 +203,7 @@ void GPENCIL_OT_select_all(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - ot->ui = gpencil_select_ui; - WM_operator_properties_select_all(ot); - WM_operator_property_error_threshold(ot); } /** \} */ @@ -1868,14 +1826,12 @@ void GPENCIL_OT_select(wmOperatorType *ot) ot->invoke = gpencil_select_invoke; ot->exec = gpencil_select_exec; ot->poll = gpencil_select_poll; - ot->ui = gpencil_select_ui; /* flag */ ot->flag = OPTYPE_UNDO; /* properties */ WM_operator_properties_mouse_select(ot); - WM_operator_property_error_threshold(ot); prop = RNA_def_boolean(ot->srna, "entire_strokes", diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index 4b094cc3b23..82287b81171 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -2247,11 +2247,11 @@ static void gpencil_copy_points( } static void gpencil_insert_point(bGPdata *gpd, -bGPDstroke *gps, -bGPDspoint *a_pt, -bGPDspoint *b_pt, -const float co_a[3], -float co_b[3]) + bGPDstroke *gps, + bGPDspoint *a_pt, + bGPDspoint *b_pt, + const float co_a[3], + float co_b[3]) { bGPDspoint *temp_points; int totnewpoints, oldtotpoints; @@ -2615,7
[Bf-blender-cvs] [fa662dceef3] soc-2020-greasepencil-curve: GPencil: Support cyclic curves
Commit: fa662dceef378f9c68d56c7d1e5e403d14bc8b46 Author: Falk David Date: Mon Jul 6 17:05:05 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBfa662dceef378f9c68d56c7d1e5e403d14bc8b46 GPencil: Support cyclic curves Generte points between the first and last curve point when converting a curve to a stroke. === M source/blender/blenkernel/intern/gpencil_curve.c === diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index ac3ef162b22..6b0016734df 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -676,6 +676,38 @@ static void gpencil_interpolate_v4_from_to( } } +static void gpencil_calculate_stroke_points_curve_point( +bGPDcurve_point *cpt, bGPDcurve_point *cpt_next, float *points_offset, int resolu, int stride) +{ + /* sample points on all 3 axis between two curve points */ + for (uint axis = 0; axis < 3; axis++) { +BKE_curve_forward_diff_bezier(cpt->bezt.vec[1][axis], + cpt->bezt.vec[2][axis], + cpt_next->bezt.vec[0][axis], + cpt_next->bezt.vec[1][axis], + POINTER_OFFSET(points_offset, sizeof(float) * axis), + (int)resolu, + stride); + } + + /* interpolate other attributes */ + gpencil_interpolate_fl_from_to(cpt->pressure, + cpt_next->pressure, + POINTER_OFFSET(points_offset, sizeof(float) * 3), + resolu, + stride); + gpencil_interpolate_fl_from_to(cpt->strength, + cpt_next->strength, + POINTER_OFFSET(points_offset, sizeof(float) * 4), + resolu, + stride); + gpencil_interpolate_v4_from_to(cpt->vert_color, + cpt_next->vert_color, + POINTER_OFFSET(points_offset, sizeof(float) * 5), + resolu, + stride); +} + /** * Recalculate stroke points with the editcurve of the stroke. */ @@ -696,7 +728,7 @@ void BKE_gpencil_stroke_update_geometry_from_editcurve(bGPDstroke *gps) const uint stride = sizeof(float[9]); const uint resolu_stride = resolu * stride; const uint points_len = BKE_curve_calc_coords_axis_len( - curve_point_array_len, resolu, is_cyclic, true); + curve_point_array_len, resolu, is_cyclic, false); float(*points)[9] = MEM_callocN((stride * points_len * (is_cyclic ? 2 : 1)), __func__); float *points_offset = [0][0]; @@ -704,59 +736,23 @@ void BKE_gpencil_stroke_update_geometry_from_editcurve(bGPDstroke *gps) bGPDcurve_point *cpt_curr = _point_array[i]; bGPDcurve_point *cpt_next = _point_array[i + 1]; -/* sample points on all 3 axis between two curve points */ -for (uint axis = 0; axis < 3; axis++) { - BKE_curve_forward_diff_bezier(cpt_curr->bezt.vec[1][axis], -cpt_curr->bezt.vec[2][axis], -cpt_next->bezt.vec[0][axis], -cpt_next->bezt.vec[1][axis], -POINTER_OFFSET(points_offset, sizeof(float) * axis), -(int)resolu, -stride); -} - -/* interpolate other attributes */ -gpencil_interpolate_fl_from_to(cpt_curr->pressure, - cpt_next->pressure, - POINTER_OFFSET(points_offset, sizeof(float) * 3), - resolu, - stride); -gpencil_interpolate_fl_from_to(cpt_curr->strength, - cpt_next->strength, - POINTER_OFFSET(points_offset, sizeof(float) * 4), - resolu, - stride); -gpencil_interpolate_v4_from_to(cpt_curr->vert_color, - cpt_next->vert_color, - POINTER_OFFSET(points_offset, sizeof(float) * 5), - resolu, - stride); +gpencil_calculate_stroke_points_curve_point(cpt_curr, cpt_next, points_offset, resolu, stride); /* update the index */ cpt_curr->point_index = i * resolu; points_offset = POINTER_OFFSET(points_offset, resolu_stride
[Bf-blender-cvs] [ab91491963f] soc-2020-greasepencil-curve: GPencil: Recalculating handles for cyclic curves
Commit: ab91491963f555609c95dfe1bdc5317dcfd0a665 Author: Falk David Date: Mon Jul 6 17:07:34 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBab91491963f555609c95dfe1bdc5317dcfd0a665 GPencil: Recalculating handles for cyclic curves === M source/blender/blenkernel/intern/gpencil_curve.c === diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index 6b0016734df..949b741d67c 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -566,19 +566,19 @@ void BKE_gpencil_editcurve_stroke_sync_selection(bGPDstroke *gps, bGPDcurve *gpc if (gps->flag & GP_STROKE_SELECT) { gpc->flag |= GP_CURVE_SELECT; - for (int i = 0; i < gpc->tot_curve_points; i++) { -bGPDcurve_point *gpc_pt = >curve_points[i]; -bGPDspoint *pt = >points[gpc_pt->point_index]; -if (pt->flag & GP_SPOINT_SELECT) { - gpc_pt->flag |= GP_CURVE_POINT_SELECT; - BEZT_SEL_ALL(_pt->bezt); -} -else { - gpc_pt->flag &= ~GP_CURVE_POINT_SELECT; - BEZT_DESEL_ALL(_pt->bezt); +for (int i = 0; i < gpc->tot_curve_points; i++) { + bGPDcurve_point *gpc_pt = >curve_points[i]; + bGPDspoint *pt = >points[gpc_pt->point_index]; + if (pt->flag & GP_SPOINT_SELECT) { +gpc_pt->flag |= GP_CURVE_POINT_SELECT; +BEZT_SEL_ALL(_pt->bezt); + } + else { +gpc_pt->flag &= ~GP_CURVE_POINT_SELECT; +BEZT_DESEL_ALL(_pt->bezt); + } } } -} else { gpc->flag &= ~GP_CURVE_SELECT; gpencil_editstroke_deselect_all(gpc); @@ -594,12 +594,12 @@ void BKE_gpencil_stroke_editcurve_sync_selection(bGPDstroke *gps, bGPDcurve *gpc gps->flag |= GP_STROKE_SELECT; for (int i = 0; i < gpc->tot_curve_points - 1; i++) { -bGPDcurve_point *gpc_pt = >curve_points[i]; -bGPDspoint *pt = >points[gpc_pt->point_index]; + bGPDcurve_point *gpc_pt = >curve_points[i]; + bGPDspoint *pt = >points[gpc_pt->point_index]; bGPDcurve_point *gpc_pt_next = >curve_points[i + 1]; -if (gpc_pt->flag & GP_CURVE_POINT_SELECT) { - pt->flag |= GP_SPOINT_SELECT; + if (gpc_pt->flag & GP_CURVE_POINT_SELECT) { +pt->flag |= GP_SPOINT_SELECT; if (gpc_pt_next->flag & GP_CURVE_POINT_SELECT) { /* select all the points after */ for (int j = gpc_pt->point_index + 1; j < gpc_pt_next->point_index; j++) { @@ -614,9 +614,9 @@ void BKE_gpencil_stroke_editcurve_sync_selection(bGPDstroke *gps, bGPDcurve *gpc for (int j = gpc_pt->point_index + 1; j < gpc_pt_next->point_index; j++) { bGPDspoint *pt_next = >points[j]; pt_next->flag &= ~GP_SPOINT_SELECT; +} + } } - } -} bGPDcurve_point *gpc_first = >curve_points[0]; bGPDcurve_point *gpc_last = >curve_points[gpc->tot_curve_points - 1]; @@ -792,24 +792,56 @@ void BKE_gpencil_editcurve_recalculate_handles(bGPDstroke *gps) return; } - for (int i = 0; i < gpc->tot_curve_points; i++) { + if (gpc->tot_curve_points == 1) { +BKE_nurb_handle_calc(&(gpc->curve_points[0].bezt), NULL, NULL, false, 0); +gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE; + } + + for (int i = 1; i < gpc->tot_curve_points - 1; i++) { bGPDcurve_point *gpc_pt = >curve_points[i]; -bGPDcurve_point *gpc_pt_prev = (i > 0) ? >curve_points[i - 1] : NULL; -bGPDcurve_point *gpc_pt_next = (i < gpc->tot_curve_points - 1) ? >curve_points[i + 1] : - NULL; +bGPDcurve_point *gpc_pt_prev = >curve_points[i - 1]; +bGPDcurve_point *gpc_pt_next = >curve_points[i + 1]; /* update handle if point or neighbour is selected */ -if (gpc_pt->flag & GP_CURVE_POINT_SELECT || -(gpc_pt_prev != NULL && gpc_pt_prev->flag & GP_CURVE_POINT_SELECT) || -(gpc_pt_next != NULL && gpc_pt_next->flag & GP_CURVE_POINT_SELECT)) { +if (gpc_pt->flag & GP_CURVE_POINT_SELECT || gpc_pt_prev->flag & GP_CURVE_POINT_SELECT || +gpc_pt_next->flag & GP_CURVE_POINT_SELECT) { BezTriple *bezt = _pt->bezt; - BezTriple *bezt_prev = gpc_pt_prev != NULL ? _pt_prev->bezt : NULL; - BezTriple *bezt_next = gpc_pt_next != NULL ? _pt_next->bezt : NULL; + BezTriple *bezt_prev = _pt_prev->bezt; + BezTriple *bezt_next = _pt_next->bezt; BKE_nurb_handle_calc(bezt, bezt_prev, bezt_next, false, 0); changed = true; } } + bGPDcurv
[Bf-blender-cvs] [d1b1eaf9bb5] soc-2020-greasepencil-curve: Merge branch 'soc-2020-greasepencil-curve' of git.blender.org:blender into soc-2020-greasepencil-curve
Commit: d1b1eaf9bb5758c0963e2947b24c9c4a7f083169 Author: Falk David Date: Mon Jul 6 17:20:11 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBd1b1eaf9bb5758c0963e2947b24c9c4a7f083169 Merge branch 'soc-2020-greasepencil-curve' of git.blender.org:blender into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [96eca6c3d44] soc-2020-greasepencil-curve: GPencil: Fix selection sync for cyclic strokes
Commit: 96eca6c3d44709dde799865935a0361b9ea09052 Author: Falk David Date: Mon Jul 6 17:02:49 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB96eca6c3d44709dde799865935a0361b9ea09052 GPencil: Fix selection sync for cyclic strokes === M source/blender/blenkernel/intern/gpencil_curve.c === diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index 0159ac836e5..ac3ef162b22 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -393,6 +393,16 @@ static void gpencil_convert_spline(Main *bmain, BKE_gpencil_stroke_geometry_update(gpd, gps); } +static void gpencil_editstroke_deselect_all(bGPDcurve *gpc) +{ + for (int i = 0; i < gpc->tot_curve_points; i++) { +bGPDcurve_point *gpc_pt = >curve_points[i]; +BezTriple *bezt = _pt->bezt; +gpc_pt->flag &= ~GP_CURVE_POINT_SELECT; +BEZT_DESEL_ALL(bezt); + } +} + /** * Convert a curve object to grease pencil stroke. * @@ -555,10 +565,6 @@ void BKE_gpencil_editcurve_stroke_sync_selection(bGPDstroke *gps, bGPDcurve *gpc { if (gps->flag & GP_STROKE_SELECT) { gpc->flag |= GP_CURVE_SELECT; - } - else { -gpc->flag &= ~GP_CURVE_SELECT; - } for (int i = 0; i < gpc->tot_curve_points; i++) { bGPDcurve_point *gpc_pt = >curve_points[i]; @@ -573,6 +579,11 @@ void BKE_gpencil_editcurve_stroke_sync_selection(bGPDstroke *gps, bGPDcurve *gpc } } } + else { +gpc->flag &= ~GP_CURVE_SELECT; +gpencil_editstroke_deselect_all(gpc); + } +} /** * Sync the selection from editcurve to stroke @@ -581,27 +592,62 @@ void BKE_gpencil_stroke_editcurve_sync_selection(bGPDstroke *gps, bGPDcurve *gpc { if (gpc->flag & GP_CURVE_SELECT) { gps->flag |= GP_STROKE_SELECT; - } - else { -gps->flag &= ~GP_STROKE_SELECT; - } - for (int i = 0; i < gpc->tot_curve_points; i++) { +for (int i = 0; i < gpc->tot_curve_points - 1; i++) { bGPDcurve_point *gpc_pt = >curve_points[i]; bGPDspoint *pt = >points[gpc_pt->point_index]; + bGPDcurve_point *gpc_pt_next = >curve_points[i + 1]; if (gpc_pt->flag & GP_CURVE_POINT_SELECT) { pt->flag |= GP_SPOINT_SELECT; - if (i + 1 < gpc->tot_curve_points) { -bGPDcurve_point *gpc_pt_next = >curve_points[i + 1]; if (gpc_pt_next->flag & GP_CURVE_POINT_SELECT) { - /* select all the points inbetween */ + /* select all the points after */ for (int j = gpc_pt->point_index + 1; j < gpc_pt_next->point_index; j++) { bGPDspoint *pt_next = >points[j]; pt_next->flag |= GP_SPOINT_SELECT; } } } + else { +pt->flag &= ~GP_SPOINT_SELECT; +/* deselect all points after */ +for (int j = gpc_pt->point_index + 1; j < gpc_pt_next->point_index; j++) { + bGPDspoint *pt_next = >points[j]; + pt_next->flag &= ~GP_SPOINT_SELECT; +} + } +} + +bGPDcurve_point *gpc_first = >curve_points[0]; +bGPDcurve_point *gpc_last = >curve_points[gpc->tot_curve_points - 1]; +bGPDspoint *last_pt = >points[gpc_last->point_index]; +if (gpc_last->flag & GP_CURVE_POINT_SELECT) { + last_pt->flag |= GP_SPOINT_SELECT; +} +else { + last_pt->flag &= ~GP_SPOINT_SELECT; +} + +if (gps->flag & GP_STROKE_CYCLIC) { + if (gpc_first->flag & GP_CURVE_POINT_SELECT && gpc_last->flag & GP_CURVE_POINT_SELECT) { +for (int i = gpc_last->point_index + 1; i < gps->totpoints; i++) { + bGPDspoint *pt_next = >points[i]; + pt_next->flag |= GP_SPOINT_SELECT; +} + } + else { +for (int i = gpc_last->point_index + 1; i < gps->totpoints; i++) { + bGPDspoint *pt_next = >points[i]; + pt_next->flag &= ~GP_SPOINT_SELECT; +} + } +} + } + else { +gps->flag &= ~GP_STROKE_SELECT; +for (int i = 0; i < gps->totpoints; i++) { + bGPDspoint *pt = >points[i]; + pt->flag &= ~GP_SPOINT_SELECT; } } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [68a3c874ce6] soc-2020-greasepencil-curve: GPencil: Set flag to fit curve to cyclic stroke
Commit: 68a3c874ce61cb33d302c3861608cb6090b73ff1 Author: Falk David Date: Mon Jul 6 17:19:59 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB68a3c874ce61cb33d302c3861608cb6090b73ff1 GPencil: Set flag to fit curve to cyclic stroke === M source/blender/blenkernel/intern/gpencil_curve.c === diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index 949b741d67c..4bd3c326a09 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -481,6 +481,11 @@ bGPDcurve *BKE_gpencil_stroke_editcurve_generate(bGPDstroke *gps, float error_th copy_v3_v3(to, >x); } + uint calc_flag = CURVE_FIT_CALC_HIGH_QUALIY; + if (gps->totpoints > 2 && gps->flag & GP_STROKE_CYCLIC) { +calc_flag |= CURVE_FIT_CALC_CYCLIC; + } + float *r_cubic_array = NULL; unsigned int r_cubic_array_len = 0; unsigned int *r_cubic_orig_index = NULL; @@ -490,7 +495,7 @@ bGPDcurve *BKE_gpencil_stroke_editcurve_generate(bGPDstroke *gps, float error_th gps->totpoints, POINT_DIM, error_threshold, - CURVE_FIT_CALC_HIGH_QUALIY, + calc_flag, NULL, 0, _cubic_array, ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [486a06d71be] soc-2020-greasepencil-curve: GPencil: Set handle type for individual handle
Commit: 486a06d71be1a27ba2f90c51140a0d5e39471de1 Author: Falk David Date: Mon Jul 6 17:06:54 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB486a06d71be1a27ba2f90c51140a0d5e39471de1 GPencil: Set handle type for individual handle Before it was only possible to set the handle type for both handles of a bezier tripple. Now the user can set the type individually. === M source/blender/editors/gpencil/gpencil_edit_curve.c === diff --git a/source/blender/editors/gpencil/gpencil_edit_curve.c b/source/blender/editors/gpencil/gpencil_edit_curve.c index b919f73d024..fb8e608551d 100644 --- a/source/blender/editors/gpencil/gpencil_edit_curve.c +++ b/source/blender/editors/gpencil/gpencil_edit_curve.c @@ -87,7 +87,7 @@ static int gpencil_stroke_enter_editcurve_mode(bContext *C, wmOperator *op) if (gpf == gpl->actframe) { LISTBASE_FOREACH (bGPDstroke *, gps, >strokes) { /* only allow selected and non-converted strokes to be transformed */ - if ((gps->flag & GP_STROKE_SELECT) && gps->editcurve == NULL || + if ((gps->flag & GP_STROKE_SELECT && gps->editcurve == NULL) || (gps->editcurve != NULL && gps->editcurve->flag & GP_CURVE_NEEDS_STROKE_UPDATE)) { BKE_gpencil_stroke_editcurve_update(gps, gpd->curve_edit_threshold); if (gps->editcurve != NULL) { @@ -153,18 +153,28 @@ static int gpencil_editcurve_set_handle_type_exec(bContext *C, wmOperator *op) bGPDcurve_point *gpc_pt = >curve_points[i]; if (gpc_pt->flag & GP_CURVE_POINT_SELECT) { +BezTriple *bezt = _pt->bezt; bGPDcurve_point *gpc_pt_prev = (i > 0) ? >curve_points[i - 1] : NULL; bGPDcurve_point *gpc_pt_next = (i < gpc->tot_curve_points - 1) ? >curve_points[i + 1] : NULL; BezTriple *bezt_prev = gpc_pt_prev != NULL ? _pt_prev->bezt : NULL; -BezTriple *bezt = _pt->bezt; BezTriple *bezt_next = gpc_pt_next != NULL ? _pt_next->bezt : NULL; -bezt->h1 = handle_type; -bezt->h2 = handle_type; - -BKE_nurb_handle_calc(bezt, bezt_prev, bezt_next, false, 0); +if (bezt->f2 & SELECT) { + bezt->h1 = handle_type; + bezt->h2 = handle_type; + BKE_nurb_handle_calc(bezt, bezt_prev, bezt_next, false, 0); +} +else { + if (bezt->f1 & SELECT) { +bezt->h1 = handle_type; + } + if (bezt->f3 & SELECT) { +bezt->h2 = handle_type; + } + BKE_nurb_handle_calc(bezt, bezt_prev, bezt_next, false, 0); +} gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE; BKE_gpencil_stroke_geometry_update(gpd, gps); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2575fc9181b] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: 2575fc9181b093625e5090d674107d657efdecde Author: Falk David Date: Sun Jul 5 15:59:40 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB2575fc9181b093625e5090d674107d657efdecde Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [04fc48300b3] soc-2020-greasepencil-curve: Gpencil: Fix compiler warning
Commit: 04fc48300b32f95fdf6439e33b1fa93c3bf61aa6 Author: Falk David Date: Fri Jul 3 20:56:50 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB04fc48300b32f95fdf6439e33b1fa93c3bf61aa6 Gpencil: Fix compiler warning === M source/blender/editors/gpencil/gpencil_edit_curve.c === diff --git a/source/blender/editors/gpencil/gpencil_edit_curve.c b/source/blender/editors/gpencil/gpencil_edit_curve.c index 748cc53e7e3..b919f73d024 100644 --- a/source/blender/editors/gpencil/gpencil_edit_curve.c +++ b/source/blender/editors/gpencil/gpencil_edit_curve.c @@ -87,7 +87,7 @@ static int gpencil_stroke_enter_editcurve_mode(bContext *C, wmOperator *op) if (gpf == gpl->actframe) { LISTBASE_FOREACH (bGPDstroke *, gps, >strokes) { /* only allow selected and non-converted strokes to be transformed */ - if (gps->flag & GP_STROKE_SELECT && gps->editcurve == NULL || + if ((gps->flag & GP_STROKE_SELECT) && gps->editcurve == NULL || (gps->editcurve != NULL && gps->editcurve->flag & GP_CURVE_NEEDS_STROKE_UPDATE)) { BKE_gpencil_stroke_editcurve_update(gps, gpd->curve_edit_threshold); if (gps->editcurve != NULL) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [1fca1d9f74f] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: 1fca1d9f74f88957be7f4697bcbb75cb256e7b41 Author: Falk David Date: Fri Jul 3 20:57:13 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB1fca1d9f74f88957be7f4697bcbb75cb256e7b41 Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [85a11fd2b31] soc-2020-greasepencil-curve: GPencil: Review of curve <> stroke conversion
Commit: 85a11fd2b31275a74f092011a1e22016c5b1a379 Author: Falk David Date: Fri Jul 3 17:20:12 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rB85a11fd2b31275a74f092011a1e22016c5b1a379 GPencil: Review of curve <> stroke conversion This commit introduces a new flag GP_STROKE_NEEDS_CURVE_UPDATE in the stroke that replaces GP_CURVE_RECALC_GEOMETRY. The name was not consistent and it didn't make much sense to have it in the editcurve. Another flag was added: GP_CURVE_NEEDS_STROKE_UPDATE. This indicates that the curve data is dirty and needs to be regenerated. === M source/blender/blenkernel/intern/gpencil_curve.c M source/blender/blenkernel/intern/gpencil_geom.c M source/blender/editors/gpencil/gpencil_edit_curve.c M source/blender/editors/gpencil/gpencil_utils.c M source/blender/editors/transform/transform_convert_gpencil.c M source/blender/makesdna/DNA_gpencil_types.h M source/blender/makesrna/intern/rna_gpencil.c === diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index 385123a71d8..0159ac836e5 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -528,7 +528,7 @@ bGPDcurve *BKE_gpencil_stroke_editcurve_generate(bGPDstroke *gps, float error_th } /** - * Updates the editcurve for a stroke. + * Updates the editcurve for a stroke. Frees the old curve if one exists and generates a new one. */ void BKE_gpencil_stroke_editcurve_update(bGPDstroke *gps, float error_threshold) { @@ -544,8 +544,7 @@ void BKE_gpencil_stroke_editcurve_update(bGPDstroke *gps, float error_threshold) if (editcurve == NULL) { return; } - /* update the selection based on the selected points in the stroke */ - BKE_gpencil_editcurve_stroke_sync_selection(gps, editcurve); + gps->editcurve = editcurve; } @@ -607,44 +606,6 @@ void BKE_gpencil_stroke_editcurve_sync_selection(bGPDstroke *gps, bGPDcurve *gpc } } -/** - * Update editcurve for all selected strokes. - */ -void BKE_gpencil_selected_strokes_editcurve_update(bGPdata *gpd) -{ - if (gpd == NULL) { -return; - } - - const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); - - LISTBASE_FOREACH (bGPDlayer *, gpl, >layers) { -if (!BKE_gpencil_layer_is_editable(gpl)) { - continue; -} -bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe; -for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) { - if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && is_multiedit)) { -LISTBASE_FOREACH (bGPDstroke *, gps, >strokes) { - /* skip deselected stroke */ - if (!(gps->flag & GP_STROKE_SELECT)) { -continue; - } - - if (gps->editcurve == NULL) { -BKE_gpencil_stroke_editcurve_update(gps, gpd->curve_edit_threshold); -if (gps->editcurve != NULL) { - gps->editcurve->resolution = gpd->editcurve_resolution; - gps->editcurve->flag |= GP_CURVE_RECALC_GEOMETRY; -} - } - BKE_gpencil_stroke_geometry_update(gpd, gps); -} - } -} - } -} - static void gpencil_interpolate_fl_from_to( float from, float to, float *point_offset, int it, int stride) { @@ -770,6 +731,7 @@ void BKE_gpencil_stroke_update_geometry_from_editcurve(bGPDstroke *gps) copy_v4_v4(pt->vert_color, [i][5]); } + /* free temp data */ MEM_freeN(points); } @@ -784,13 +746,19 @@ void BKE_gpencil_editcurve_recalculate_handles(bGPDstroke *gps) bool changed = false; bGPDcurve *gpc = gps->editcurve; + if (gpc->tot_curve_points < 1) { +return; + } + for (int i = 0; i < gpc->tot_curve_points; i++) { bGPDcurve_point *gpc_pt = >curve_points[i]; -if (gpc_pt->flag & GP_CURVE_POINT_SELECT) { - bGPDcurve_point *gpc_pt_prev = (i > 0) ? >curve_points[i - 1] : NULL; - bGPDcurve_point *gpc_pt_next = (i < gpc->tot_curve_points - 1) ? >curve_points[i + 1] : - NULL; - +bGPDcurve_point *gpc_pt_prev = (i > 0) ? >curve_points[i - 1] : NULL; +bGPDcurve_point *gpc_pt_next = (i < gpc->tot_curve_points - 1) ? >curve_points[i + 1] : + NULL; +/* update handle if point or neighbour is selected */ +if (gpc_pt->flag & GP_CURVE_POINT_SELECT || +(gpc_pt_prev != NULL && gpc_pt_prev->flag & GP_CURVE_POINT_SELECT) || +(gpc_pt_next != NULL && gpc_pt_next->flag & GP_CURVE_POINT_SELECT)) { BezTriple
[Bf-blender-cvs] [a18bf89232a] soc-2020-greasepencil-curve: Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve
Commit: a18bf89232a731cc27f8b8762e4c181a1740ec26 Author: Falk David Date: Fri Jul 3 17:21:23 2020 +0200 Branches: soc-2020-greasepencil-curve https://developer.blender.org/rBa18bf89232a731cc27f8b8762e4c181a1740ec26 Merge branch 'greasepencil-edit-curve' into soc-2020-greasepencil-curve === === diff --cc source/blender/blenkernel/intern/gpencil_geom.c index 01c6c52cc12,f374e09b0d4..101e3c6c486 --- a/source/blender/blenkernel/intern/gpencil_geom.c +++ b/source/blender/blenkernel/intern/gpencil_geom.c @@@ -1201,8 -1268,12 +1268,12 @@@ void BKE_gpencil_stroke_uv_update(bGPDs } } - /* Recalc the internal geometry caches for fill and uvs. */ + /** + * Recalc all internal geometry data for the stroke + * \param gpd: Grease pencil data-block + * \param gps: Grease pencil stroke + */ -void BKE_gpencil_stroke_geometry_update(bGPdata *UNUSED(gpd), bGPDstroke *gps) +void BKE_gpencil_stroke_geometry_update(bGPdata *gpd, bGPDstroke *gps) { if (gps == NULL) { return; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs