diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-12-03 17:16:32 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-12-03 17:16:32 +0400 |
commit | 4344d84c02809e58faaf9516ec6431f3194389c4 (patch) | |
tree | a2e444ed593f672dbf1cdda4c6b0e3097ad89ddc /source/blender/editors/transform/transform_input.c | |
parent | 3167a9a8995e283922e0e21c0ebe704c635a2460 (diff) |
Fix #29483: edge slide gives nan when zoomed in close. Cause was integer
overflow leading to negative value for sqrt().
Diffstat (limited to 'source/blender/editors/transform/transform_input.c')
-rw-r--r-- | source/blender/editors/transform/transform_input.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index 3de68a6e312..a4f03e76fd1 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -189,16 +189,16 @@ void setCustomPoints(TransInfo *UNUSED(t), MouseInput *mi, int start[2], int end static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], float output[3]) { - float length; - float distance; + double length; + double distance; + double dx, dy; int *data = mi->data; - int dx, dy; if (data) { dx = data[2] - data[0]; dy = data[3] - data[1]; - length = (float)sqrtf(dx*dx + dy*dy); + length = sqrt(dx*dx + dy*dy); if (mi->precision) { /* deal with Shift key by adding motion / 10 to motion before shift press */ @@ -216,7 +216,7 @@ static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const int mva distance = (length != 0.0f)? (mdx*dx + mdy*dy) / length: 0.0f; } - output[0] = (length != 0.0f)? distance / length: 0.0f; + output[0] = (float)((length != 0.0f)? distance / length: 0.0f); } } |