aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRay <raysan5@gmail.com>2019-05-06 10:07:06 +0200
committerRay <raysan5@gmail.com>2019-05-06 10:07:06 +0200
commit80c8599e818fe765f6129bcdb2fda859c8f193cb (patch)
treecc1beb7c1ccb7ef928025a2bfcf6859c119ac128 /src
parent4c33d3881288311be48fbf8f7590f9f27fefc453 (diff)
downloadraylib-80c8599e818fe765f6129bcdb2fda859c8f193cb.tar.gz
raylib-80c8599e818fe765f6129bcdb2fda859c8f193cb.zip
Avoid warnings pre-evaluating values
Variable operations inside the functions should be evaluated before the function operations.
Diffstat (limited to 'src')
-rw-r--r--src/easings.h30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/easings.h b/src/easings.h
index 810aeccb..892ce352 100644
--- a/src/easings.h
+++ b/src/easings.h
@@ -112,30 +112,30 @@ EASEDEF float EaseSineOut(float t, float b, float c, float d) { return (c*sin(t/
EASEDEF float EaseSineInOut(float t, float b, float c, float d) { return (-c/2*(cos(PI*t/d) - 1) + b); }
// Circular Easing functions
-EASEDEF float EaseCircIn(float t, float b, float c, float d) { return (-c*(sqrt(1 - (t/=d)*t) - 1) + b); }
-EASEDEF float EaseCircOut(float t, float b, float c, float d) { return (c*sqrt(1 - (t=t/d-1)*t) + b); }
+EASEDEF float EaseCircIn(float t, float b, float c, float d) { t /= d; return (-c*(sqrt(1 - t*t) - 1) + b); }
+EASEDEF float EaseCircOut(float t, float b, float c, float d) { t = t/d - 1; return (c*sqrt(1 - t*t) + b); }
EASEDEF float EaseCircInOut(float t, float b, float c, float d)
{
if ((t/=d/2) < 1) return (-c/2*(sqrt(1 - t*t) - 1) + b);
- return (c/2*(sqrt(1 - t*(t-=2)) + 1) + b);
+ t -= 2; return (c/2*(sqrt(1 - t*t) + 1) + b);
}
// Cubic Easing functions
-EASEDEF float EaseCubicIn(float t, float b, float c, float d) { return (c*(t/=d)*t*t + b); }
-EASEDEF float EaseCubicOut(float t, float b, float c, float d) { return (c*((t=t/d-1)*t*t + 1) + b); }
+EASEDEF float EaseCubicIn(float t, float b, float c, float d) { t /= d; return (c*t*t*t + b); }
+EASEDEF float EaseCubicOut(float t, float b, float c, float d) { t = t/d-1; return (c*(t*t*t + 1) + b); }
EASEDEF float EaseCubicInOut(float t, float b, float c, float d)
{
if ((t/=d/2) < 1) return (c/2*t*t*t + b);
- return (c/2*((t-=2)*t*t + 2) + b);
+ t -= 2; return (c/2*(t*t*t + 2) + b);
}
// Quadratic Easing functions
-EASEDEF float EaseQuadIn(float t, float b, float c, float d) { return (c*(t/=d)*t + b); }
-EASEDEF float EaseQuadOut(float t, float b, float c, float d) { return (-c*(t/=d)*(t-2) + b); }
+EASEDEF float EaseQuadIn(float t, float b, float c, float d) { t /= d; return (c*t*t + b); }
+EASEDEF float EaseQuadOut(float t, float b, float c, float d) { t /= d; return (-c*t*(t - 2) + b); }
EASEDEF float EaseQuadInOut(float t, float b, float c, float d)
{
if ((t/=d/2) < 1) return (((c/2)*(t*t)) + b);
- return (-c/2*(((t-2)*(--t)) - 1) + b);
+ t--; return (-c/2*(((t - 2)*t) - 1) + b);
}
// Exponential Easing functions
@@ -161,16 +161,22 @@ EASEDEF float EaseBackIn(float t, float b, float c, float d)
EASEDEF float EaseBackOut(float t, float b, float c, float d)
{
float s = 1.70158f;
- return (c*((t=t/d-1)*t*((s + 1)*t + s) + 1) + b);
+ t = t/d - 1;
+ return (c*(t*t*((s + 1)*t + s) + 1) + b);
}
EASEDEF float EaseBackInOut(float t, float b, float c, float d)
{
float s = 1.70158f;
- if ((t/=d/2) < 1) return (c/2*(t*t*(((s*=(1.525f)) + 1)*t - s)) + b);
+ if ((t/=d/2) < 1)
+ {
+ s *= 1.525f;
+ return (c/2*(t*t*((s + 1)*t - s)) + b);
+ }
float postFix = t-=2;
- return (c/2*((postFix)*t*(((s*=(1.525f)) + 1)*t + s) + 2) + b);
+ s *= 1.525f;
+ return (c/2*((postFix)*t*((s + 1)*t + s) + 2) + b);
}
// Bounce Easing functions