Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Poirier <theeth@yahoo.com>2009-11-18 20:14:56 +0300
committerMartin Poirier <theeth@yahoo.com>2009-11-18 20:14:56 +0300
commit7f151b0dc68dcc962efc5a4372291bd69c50f640 (patch)
tree7cc12dd6cc13dec1d4fbb7e93c3a188e4d2cc35c /source/blender/editors/transform/transform_input.c
parenta90c770286eb805a11e096017c51dfe5a62b88f3 (diff)
Custom Ratio mouse input didn't check for initialization properly, which could lead to NaN values with edge slide.
Also adding missing modal keymaps for some transform operators.
Diffstat (limited to 'source/blender/editors/transform/transform_input.c')
-rw-r--r--source/blender/editors/transform/transform_input.c49
1 files changed, 28 insertions, 21 deletions
diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c
index bccbfbc65f7..fbc7f0dd746 100644
--- a/source/blender/editors/transform/transform_input.c
+++ b/source/blender/editors/transform/transform_input.c
@@ -165,8 +165,14 @@ void InputVerticalAbsolute(TransInfo *t, MouseInput *mi, short mval[2], float ou
void setCustomPoints(TransInfo *t, MouseInput *mi, short start[2], short end[2])
{
- short *data = mi->data;
+ short *data;
+
+ if (mi->data == NULL) {
+ mi->data = MEM_callocN(sizeof(short) * 4, "custom points");
+ }
+ data = mi->data;
+
data[0] = start[0];
data[1] = start[1];
data[2] = end[0];
@@ -180,28 +186,30 @@ void InputCustomRatio(TransInfo *t, MouseInput *mi, short mval[2], float output[
short *data = mi->data;
short dx, dy;
- dx = data[2] - data[0];
- dy = data[3] - data[1];
-
- length = (float)sqrtf(dx*dx + dy*dy);
-
- if (mi->precision) {
- /* deal with Shift key by adding motion / 10 to motion before shift press */
- short mdx, mdy;
- mdx = (mi->precision_mval[0] + (float)(mval[0] - mi->precision_mval[0]) / 10.0f) - data[2];
- mdy = (mi->precision_mval[1] + (float)(mval[1] - mi->precision_mval[1]) / 10.0f) - data[3];
+ if (data) {
+ dx = data[2] - data[0];
+ dy = data[3] - data[1];
- distance = (mdx*dx + mdy*dy) / length;
- }
- else {
- short mdx, mdy;
- mdx = mval[0] - data[2];
- mdy = mval[1] - data[3];
+ length = (float)sqrtf(dx*dx + dy*dy);
- distance = (mdx*dx + mdy*dy) / length;
- }
+ if (mi->precision) {
+ /* deal with Shift key by adding motion / 10 to motion before shift press */
+ short mdx, mdy;
+ mdx = (mi->precision_mval[0] + (float)(mval[0] - mi->precision_mval[0]) / 10.0f) - data[2];
+ mdy = (mi->precision_mval[1] + (float)(mval[1] - mi->precision_mval[1]) / 10.0f) - data[3];
+
+ distance = (mdx*dx + mdy*dy) / length;
+ }
+ else {
+ short mdx, mdy;
+ mdx = mval[0] - data[2];
+ mdy = mval[1] - data[3];
- output[0] = distance / length;
+ distance = (mdx*dx + mdy*dy) / length;
+ }
+
+ output[0] = distance / length;
+ }
}
void InputAngle(TransInfo *t, MouseInput *mi, short mval[2], float output[3])
@@ -335,7 +343,6 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
case INPUT_CUSTOM_RATIO:
mi->apply = InputCustomRatio;
t->helpline = HLP_NONE;
- mi->data = MEM_callocN(sizeof(short) * 4, "custom points");
break;
case INPUT_NONE:
default: