diff options
author | Antonioya <blendergit@gmail.com> | 2018-12-19 00:56:23 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2018-12-19 00:56:40 +0300 |
commit | 61a816e8ff060016f6e450bb6bbd9df5c93665a6 (patch) | |
tree | 3031499bf9ced75fff1444c8032e3bd4dda91ed6 | |
parent | 0d7fe55d0e76abd3c3bdac4af224ee7393b1cdb7 (diff) |
GP: Add calculation of center for transformation by stroke (WIP)
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 0184e754305..3576406ee0b 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -8204,6 +8204,33 @@ void flushTransPaintCurve(TransInfo *t) } } +static void createTransGPencil_center_get( + bGPDstroke *gps, const bool is_prop_edit, float r_center[3]) +{ + bGPDspoint *pt; + int i; + + zero_v3(r_center); + int tot_sel = 0; + for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { + bool point_ok; + if (is_prop_edit) { + point_ok = true; + } + else { + /* Only selected points in selected strokes */ + point_ok = (pt->flag & GP_SPOINT_SELECT) != 0; + } + if (point_ok) { + add_v3_v3(r_center, &pt->x); + tot_sel++; + } + } + + if (tot_sel > 0) { + mul_v3_fl(r_center, 1.0f / tot_sel); + } +} static void createTransGPencil(bContext *C, TransInfo *t) { @@ -8407,6 +8434,10 @@ static void createTransGPencil(bContext *C, TransInfo *t) /* save falloff factor */ gps->runtime.multi_frame_falloff = falloff; + /* calculate stroke center */ + float center[3]; + createTransGPencil_center_get(gps, is_prop_edit, ¢er[0]); + /* add all necessary points... */ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { bool point_ok; @@ -8424,7 +8455,7 @@ static void createTransGPencil(bContext *C, TransInfo *t) /* do point... */ if (point_ok) { copy_v3_v3(td->iloc, &pt->x); - copy_v3_v3(td->center, &pt->x); // XXX: what about t->around == local? + copy_v3_v3(td->center, center); td->loc = &pt->x; |