From 87be0faad0b67b8bd0de8062c2e49289fd091295 Mon Sep 17 00:00:00 2001 From: kramm Date: Sun, 9 Dec 2007 10:49:41 +0000 Subject: [PATCH] fixed compile warnings --- src/swfc-interpolation.c | 244 +++++++++++++++++++++++----------------------- 1 file changed, 123 insertions(+), 121 deletions(-) diff --git a/src/swfc-interpolation.c b/src/swfc-interpolation.c index b3a0c35..f543bd2 100644 --- a/src/swfc-interpolation.c +++ b/src/swfc-interpolation.c @@ -31,75 +31,75 @@ static inline float poly(float fraction, float start, float delta, float slope, float linear(float fraction, float start, float delta) { - return poly(fraction, start, delta, 0, 1); + return poly(fraction, start, delta, 0, 1); } float quadIn(float fraction, float start, float delta, float slope) { - return poly(fraction, start, delta, slope, 2); + return poly(fraction, start, delta, slope, 2); } float quadOut(float fraction, float start, float delta, float slope) { - return quadIn(1 - fraction, start + delta, -delta, slope); + return quadIn(1 - fraction, start + delta, -delta, slope); } float quadInOut(float fraction, float start, float delta, float slope) { - if (fraction < 0.5) - return quadIn(2 * fraction, start, delta / 2, slope); - return quadOut(2 * fraction - 1, start + delta / 2, delta / 2, slope); + if (fraction < 0.5) + return quadIn(2 * fraction, start, delta / 2, slope); + return quadOut(2 * fraction - 1, start + delta / 2, delta / 2, slope); } float cubicIn(float fraction, float start, float delta, float slope) { - return poly(fraction, start, delta, slope, 3); + return poly(fraction, start, delta, slope, 3); } float cubicOut(float fraction, float start, float delta, float slope) { - return cubicIn(1 - fraction, start + delta, -delta, slope); + return cubicIn(1 - fraction, start + delta, -delta, slope); } float cubicInOut(float fraction, float start, float delta, float slope) { - if (fraction < 0.5) - return cubicIn(2 * fraction, start, delta / 2, slope); - return cubicOut(2 * fraction - 1, start + delta / 2, delta / 2, slope); + if (fraction < 0.5) + return cubicIn(2 * fraction, start, delta / 2, slope); + return cubicOut(2 * fraction - 1, start + delta / 2, delta / 2, slope); } float quartIn(float fraction, float start, float delta, float slope) { - return poly(fraction, start, delta, slope, 4); + return poly(fraction, start, delta, slope, 4); } float quartOut(float fraction, float start, float delta, float slope) { - return quartIn(1 - fraction, start + delta, -delta, slope); + return quartIn(1 - fraction, start + delta, -delta, slope); } float quartInOut(float fraction, float start, float delta, float slope) { - if (fraction < 0.5) - return quartIn(2 * fraction, start, delta / 2, slope); - return quartOut(2 * fraction - 1, start + delta / 2, delta / 2, slope); + if (fraction < 0.5) + return quartIn(2 * fraction, start, delta / 2, slope); + return quartOut(2 * fraction - 1, start + delta / 2, delta / 2, slope); } float quintIn(float fraction, float start, float delta, float slope) { - return poly(fraction, start, delta, slope, 5); + return poly(fraction, start, delta, slope, 5); } float quintOut(float fraction, float start, float delta, float slope) { - return quintIn(1 - fraction, start + delta, -delta, slope); + return quintIn(1 - fraction, start + delta, -delta, slope); } float quintInOut(float fraction, float start, float delta, float slope) { - if (fraction < 0.5) - return quintIn(2 * fraction, start, delta / 2, slope); - return quintOut(2 * fraction - 1, start + delta / 2, delta / 2, slope); + if (fraction < 0.5) + return quintIn(2 * fraction, start, delta / 2, slope); + return quintOut(2 * fraction - 1, start + delta / 2, delta / 2, slope); } float circleIn(float fraction, float start, float delta, float slope) @@ -109,91 +109,91 @@ float circleIn(float fraction, float start, float delta, float slope) float circleOut(float fraction, float start, float delta, float slope) { - return circleIn(1 - fraction, start + delta, -delta, slope); + return circleIn(1 - fraction, start + delta, -delta, slope); } float circleInOut(float fraction, float start, float delta, float slope) { - if (fraction < 0.5) - return circleIn(2 * fraction, start, delta / 2, slope); - return circleOut(2 * fraction - 1, start + delta / 2, delta / 2, slope); + if (fraction < 0.5) + return circleIn(2 * fraction, start, delta / 2, slope); + return circleOut(2 * fraction - 1, start + delta / 2, delta / 2, slope); } float exponentialIn(float fraction, float start, float delta) { - if (fraction == 0) - return start; - return delta * pow(2, 10 * (fraction - 1)) + start; + if (fraction == 0) + return start; + return delta * pow(2, 10 * (fraction - 1)) + start; } float exponentialOut(float fraction, float start, float delta) { - return exponentialIn(1 - fraction, start + delta, -delta); + return exponentialIn(1 - fraction, start + delta, -delta); } float exponentialInOut(float fraction, float start, float delta) { - if (fraction < 0.5) - return exponentialIn(2 * fraction, start, delta / 2); - return exponentialOut(2 * fraction - 1, start + delta / 2, delta / 2); + if (fraction < 0.5) + return exponentialIn(2 * fraction, start, delta / 2); + return exponentialOut(2 * fraction - 1, start + delta / 2, delta / 2); } float sineIn(float fraction, float start, float delta) { - return delta * (1 - cos(fraction * M_PI/2)) + start; + return delta * (1 - cos(fraction * M_PI/2)) + start; } float sineOut(float fraction, float start, float delta) { - return sineIn(1 - fraction, start + delta, -delta); + return sineIn(1 - fraction, start + delta, -delta); } float sineInOut(float fraction, float start, float delta) { - if (fraction < 0.5) - return sineIn(2 * fraction, start, delta / 2); - return sineOut(2 * fraction - 1, start + delta / 2, delta / 2); + if (fraction < 0.5) + return sineIn(2 * fraction, start, delta / 2); + return sineOut(2 * fraction - 1, start + delta / 2, delta / 2); } float elasticIn(float fraction, float start, float delta, float amplitude, int bounces, float damping) { - if (fraction == 0 || delta == 0) - return start; - if (fraction == 1) - return start + delta; - if (amplitude < fabs(delta)) - amplitude = delta; - float period = 1 / (bounces + 0.25); - return amplitude * pow(2, damping * (fraction - 1)) * sin(fraction * (2 * M_PI) / period) + start; + if (fraction == 0 || delta == 0) + return start; + if (fraction == 1) + return start + delta; + if (amplitude < fabs(delta)) + amplitude = delta; + float period = 1 / (bounces + 0.25); + return amplitude * pow(2, damping * (fraction - 1)) * sin(fraction * (2 * M_PI) / period) + start; } float elasticOut(float fraction, float start, float delta, float amplitude, int bounces, float damping) { - return elasticIn(1 - fraction, start + delta, -delta, amplitude, bounces, damping); + return elasticIn(1 - fraction, start + delta, -delta, amplitude, bounces, damping); } - + float elasticInOut(float fraction, float start, float delta, float amplitude, int bounces, float damping) { - if (fraction < 0.5) - return elasticIn(2 * fraction, start, delta / 2, amplitude, bounces, damping); - return elasticOut(2 * fraction - 1, start + delta / 2, delta / 2, amplitude, bounces, damping); + if (fraction < 0.5) + return elasticIn(2 * fraction, start, delta / 2, amplitude, bounces, damping); + return elasticOut(2 * fraction - 1, start + delta / 2, delta / 2, amplitude, bounces, damping); } float backIn(float fraction, float start, float delta, float speed) { - return delta * fraction * fraction * ((speed + 1) * fraction - speed) + start; + return delta * fraction * fraction * ((speed + 1) * fraction - speed) + start; } float backOut(float fraction, float start, float delta, float speed) { - return backIn(1 - fraction, start + delta, -delta, speed); + return backIn(1 - fraction, start + delta, -delta, speed); } float backInOut(float fraction, float start, float delta, float speed) { - if (fraction < 0.5) - return backIn(2 * fraction, start, delta / 2, speed); - return backOut(2 * fraction - 1, start + delta / 2, delta / 2, speed); + if (fraction < 0.5) + return backIn(2 * fraction, start, delta / 2, speed); + return backOut(2 * fraction - 1, start + delta / 2, delta / 2, speed); } /* when applied to movement bounceIn the object 'hits the floor' bounces times @@ -204,35 +204,36 @@ float backInOut(float fraction, float start, float delta, float speed) float bounceIn(float fraction, float start, float delta, int bounces, float growth, float damping) { - if (fraction == 0 || delta == 0) - return start; - if (fraction == 1) - return start + delta; - float w0; - if (growth == 1.0) - w0 = 1 / (bounces + 0.5); - else - { - float gN = pow(growth, bounces); - w0 = 1 / ((gN - 1) / (growth - 1) + gN / 2 ); - } - float bounceStart = 0; - int i; - float w = w0; - for (i = 0; i <= bounces; i++) - { - float bounceEnd = bounceStart + w; - if (fraction >= bounceStart && fraction < bounceEnd) - { - float half = (bounceEnd + bounceStart) / 2; - float top = delta / pow(2, damping * ((bounces - i))); - fraction -= half; - fraction /= (w / 2); - return (1 - fraction * fraction) * top + start; - } - bounceStart = bounceEnd; - w = w * growth; - } + if (fraction == 0 || delta == 0) + return start; + if (fraction == 1) + return start + delta; + float w0; + if (growth == 1.0) + w0 = 1 / (bounces + 0.5); + else + { + float gN = pow(growth, bounces); + w0 = 1 / ((gN - 1) / (growth - 1) + gN / 2 ); + } + float bounceStart = 0; + int i; + float w = w0; + for (i = 0; i <= bounces; i++) + { + float bounceEnd = bounceStart + w; + if (fraction >= bounceStart && fraction < bounceEnd) + { + float half = (bounceEnd + bounceStart) / 2; + float top = delta / pow(2, damping * ((bounces - i))); + fraction -= half; + fraction /= (w / 2); + return (1 - fraction * fraction) * top + start; + } + bounceStart = bounceEnd; + w = w * growth; + } + return w; } /* bounceOut is a time-reversed bounceIn; therefore each bounce takes 1/growth times as long as @@ -240,7 +241,7 @@ float bounceIn(float fraction, float start, float delta, int bounces, float grow float bounceOut(float fraction, float start, float delta, int bounces, float growth, float damping) { - return bounceIn(1 - fraction, start + delta, -delta, bounces, growth, damping); + return bounceIn(1 - fraction, start + delta, -delta, bounces, growth, damping); } /* since bounceIn and bounceOut are combined, if growth > 1 then the bounce-times will increase in @@ -248,53 +249,54 @@ float bounceOut(float fraction, float start, float delta, int bounces, float gro float bounceInOut(float fraction, float start, float delta, int bounces, float growth, float damping) { - if (fraction < 0.5) - return bounceIn(2 * fraction, start, delta / 2, bounces, growth, damping); - return bounceOut(2 * fraction - 1, start + delta / 2, delta / 2, bounces, growth, damping); + if (fraction < 0.5) + return bounceIn(2 * fraction, start, delta / 2, bounces, growth, damping); + return bounceOut(2 * fraction - 1, start + delta / 2, delta / 2, bounces, growth, damping); } /* fastBounce(In/Out) doesn't end or start in a horizontal slope (= gentle end or start) as * bounce(In/Out) do which means fastBounceInOut doesn't have the 'delay' in the middle */ float fastBounceIn(float fraction, float start, float delta, int bounces, float growth, float damping) { - if (fraction == 0 || delta == 0) - return start; - if (fraction == 1) - return start + delta; - float w0; - if (growth == 1.0) - w0 = 1 / (bounces + 0.25); /* in general (bounces + 1 / (2 * f)) */ - else - { - float gN = pow(growth, bounces); - w0 = 1 / ((gN - 1) / (growth - 1) + gN / 4 /* in general: gN / (2 * f) */ ); - } - float bounceStart = 0; - int i; - float w = w0; - for (i = 0; i <= bounces; i++) - { - float bounceEnd = bounceStart + w; - if (fraction >= bounceStart && fraction < bounceEnd) - { - float half = (bounceEnd + bounceStart) / 2; - float top = delta / 0.75/* in general: (1 - (1 / f) * (1 / f)) */ / pow(2, damping * ((bounces - i))); - fraction -= half; - fraction /= (w / 2); - return (1 - fraction * fraction) * top + start; - } - bounceStart = bounceEnd; - w = w * growth; - } + if (fraction == 0 || delta == 0) + return start; + if (fraction == 1) + return start + delta; + float w0; + if (growth == 1.0) + w0 = 1 / (bounces + 0.25); /* in general (bounces + 1 / (2 * f)) */ + else + { + float gN = pow(growth, bounces); + w0 = 1 / ((gN - 1) / (growth - 1) + gN / 4 /* in general: gN / (2 * f) */ ); + } + float bounceStart = 0; + int i; + float w = w0; + for (i = 0; i <= bounces; i++) + { + float bounceEnd = bounceStart + w; + if (fraction >= bounceStart && fraction < bounceEnd) + { + float half = (bounceEnd + bounceStart) / 2; + float top = delta / 0.75/* in general: (1 - (1 / f) * (1 / f)) */ / pow(2, damping * ((bounces - i))); + fraction -= half; + fraction /= (w / 2); + return (1 - fraction * fraction) * top + start; + } + bounceStart = bounceEnd; + w = w * growth; + } + return 0; } float fastBounceOut(float fraction, float start, float delta, int bounces, float growth, float damping) { - return fastBounceIn(1 - fraction, start + delta, -delta, bounces, growth, damping); + return fastBounceIn(1 - fraction, start + delta, -delta, bounces, growth, damping); } float fastBounceInOut(float fraction, float start, float delta, int bounces, float growth, float damping) { - if (fraction < 0.5) - return fastBounceIn(2 * fraction, start, delta / 2, bounces, growth, damping); - return fastBounceOut(2 * fraction - 1, start + delta / 2, delta / 2, bounces, growth, damping); + if (fraction < 0.5) + return fastBounceIn(2 * fraction, start, delta / 2, bounces, growth, damping); + return fastBounceOut(2 * fraction - 1, start + delta / 2, delta / 2, bounces, growth, damping); } -- 1.7.10.4