summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--draw/wall.cpp3
-rw-r--r--editor/tile-editor.cpp3
-rw-r--r--editor/tile-editor.hpp1
-rw-r--r--editor/wall-editor.cpp2
m---------external/corrade0
m---------external/magnum0
-rw-r--r--loader/wall-atlas.cpp7
-rw-r--r--src/chunk-walls.cpp9
8 files changed, 16 insertions, 9 deletions
diff --git a/draw/wall.cpp b/draw/wall.cpp
index 870cf9b9..1c9c80cc 100644
--- a/draw/wall.cpp
+++ b/draw/wall.cpp
@@ -38,7 +38,8 @@ void wall_mesh::draw(tile_shader& shader, chunk& c)
size_t k;
for (k = 0; k < size; k++)
do_draw(k, c.wall_atlas_at(ids[k]), max_index);
- do_draw(size, nullptr, max_index);
+ if (size)
+ do_draw(size, nullptr, max_index);
//#define FM_DEBUG_DRAW_COUNT
#ifdef FM_DEBUG_DRAW_COUNT
diff --git a/editor/tile-editor.cpp b/editor/tile-editor.cpp
index e6d98079..0bccd6d9 100644
--- a/editor/tile-editor.cpp
+++ b/editor/tile-editor.cpp
@@ -17,8 +17,7 @@ tile_editor::tile_editor()
void tile_editor::load_atlases()
{
- const auto filename = _name + ".json";
- for (const auto& atlas : loader.tile_atlases(filename))
+ for (const auto& atlas : loader.tile_atlases("floor.json"_s))
{
auto& [_, vec] = _permutation;
vec.reserve(atlas->num_tiles());
diff --git a/editor/tile-editor.hpp b/editor/tile-editor.hpp
index 57347bf0..a33ed848 100644
--- a/editor/tile-editor.hpp
+++ b/editor/tile-editor.hpp
@@ -23,7 +23,6 @@ class tile_editor final
std::vector<decltype(tile_image_proto::variant)> variant;
};
- String _name;
std::map<StringView, std::shared_ptr<tile_atlas>> _atlases;
tile_image_proto _selected_tile;
tuple _permutation;
diff --git a/editor/wall-editor.cpp b/editor/wall-editor.cpp
index c0bb2b4b..d1bcd650 100644
--- a/editor/wall-editor.cpp
+++ b/editor/wall-editor.cpp
@@ -58,6 +58,7 @@ void wall_editor::load_atlases()
wall_editor::wall_editor()
{
load_atlases();
+ _selected_atlas = _atlases.begin()->second.atlas; // todo
}
StringView wall_editor::name() const { return "wall"_s; }
@@ -79,6 +80,7 @@ void wall_editor::place_tile(world& w, global_coords coords, const std::shared_p
case rotation::W: t.wall_west() = { atlas, (uint8_t)-1 }; break;
default: std::unreachable();
}
+ c.mark_walls_modified();
}
editor_snap_mode wall_editor::check_snap(int mods) const
diff --git a/external/corrade b/external/corrade
-Subproject b0a0924ebc03a8db3947ad818e7393303dda588
+Subproject 41e36b29b4ca2b3de26f90b353974d30ca33532
diff --git a/external/magnum b/external/magnum
-Subproject 2d77428750d0d33d726f094a769d1f4cae76209
+Subproject fd5bf6aab73205979659d609d4ccfea9c67af96
diff --git a/loader/wall-atlas.cpp b/loader/wall-atlas.cpp
index 2e4d3704..4f13e91a 100644
--- a/loader/wall-atlas.cpp
+++ b/loader/wall-atlas.cpp
@@ -19,6 +19,7 @@
namespace floormat {
using nlohmann::json;
+using loader_detail::loader_impl;
[[maybe_unused]] static void from_json(const json& j, wall_info& val)
{
@@ -42,8 +43,9 @@ namespace floormat::loader_detail {
std::shared_ptr<wall_atlas> loader_impl::get_wall_atlas(StringView name, StringView path)
{
- auto def = wall_atlas_def::deserialize(""_s.join({path, ".json"_s}));
- auto tex = texture(""_s, path);
+ auto filename = Path::join(path, name);
+ auto def = wall_atlas_def::deserialize(""_s.join({filename, ".json"_s}));
+ auto tex = texture(""_s, filename, false);
fm_soft_assert(name == def.header.name);
fm_soft_assert(!def.frames.empty());
@@ -101,6 +103,7 @@ void loader_impl::get_wall_atlas_list()
for (auto& x : wall_atlas_array)
{
fm_soft_assert(check_atlas_name(x.name));
+ x.atlas = get_wall_atlas(x.name, WALL_TILESET_PATH);
StringView name = x.name;
wall_atlas_map[name] = &x;
fm_debug_assert(name.data() == wall_atlas_map[name]->name.data());
diff --git a/src/chunk-walls.cpp b/src/chunk-walls.cpp
index e64ddf7e..f2c490a3 100644
--- a/src/chunk-walls.cpp
+++ b/src/chunk-walls.cpp
@@ -166,7 +166,8 @@ GL::Mesh chunk::make_wall_mesh()
{
const auto D = k & 1 ? Wall::Direction_::W : Wall::Direction_::N;
const auto& atlas = _walls->atlases[k];
- fm_assert(atlas != nullptr);
+ if (!atlas)
+ continue;
const auto variant_ = _walls->variants[k];
const auto pos = local_coords{k / 2u};
const auto center = Vector3(pos) * TILE_SIZE;
@@ -207,13 +208,15 @@ GL::Mesh chunk::make_wall_mesh()
const auto& frame = frames[variant];
const auto texcoords = Quads::texcoords_at(frame.offset, frame.size, atlas->image_size());
const auto depth = tile_shader::depth_value(pos, depth_offset);
+ fm_debug_assert(i < vertexes.size());
auto& v = vertexes[i];
for (uint8_t j = 0; j < 4; j++)
v[j] = { quad[j], texcoords[j], depth };
}
}
- ranges::sort(ranges::zip_view(vertexes, _walls->mesh_indexes),
+ ranges::sort(ranges::zip_view(vertexes.prefix(N),
+ ArrayView<uint_fast16_t>{_walls->mesh_indexes.data(), N}),
[&A = _walls->atlases](const auto& a, const auto& b) { return A[a.second] < A[b.second]; });
auto vertex_view = std::as_const(vertexes).prefix(N);
@@ -235,8 +238,8 @@ auto chunk::ensure_wall_mesh() noexcept -> wall_mesh_tuple
if (!_walls_modified)
return { wall_mesh, _walls->mesh_indexes, (size_t)wall_mesh.count()/6u };
- _walls_modified = false;
+ _walls_modified = false;
wall_mesh = make_wall_mesh();
return { wall_mesh, _walls->mesh_indexes, (size_t)wall_mesh.count()/6u };
}