From c734808fb0422339341a3567bea90498b4046e9d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 31 Jan 2013 22:18:37 +0000 Subject: fix error with flipped vertex slide failing, also fix bug where you could be flipped and in proportional vertex slide mode. --- source/blender/editors/transform/transform.c | 30 ++++++++++------------ source/blender/editors/transform/transform.h | 3 ++- source/blender/editors/transform/transform_input.c | 12 ++++++++- 3 files changed, 26 insertions(+), 19 deletions(-) (limited to 'source/blender/editors/transform') diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 114a8c7a06c..f6c9c27dd76 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -5625,7 +5625,7 @@ void initEdgeSlide(TransInfo *t) /* set custom point first if you want value to be initialized by init */ setCustomPoints(t, &t->mouse, sld->end, sld->start); - initMouseInputMode(t, &t->mouse, INPUT_CUSTOM_RATIO); + initMouseInputMode(t, &t->mouse, INPUT_CUSTOM_RATIO_FLIP); t->idx_max = 0; t->num.idx_max = 0; @@ -5876,19 +5876,14 @@ static void calcVertSlideCustomPoints(struct TransInfo *t) TransDataVertSlideVert *sv = &sld->sv[sld->curr_sv_index]; float *co_orig = sv->co_orig_2d; float *co_curr = sv->co_link_orig_2d[sv->co_link_curr]; - float co_curr_flip[2]; - - flip_v2_v2v2(co_curr_flip, co_orig, co_curr); + const int start[2] = {co_orig[0], co_orig[1]}; + const int end[2] = {co_curr[0], co_curr[1]}; - { - const int start[2] = {co_orig[0], co_orig[1]}; - const int end[2] = {co_curr_flip[0], co_curr_flip[1]}; - if (!sld->flipped_vtx) { - setCustomPoints(t, &t->mouse, end, start); - } - else { - setCustomPoints(t, &t->mouse, start, end); - } + if (sld->flipped_vtx && sld->is_proportional == false) { + setCustomPoints(t, &t->mouse, start, end); + } + else { + setCustomPoints(t, &t->mouse, end, start); } } @@ -6144,16 +6139,17 @@ int handleEventVertSlide(struct TransInfo *t, struct wmEvent *event) case EKEY: if (event->val == KM_PRESS) { sld->is_proportional = !sld->is_proportional; + if (sld->flipped_vtx) { + calcVertSlideCustomPoints(t); + } return 1; } break; case FKEY: { if (event->val == KM_PRESS) { - if (sld->is_proportional == FALSE) { - sld->flipped_vtx = !sld->flipped_vtx; - calcVertSlideCustomPoints(t); - } + sld->flipped_vtx = !sld->flipped_vtx; + calcVertSlideCustomPoints(t); return 1; } break; diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index c72c6a83d82..a27fe91c3c3 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -677,7 +677,8 @@ typedef enum { INPUT_HORIZONTAL_ABSOLUTE, INPUT_VERTICAL_RATIO, INPUT_VERTICAL_ABSOLUTE, - INPUT_CUSTOM_RATIO + INPUT_CUSTOM_RATIO, + INPUT_CUSTOM_RATIO_FLIP } MouseInputMode; void initMouseInput(TransInfo *t, MouseInput *mi, const int center[2], const int mval[2]); diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index c805dfe1b41..2e34de6c568 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -180,7 +180,7 @@ void setCustomPoints(TransInfo *UNUSED(t), MouseInput *mi, const int start[2], c data[3] = end[1]; } -static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], float output[3]) +static void InputCustomRatioFlip(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], float output[3]) { double length; double distance; @@ -213,6 +213,12 @@ static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const int mva } } +static void InputCustomRatio(TransInfo *t, MouseInput *mi, const int mval[2], float output[3]) +{ + InputCustomRatioFlip(t, mi, mval, output); + output[0] = -output[0]; +} + static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], float output[3]) { double dx2 = mval[0] - mi->center[0]; @@ -358,6 +364,10 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode) mi->apply = InputCustomRatio; t->helpline = HLP_NONE; break; + case INPUT_CUSTOM_RATIO_FLIP: + mi->apply = InputCustomRatioFlip; + t->helpline = HLP_NONE; + break; case INPUT_NONE: default: mi->apply = NULL; -- cgit v1.2.3