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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-06-14 11:27:50 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-06-14 11:34:52 +0400
commit8cd9d784c7e4785d38b336bc852ffb8be3fde867 (patch)
treea3f8132de4d6c9db8fd334bb6936c0418caf241a /source
parent94d4b313231cf0d7d94de1e9eaf21037c4929ee6 (diff)
Replace sqrt with hypot for wipe-effect & transform code
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c8
-rw-r--r--source/blender/editors/transform/transform.c2
-rw-r--r--source/blender/editors/transform/transform_input.c8
3 files changed, 9 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index 7ed9af8b87f..2b14b92217b 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -1398,7 +1398,7 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f
x = x - halfx;
y = y - halfy;
- temp2 = asin(abs(y) / sqrt(x * x + y * y));
+ temp2 = asin(abs(y) / hypot(x, y));
if (x <= 0 && y >= 0) temp2 = (float)M_PI - temp2;
else if (x <= 0 && y <= 0) temp2 += (float)M_PI;
else if (x >= 0 && y <= 0) temp2 = 2.0f * (float)M_PI - temp2;
@@ -1441,7 +1441,7 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f
temp1 = xo * (1 - facf0 / 2) - xo * facf0 / 2;
temp2 = yo * (1 - facf0 / 2) - yo * facf0 / 2;
- pointdist = sqrtf(temp1 * temp1 + temp2 * temp2);
+ pointdist = hypot(temp1, temp2);
if (b2 < b1 && b2 < b3) {
if (hwidth < pointdist)
@@ -1498,9 +1498,9 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f
hwidth = width * 0.5f;
temp1 = (halfx - (halfx) * facf0);
- pointdist = sqrtf(temp1 * temp1 + temp1 * temp1);
+ pointdist = hypotf(temp1, temp1);
- temp2 = sqrtf((halfx - x) * (halfx - x) + (halfy - y) * (halfy - y));
+ temp2 = hypotf(halfx - x, halfy - y);
if (temp2 > pointdist) output = in_band(hwidth, fabsf(temp2 - pointdist), 0, 1);
else output = in_band(hwidth, fabsf(temp2 - pointdist), 1, 1);
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 899f1191e33..ab0bc061c32 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1718,7 +1718,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
{
float dx = t->mval[0] - cent[0], dy = t->mval[1] - cent[1];
float angle = atan2f(dy, dx);
- float dist = sqrtf(dx * dx + dy * dy);
+ float dist = hypotf(dx, dy);
float delta_angle = min_ff(15.0f / dist, (float)M_PI / 4.0f);
float spacing_angle = min_ff(5.0f / dist, (float)M_PI / 12.0f);
UI_ThemeColor(TH_VIEW_OVERLAY);
diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c
index 6546a05aedd..61b2deabe12 100644
--- a/source/blender/editors/transform/transform_input.c
+++ b/source/blender/editors/transform/transform_input.c
@@ -64,18 +64,18 @@ static void InputSpring(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2],
/* calculate ratio for shiftkey pos, and for total, and blend these for precision */
dx = (float)(mi->center[0] - mi->precision_mval[0]);
dy = (float)(mi->center[1] - mi->precision_mval[1]);
- ratio = sqrtf(dx * dx + dy * dy);
+ ratio = hypotf(dx, dy);
dx = (float)(mi->center[0] - mval[0]);
dy = (float)(mi->center[1] - mval[1]);
- precise_ratio = sqrtf(dx * dx + dy * dy);
+ precise_ratio = hypotf(dx, dy);
ratio = (ratio + (precise_ratio - ratio) / 10.0f) / mi->factor;
}
else {
dx = (float)(mi->center[0] - mval[0]);
dy = (float)(mi->center[1] - mval[1]);
- ratio = sqrtf(dx * dx + dy * dy) / mi->factor;
+ ratio = hypotf(dx, dy) / mi->factor;
}
output[0] = ratio;
@@ -195,7 +195,7 @@ static void InputCustomRatioFlip(TransInfo *UNUSED(t), MouseInput *mi, const int
dx = data[2] - data[0];
dy = data[3] - data[1];
- length = sqrt(dx * dx + dy * dy);
+ length = hypot(dx, dy);
if (mi->precision) {
/* deal with Shift key by adding motion / 10 to motion before shift press */