summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--editor/update.cpp7
-rw-r--r--serialize/world-writer.cpp2
-rw-r--r--src/camera-offset.cpp4
-rw-r--r--src/global-coords.hpp2
-rw-r--r--src/world.cpp6
-rw-r--r--src/world.hpp2
6 files changed, 11 insertions, 12 deletions
diff --git a/editor/update.cpp b/editor/update.cpp
index 0b82c099..b4c70211 100644
--- a/editor/update.cpp
+++ b/editor/update.cpp
@@ -104,7 +104,7 @@ void app::do_mouse_up_down(uint8_t button, bool is_down, int mods)
void app::do_mouse_scroll(int offset)
{
- _z_level = (int8_t)Math::clamp(_z_level + offset, 0, (int)chunk_max_z);
+ _z_level = (int8_t)Math::clamp(_z_level + offset, 0, (int)chunk_z_max);
}
void app::do_rotate(bool backward)
@@ -190,11 +190,10 @@ void app::apply_commands(const key_set& keys)
void app::update_world(float dt)
{
auto& world = M->world();
- auto [z_min, z_max] = get_z_bounds();
world.increment_frame_no();
auto [minx, maxx, miny, maxy] = M->get_draw_bounds();
minx--; miny--; maxx++; maxy++;
- for (int8_t z = z_min; z <= z_max; z++)
+ for (int8_t z = chunk_z_min; z <= chunk_z_max; z++)
for (int16_t y = miny; y <= maxy; y++)
for (int16_t x = minx; x <= maxx; x++)
{
@@ -236,7 +235,7 @@ void app::set_cursor()
auto app::get_z_bounds() -> z_bounds
{
if (_render_all_z_levels)
- return { chunk_min_z, chunk_max_z };
+ return { chunk_z_min, chunk_z_max };
else
return { _z_level, _z_level };
}
diff --git a/serialize/world-writer.cpp b/serialize/world-writer.cpp
index 8127eacb..d0a960ef 100644
--- a/serialize/world-writer.cpp
+++ b/serialize/world-writer.cpp
@@ -408,7 +408,7 @@ void writer_state::serialize_chunk(const chunk& c, chunk_coords_ coord)
auto s = binary_writer{chunk_buf.begin()};
s << chunk_magic << coord.x << coord.y;
- fm_assert(coord.z >= chunk_min_z && coord.z <= chunk_max_z);
+ fm_assert(coord.z >= chunk_z_min && coord.z <= chunk_z_max);
s << coord.z;
for (auto i = 0uz; i < TILE_COUNT; i++)
diff --git a/src/camera-offset.cpp b/src/camera-offset.cpp
index fb4724cc..e8c80861 100644
--- a/src/camera-offset.cpp
+++ b/src/camera-offset.cpp
@@ -16,10 +16,10 @@ with_shifted_camera_offset::with_shifted_camera_offset(tile_shader& shader, chun
auto len_x = (float)(last.x - first.x), cx = (float)(c.x - first.x), cy = (float)(c.y - first.y);
//cx += c.z; cy += c.z;
float depth_offset = shader.depth_tile_size*(cy*TILE_MAX_DIM*len_x*TILE_MAX_DIM + cx*TILE_MAX_DIM);
- const int z = c.z - chunk_min_z;
+ const int z = c.z - chunk_z_min;
depth_offset += tile_shader::depth_value(local_coords{z, z});
- if (c.z == chunk_max_z)
+ if (c.z == chunk_z_max)
depth_offset = 1;
_shader.set_camera_offset(offset, depth_offset);
diff --git a/src/global-coords.hpp b/src/global-coords.hpp
index c86cee59..b3681992 100644
--- a/src/global-coords.hpp
+++ b/src/global-coords.hpp
@@ -37,7 +37,7 @@ struct chunk_coords_ final {
constexpr bool operator==(const chunk_coords_&) const noexcept = default;
};
-constexpr inline int8_t chunk_min_z = -1, chunk_max_z = 14;
+constexpr inline int8_t chunk_z_min = -1, chunk_z_max = 14;
struct global_coords final {
using u0 = std::integral_constant<uint32_t, (1<<15)>;
diff --git a/src/world.cpp b/src/world.cpp
index 5a6e505f..9c3f8276 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -13,9 +13,9 @@ size_t std::hash<chunk_coords_>::operator()(const chunk_coords_& coord) const no
x |= size_t(uint16_t(coord.y)) << 16;
x |= size_t(uint16_t(coord.x));
if constexpr(sizeof(size_t) > 4)
- x |= size_t(uint8_t(coord.z-chunk_min_z) & 0xf) << 32;
+ x |= size_t(uint8_t(coord.z- chunk_z_min) & 0xf) << 32;
else
- x ^= size_t(uint8_t(coord.z-chunk_min_z) & 0xf) * size_t(1664525);
+ x ^= size_t(uint8_t(coord.z- chunk_z_min) & 0xf) * size_t(1664525);
if constexpr(sizeof(size_t) > 4)
return int_hash(uint64_t(x));
@@ -88,7 +88,7 @@ world::world(size_t capacity) : _chunks{capacity}
chunk& world::operator[](chunk_coords_ coord) noexcept
{
- fm_debug_assert(coord.z >= chunk_min_z && coord.z <= chunk_max_z);
+ fm_debug_assert(coord.z >= chunk_z_min && coord.z <= chunk_z_max);
auto& [c, coord2] = _last_chunk;
if (coord != coord2)
c = &_chunks.try_emplace(coord, *this).first->second;
diff --git a/src/world.hpp b/src/world.hpp
index 1379d820..c4231173 100644
--- a/src/world.hpp
+++ b/src/world.hpp
@@ -30,7 +30,7 @@ struct world final
private:
struct chunk_tuple final {
- static constexpr chunk_coords_ invalid_coords = { -1 << 15, -1 << 15, chunk_min_z };
+ static constexpr chunk_coords_ invalid_coords = { -1 << 15, -1 << 15, chunk_z_min };
chunk* c = nullptr;
chunk_coords_ pos = invalid_coords;
} _last_chunk;