1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Merge pull request #104386 from Repiteo/core/cpp-math

Core: Replace C math headers with C++ equivalents
This commit is contained in:
Thaddeus Crews
2025-04-27 19:21:22 -05:00
101 changed files with 414 additions and 498 deletions

View File

@@ -160,7 +160,7 @@ void AnimationPlayer::_notification(int p_what) {
void AnimationPlayer::_process_playback_data(PlaybackData &cd, double p_delta, float p_blend, bool p_seeked, bool p_internal_seeked, bool p_started, bool p_is_current) {
double speed = speed_scale * cd.speed_scale;
bool backwards = signbit(speed); // Negative zero means playing backwards too.
bool backwards = std::signbit(speed); // Negative zero means playing backwards too.
double delta = p_started ? 0 : p_delta * speed;
double next_pos = cd.pos + delta;
@@ -284,7 +284,7 @@ void AnimationPlayer::_blend_playback_data(double p_delta, bool p_started) {
List<List<Blend>::Element *> to_erase;
for (List<Blend>::Element *E = c.blend.front(); E; E = E->next()) {
Blend &b = E->get();
b.blend_left = MAX(0, b.blend_left - Math::absf(speed_scale * p_delta) / b.blend_time);
b.blend_left = MAX(0, b.blend_left - Math::abs(speed_scale * p_delta) / b.blend_time);
if (Animation::is_less_or_equal_approx(b.blend_left, 0)) {
to_erase.push_back(E);
b.blend_left = CMP_EPSILON; // May want to play last frame.
@@ -546,7 +546,7 @@ void AnimationPlayer::_capture(const StringName &p_name, bool p_from_end, double
if (anim.is_null() || !anim->is_capture_included()) {
return;
}
if (signbit(p_duration)) {
if (std::signbit(p_duration)) {
double max_dur = 0;
double current_pos = playback.current.pos;
if (playback.assigned != name) {
@@ -588,7 +588,7 @@ void AnimationPlayer::set_current_animation(const String &p_animation) {
play(p_animation);
} else if (playback.assigned != p_animation) {
float speed = playback.current.speed_scale;
play(p_animation, -1.0, speed, signbit(speed));
play(p_animation, -1.0, speed, std::signbit(speed));
} else {
// Same animation, do not replay from start.
}
@@ -601,7 +601,7 @@ String AnimationPlayer::get_current_animation() const {
void AnimationPlayer::set_assigned_animation(const String &p_animation) {
if (is_playing()) {
float speed = playback.current.speed_scale;
play(p_animation, -1.0, speed, signbit(speed));
play(p_animation, -1.0, speed, std::signbit(speed));
} else {
ERR_FAIL_COND_MSG(!animation_set.has(p_animation), vformat("Animation not found: %s.", p_animation));
playback.current.pos = 0;