diff options
Diffstat (limited to 'game/shared')
| -rw-r--r-- | game/shared/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | game/shared/collision.cc | 21 | ||||
| -rw-r--r-- | game/shared/const.hh | 2 | ||||
| -rw-r--r-- | game/shared/coord.hh | 9 | ||||
| -rw-r--r-- | game/shared/game_items.cc | 26 | ||||
| -rw-r--r-- | game/shared/game_voxels.cc | 15 | ||||
| -rw-r--r-- | game/shared/ray_dda.cc | 6 | ||||
| -rw-r--r-- | game/shared/splash.cc | 2 | ||||
| -rw-r--r-- | game/shared/threading.cc | 4 |
9 files changed, 53 insertions, 36 deletions
diff --git a/game/shared/CMakeLists.txt b/game/shared/CMakeLists.txt index b0cd086..e9d3762 100644 --- a/game/shared/CMakeLists.txt +++ b/game/shared/CMakeLists.txt @@ -49,9 +49,9 @@ add_library(shared STATIC "${CMAKE_CURRENT_LIST_DIR}/voxel_registry.hh" "${CMAKE_CURRENT_LIST_DIR}/voxel_storage.cc" "${CMAKE_CURRENT_LIST_DIR}/voxel_storage.hh") -target_compile_features(shared PUBLIC cxx_std_17) +target_compile_features(shared PUBLIC cxx_std_20) target_include_directories(shared PUBLIC "${DEPS_INCLUDE_DIR}") target_include_directories(shared PRIVATE "${PROJECT_SOURCE_DIR}") target_include_directories(shared PRIVATE "${PROJECT_SOURCE_DIR}/game") target_precompile_headers(shared PRIVATE "${CMAKE_CURRENT_LIST_DIR}/pch.hh") -target_link_libraries(shared PUBLIC core enet FNL miniz parson) +target_link_libraries(shared PUBLIC core enet entt FNL miniz parson thread_pool) diff --git a/game/shared/collision.cc b/game/shared/collision.cc index af880ab..dd51dd5 100644 --- a/game/shared/collision.cc +++ b/game/shared/collision.cc @@ -13,10 +13,11 @@ #include "shared/velocity.hh" #include "shared/voxel_registry.hh" -static int vgrid_collide(const Dimension* dimension, int d, CollisionComponent& collision, TransformComponent& transform, VelocityComponent& velocity, voxel_surface& touch_surface) +static int vgrid_collide(const Dimension* dimension, int d, CollisionComponent& collision, TransformComponent& transform, + VelocityComponent& velocity, voxel_surface& touch_surface) { const auto move = globals::fixed_frametime * velocity.value[d]; - const auto move_sign = cxpr::sign<int>(move); + const auto move_sign = vx::sign<int>(move); const auto& ref_aabb = collision.aabb; const auto current_aabb = ref_aabb.push(transform.local); @@ -26,14 +27,14 @@ static int vgrid_collide(const Dimension* dimension, int d, CollisionComponent& next_aabb.max[d] += move; local_pos lpos_min; - lpos_min.x = cxpr::floor<local_pos::value_type>(next_aabb.min.x); - lpos_min.y = cxpr::floor<local_pos::value_type>(next_aabb.min.y); - lpos_min.z = cxpr::floor<local_pos::value_type>(next_aabb.min.z); + lpos_min.x = vx::floor<local_pos::value_type>(next_aabb.min.x); + lpos_min.y = vx::floor<local_pos::value_type>(next_aabb.min.y); + lpos_min.z = vx::floor<local_pos::value_type>(next_aabb.min.z); local_pos lpos_max; - lpos_max.x = cxpr::ceil<local_pos::value_type>(next_aabb.max.x); - lpos_max.y = cxpr::ceil<local_pos::value_type>(next_aabb.max.y); - lpos_max.z = cxpr::ceil<local_pos::value_type>(next_aabb.max.z); + lpos_max.x = vx::ceil<local_pos::value_type>(next_aabb.max.x); + lpos_max.y = vx::ceil<local_pos::value_type>(next_aabb.max.y); + lpos_max.z = vx::ceil<local_pos::value_type>(next_aabb.max.z); // Other axes const int u = (d + 1) % 3; @@ -108,7 +109,7 @@ static int vgrid_collide(const Dimension* dimension, int d, CollisionComponent& if(latch_touch != voxel_touch::NOTHING) { if(latch_touch == voxel_touch::BOUNCE) { - const auto move_distance = cxpr::abs(current_aabb.min[d] - next_aabb.min[d]); + const auto move_distance = vx::abs(current_aabb.min[d] - next_aabb.min[d]); const auto threshold = 2.0f * globals::fixed_frametime; if(move_distance > threshold) { @@ -150,7 +151,7 @@ void CollisionComponent::fixed_update(Dimension* dimension) auto vertical_move = vgrid_collide(dimension, 1, collision, transform, velocity, surface); if(dimension->entities.any_of<GravityComponent>(entity)) { - if(vertical_move == cxpr::sign<int>(dimension->get_gravity())) { + if(vertical_move == vx::sign<int>(dimension->get_gravity())) { dimension->entities.emplace_or_replace<GroundedComponent>(entity, GroundedComponent { surface }); } else { dimension->entities.remove<GroundedComponent>(entity); diff --git a/game/shared/const.hh b/game/shared/const.hh index 8f8f0f9..4639c4b 100644 --- a/game/shared/const.hh +++ b/game/shared/const.hh @@ -7,7 +7,7 @@ constexpr static unsigned int CHUNK_SIZE = 16; constexpr static unsigned int CHUNK_AREA = CHUNK_SIZE * CHUNK_SIZE; constexpr static unsigned int CHUNK_VOLUME = CHUNK_SIZE * CHUNK_SIZE * CHUNK_SIZE; -constexpr static unsigned int CHUNK_BITSHIFT = cxpr::log2(CHUNK_SIZE); +constexpr static unsigned int CHUNK_BITSHIFT = vx::log2(CHUNK_SIZE); template<typename T> constexpr static glm::vec<3, T> DIR_NORTH = glm::vec<3, T>(0, 0, +1); diff --git a/game/shared/coord.hh b/game/shared/coord.hh index 4a11e60..f1a2e70 100644 --- a/game/shared/coord.hh +++ b/game/shared/coord.hh @@ -53,9 +53,9 @@ inline constexpr chunk_pos coord::to_chunk(const voxel_pos& vpos) inline constexpr local_pos coord::to_local(const voxel_pos& vpos) { return local_pos { - static_cast<local_pos::value_type>(cxpr::mod_signed<voxel_pos::value_type>(vpos.x, CHUNK_SIZE)), - static_cast<local_pos::value_type>(cxpr::mod_signed<voxel_pos::value_type>(vpos.y, CHUNK_SIZE)), - static_cast<local_pos::value_type>(cxpr::mod_signed<voxel_pos::value_type>(vpos.z, CHUNK_SIZE)), + static_cast<local_pos::value_type>(vx::mod_signed<voxel_pos::value_type>(vpos.x, CHUNK_SIZE)), + static_cast<local_pos::value_type>(vx::mod_signed<voxel_pos::value_type>(vpos.y, CHUNK_SIZE)), + static_cast<local_pos::value_type>(vx::mod_signed<voxel_pos::value_type>(vpos.z, CHUNK_SIZE)), }; } @@ -118,7 +118,8 @@ inline constexpr glm::fvec3 coord::to_relative(const chunk_pos& pivot_cpos, cons }; } -inline constexpr glm::fvec3 coord::to_relative(const chunk_pos& pivot_cpos, const glm::fvec3& pivot_fvec, const chunk_pos& cpos, const glm::fvec3& fvec) +inline constexpr glm::fvec3 coord::to_relative( + const chunk_pos& pivot_cpos, const glm::fvec3& pivot_fvec, const chunk_pos& cpos, const glm::fvec3& fvec) { return glm::fvec3 { static_cast<float>((cpos.x - pivot_cpos.x) << CHUNK_BITSHIFT) + (fvec.x - pivot_fvec.x), diff --git a/game/shared/game_items.cc b/game/shared/game_items.cc index f2f1c0c..6351969 100644 --- a/game/shared/game_items.cc +++ b/game/shared/game_items.cc @@ -19,31 +19,41 @@ item_id game_items::mud = NULL_ITEM_ID; void game_items::populate(void) { // Stone; a hardened slate rock - game_items::stone = item_registry::construct("stone").set_texture("textures/item/stone.png").set_place_voxel(game_voxels::stone).build(); + game_items::stone = + item_registry::construct("stone").set_texture("textures/item/stone.png").set_place_voxel(game_voxels::stone).build(); // Cobblestone; a bunch of small stones - game_items::cobblestone = item_registry::construct("cobblestone").set_texture("textures/item/cobblestone.png").set_place_voxel(game_voxels::cobblestone).build(); + game_items::cobblestone = item_registry::construct("cobblestone") + .set_texture("textures/item/cobblestone.png") + .set_place_voxel(game_voxels::cobblestone) + .build(); // Dirt; it's very dirty game_items::dirt = item_registry::construct("dirt").set_texture("textures/item/dirt.png").set_place_voxel(game_voxels::dirt).build(); // Grass; literally just grassy dirt - game_items::grass = item_registry::construct("grass").set_texture("textures/item/grass.png").set_place_voxel(game_voxels::grass).build(); + game_items::grass = + item_registry::construct("grass").set_texture("textures/item/grass.png").set_place_voxel(game_voxels::grass).build(); // Oak leaves; they're bushy! - game_items::oak_leaves = item_registry::construct("oak_leaves").set_texture("textures/item/oak_leaves.png").set_place_voxel(game_voxels::oak_leaves).build(); + game_items::oak_leaves = + item_registry::construct("oak_leaves").set_texture("textures/item/oak_leaves.png").set_place_voxel(game_voxels::oak_leaves).build(); // Oak planks; watch for splinters! - game_items::oak_planks = item_registry::construct("oak_planks").set_texture("textures/item/oak_planks.png").set_place_voxel(game_voxels::oak_planks).build(); + game_items::oak_planks = + item_registry::construct("oak_planks").set_texture("textures/item/oak_planks.png").set_place_voxel(game_voxels::oak_planks).build(); // Oak log; a big wad of wood - game_items::oak_log = item_registry::construct("oak_log").set_texture("textures/item/oak_log.png").set_place_voxel(game_voxels::oak_log).build(); + game_items::oak_log = + item_registry::construct("oak_log").set_texture("textures/item/oak_log.png").set_place_voxel(game_voxels::oak_log).build(); // Glass; used for windowing - game_items::glass = item_registry::construct("glass").set_texture("textures/item/glass.png").set_place_voxel(game_voxels::glass).build(); + game_items::glass = + item_registry::construct("glass").set_texture("textures/item/glass.png").set_place_voxel(game_voxels::glass).build(); // Slime; it's bouncy! - game_items::slime = item_registry::construct("slime").set_texture("textures/item/slime.png").set_place_voxel(game_voxels::slime).build(); + game_items::slime = + item_registry::construct("slime").set_texture("textures/item/slime.png").set_place_voxel(game_voxels::slime).build(); // Mud; you sink in it! game_items::mud = item_registry::construct("mud").set_texture("textures/item/mud.png").build(); diff --git a/game/shared/game_voxels.cc b/game/shared/game_voxels.cc index 23c953b..72410fc 100644 --- a/game/shared/game_voxels.cc +++ b/game/shared/game_voxels.cc @@ -66,11 +66,14 @@ void game_voxels::populate(void) .build(); // VTest-CK; a pure blue chromakey I used to make the game's logo - game_voxels::vtest_ck = voxel_registry::construct("vtest_ck", voxel_type::CUBE, false, false).add_texture_default("textures/voxel/chromakey.png").build(); + game_voxels::vtest_ck = + voxel_registry::construct("vtest_ck", voxel_type::CUBE, false, false).add_texture_default("textures/voxel/chromakey.png").build(); // Oak leaves; greenery. TODO: add trees as surface features - game_voxels::oak_leaves = - voxel_registry::construct("oak_leaves", voxel_type::CUBE, false, false).add_texture_default("textures/voxel/oak_leaves.png").set_surface(voxel_surface::GRASS).build(); + game_voxels::oak_leaves = voxel_registry::construct("oak_leaves", voxel_type::CUBE, false, false) + .add_texture_default("textures/voxel/oak_leaves.png") + .set_surface(voxel_surface::GRASS) + .build(); // Oak planks; the thing that comes out of oak logs game_voxels::oak_planks = voxel_registry::construct("oak_planks", voxel_type::CUBE, false, false) @@ -89,8 +92,10 @@ void game_voxels::populate(void) .build(); // Glass; blend rendering test - game_voxels::glass = - voxel_registry::construct("glass", voxel_type::CUBE, false, true).add_texture_default("textures/voxel/glass_01.png").set_surface(voxel_surface::GLASS).build(); + game_voxels::glass = voxel_registry::construct("glass", voxel_type::CUBE, false, true) + .add_texture_default("textures/voxel/glass_01.png") + .set_surface(voxel_surface::GLASS) + .build(); // Slime; it's bouncy! game_voxels::slime = voxel_registry::construct("slime", voxel_type::CUBE, false, true) diff --git a/game/shared/ray_dda.cc b/game/shared/ray_dda.cc index 3520817..75d4386 100644 --- a/game/shared/ray_dda.cc +++ b/game/shared/ray_dda.cc @@ -22,9 +22,9 @@ void RayDDA::reset(const Dimension* dimension, const chunk_pos& start_chunk, con this->start_fpos = start_fpos; this->direction = direction; - this->delta_dist.x = direction.x ? cxpr::abs(1.0f / direction.x) : std::numeric_limits<float>::max(); - this->delta_dist.y = direction.y ? cxpr::abs(1.0f / direction.y) : std::numeric_limits<float>::max(); - this->delta_dist.z = direction.z ? cxpr::abs(1.0f / direction.z) : std::numeric_limits<float>::max(); + this->delta_dist.x = direction.x ? vx::abs(1.0f / direction.x) : std::numeric_limits<float>::max(); + this->delta_dist.y = direction.y ? vx::abs(1.0f / direction.y) : std::numeric_limits<float>::max(); + this->delta_dist.z = direction.z ? vx::abs(1.0f / direction.z) : std::numeric_limits<float>::max(); this->distance = 0.0f; this->vpos = coord::to_voxel(start_chunk, start_fpos); diff --git a/game/shared/splash.cc b/game/shared/splash.cc index 2381f7a..0cd5f50 100644 --- a/game/shared/splash.cc +++ b/game/shared/splash.cc @@ -36,7 +36,7 @@ static void splash_init_filename(const char* filename) splash_lines.push_back(sanitize_line(line)); splash_random.seed(std::random_device()()); } else { - splash_lines.push_back(fmt::format("{}: {}", filename, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()))); + splash_lines.push_back(std::format("{}: {}", filename, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()))); splash_random.seed(std::random_device()()); } } diff --git a/game/shared/threading.cc b/game/shared/threading.cc index ad496ee..9e46d17 100644 --- a/game/shared/threading.cc +++ b/game/shared/threading.cc @@ -44,9 +44,9 @@ void threading::init(void) thread_pool_size = num_concurrent_threads; } else { if(num_concurrent_threads) { - thread_pool_size = cxpr::clamp<unsigned int>(std::strtoul(argument, nullptr, 10), 1U, num_concurrent_threads); + thread_pool_size = vx::clamp<unsigned int>(std::strtoul(argument, nullptr, 10), 1U, num_concurrent_threads); } else { - thread_pool_size = cxpr::max<unsigned int>(std::strtoul(argument, nullptr, 10), 1U); + thread_pool_size = vx::max<unsigned int>(std::strtoul(argument, nullptr, 10), 1U); } } |
