mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-05 23:07:42 -05:00
Core: Use Math namespace for constants
This commit is contained in:
@@ -1589,17 +1589,17 @@ void AnimationMixer::_blend_process(double p_delta, bool p_update_only) {
|
||||
float rot_a = t->value;
|
||||
float rot_b = value;
|
||||
float rot_init = t->init_value;
|
||||
rot_a = Math::fposmod(rot_a, (float)Math_TAU);
|
||||
rot_b = Math::fposmod(rot_b, (float)Math_TAU);
|
||||
rot_init = Math::fposmod(rot_init, (float)Math_TAU);
|
||||
if (rot_init < Math_PI) {
|
||||
rot_a = rot_a > rot_init + Math_PI ? rot_a - Math_TAU : rot_a;
|
||||
rot_b = rot_b > rot_init + Math_PI ? rot_b - Math_TAU : rot_b;
|
||||
rot_a = Math::fposmod(rot_a, (float)Math::TAU);
|
||||
rot_b = Math::fposmod(rot_b, (float)Math::TAU);
|
||||
rot_init = Math::fposmod(rot_init, (float)Math::TAU);
|
||||
if (rot_init < Math::PI) {
|
||||
rot_a = rot_a > rot_init + Math::PI ? rot_a - Math::TAU : rot_a;
|
||||
rot_b = rot_b > rot_init + Math::PI ? rot_b - Math::TAU : rot_b;
|
||||
} else {
|
||||
rot_a = rot_a < rot_init - Math_PI ? rot_a + Math_TAU : rot_a;
|
||||
rot_b = rot_b < rot_init - Math_PI ? rot_b + Math_TAU : rot_b;
|
||||
rot_a = rot_a < rot_init - Math::PI ? rot_a + Math::TAU : rot_a;
|
||||
rot_b = rot_b < rot_init - Math::PI ? rot_b + Math::TAU : rot_b;
|
||||
}
|
||||
t->value = Math::fposmod(rot_a + (rot_b - rot_init) * (float)blend, (float)Math_TAU);
|
||||
t->value = Math::fposmod(rot_a + (rot_b - rot_init) * (float)blend, (float)Math::TAU);
|
||||
} else {
|
||||
value = Animation::cast_to_blendwise(value);
|
||||
if (t->init_value.is_array()) {
|
||||
|
||||
@@ -62,15 +62,15 @@ static real_t in(real_t t, real_t b, real_t c, real_t d) {
|
||||
|
||||
namespace Sine {
|
||||
static real_t in(real_t t, real_t b, real_t c, real_t d) {
|
||||
return -c * cos(t / d * (Math_PI / 2)) + c + b;
|
||||
return -c * cos(t / d * (Math::PI / 2)) + c + b;
|
||||
}
|
||||
|
||||
static real_t out(real_t t, real_t b, real_t c, real_t d) {
|
||||
return c * sin(t / d * (Math_PI / 2)) + b;
|
||||
return c * sin(t / d * (Math::PI / 2)) + b;
|
||||
}
|
||||
|
||||
static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
|
||||
return -c / 2 * (cos(Math_PI * t / d) - 1) + b;
|
||||
return -c / 2 * (cos(Math::PI * t / d) - 1) + b;
|
||||
}
|
||||
|
||||
static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
|
||||
@@ -221,7 +221,7 @@ static real_t in(real_t t, real_t b, real_t c, real_t d) {
|
||||
float a = c * pow(2, 10 * t);
|
||||
float s = p / 4;
|
||||
|
||||
return -(a * sin((t * d - s) * (2 * Math_PI) / p)) + b;
|
||||
return -(a * sin((t * d - s) * (2 * Math::PI) / p)) + b;
|
||||
}
|
||||
|
||||
static real_t out(real_t t, real_t b, real_t c, real_t d) {
|
||||
@@ -237,7 +237,7 @@ static real_t out(real_t t, real_t b, real_t c, real_t d) {
|
||||
float p = d * 0.3f;
|
||||
float s = p / 4;
|
||||
|
||||
return (c * pow(2, -10 * t) * sin((t * d - s) * (2 * Math_PI) / p) + c + b);
|
||||
return (c * pow(2, -10 * t) * sin((t * d - s) * (2 * Math::PI) / p) + c + b);
|
||||
}
|
||||
|
||||
static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
|
||||
@@ -256,12 +256,12 @@ static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
|
||||
if (t < 1) {
|
||||
t -= 1;
|
||||
a *= pow(2, 10 * t);
|
||||
return -0.5f * (a * sin((t * d - s) * (2 * Math_PI) / p)) + b;
|
||||
return -0.5f * (a * sin((t * d - s) * (2 * Math::PI) / p)) + b;
|
||||
}
|
||||
|
||||
t -= 1;
|
||||
a *= pow(2, -10 * t);
|
||||
return a * sin((t * d - s) * (2 * Math_PI) / p) * 0.5f + c + b;
|
||||
return a * sin((t * d - s) * (2 * Math::PI) / p) * 0.5f + c + b;
|
||||
}
|
||||
|
||||
static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
|
||||
@@ -416,7 +416,7 @@ namespace Spring {
|
||||
static real_t out(real_t t, real_t b, real_t c, real_t d) {
|
||||
t /= d;
|
||||
real_t s = 1.0 - t;
|
||||
t = (sin(t * Math_PI * (0.2 + 2.5 * t * t * t)) * pow(s, 2.2) + t) * (1.0 + (1.2 * s));
|
||||
t = (sin(t * Math::PI * (0.2 + 2.5 * t * t * t)) * pow(s, 2.2) + t) * (1.0 + (1.2 * s));
|
||||
return c * t + b;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user