summaryrefslogtreecommitdiffstats
path: root/game/client
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-09-14 19:16:44 +0500
committeruntodesu <kirill@untode.su>2025-09-14 19:16:44 +0500
commit8bcbd2729388edc63c82d77d314b583af1447c49 (patch)
tree460c2b509372077f6adf95d72c4245988a580aed /game/client
parent7fc7fdb001bea8674fe0dbc1b962f3ec2702debb (diff)
downloadvoxelius-8bcbd2729388edc63c82d77d314b583af1447c49.tar.bz2
voxelius-8bcbd2729388edc63c82d77d314b583af1447c49.zip
Cleanup math with qfengine ports again
Diffstat (limited to 'game/client')
-rw-r--r--game/client/config/gamepad_axis.cc2
-rw-r--r--game/client/entity/interpolation.cc24
-rw-r--r--game/client/entity/listener.cc2
-rw-r--r--game/client/entity/player_look.cc2
-rw-r--r--game/client/entity/player_move.cc6
-rw-r--r--game/client/entity/sound_emitter.cc2
-rw-r--r--game/client/game.cc12
-rw-r--r--game/client/gui/crosshair.cc4
-rw-r--r--game/client/gui/direct_connection.cc2
-rw-r--r--game/client/gui/language.cc5
-rw-r--r--game/client/gui/main_menu.cc2
-rw-r--r--game/client/gui/play_menu.cc4
-rw-r--r--game/client/gui/progress_bar.cc8
-rw-r--r--game/client/gui/scoreboard.cc2
-rw-r--r--game/client/gui/splash.cc2
-rw-r--r--game/client/io/gamepad.cc8
-rw-r--r--game/client/main.cc4
-rw-r--r--game/client/program.cc6
-rw-r--r--game/client/resource/sound_effect.cc4
-rw-r--r--game/client/session.cc2
-rw-r--r--game/client/sound/sound.cc12
-rw-r--r--game/client/world/chunk_mesher.cc6
-rw-r--r--game/client/world/voxel_atlas.cc4
23 files changed, 64 insertions, 61 deletions
diff --git a/game/client/config/gamepad_axis.cc b/game/client/config/gamepad_axis.cc
index c782c19..9cc731c 100644
--- a/game/client/config/gamepad_axis.cc
+++ b/game/client/config/gamepad_axis.cc
@@ -99,7 +99,7 @@ float config::GamepadAxis::get_value(const GLFWgamepadstate& state, float deadzo
if(m_gamepad_axis <= math::array_size(state.axes)) {
auto value = state.axes[m_gamepad_axis];
- if(math::abs(value) > deadzone) {
+ if(glm::abs(value) > deadzone) {
return m_inverted ? -value : value;
}
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<entity::Transform, entity::client::TransformPrev>);
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<entity::client::HeadIntr>(entt::get<entity::Head, entity::client::HeadPrev>);
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<entity::SoundEmitter>();
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);
diff --git a/game/client/game.cc b/game/client/game.cc
index d61ce84..e772ff8 100644
--- a/game/client/game.cc
+++ b/game/client/game.cc
@@ -12,7 +12,7 @@
#include "core/resource/resource.hh"
-#include "core/utils/physfs.hh"
+#include "core/io/physfs.hh"
#include "shared/entity/collision.hh"
#include "shared/entity/gravity.hh"
@@ -101,7 +101,7 @@ static ImFont* load_font(std::string_view path, float size, ImFontConfig& font_c
bool font_load_success;
std::vector<std::byte> font;
- if(!utils::read_file(path, font)) {
+ if(!io::read_file(path, font)) {
spdlog::error("{}: utils::read_file failed", path);
std::terminate();
}
@@ -549,10 +549,10 @@ void client_game::update(void)
auto twice_scale_x = static_cast<float>(globals::width) / half_base_width;
auto twice_scale_y = static_cast<float>(globals::height) / half_base_height;
- auto scale_x = math::max(1.0f, 0.5f * glm::floor(twice_scale_x));
- auto scale_y = math::max(1.0f, 0.5f * glm::floor(twice_scale_y));
- auto scale_min = math::ceil<unsigned int>(math::min(scale_x, scale_y));
- auto scale_int = math::max(1U, (scale_min / 2U) * 2U);
+ auto scale_x = glm::max(1.0f, 0.5f * glm::floor(twice_scale_x));
+ auto scale_y = glm::max(1.0f, 0.5f * glm::floor(twice_scale_y));
+ auto scale_min = static_cast<unsigned int>(glm::ceil(glm::min(scale_x, scale_y)));
+ auto scale_int = glm::max(1U, (scale_min / 2U) * 2U);
auto& io = ImGui::GetIO();
io.FontGlobalScale = scale_int;
diff --git a/game/client/gui/crosshair.cc b/game/client/gui/crosshair.cc
index b5650a9..2e6eeba 100644
--- a/game/client/gui/crosshair.cc
+++ b/game/client/gui/crosshair.cc
@@ -34,8 +34,8 @@ void gui::crosshair::layout(void)
auto viewport = ImGui::GetMainViewport();
auto draw_list = ImGui::GetForegroundDrawList();
- auto scaled_width = math::max<int>(texture->size.x, globals::gui_scale * texture->size.x / 2);
- auto scaled_height = math::max<int>(texture->size.y, globals::gui_scale * texture->size.y / 2);
+ auto scaled_width = glm::max<int>(texture->size.x, globals::gui_scale * texture->size.x / 2);
+ auto scaled_height = glm::max<int>(texture->size.y, globals::gui_scale * texture->size.y / 2);
auto start = ImVec2(static_cast<int>(0.5f * viewport->Size.x) - (scaled_width / 2),
static_cast<int>(0.5f * viewport->Size.y) - (scaled_height / 2));
auto end = ImVec2(start.x + scaled_width, start.y + scaled_height);
diff --git a/game/client/gui/direct_connection.cc b/game/client/gui/direct_connection.cc
index dfbd05b..c521232 100644
--- a/game/client/gui/direct_connection.cc
+++ b/game/client/gui/direct_connection.cc
@@ -63,7 +63,7 @@ static void connect_to_server(void)
}
if(parts.size() >= 2) {
- parsed_port = math::clamp<std::uint16_t>(strtoul(parts[1].c_str(), nullptr, 10), 1024, UINT16_MAX);
+ parsed_port = glm::clamp<std::uint16_t>(strtoul(parts[1].c_str(), nullptr, 10), 1024, UINT16_MAX);
}
else {
parsed_port = protocol::PORT;
diff --git a/game/client/gui/language.cc b/game/client/gui/language.cc
index 57a43fe..d10f88b 100644
--- a/game/client/gui/language.cc
+++ b/game/client/gui/language.cc
@@ -5,6 +5,7 @@
#include "core/config/string.hh"
#include "core/io/config_map.hh"
+#include "core/io/physfs.hh"
#include "client/gui/settings.hh"
@@ -40,7 +41,7 @@ void gui::language::init(void)
auto file = PHYSFS_openRead(std::string(MANIFEST_PATH).c_str());
if(file == nullptr) {
- spdlog::critical("language: {}: {}", MANIFEST_PATH, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
+ spdlog::critical("language: {}: {}", MANIFEST_PATH, io::physfs_error());
std::terminate();
}
@@ -113,7 +114,7 @@ void gui::language::set(LanguageIterator new_language)
auto file = PHYSFS_openRead(path.c_str());
if(file == nullptr) {
- spdlog::warn("language: {}: {}", path, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
+ spdlog::warn("language: {}: {}", path, io::physfs_error());
send_language_event(new_language);
return;
}
diff --git a/game/client/gui/main_menu.cc b/game/client/gui/main_menu.cc
index aa506d3..6c0ee37 100644
--- a/game/client/gui/main_menu.cc
+++ b/game/client/gui/main_menu.cc
@@ -96,7 +96,7 @@ void gui::main_menu::layout(void)
}
else {
auto reference_height = 0.225f * window_size.y;
- auto image_width = math::min(window_size.x, reference_height * title_aspect);
+ auto image_width = glm::min(window_size.x, reference_height * title_aspect);
auto image_height = image_width / title_aspect;
ImGui::SetCursorPosX(0.5f * (window_size.x - image_width));
ImGui::Image(title->handle, ImVec2(image_width, image_height));
diff --git a/game/client/gui/play_menu.cc b/game/client/gui/play_menu.cc
index 0747e3a..cd7f730 100644
--- a/game/client/gui/play_menu.cc
+++ b/game/client/gui/play_menu.cc
@@ -95,7 +95,7 @@ static void parse_hostname(ServerStatusItem* item, const std::string& hostname)
}
if(parts.size() >= 2) {
- item->port = math::clamp<std::uint16_t>(strtoul(parts[1].c_str(), nullptr, 10), 1024, UINT16_MAX);
+ item->port = glm::clamp<std::uint16_t>(strtoul(parts[1].c_str(), nullptr, 10), 1024, UINT16_MAX);
}
else {
item->port = protocol::PORT;
@@ -305,7 +305,7 @@ static void layout_server_item(ServerStatusItem* item)
auto outline_pos = ImVec2(version_pos.x - 2U * globals::gui_scale, version_pos.y - 2U * globals::gui_scale);
auto outline_end = ImVec2(version_end.x + 2U * globals::gui_scale, version_end.y + 2U * globals::gui_scale);
- auto outline_thickness = math::max<float>(1.0f, 0.5f * static_cast<float>(globals::gui_scale));
+ auto outline_thickness = glm::max<float>(1.0f, 0.5f * static_cast<float>(globals::gui_scale));
draw_list->AddRect(outline_pos, outline_end, version_color, 0.0f, 0, outline_thickness);
draw_list->AddText(version_pos, version_color, version_toast.c_str(), version_toast.c_str() + version_toast.size());
diff --git a/game/client/gui/progress_bar.cc b/game/client/gui/progress_bar.cc
index 9266ce1..46277b5 100644
--- a/game/client/gui/progress_bar.cc
+++ b/game/client/gui/progress_bar.cc
@@ -58,10 +58,10 @@ void gui::progress_bar::layout(void)
const float modifier = std::exp(-8.0f * (0.5f + 0.5f * sinval));
ImVec4 color = {};
- color.x = math::lerp(background.x, foreground.x, modifier);
- color.y = math::lerp(background.y, foreground.y, modifier);
- color.z = math::lerp(background.z, foreground.z, modifier);
- color.w = math::lerp(background.w, foreground.w, modifier);
+ color.x = glm::mix(background.x, foreground.x, modifier);
+ color.y = glm::mix(background.y, foreground.y, modifier);
+ color.z = glm::mix(background.z, foreground.z, modifier);
+ color.w = glm::mix(background.w, foreground.w, modifier);
const ImVec2 start = ImVec2(base_xpos + bar_width * i, base_ypos);
const ImVec2 end = ImVec2(start.x + bar_width, start.y + bar_height);
diff --git a/game/client/gui/scoreboard.cc b/game/client/gui/scoreboard.cc
index f875ef2..12a4f41 100644
--- a/game/client/gui/scoreboard.cc
+++ b/game/client/gui/scoreboard.cc
@@ -69,7 +69,7 @@ void gui::scoreboard::layout(void)
// Having a minimum size allows for
// generally better in-game visibility
- const float true_size = math::max<float>(0.25f * window_size.x, max_username_size);
+ const float true_size = glm::max<float>(0.25f * window_size.x, max_username_size);
// Figure out username rect dimensions
const float rect_start_x = 0.5f * window_size.x - 0.5f * true_size;
diff --git a/game/client/gui/splash.cc b/game/client/gui/splash.cc
index 9990103..5eae0f2 100644
--- a/game/client/gui/splash.cc
+++ b/game/client/gui/splash.cc
@@ -99,7 +99,7 @@ void gui::client_splash::init_late(void)
break;
}
- texture_alpha = math::smoothstep(0.25f, 0.6f, static_cast<float>(remains) / static_cast<float>(DELAY_MICROSECONDS));
+ texture_alpha = glm::smoothstep(0.25f, 0.6f, static_cast<float>(remains) / static_cast<float>(DELAY_MICROSECONDS));
gui::client_splash::render();
}
diff --git a/game/client/io/gamepad.cc b/game/client/io/gamepad.cc
index 1407996..f19f04a 100644
--- a/game/client/io/gamepad.cc
+++ b/game/client/io/gamepad.cc
@@ -147,8 +147,8 @@ void io::gamepad::update_late(void)
if(glfwGetGamepadState(active_gamepad_id, &io::gamepad::state)) {
for(int i = 0; i < NUM_AXES; ++i) {
- if((math::abs(io::gamepad::state.axes[i]) > GAMEPAD_AXIS_EVENT_THRESHOLD)
- && (math::abs(io::gamepad::last_state.axes[i]) <= GAMEPAD_AXIS_EVENT_THRESHOLD)) {
+ if((glm::abs(io::gamepad::state.axes[i]) > GAMEPAD_AXIS_EVENT_THRESHOLD)
+ && (glm::abs(io::gamepad::last_state.axes[i]) <= GAMEPAD_AXIS_EVENT_THRESHOLD)) {
GamepadAxisEvent event;
event.action = GLFW_PRESS;
event.axis = i;
@@ -156,8 +156,8 @@ void io::gamepad::update_late(void)
continue;
}
- if((math::abs(io::gamepad::state.axes[i]) <= GAMEPAD_AXIS_EVENT_THRESHOLD)
- && (math::abs(io::gamepad::last_state.axes[i]) > GAMEPAD_AXIS_EVENT_THRESHOLD)) {
+ if((glm::abs(io::gamepad::state.axes[i]) <= GAMEPAD_AXIS_EVENT_THRESHOLD)
+ && (glm::abs(io::gamepad::last_state.axes[i]) > GAMEPAD_AXIS_EVENT_THRESHOLD)) {
GamepadAxisEvent event;
event.action = GLFW_RELEASE;
event.axis = i;
diff --git a/game/client/main.cc b/game/client/main.cc
index e20fd5c..b2a6a01 100644
--- a/game/client/main.cc
+++ b/game/client/main.cc
@@ -321,8 +321,8 @@ int main(int argc, char** argv)
if(auto vmode = io::cmdline::get_cstr("mode")) {
std::sscanf(vmode, "%dx%d", &vmode_width, &vmode_height);
- vmode_height = math::max(vmode_height, MIN_HEIGHT);
- vmode_width = math::max(vmode_width, MIN_WIDTH);
+ vmode_height = glm::max(vmode_height, MIN_HEIGHT);
+ vmode_width = glm::max(vmode_width, MIN_WIDTH);
}
glfwSetWindowSize(globals::window, vmode_width, vmode_height);
diff --git a/game/client/program.cc b/game/client/program.cc
index 9eba02f..6a2dfa0 100644
--- a/game/client/program.cc
+++ b/game/client/program.cc
@@ -2,6 +2,8 @@
#include "client/program.hh"
+#include "core/io/physfs.hh"
+
#include "core/utils/string.hh"
// This fills up the array of source lines and figures out
@@ -76,7 +78,7 @@ bool GL_Program::setup(std::string_view vpath, std::string_view fpath)
auto vfile = PHYSFS_openRead(vert_path.c_str());
if(vfile == nullptr) {
- spdlog::warn("gl_program: {}: {}", vpath, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
+ spdlog::warn("gl_program: {}: {}", vpath, io::physfs_error());
return false;
}
@@ -87,7 +89,7 @@ bool GL_Program::setup(std::string_view vpath, std::string_view fpath)
auto ffile = PHYSFS_openRead(frag_path.c_str());
if(ffile == nullptr) {
- spdlog::warn("gl_program: {}: {}", fpath, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
+ spdlog::warn("gl_program: {}: {}", fpath, io::physfs_error());
return false;
}
diff --git a/game/client/resource/sound_effect.cc b/game/client/resource/sound_effect.cc
index d6cc7c5..9d5d8a9 100644
--- a/game/client/resource/sound_effect.cc
+++ b/game/client/resource/sound_effect.cc
@@ -4,7 +4,7 @@
#include "core/resource/resource.hh"
-#include "core/utils/physfs.hh"
+#include "core/io/physfs.hh"
#include "client/globals.hh"
@@ -35,7 +35,7 @@ static const void* sound_effect_load_func(const char* name, std::uint32_t flags)
auto file = PHYSFS_openRead(name);
if(file == nullptr) {
- spdlog::warn("sfx: {}: {}", name, utils::physfs_error());
+ spdlog::warn("sfx: {}: {}", name, io::physfs_error());
return nullptr;
}
diff --git a/game/client/session.cc b/game/client/session.cc
index ce3d616..d8666b9 100644
--- a/game/client/session.cc
+++ b/game/client/session.cc
@@ -41,7 +41,7 @@ static std::uint64_t server_password_hash = UINT64_MAX;
static void set_fixed_tickrate(std::uint16_t tickrate)
{
- globals::fixed_frametime_us = 1000000U / math::clamp<std::uint64_t>(tickrate, 10U, 300U);
+ globals::fixed_frametime_us = 1000000U / glm::clamp<std::uint64_t>(tickrate, 10U, 300U);
globals::fixed_frametime = static_cast<float>(globals::fixed_frametime_us) / 1000000.0f;
globals::fixed_accumulator = 0;
}
diff --git a/game/client/sound/sound.cc b/game/client/sound/sound.cc
index 403bd3e..0eb0463 100644
--- a/game/client/sound/sound.cc
+++ b/game/client/sound/sound.cc
@@ -92,11 +92,11 @@ void sound::shutdown(void)
void sound::update(void)
{
- auto effects_gain = math::clamp(0.01f * sound::volume_effects.get_value(), 0.0f, 1.0f);
+ auto effects_gain = glm::clamp(0.01f * sound::volume_effects.get_value(), 0.0f, 1.0f);
alSourcef(generic_source, AL_GAIN, effects_gain);
alSourcef(player_source, AL_GAIN, effects_gain);
- auto ui_gain = math::clamp(0.01f * sound::volume_ui.get_value(), 0.0f, 1.0f);
+ auto ui_gain = glm::clamp(0.01f * sound::volume_ui.get_value(), 0.0f, 1.0f);
alSourcef(ui_source, AL_GAIN, ui_gain);
}
@@ -149,7 +149,7 @@ void sound::play_generic(resource_ptr<SoundEffect> sound, bool looping, float pi
if(sfx_generic) {
alSourcei(generic_source, AL_BUFFER, sfx_generic->buffer);
alSourcei(generic_source, AL_LOOPING, looping);
- alSourcef(generic_source, AL_PITCH, math::clamp(pitch, MIN_PITCH, MAX_PITCH));
+ alSourcef(generic_source, AL_PITCH, glm::clamp(pitch, MIN_PITCH, MAX_PITCH));
alSourcePlay(generic_source);
}
}
@@ -165,7 +165,7 @@ void sound::play_entity(entt::entity entity, resource_ptr<SoundEffect> sound, bo
if(emitter->sound) {
alSourcei(emitter->source, AL_BUFFER, emitter->sound->buffer);
alSourcei(emitter->source, AL_LOOPING, looping);
- alSourcef(emitter->source, AL_PITCH, math::clamp(pitch, MIN_PITCH, MAX_PITCH));
+ alSourcef(emitter->source, AL_PITCH, glm::clamp(pitch, MIN_PITCH, MAX_PITCH));
alSourcePlay(emitter->source);
}
}
@@ -191,7 +191,7 @@ void sound::play_player(resource_ptr<SoundEffect> sound, bool looping, float pit
if(sfx_player) {
alSourcei(player_source, AL_BUFFER, sfx_player->buffer);
alSourcei(player_source, AL_LOOPING, looping);
- alSourcef(player_source, AL_PITCH, math::clamp(pitch, MIN_PITCH, MAX_PITCH));
+ alSourcef(player_source, AL_PITCH, glm::clamp(pitch, MIN_PITCH, MAX_PITCH));
alSourcePlay(player_source);
}
}
@@ -205,7 +205,7 @@ void sound::play_ui(resource_ptr<SoundEffect> sound, bool looping, float pitch)
if(sfx_ui) {
alSourcei(ui_source, AL_BUFFER, sfx_ui->buffer);
alSourcei(ui_source, AL_LOOPING, looping);
- alSourcef(ui_source, AL_PITCH, math::clamp(pitch, MIN_PITCH, MAX_PITCH));
+ alSourcef(ui_source, AL_PITCH, glm::clamp(pitch, MIN_PITCH, MAX_PITCH));
alSourcePlay(ui_source);
}
}
diff --git a/game/client/world/chunk_mesher.cc b/game/client/world/chunk_mesher.cc
index bc90a03..da90d2e 100644
--- a/game/client/world/chunk_mesher.cc
+++ b/game/client/world/chunk_mesher.cc
@@ -39,9 +39,9 @@ static const CachedChunkCoord get_cached_cpos(const chunk_pos& pivot, const chun
if(pivot != cpos) {
chunk_pos delta = pivot - cpos;
- delta[0] = math::clamp<std::int64_t>(delta[0], -1, 1);
- delta[1] = math::clamp<std::int64_t>(delta[1], -1, 1);
- delta[2] = math::clamp<std::int64_t>(delta[2], -1, 1);
+ delta[0] = glm::clamp<std::int64_t>(delta[0], -1, 1);
+ delta[1] = glm::clamp<std::int64_t>(delta[1], -1, 1);
+ delta[2] = glm::clamp<std::int64_t>(delta[2], -1, 1);
if(delta[0]) {
return nx[delta[0] + 1];
diff --git a/game/client/world/voxel_atlas.cc b/game/client/world/voxel_atlas.cc
index a01db12..67832d3 100644
--- a/game/client/world/voxel_atlas.cc
+++ b/game/client/world/voxel_atlas.cc
@@ -96,12 +96,12 @@ void world::voxel_atlas::create(int width, int height, std::size_t count)
// how voxel quad meshes are packed in memory: each texture index is
// confined in 11 bits so having bigger atlas planes makes no sense;
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &max_plane_layers);
- max_plane_layers = math::clamp(max_plane_layers, 256, 2048);
+ max_plane_layers = glm::clamp(max_plane_layers, 256, 2048);
for(long i = count; i > 0L; i -= max_plane_layers) {
AtlasPlane plane = {};
plane.plane_id = planes.size();
- plane.layer_count_max = math::min<std::size_t>(max_plane_layers, i);
+ plane.layer_count_max = glm::min<std::size_t>(max_plane_layers, i);
plane.layer_count = 0;
const std::size_t save_id = plane.plane_id;