[Bf-blender-cvs] [e71421c542d] greasepencil-experimental: GPencil: Modify Select operaors (wip)
Antonioya
noreply at git.blender.org
Wed May 8 20:26:31 CEST 2019
Commit: e71421c542dfb16f8616e0613b71638edc934e60
Author: Antonioya
Date: Wed May 8 20:25:44 2019 +0200
Branches: greasepencil-experimental
https://developer.blender.org/rBe71421c542dfb16f8616e0613b71638edc934e60
GPencil: Modify Select operaors (wip)
Prepare operators to work with derived data.
===================================================================
M source/blender/blenkernel/intern/gpencil_modifier.c
M source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M source/blender/editors/gpencil/gpencil_select.c
===================================================================
diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c
index 07e6d274c7f..e5e3418c2a5 100644
--- a/source/blender/blenkernel/intern/gpencil_modifier.c
+++ b/source/blender/blenkernel/intern/gpencil_modifier.c
@@ -781,6 +781,7 @@ void BKE_gpencil_subdivide(bGPDstroke *gps, int level, int flag)
pt_final->strength = pt->strength;
pt_final->time = pt->time;
pt_final->flag = pt->flag;
+ pt_final->runtime.pt_orig = pt->runtime.pt_orig;
if (gps->dvert != NULL) {
dvert = &temp_dverts[i];
@@ -868,10 +869,9 @@ static void gpencil_copy_frame(bGPDframe *gpf, bGPDframe *derived_gpf)
/* Save original pointers for using in edit and select operators. */
gps_dst->runtime.gps_orig = gps_src;
- bGPDspoint *pt_src = gps_src->points;
- bGPDspoint *pt_dst = gps_dst->points;
- for (int i = 0; i < gps_src->totpoints; i++, pt_dst++, pt_src++) {
- pt_dst->runtime.pt_orig = pt_src;
+ for (int i = 0; i < gps_src->totpoints; i++) {
+ bGPDspoint *pt_dst = &gps_dst->points[i];
+ pt_dst->runtime.pt_orig = &gps_src->points[i];
}
BLI_addtail(&derived_gpf->strokes, gps_dst);
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 9849c23c947..11cdcc792e4 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -734,6 +734,9 @@ void DRW_gpencil_get_edit_geom(struct GpencilBatchCacheElem *be,
UI_GetThemeColor3fv(TH_GP_VERTEX, unselectColor);
unselectColor[3] = alpha;
+ float linecolor[4];
+ copy_v4_v4(linecolor, gpd->line_color);
+
if (be->vbo == NULL) {
gpencil_elem_format_ensure(be);
be->pos_id = GPU_vertformat_attr_add(be->format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
@@ -778,6 +781,12 @@ void DRW_gpencil_get_edit_geom(struct GpencilBatchCacheElem *be,
ARRAY_SET_ITEMS(fcolor, 1.0f, 0.0f, 0.0f, 1.0f);
fsize = vsize + 1;
}
+ else if (pt->runtime.pt_orig == NULL) {
+ ARRAY_SET_ITEMS(fcolor, linecolor[0], linecolor[1], linecolor[2], selectColor[3]);
+ mul_v4_fl(fcolor, 0.9f);
+ copy_v4_v4(fcolor, fcolor);
+ fsize = vsize * 0.8f;
+ }
else if (pt->flag & GP_SPOINT_SELECT) {
copy_v4_v4(fcolor, selectColor);
fsize = vsize;
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index 52d0774d4ac..560662a7790 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -1057,28 +1057,39 @@ static int gpencil_generic_select_exec(bContext *C,
}
/* select/deselect points */
- GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
+ GP_DERIVED_STROKES_BEGIN(gpstroke_iter, C, gpl, gps)
+ {
bGPDspoint *pt;
int i;
bool hit = false;
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
+ if (pt->runtime.pt_orig == NULL) {
+ continue;
+ }
+
/* convert point coords to screenspace */
const bool is_inside = is_inside_fn(gps, pt, &gsc, gpstroke_iter.diff_mat, user_data);
if (strokemode == false) {
- const bool is_select = (pt->flag & GP_SPOINT_SELECT) != 0;
+ const bool is_select = (pt->runtime.pt_orig->flag & GP_SPOINT_SELECT) != 0;
const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside);
if (sel_op_result != -1) {
- SET_FLAG_FROM_TEST(pt->flag, sel_op_result, GP_SPOINT_SELECT);
+ SET_FLAG_FROM_TEST(pt->runtime.pt_orig->flag, sel_op_result, GP_SPOINT_SELECT);
changed = true;
/* expand selection to segment */
if ((sel_op_result != -1) && (segmentmode)) {
- bool hit_select = (bool)(pt->flag & GP_SPOINT_SELECT);
+ bool hit_select = (bool)(pt->runtime.pt_orig->flag & GP_SPOINT_SELECT);
float r_hita[3], r_hitb[3];
- ED_gpencil_select_stroke_segment(
- gpl, gps, pt, hit_select, false, scale, r_hita, r_hitb);
+ ED_gpencil_select_stroke_segment(gpl,
+ gps->runtime.gps_orig,
+ pt->runtime.pt_orig,
+ hit_select,
+ false,
+ scale,
+ r_hita,
+ r_hitb);
}
}
}
@@ -1092,16 +1103,19 @@ static int gpencil_generic_select_exec(bContext *C,
/* if stroke mode expand selection */
if (strokemode) {
- const bool is_select = BKE_gpencil_stroke_select_check(gps);
+ const bool is_select = BKE_gpencil_stroke_select_check(gps->runtime.gps_orig);
const bool is_inside = hit;
const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside);
if (sel_op_result != -1) {
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
+ if (pt->runtime.pt_orig == NULL) {
+ continue;
+ }
if (sel_op_result) {
- pt->flag |= GP_SPOINT_SELECT;
+ pt->runtime.pt_orig->flag |= GP_SPOINT_SELECT;
}
else {
- pt->flag &= ~GP_SPOINT_SELECT;
+ pt->runtime.pt_orig->flag &= ~GP_SPOINT_SELECT;
}
}
changed = true;
@@ -1109,9 +1123,9 @@ static int gpencil_generic_select_exec(bContext *C,
}
/* Ensure that stroke selection is in sync with its points */
- BKE_gpencil_stroke_sync_selection(gps);
+ BKE_gpencil_stroke_sync_selection(gps->runtime.gps_orig);
}
- GP_EDITABLE_STROKES_END(gpstroke_iter);
+ GP_DERIVED_STROKES_END(gpstroke_iter);
/* if paint mode,delete selected points */
if (gpd->flag & GP_DATA_STROKE_PAINTMODE) {
@@ -1336,6 +1350,9 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
/* firstly, check for hit-point */
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
int xy[2];
+ if (pt->runtime.pt_orig == NULL) {
+ continue;
+ }
bGPDspoint pt2;
gp_point_to_parent_space(pt, gpstroke_iter.diff_mat, &pt2);
@@ -1350,8 +1367,8 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
/* only use this point if it is a better match than the current hit - T44685 */
if (pt_distance < hit_distance) {
hit_layer = gpl;
- hit_stroke = gps;
- hit_point = pt;
+ hit_stroke = gps->runtime.gps_orig;
+ hit_point = pt->runtime.pt_orig;
hit_distance = pt_distance;
}
}
More information about the Bf-blender-cvs
mailing list