forked from bartvdbraak/blender
Replace sqrt with hypot for wipe-effect & transform code
This commit is contained in:
parent
94d4b31323
commit
8cd9d784c7
@ -1398,7 +1398,7 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f
|
|||||||
x = x - halfx;
|
x = x - halfx;
|
||||||
y = y - halfy;
|
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;
|
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 += (float)M_PI;
|
||||||
else if (x >= 0 && y <= 0) temp2 = 2.0f * (float)M_PI - temp2;
|
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;
|
temp1 = xo * (1 - facf0 / 2) - xo * facf0 / 2;
|
||||||
temp2 = yo * (1 - facf0 / 2) - yo * 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 (b2 < b1 && b2 < b3) {
|
||||||
if (hwidth < pointdist)
|
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;
|
hwidth = width * 0.5f;
|
||||||
|
|
||||||
temp1 = (halfx - (halfx) * facf0);
|
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);
|
if (temp2 > pointdist) output = in_band(hwidth, fabsf(temp2 - pointdist), 0, 1);
|
||||||
else output = in_band(hwidth, fabsf(temp2 - pointdist), 1, 1);
|
else output = in_band(hwidth, fabsf(temp2 - pointdist), 1, 1);
|
||||||
|
|
||||||
|
@ -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 dx = t->mval[0] - cent[0], dy = t->mval[1] - cent[1];
|
||||||
float angle = atan2f(dy, dx);
|
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 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);
|
float spacing_angle = min_ff(5.0f / dist, (float)M_PI / 12.0f);
|
||||||
UI_ThemeColor(TH_VIEW_OVERLAY);
|
UI_ThemeColor(TH_VIEW_OVERLAY);
|
||||||
|
@ -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 */
|
/* calculate ratio for shiftkey pos, and for total, and blend these for precision */
|
||||||
dx = (float)(mi->center[0] - mi->precision_mval[0]);
|
dx = (float)(mi->center[0] - mi->precision_mval[0]);
|
||||||
dy = (float)(mi->center[1] - mi->precision_mval[1]);
|
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]);
|
dx = (float)(mi->center[0] - mval[0]);
|
||||||
dy = (float)(mi->center[1] - mval[1]);
|
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;
|
ratio = (ratio + (precise_ratio - ratio) / 10.0f) / mi->factor;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dx = (float)(mi->center[0] - mval[0]);
|
dx = (float)(mi->center[0] - mval[0]);
|
||||||
dy = (float)(mi->center[1] - mval[1]);
|
dy = (float)(mi->center[1] - mval[1]);
|
||||||
ratio = sqrtf(dx * dx + dy * dy) / mi->factor;
|
ratio = hypotf(dx, dy) / mi->factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
output[0] = ratio;
|
output[0] = ratio;
|
||||||
@ -195,7 +195,7 @@ static void InputCustomRatioFlip(TransInfo *UNUSED(t), MouseInput *mi, const int
|
|||||||
dx = data[2] - data[0];
|
dx = data[2] - data[0];
|
||||||
dy = data[3] - data[1];
|
dy = data[3] - data[1];
|
||||||
|
|
||||||
length = sqrt(dx * dx + dy * dy);
|
length = hypot(dx, dy);
|
||||||
|
|
||||||
if (mi->precision) {
|
if (mi->precision) {
|
||||||
/* deal with Shift key by adding motion / 10 to motion before shift press */
|
/* deal with Shift key by adding motion / 10 to motion before shift press */
|
||||||
|
Loading…
Reference in New Issue
Block a user