diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-05-06 10:52:12 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-05-06 11:14:16 +0300 |
commit | 47de0321bf68c8cd96c14e8d0f5ddd8850a2cc12 (patch) | |
tree | eb0bec6eed1fa85fb248bc5ad754ca8a7eeaad3a /source/blender/editors/transform | |
parent | f7123f0f11c747847a0b5f785fe393f073efcc1d (diff) |
Transform: support initial offset option
Needed to redo extrude+transform macro w/o resetting the translation.
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r-- | source/blender/editors/transform/transform.c | 12 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.h | 1 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_input.c | 6 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_ops.c | 5 |
4 files changed, 21 insertions, 3 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 69f48292b71..0f1abe00eb4 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -2408,6 +2408,8 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } } + BLI_assert(is_zero_v4(t->values_modal_offset)); + /* overwrite initial values if operator supplied a non-null vector * * keep last so we can apply the constraints space. @@ -2423,8 +2425,14 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } copy_v4_v4(t->values, values); - copy_v4_v4(t->auto_values, values); - t->flag |= T_AUTOVALUES; + + if (t->flag & T_MODAL) { + copy_v4_v4(t->values_modal_offset, values); + } + else { + copy_v4_v4(t->auto_values, values); + t->flag |= T_AUTOVALUES; + } } t->context = NULL; diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 358be8f9e29..7686431d808 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -511,6 +511,7 @@ typedef struct TransInfo { short mirror; float values[4]; + float values_modal_offset[4]; /* Offset applied ontop of modal input. */ float auto_values[4]; float axis[3]; float axis_orig[3]; /* TransCon can change 'axis', store the original value here */ diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index db761e5e23a..799d2acb918 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -417,6 +417,12 @@ void applyMouseInput(TransInfo *t, MouseInput *mi, const int mval[2], float outp mi->apply(t, mi, mval_db, output); } + if (!is_zero_v3(t->values_modal_offset)) { + float values_ofs[3]; + mul_v3_m3v3(values_ofs, t->spacemtx, t->values_modal_offset); + add_v3_v3(t->values, values_ofs); + } + if (mi->post) { mi->post(t, output); } diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 6f31f5311bc..eba03087711 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -479,7 +479,10 @@ static int transform_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_CANCELLED; } - if (RNA_struct_property_is_set(op->ptr, "value")) { + /* When modal, allow 'value' to set initial offset. */ + if ((event == NULL) && + RNA_struct_property_is_set(op->ptr, "value")) + { return transform_exec(C, op); } else { |