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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-03-27 05:16:10 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-03-27 05:17:30 +0300
commit9ba948a4859da3308033fa6dc54f74433d7e6a21 (patch)
tree0bd6e95eb59d9af03aa32d925c68e1cbebecc246 /source/blender/blenlib/intern/easing.c
parent337eb8c1de4c57c34520b467d79779153335eecb (diff)
Cleanup: style, use braces for blenlib
Diffstat (limited to 'source/blender/blenlib/intern/easing.c')
-rw-r--r--source/blender/blenlib/intern/easing.c57
1 files changed, 38 insertions, 19 deletions
diff --git a/source/blender/blenlib/intern/easing.c b/source/blender/blenlib/intern/easing.c
index b1df6e4c58e..99077eddc4e 100644
--- a/source/blender/blenlib/intern/easing.c
+++ b/source/blender/blenlib/intern/easing.c
@@ -91,10 +91,12 @@ float BLI_easing_bounce_ease_in(float time, float begin, float change, float dur
float BLI_easing_bounce_ease_in_out(float time, float begin, float change, float duration)
{
- if (time < duration / 2)
+ if (time < duration / 2) {
return BLI_easing_bounce_ease_in(time * 2, 0, change, duration) * 0.5f + begin;
- else
+ }
+ else {
return BLI_easing_bounce_ease_out(time * 2 - duration, 0, change, duration) * 0.5f + change * 0.5f + begin;
+ }
}
float BLI_easing_circ_ease_in(float time, float begin, float change, float duration)
@@ -111,8 +113,9 @@ float BLI_easing_circ_ease_out(float time, float begin, float change, float dura
float BLI_easing_circ_ease_in_out(float time, float begin, float change, float duration)
{
- if ((time /= duration / 2) < 1.0f)
+ if ((time /= duration / 2) < 1.0f) {
return -change / 2 * (sqrtf(1 - time * time) - 1) + begin;
+ }
time -= 2.0f;
return change / 2 * (sqrtf(1 - time * time) + 1) + begin;
}
@@ -131,8 +134,9 @@ float BLI_easing_cubic_ease_out(float time, float begin, float change, float dur
float BLI_easing_cubic_ease_in_out(float time, float begin, float change, float duration)
{
- if ((time /= duration / 2) < 1.0f)
+ if ((time /= duration / 2) < 1.0f) {
return change / 2 * time * time * time + begin;
+ }
time -= 2.0f;
return change / 2 * (time * time * time + 2) + begin;
}
@@ -170,14 +174,17 @@ float BLI_easing_elastic_ease_in(float time, float begin, float change, float du
float s;
float f = 1.0f;
- if (time == 0.0f)
+ if (time == 0.0f) {
return begin;
+ }
- if ((time /= duration) == 1.0f)
+ if ((time /= duration) == 1.0f) {
return begin + change;
+ }
time -= 1.0f;
- if (!period)
+ if (!period) {
period = duration * 0.3f;
+ }
if (!amplitude || amplitude < fabsf(change)) {
s = period / 4;
#ifdef USE_ELASTIC_BLEND
@@ -185,8 +192,9 @@ float BLI_easing_elastic_ease_in(float time, float begin, float change, float du
#endif
amplitude = change;
}
- else
+ else {
s = period / (2 * (float)M_PI) * asinf(change / amplitude);
+ }
return (-f * (amplitude * powf(2, 10 * time) * sinf((time * duration - s) * (2 * (float)M_PI) / period))) + begin;
}
@@ -196,13 +204,16 @@ float BLI_easing_elastic_ease_out(float time, float begin, float change, float d
float s;
float f = 1.0f;
- if (time == 0.0f)
+ if (time == 0.0f) {
return begin;
- if ((time /= duration) == 1.0f)
+ }
+ if ((time /= duration) == 1.0f) {
return begin + change;
+ }
time = -time;
- if (!period)
+ if (!period) {
period = duration * 0.3f;
+ }
if (!amplitude || amplitude < fabsf(change)) {
s = period / 4;
#ifdef USE_ELASTIC_BLEND
@@ -210,8 +221,9 @@ float BLI_easing_elastic_ease_out(float time, float begin, float change, float d
#endif
amplitude = change;
}
- else
+ else {
s = period / (2 * (float)M_PI) * asinf(change / amplitude);
+ }
return (f * (amplitude * powf(2, 10 * time) * sinf((time * duration - s) * (2 * (float)M_PI) / period))) + change + begin;
}
@@ -221,13 +233,16 @@ float BLI_easing_elastic_ease_in_out(float time, float begin, float change, floa
float s;
float f = 1.0f;
- if (time == 0.0f)
+ if (time == 0.0f) {
return begin;
- if ((time /= duration / 2) == 2.0f)
+ }
+ if ((time /= duration / 2) == 2.0f) {
return begin + change;
+ }
time -= 1.0f;
- if (!period)
+ if (!period) {
period = duration * (0.3f * 1.5f);
+ }
if (!amplitude || amplitude < fabsf(change)) {
s = period / 4;
#ifdef USE_ELASTIC_BLEND
@@ -235,8 +250,9 @@ float BLI_easing_elastic_ease_in_out(float time, float begin, float change, floa
#endif
amplitude = change;
}
- else
+ else {
s = period / (2 * (float)M_PI) * asinf(change / amplitude);
+ }
if (time < 0.0f) {
f *= -0.5f;
@@ -301,8 +317,9 @@ float BLI_easing_quad_ease_out(float time, float begin, float change, float dura
float BLI_easing_quad_ease_in_out(float time, float begin, float change, float duration)
{
- if ((time /= duration / 2) < 1.0f)
+ if ((time /= duration / 2) < 1.0f) {
return change / 2 * time * time + begin;
+ }
time -= 1.0f;
return -change / 2 * (time * (time - 2) - 1) + begin;
}
@@ -322,8 +339,9 @@ float BLI_easing_quart_ease_out(float time, float begin, float change, float dur
float BLI_easing_quart_ease_in_out(float time, float begin, float change, float duration)
{
- if ((time /= duration / 2) < 1.0f)
+ if ((time /= duration / 2) < 1.0f) {
return change / 2 * time * time * time * time + begin;
+ }
time -= 2.0f;
return -change / 2 * ( time * time * time * time - 2) + begin;
}
@@ -340,8 +358,9 @@ float BLI_easing_quint_ease_out(float time, float begin, float change, float dur
}
float BLI_easing_quint_ease_in_out(float time, float begin, float change, float duration)
{
- if ((time /= duration / 2) < 1.0f)
+ if ((time /= duration / 2) < 1.0f) {
return change / 2 * time * time * time * time * time + begin;
+ }
time -= 2.0f;
return change / 2 * (time * time * time * time * time + 2) + begin;
}