[Bf-blender-cvs] [81dc76c19cf] master: Fix T63570: Proportional editing resets scaling along Y and Z axis on mouse wheel
mano-wii
noreply at git.blender.org
Fri Aug 2 06:16:13 CEST 2019
Commit: 81dc76c19cff51c9c1d13ab47cbfc9a855fc3263
Author: mano-wii
Date: Fri Aug 2 01:15:33 2019 -0300
Branches: master
https://developer.blender.org/rB81dc76c19cff51c9c1d13ab47cbfc9a855fc3263
Fix T63570: Proportional editing resets scaling along Y and Z axis on mouse wheel
`applyResize(...)` considers that `t->values` always represents a `ratio`.
But this is only `true` with the `MOUSEMOVE` event.
The solution proposed is to never change `t->values`.
The result of the final transformation is now written to `t->values_final`.
Reviewers: campbellbarton
Differential Revision: https://developer.blender.org/D5212
===================================================================
M source/blender/editors/transform/transform.c
M source/blender/editors/transform/transform.h
M source/blender/editors/transform/transform_constraints.c
===================================================================
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 5ef86c71d2d..973c1c0b7f7 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -2093,15 +2093,11 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
}
if ((prop = RNA_struct_find_property(op->ptr, "value"))) {
- float values[4];
-
- copy_v4_v4(values, (t->flag & T_AUTOVALUES) ? t->auto_values : t->values);
-
if (RNA_property_array_check(prop)) {
- RNA_property_float_set_array(op->ptr, prop, values);
+ RNA_property_float_set_array(op->ptr, prop, t->values_final);
}
else {
- RNA_property_float_set(op->ptr, prop, values[0]);
+ RNA_property_float_set(op->ptr, prop, t->values_final[0]);
}
}
@@ -2488,8 +2484,8 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->redraw = TREDRAW_HARD;
}
else {
- copy_v4_v4(t->auto_values, values);
- t->flag |= T_AUTOVALUES;
+ copy_v4_v4(t->values, values);
+ t->flag |= T_INPUT_IS_VALUES_FINAL;
}
}
@@ -3374,7 +3370,7 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2]))
values.scale = values.scale / data->warp_init_dist;
}
- copy_v2_v2(t->values, values.vector);
+ copy_v2_v2(t->values_final, values.vector);
/* header print for NumInput */
if (hasNumInput(&t->num)) {
@@ -3615,7 +3611,7 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
applyNumInput(&t->num, &value);
- t->values[0] = value;
+ t->values_final[0] = value;
/* header print for NumInput */
if (hasNumInput(&t->num)) {
@@ -3946,10 +3942,10 @@ static void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, f
/* scale stroke thickness */
if (td->val) {
- snapGridIncrement(t, t->values);
- applyNumInput(&t->num, t->values);
+ snapGridIncrement(t, t->values_final);
+ applyNumInput(&t->num, t->values_final);
- float ratio = t->values[0];
+ float ratio = t->values_final[0];
*td->val = td->ival * ratio * gps->runtime.multi_frame_falloff;
CLAMP_MIN(*td->val, 0.001f);
}
@@ -3976,24 +3972,24 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2]))
int i;
char str[UI_MAX_DRAW_STR];
- if (t->flag & T_AUTOVALUES) {
- copy_v3_v3(t->values, t->auto_values);
+ if (t->flag & T_INPUT_IS_VALUES_FINAL) {
+ copy_v3_v3(t->values_final, t->values);
}
else {
float ratio = t->values[0];
- copy_v3_fl(t->values, ratio);
+ copy_v3_fl(t->values_final, ratio);
- snapGridIncrement(t, t->values);
+ snapGridIncrement(t, t->values_final);
- if (applyNumInput(&t->num, t->values)) {
- constraintNumInput(t, t->values);
+ if (applyNumInput(&t->num, t->values_final)) {
+ constraintNumInput(t, t->values_final);
}
- applySnapping(t, t->values);
+ applySnapping(t, t->values_final);
}
- size_to_mat3(mat, t->values);
+ size_to_mat3(mat, t->values_final);
if (t->con.mode & CON_APPLY) {
t->con.applySize(t, NULL, NULL, mat);
@@ -4002,16 +3998,16 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2]))
int j = 0;
for (i = 0; i < 3; i++) {
if (!(t->con.mode & (CON_AXIS0 << i))) {
- t->values[i] = 1.0f;
+ t->values_final[i] = 1.0f;
}
else {
- pvec[j++] = t->values[i];
+ pvec[j++] = t->values_final[i];
}
}
headerResize(t, pvec, str);
}
else {
- headerResize(t, t->values, str);
+ headerResize(t, t->values_final, str);
}
copy_m3_m3(t->mat, mat); // used in gizmo
@@ -4032,8 +4028,8 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2]))
}
/* evil hack - redo resize if cliping needed */
- if (t->flag & T_CLIP_UV && clipUVTransform(t, t->values, 1)) {
- size_to_mat3(mat, t->values);
+ if (t->flag & T_CLIP_UV && clipUVTransform(t, t->values_final, 1)) {
+ size_to_mat3(mat, t->values_final);
if (t->con.mode & CON_APPLY) {
t->con.applySize(t, NULL, NULL, mat);
@@ -4103,29 +4099,28 @@ static void initSkinResize(TransInfo *t)
static void applySkinResize(TransInfo *t, const int UNUSED(mval[2]))
{
- float size[3], mat[3][3];
+ float mat[3][3];
int i;
char str[UI_MAX_DRAW_STR];
- copy_v3_fl(size, t->values[0]);
-
- snapGridIncrement(t, size);
-
- if (applyNumInput(&t->num, size)) {
- constraintNumInput(t, size);
+ if (t->flag & T_INPUT_IS_VALUES_FINAL) {
+ copy_v3_v3(t->values_final, t->values);
}
+ else {
+ copy_v3_fl(t->values_final, t->values[0]);
- applySnapping(t, size);
+ snapGridIncrement(t, t->values_final);
- if (t->flag & T_AUTOVALUES) {
- copy_v3_v3(size, t->auto_values);
- }
+ if (applyNumInput(&t->num, t->values_final)) {
+ constraintNumInput(t, t->values_final);
+ }
- copy_v3_v3(t->values, size);
+ applySnapping(t, t->values_final);
+ }
- size_to_mat3(mat, size);
+ size_to_mat3(mat, t->values_final);
- headerResize(t, size, str);
+ headerResize(t, t->values_final, str);
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
@@ -4219,7 +4214,7 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2]))
CLAMP(ratio, 0.0f, 1.0f);
- t->values[0] = ratio;
+ t->values_final[0] = ratio;
/* header print for NumInput */
if (hasNumInput(&t->num)) {
@@ -4685,7 +4680,7 @@ static void applyRotation(TransInfo *t, const int UNUSED(mval[2]))
final = large_rotation_limit(final);
}
- t->values[0] = final;
+ t->values_final[0] = final;
headerRotation(t, str, final);
@@ -4782,7 +4777,7 @@ static void applyTrackball(TransInfo *t, const int UNUSED(mval[2]))
applyNumInput(&t->num, phi);
- copy_v2_v2(t->values, phi);
+ copy_v2_v2(t->values_final, phi);
if (hasNumInput(&t->num)) {
char c[NUM_STR_REP_LEN * 2];
@@ -4935,6 +4930,8 @@ static void applyNormalRotation(TransInfo *t, const int UNUSED(mval[2]))
BKE_lnor_space_custom_normal_to_data(
bm->lnor_spacearr->lspacearr[lnor_ed->loop_index], lnor_ed->nloc, lnor_ed->clnors_data);
}
+
+ t->values_final[0] = angle;
}
recalcData(t);
@@ -5291,43 +5288,45 @@ static void applyTranslationValue(TransInfo *t, const float vec[3])
static void applyTranslation(TransInfo *t, const int UNUSED(mval[2]))
{
char str[UI_MAX_DRAW_STR];
- float value_final[3];
+ float values_final[3];
- if (t->flag & T_AUTOVALUES) {
- copy_v3_v3(t->values, t->auto_values);
+ if (t->flag & T_INPUT_IS_VALUES_FINAL) {
+ copy_v3_v3(t->values_final, t->values);
}
else {
+ copy_v3_v3(t->values_final, t->values);
if ((t->con.mode & CON_APPLY) == 0) {
- snapGridIncrement(t, t->values);
+ snapGridIncrement(t, t->values_final);
}
- if (applyNumInput(&t->num, t->values)) {
- removeAspectRatio(t, t->values);
+ if (applyNumInput(&t->num, t->values_final)) {
+ removeAspectRatio(t, t->values_final);
}
- applySnapping(t, t->values);
+ applySnapping(t, t->values_final);
}
+ copy_v3_v3(values_final, t->values_final);
if (t->con.mode & CON_APPLY) {
float pvec[3] = {0.0f, 0.0f, 0.0f};
- t->con.applyVec(t, NULL, NULL, t->values, value_final, pvec);
+ t->con.applyVec(t, NULL, NULL, t->values_final, values_final, pvec);
headerTranslation(t, pvec, str);
/* only so we have re-usable value with redo, see T46741. */
- mul_v3_m3v3(t->values, t->con.imtx, value_final);
+ mul_v3_m3v3(t->values_final, t->con.imtx, values_final);
}
else {
- headerTranslation(t, t->values, str);
- copy_v3_v3(value_final, t->values);
+ headerTranslation(t, t->values_final, str);
+ copy_v3_v3(values_final, t->values_final);
}
/* don't use 't->values' now on */
- applyTranslationValue(t, value_final);
+ applyTranslationValue(t, values_final);
/* evil hack - redo translation if clipping needed */
- if (t->flag & T_CLIP_UV && clipUVTransform(t, value_final, 0)) {
- applyTranslationValue(t, value_final);
+ if (t->flag & T_CLIP_UV && clipUVTransform(t, values_final, 0)) {
+ applyTranslationValue(t, values_final);
/* In proportional edit it can happen that */
/* vertices in the radius of the brush end */
@@ -5389,7 +5388,7 @@ static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
applyNumInput(&t->num, &distance);
- t->values[0] = -distance;
+ t->values_final[0] = -distance;
/* header print for NumInput */
ofs += BLI_strncpy_rlen(str + ofs, TIP_("Shrink/Fatten:"), sizeof(str) - ofs);
@@ -5488,7 +5487,7 @@ static void applyTilt(TransInfo *t, const int UNUSED(mval[2]))
applyNumInput(&t->num, &final);
- t->values[0] = final;
+ t->values_final[0] = final;
if (hasNumInput(&t->num)) {
char c[NUM_STR_REP_LEN];
@@ -5498,7 +5497,7 @@ static void applyTilt(TransInfo *t, const int UNUSED(mval[2]))
BLI_snprintf(str, sizeof(str), TIP_("Tilt: %s° %s"), &c[0], t->proptext);
/* XXX For some reason, this seems needed for this op, else RNA prop is not updated... :/ */
- t->values[0] = final;
+ t->values_final[0] = final;
}
else {
BLI_snprintf(str, sizeof(str), TIP_("Tilt: %.2f° %s"), RAD2DEGF(final), t->proptext);
@@ -5570,7 +5569,7 @@ static void applyCurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
applyNumInput(&t->num, &ratio);
- t->values[0] = ratio;
+ t->values_final[0] = ratio;
/* header print for NumInput */
if (hasNumInput(&t->num)) {
@@ -5655,7 +5654,7 @@ static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
applyNumInput(&t->num, &ratio);
- t->values[0] = ratio;
+ t->values_final[0] = ratio;
/* header print for NumInput */
if (hasNumInput(&t->num)) {
@@ -5768,7 +5767,7 @@ static void applyGPShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
applyNumInput(&t->num, &ratio);
- t->values[0] = ratio;
+ t->values_final[0] = ratio;
/* header print for NumInput */
if (hasNumInput(&t->num)) {
@@ -5850,7 +5849,7 @@ static void applyGPOpacity(TransInfo *t, const int UNUSED(mval[2])
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list