summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--serialize/world-reader.cpp19
-rw-r--r--shaders/shader.hpp2
-rw-r--r--src/chunk-walls.cpp18
3 files changed, 24 insertions, 15 deletions
diff --git a/serialize/world-reader.cpp b/serialize/world-reader.cpp
index f90acbd6..05b880b8 100644
--- a/serialize/world-reader.cpp
+++ b/serialize/world-reader.cpp
@@ -35,6 +35,7 @@ private:
void read_strings(reader_t& reader);
void read_chunks(reader_t& reader);
void read_old_scenery(reader_t& s, chunk_coords_ ch, size_t i);
+ void preload_chunks();
std::vector<String> strings;
std::vector<scenery_proto> sceneries;
@@ -391,10 +392,19 @@ void reader_state::read_chunks(reader_t& s)
fm_assert(c.is_scenery_modified());
fm_assert(c.is_passability_modified());
c.sort_objects();
- c.ensure_ground_mesh();
- c.ensure_wall_mesh();
- c.ensure_scenery_mesh({ draw_array, draw_vertexes, draw_indexes });
- c.ensure_passability();
+ }
+}
+
+void reader_state::preload_chunks()
+{
+ for (auto& [coord, _] : _world->chunks())
+ {
+ auto* c = _world->at(coord);
+ fm_assert(c);
+ c->ensure_ground_mesh();
+ c->ensure_wall_mesh();
+ c->ensure_scenery_mesh({ draw_array, draw_vertexes, draw_indexes });
+ c->ensure_passability();
}
}
@@ -470,6 +480,7 @@ void reader_state::deserialize_world(ArrayView<const char> buf)
_world->set_object_counter(object_counter);
else if (PROTO >= 8) [[likely]]
_world->set_object_counter(std::max(world::object_counter_init, object_counter));
+ preload_chunks();
_world = nullptr;
}
diff --git a/shaders/shader.hpp b/shaders/shader.hpp
index 5b46fcb2..cb79fe94 100644
--- a/shaders/shader.hpp
+++ b/shaders/shader.hpp
@@ -44,7 +44,7 @@ struct tile_shader final : private GL::AbstractShaderProgram
static constexpr float scenery_depth_offset = 1 + 2./64;
static constexpr float ground_depth_offset = 0;
static constexpr float wall_depth_offset = 1;
- static constexpr float wall_overlay_depth_offset = 1 + 1./64; // todo add this
+ static constexpr float wall_west_offset = 1./64;
static constexpr float wall_side_offset = 1 - 4./64;
static constexpr float z_depth_offset = 1 + 4./64;
static constexpr float depth_tile_size = 1.f/(TILE_MAX_DIM * 2 * max_screen_tiles.product());
diff --git a/src/chunk-walls.cpp b/src/chunk-walls.cpp
index 67941077..3241991f 100644
--- a/src/chunk-walls.cpp
+++ b/src/chunk-walls.cpp
@@ -126,19 +126,17 @@ ArrayView<const Quads::indexes> make_indexes(size_t max)
return indexes.prefix(max);
}
-constexpr auto depth_offset_for_group(Group_ G)
+constexpr auto depth_offset_for_group(Group_ G, bool is_west)
{
CORRADE_ASSUME(G < Group_::COUNT);
+ float p = is_west ? tile_shader::wall_west_offset : 0;
switch (G)
{
default:
- return tile_shader::wall_depth_offset;
+ return tile_shader::wall_depth_offset + p;
case Wall::Group_::corner:
case Wall::Group_::side:
- return tile_shader::wall_side_offset;
- // // todo
- // case corner:
- // return tile_shader::wall_overlay_depth_offset
+ return tile_shader::wall_side_offset + p;
}
}
@@ -228,7 +226,7 @@ GL::Mesh chunk::make_wall_mesh()
const auto i = N++;
fm_assert(i < vertexes.size());
_walls->mesh_indexes[i] = (uint16_t)k;
- const auto depth_offset = depth_offset_for_group(Group_::top);
+ const auto depth_offset = depth_offset_for_group(Group_::top, is_west);
const auto depth = tile_shader::depth_value(pos, depth_offset);
auto& v = vertexes[i];
for (auto& v : quad)
@@ -250,7 +248,7 @@ GL::Mesh chunk::make_wall_mesh()
const auto i = N++;
fm_assert(i < vertexes.size());
_walls->mesh_indexes[i] = (uint16_t)k;
- const auto depth_offset = depth_offset_for_group(Group_::corner);
+ const auto depth_offset = depth_offset_for_group(Group_::corner, is_west);
const auto depth = tile_shader::depth_value(pos, depth_offset);
auto& v = vertexes[i];
auto quad = get_quad(D, Group_::corner, Depth);
@@ -272,7 +270,7 @@ GL::Mesh chunk::make_wall_mesh()
const auto i = N++;
fm_assert(i < vertexes.size());
_walls->mesh_indexes[i] = (uint16_t)k;
- const auto depth_offset = depth_offset_for_group(Group_::corner);
+ const auto depth_offset = depth_offset_for_group(Group_::corner, is_west);
const auto depth = tile_shader::depth_value(pos, depth_offset);
auto& v = vertexes[i];
auto quad = get_quad(D, Group_::corner, Depth);
@@ -296,7 +294,7 @@ GL::Mesh chunk::make_wall_mesh()
const auto variant = (variant_ != (uint8_t)-1 ? variant_ : vpos) % frames.size();
const auto& frame = frames[variant];
const auto texcoords = Quads::texcoords_at(frame.offset, frame.size, atlas->image_size());
- const auto depth_offset = depth_offset_for_group(G);
+ const auto depth_offset = depth_offset_for_group(G, is_west);
const auto depth = tile_shader::depth_value(pos, depth_offset);
auto quad = get_quad(D, G, Depth);
for (auto& v : quad)