Transform: support initial offset option
Needed to redo extrude+transform macro w/o resetting the translation.
This commit is contained in:
@@ -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;
|
||||
|
@@ -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 */
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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 {
|
||||
|
Reference in New Issue
Block a user