From 8bcbd2729388edc63c82d77d314b583af1447c49 Mon Sep 17 00:00:00 2001 From: untodesu Date: Sun, 14 Sep 2025 19:16:44 +0500 Subject: Cleanup math with qfengine ports again --- game/client/entity/interpolation.cc | 24 ++++++++++++------------ game/client/entity/listener.cc | 2 +- game/client/entity/player_look.cc | 2 +- game/client/entity/player_move.cc | 6 +++--- game/client/entity/sound_emitter.cc | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) (limited to 'game/client/entity') diff --git a/game/client/entity/interpolation.cc b/game/client/entity/interpolation.cc index ef23a4c..c88fcf2 100644 --- a/game/client/entity/interpolation.cc +++ b/game/client/entity/interpolation.cc @@ -19,9 +19,9 @@ static void transform_interpolate(float alpha) entt::get); for(auto [entity, interp, current, previous] : group.each()) { - interp.angles[0] = math::lerp(previous.angles[0], current.angles[0], alpha); - interp.angles[1] = math::lerp(previous.angles[1], current.angles[1], alpha); - interp.angles[2] = math::lerp(previous.angles[2], current.angles[2], alpha); + interp.angles[0] = glm::mix(previous.angles[0], current.angles[0], alpha); + interp.angles[1] = glm::mix(previous.angles[1], current.angles[1], alpha); + interp.angles[2] = glm::mix(previous.angles[2], current.angles[2], alpha); // Figure out previous chunk-local floating-point coordinates transformed // to the current WorldCoord's chunk domain coordinates; we're interpolating @@ -33,9 +33,9 @@ static void transform_interpolate(float alpha) interp.chunk.y = current.chunk.y; interp.chunk.z = current.chunk.z; - interp.local.x = math::lerp(previous_local.x, current.local.x, alpha); - interp.local.y = math::lerp(previous_local.y, current.local.y, alpha); - interp.local.z = math::lerp(previous_local.z, current.local.z, alpha); + interp.local.x = glm::mix(previous_local.x, current.local.x, alpha); + interp.local.y = glm::mix(previous_local.y, current.local.y, alpha); + interp.local.z = glm::mix(previous_local.z, current.local.z, alpha); } } @@ -44,13 +44,13 @@ static void head_interpolate(float alpha) auto group = globals::dimension->entities.group(entt::get); for(auto [entity, interp, current, previous] : group.each()) { - interp.angles[0] = math::lerp(previous.angles[0], current.angles[0], alpha); - interp.angles[1] = math::lerp(previous.angles[1], current.angles[1], alpha); - interp.angles[2] = math::lerp(previous.angles[2], current.angles[2], alpha); + interp.angles[0] = glm::mix(previous.angles[0], current.angles[0], alpha); + interp.angles[1] = glm::mix(previous.angles[1], current.angles[1], alpha); + interp.angles[2] = glm::mix(previous.angles[2], current.angles[2], alpha); - interp.offset.x = math::lerp(previous.offset.x, current.offset.x, alpha); - interp.offset.y = math::lerp(previous.offset.y, current.offset.y, alpha); - interp.offset.z = math::lerp(previous.offset.z, current.offset.z, alpha); + interp.offset.x = glm::mix(previous.offset.x, current.offset.x, alpha); + interp.offset.y = glm::mix(previous.offset.y, current.offset.y, alpha); + interp.offset.z = glm::mix(previous.offset.z, current.offset.z, alpha); } } diff --git a/game/client/entity/listener.cc b/game/client/entity/listener.cc index 3d732ae..1223438 100644 --- a/game/client/entity/listener.cc +++ b/game/client/entity/listener.cc @@ -38,5 +38,5 @@ void entity::listener::update(void) alListenerfv(AL_ORIENTATION, orientation); } - alListenerf(AL_GAIN, math::clamp(sound::volume_master.get_value() * 0.01f, 0.0f, 1.0f)); + alListenerf(AL_GAIN, glm::clamp(sound::volume_master.get_value() * 0.01f, 0.0f, 1.0f)); } diff --git a/game/client/entity/player_look.cc b/game/client/entity/player_look.cc index caa367e..b6eaf16 100644 --- a/game/client/entity/player_look.cc +++ b/game/client/entity/player_look.cc @@ -55,7 +55,7 @@ static void add_angles(float pitch, float yaw) head.angles[0] += pitch; head.angles[1] += yaw; - head.angles[0] = math::clamp(head.angles[0], PITCH_MIN, PITCH_MAX); + head.angles[0] = glm::clamp(head.angles[0], PITCH_MIN, PITCH_MAX); head.angles = math::wrap_180(head.angles); // Client-side head angles are not interpolated; diff --git a/game/client/entity/player_move.cc b/game/client/entity/player_move.cc index 2570780..17aaadd 100644 --- a/game/client/entity/player_move.cc +++ b/game/client/entity/player_move.cc @@ -80,7 +80,7 @@ static glm::fvec3 pm_accelerate(const glm::fvec3& wishdir, const glm::fvec3& vel return velocity; } - auto accel_speed = math::min(add_speed, accel * globals::fixed_frametime * wishspeed); + auto accel_speed = glm::min(add_speed, accel * globals::fixed_frametime * wishspeed); auto result = glm::fvec3(velocity); result.x += accel_speed * wishdir.x; @@ -99,7 +99,7 @@ static glm::fvec3 pm_ground_move(const glm::fvec3& wishdir, const glm::fvec3& ve { if(auto speed = glm::length(velocity)) { auto speed_drop = speed * PMOVE_FRICTION_GROUND * globals::fixed_frametime; - auto speed_factor = math::max(speed - speed_drop, 0.0f) / speed; + auto speed_factor = glm::max(speed - speed_drop, 0.0f) / speed; return pm_accelerate(wishdir, velocity * speed_factor, PMOVE_ACCELERATION_GROUND, PMOVE_MAX_SPEED_GROUND); } @@ -225,7 +225,7 @@ void entity::player_move::fixed_update(void) next_jump_us = globals::curtime + PMOVE_JUMP_COOLDOWN; if(enable_speedometer.get_value()) { - if(math::abs(speed_change) < 0.01f) { + if(glm::abs(speed_change) < 0.01f) { // No considerable speed increase within // the precision we use to draw the speedometer gui::status_lines::set(gui::STATUS_DEBUG, new_speed_text, ImVec4(0.7f, 0.7f, 0.7f, 1.0f), 1.0f); diff --git a/game/client/entity/sound_emitter.cc b/game/client/entity/sound_emitter.cc index c2a93a1..84a66c0 100644 --- a/game/client/entity/sound_emitter.cc +++ b/game/client/entity/sound_emitter.cc @@ -37,7 +37,7 @@ void entity::SoundEmitter::update(void) const auto view = globals::dimension->entities.view(); const auto& pivot = entity::camera::position_chunk; - const auto gain = math::clamp(sound::volume_effects.get_value() * 0.01f, 0.0f, 1.0f); + const auto gain = glm::clamp(sound::volume_effects.get_value() * 0.01f, 0.0f, 1.0f); for(const auto [entity, emitter] : view.each()) { alSourcef(emitter.source, AL_GAIN, gain); -- cgit