diff options
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r-- | source/blender/editors/transform/transform.c | 83 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 6 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_ops.c | 3 |
3 files changed, 91 insertions, 1 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 7044b75fefd..b928343d8bf 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -139,6 +139,9 @@ static void applyCurveShrinkFatten(TransInfo *t, const int mval[2]); static void initMaskShrinkFatten(TransInfo *t); static void applyMaskShrinkFatten(TransInfo *t, const int mval[2]); +static void initGPShrinkFatten(TransInfo *t); +static void applyGPShrinkFatten(TransInfo *t, const int mval[2]); + static void initTrackball(TransInfo *t); static void applyTrackball(TransInfo *t, const int mval[2]); @@ -2165,6 +2168,9 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve case TFM_MASK_SHRINKFATTEN: initMaskShrinkFatten(t); break; + case TFM_GPENCIL_SHRINKFATTEN: + initGPShrinkFatten(t); + break; case TFM_TRACKBALL: initTrackball(t); break; @@ -4669,6 +4675,83 @@ static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) /* -------------------------------------------------------------------- */ +/* Transform (GPencil Shrink/Fatten) */ + +/** \name Transform GPencil Strokes Shrink/Fatten + * \{ */ + +static void initGPShrinkFatten(TransInfo *t) +{ + t->mode = TFM_GPENCIL_SHRINKFATTEN; + t->transform = applyGPShrinkFatten; + + initMouseInputMode(t, &t->mouse, INPUT_SPRING); + + t->idx_max = 0; + t->num.idx_max = 0; + t->snap[0] = 0.0f; + t->snap[1] = 0.1f; + t->snap[2] = t->snap[1] * 0.1f; + + copy_v3_fl(t->num.val_inc, t->snap[1]); + t->num.unit_sys = t->scene->unit.system; + t->num.unit_type[0] = B_UNIT_NONE; + + t->flag |= T_NO_ZERO; +#ifdef USE_NUM_NO_ZERO + t->num.val_flag[0] |= NUM_NO_ZERO; +#endif + + t->flag |= T_NO_CONSTRAINT; +} + +static void applyGPShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) +{ + TransData *td = t->data; + float ratio; + int i; + char str[MAX_INFO_LEN]; + + ratio = t->values[0]; + + snapGridIncrement(t, &ratio); + + applyNumInput(&t->num, &ratio); + + /* header print for NumInput */ + if (hasNumInput(&t->num)) { + char c[NUM_STR_REP_LEN]; + + outputNumInput(&(t->num), c, &t->scene->unit); + BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Shrink/Fatten: %s"), c); + } + else { + BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Shrink/Fatten: %3f"), ratio); + } + + for (i = 0; i < t->total; i++, td++) { + if (td->flag & TD_NOACTION) + break; + + if (td->flag & TD_SKIP) + continue; + + if (td->val) { + *td->val = td->ival * ratio; + /* apply PET */ + *td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival); + if (*td->val <= 0.0f) *td->val = 0.001f; + } + } + + recalcData(t); + + ED_area_headerprint(t->sa, str); +} +/** \} */ + + +/* -------------------------------------------------------------------- */ /* Transform (Push/Pull) */ /** \name Transform Push/Pull diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 4802f8dc127..b50f56aae3e 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -7502,6 +7502,12 @@ static void createTransGPencil(bContext *C, TransInfo *t) if (pt->flag & GP_SPOINT_SELECT) td->flag |= TD_SELECTED; + + /* for other transform modes (e.g. shrink-fatten), need to additional data */ + if (t->mode == TFM_GPENCIL_SHRINKFATTEN) { + td->val = &pt->pressure; + td->ival = pt->pressure; + } /* configure 2D points so that they don't play up... */ if (gps->flag & (GP_STROKE_2DSPACE | GP_STROKE_2DIMAGE)) { diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 1498e2894d4..0ee5ab96a85 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -142,6 +142,7 @@ EnumPropertyItem transform_mode_types[] = {TFM_BONE_ENVELOPE, "BONE_ENVELOPE", 0, "Bone_Envelope", ""}, {TFM_CURVE_SHRINKFATTEN, "CURVE_SHRINKFATTEN", 0, "Curve_Shrinkfatten", ""}, {TFM_MASK_SHRINKFATTEN, "MASK_SHRINKFATTEN", 0, "Mask_Shrinkfatten", ""}, + {TFM_GPENCIL_SHRINKFATTEN, "GPENCIL_SHRINKFATTEN", 0, "GPencil_Shrinkfatten", ""}, {TFM_BONE_ROLL, "BONE_ROLL", 0, "Bone_Roll", ""}, {TFM_TIME_TRANSLATE, "TIME_TRANSLATE", 0, "Time_Translate", ""}, {TFM_TIME_SLIDE, "TIME_SLIDE", 0, "Time_Slide", ""}, @@ -974,7 +975,7 @@ static void TRANSFORM_OT_transform(struct wmOperatorType *ot) RNA_def_float_vector(ot->srna, "value", 4, NULL, -FLT_MAX, FLT_MAX, "Values", "", -FLT_MAX, FLT_MAX); - Transform_Properties(ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP); + Transform_Properties(ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP | P_GPENCIL_EDIT); } void transform_operatortypes(void) |