summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-04-10 16:46:06 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-04-10 16:46:06 +0200
commit8ffe1eac74a76ab1de9bac6dfdd81104f19a0511 (patch)
treee322155e5638db120bc7f71664318fd2c786f1d3 /src
parent5fc2c1c191440e876a26696d8879110dacf63145 (diff)
update() other layers' entities when only one is visible
Diffstat (limited to 'src')
-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
4 files changed, 7 insertions, 7 deletions
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;