summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--draw/floor.cpp7
-rw-r--r--editor/app.hpp2
-rw-r--r--editor/editor.cpp6
-rw-r--r--editor/editor.hpp10
-rw-r--r--editor/ground-editor.cpp (renamed from editor/tile-editor.cpp)38
-rw-r--r--editor/ground-editor.hpp (renamed from editor/tile-editor.hpp)22
-rw-r--r--editor/imgui-editors.cpp4
-rw-r--r--editor/update.cpp10
-rw-r--r--loader/atlas.cpp18
-rw-r--r--loader/impl.hpp10
-rw-r--r--loader/json.cpp16
-rw-r--r--loader/loader.hpp8
-rw-r--r--serialize/ground-atlas.cpp (renamed from serialize/tile-atlas.cpp)12
-rw-r--r--serialize/ground-atlas.hpp (renamed from serialize/tile-atlas.hpp)8
-rw-r--r--serialize/tile.cpp4
-rw-r--r--serialize/world-reader.cpp8
-rw-r--r--serialize/world-writer.cpp2
-rw-r--r--shaders/lightmap.cpp2
-rw-r--r--src/chunk-collision.cpp2
-rw-r--r--src/chunk-render.cpp2
-rw-r--r--src/chunk.cpp2
-rw-r--r--src/chunk.hpp4
-rw-r--r--src/ground-atlas.cpp (renamed from src/tile-atlas.cpp)14
-rw-r--r--src/ground-atlas.hpp (renamed from src/tile-atlas.hpp)4
-rw-r--r--src/tile-image.cpp4
-rw-r--r--src/tile-image.hpp6
-rw-r--r--src/tile.cpp12
-rw-r--r--src/tile.hpp14
-rw-r--r--test/json.cpp12
-rw-r--r--test/loader.cpp8
-rw-r--r--test/serializer.cpp4
31 files changed, 138 insertions, 137 deletions
diff --git a/draw/floor.cpp b/draw/floor.cpp
index 31626f1c..a073f39f 100644
--- a/draw/floor.cpp
+++ b/draw/floor.cpp
@@ -1,7 +1,7 @@
#include "floor.hpp"
#include "shaders/shader.hpp"
#include "src/chunk.hpp"
-#include "src/tile-atlas.hpp"
+#include "src/ground-atlas.hpp"
#include "compat/assert.hpp"
#include <Magnum/GL/MeshView.h>
@@ -13,13 +13,14 @@ void floor_mesh::draw(tile_shader& shader, chunk& c)
{
constexpr int quad_index_count = 6;
const auto [mesh_, ids, size] = c.ensure_ground_mesh();
- struct { tile_atlas* atlas = nullptr; size_t pos = 0; } last;
+ struct {
+ ground_atlas* atlas = nullptr; size_t pos = 0; } last;
GL::MeshView mesh{mesh_};
[[maybe_unused]] size_t draw_count = 0;
fm_debug_assert(size_t(mesh_.count()) == size*quad_index_count);
- const auto do_draw = [&](size_t i, tile_atlas* atlas, uint32_t max_index) {
+ const auto do_draw = [&](size_t i, ground_atlas* atlas, uint32_t max_index) {
if (atlas == last.atlas)
return;
if (auto len = i - last.pos; last.atlas && len > 0)
diff --git a/editor/app.hpp b/editor/app.hpp
index 45735400..09198c36 100644
--- a/editor/app.hpp
+++ b/editor/app.hpp
@@ -21,7 +21,7 @@ namespace floormat {
struct chunk;
struct floormat_main;
-class tile_atlas;
+class ground_atlas;
struct fm_settings;
class anim_atlas;
struct critter;
diff --git a/editor/editor.cpp b/editor/editor.cpp
index de2e690e..86a180b5 100644
--- a/editor/editor.cpp
+++ b/editor/editor.cpp
@@ -191,7 +191,7 @@ void editor::set_mode(editor_mode mode)
on_release();
}
-const tile_editor* editor::current_ground_editor() const noexcept
+const ground_editor* editor::current_ground_editor() const noexcept
{
switch (_mode)
{
@@ -229,9 +229,9 @@ const vobj_editor* editor::current_vobj_editor() const noexcept
return nullptr;
}
-tile_editor* editor::current_ground_editor() noexcept
+ground_editor* editor::current_ground_editor() noexcept
{
- return const_cast<tile_editor*>(static_cast<const editor&>(*this).current_ground_editor());
+ return const_cast<ground_editor*>(static_cast<const editor&>(*this).current_ground_editor());
}
wall_editor* editor::current_wall_editor() noexcept
diff --git a/editor/editor.hpp b/editor/editor.hpp
index dc897bc3..fae85c2f 100644
--- a/editor/editor.hpp
+++ b/editor/editor.hpp
@@ -4,7 +4,7 @@
#include "src/tile-image.hpp"
#include "src/scenery.hpp"
#include "editor-enums.hpp"
-#include "tile-editor.hpp"
+#include "ground-editor.hpp"
#include "wall-editor.hpp"
#include "scenery-editor.hpp"
#include "vobj-editor.hpp"
@@ -16,7 +16,7 @@ namespace floormat {
struct world;
class anim_atlas;
-class tile_atlas;
+class ground_atlas;
struct app;
struct editor final
@@ -26,8 +26,8 @@ struct editor final
[[nodiscard]] editor_mode mode() const noexcept { return _mode; }
void set_mode(editor_mode mode);
- tile_editor* current_ground_editor() noexcept;
- const tile_editor* current_ground_editor() const noexcept;
+ ground_editor* current_ground_editor() noexcept;
+ const ground_editor* current_ground_editor() const noexcept;
wall_editor* current_wall_editor() noexcept;
const wall_editor* current_wall_editor() const noexcept;
scenery_editor* current_scenery_editor() noexcept;
@@ -57,7 +57,7 @@ private:
app* _app;
- tile_editor _floor;
+ ground_editor _floor;
wall_editor _wall;
scenery_editor _scenery;
vobj_editor _vobj;
diff --git a/editor/tile-editor.cpp b/editor/ground-editor.cpp
index 1b766208..0f67853e 100644
--- a/editor/tile-editor.cpp
+++ b/editor/ground-editor.cpp
@@ -1,5 +1,5 @@
-#include "tile-editor.hpp"
-#include "src/tile-atlas.hpp"
+#include "ground-editor.hpp"
+#include "src/ground-atlas.hpp"
#include "src/world.hpp"
#include "src/random.hpp"
#include "keys.hpp"
@@ -10,14 +10,14 @@
namespace floormat {
-tile_editor::tile_editor()
+ground_editor::ground_editor()
{
load_atlases();
}
-void tile_editor::load_atlases()
+void ground_editor::load_atlases()
{
- for (const auto& atlas : loader.tile_atlases("floor.json"_s))
+ for (const auto& atlas : loader.ground_atlases("floor.json"_s))
{
auto& [_, vec] = _permutation;
vec.reserve(atlas->num_tiles());
@@ -25,7 +25,7 @@ void tile_editor::load_atlases()
}
}
-std::shared_ptr<tile_atlas> tile_editor::maybe_atlas(StringView str)
+std::shared_ptr<ground_atlas> ground_editor::maybe_atlas(StringView str)
{
if (auto it = _atlases.find(str); it != _atlases.end())
return it->second;
@@ -33,7 +33,7 @@ std::shared_ptr<tile_atlas> tile_editor::maybe_atlas(StringView str)
return nullptr;
}
-std::shared_ptr<tile_atlas> tile_editor::atlas(StringView str)
+std::shared_ptr<ground_atlas> ground_editor::atlas(StringView str)
{
if (auto ptr = maybe_atlas(str))
return ptr;
@@ -41,16 +41,16 @@ std::shared_ptr<tile_atlas> tile_editor::atlas(StringView str)
fm_throw("no such atlas: {}"_cf, str);
}
-StringView tile_editor::name() const noexcept { return "floor"_s; }
+StringView ground_editor::name() const noexcept { return "floor"_s; }
-void tile_editor::clear_selection()
+void ground_editor::clear_selection()
{
_selected_tile = {};
_permutation = {};
_selection_mode = sel_none;
}
-void tile_editor::select_tile(const std::shared_ptr<tile_atlas>& atlas, size_t variant)
+void ground_editor::select_tile(const std::shared_ptr<ground_atlas>& atlas, size_t variant)
{
fm_assert(atlas);
clear_selection();
@@ -58,7 +58,7 @@ void tile_editor::select_tile(const std::shared_ptr<tile_atlas>& atlas, size_t v
_selected_tile = { atlas, variant_t(variant % atlas->num_tiles()) };
}
-void tile_editor::select_tile_permutation(const std::shared_ptr<tile_atlas>& atlas)
+void ground_editor::select_tile_permutation(const std::shared_ptr<ground_atlas>& atlas)
{
fm_assert(atlas);
clear_selection();
@@ -66,19 +66,19 @@ void tile_editor::select_tile_permutation(const std::shared_ptr<tile_atlas>& atl
_permutation = { atlas, {} };
}
-bool tile_editor::is_tile_selected(const std::shared_ptr<const tile_atlas>& atlas, size_t variant) const
+bool ground_editor::is_tile_selected(const std::shared_ptr<const ground_atlas>& atlas, size_t variant) const
{
return atlas && _selection_mode == sel_tile && _selected_tile &&
atlas == _selected_tile.atlas && variant == _selected_tile.variant;
}
-bool tile_editor::is_permutation_selected(const std::shared_ptr<const tile_atlas>& atlas) const
+bool ground_editor::is_permutation_selected(const std::shared_ptr<const ground_atlas>& atlas) const
{
const auto& [perm, _] = _permutation;
return atlas && _selection_mode == sel_perm && perm == atlas;
}
-bool tile_editor::is_atlas_selected(const std::shared_ptr<const tile_atlas>& atlas) const
+bool ground_editor::is_atlas_selected(const std::shared_ptr<const ground_atlas>& atlas) const
{
switch (_selection_mode)
{
@@ -92,7 +92,7 @@ bool tile_editor::is_atlas_selected(const std::shared_ptr<const tile_atlas>& atl
}
}
-bool tile_editor::is_anything_selected() const
+bool ground_editor::is_anything_selected() const
{
return _selection_mode != sel_none;
}
@@ -109,7 +109,7 @@ void fisher_yates(T begin, T end)
}
}
-tile_image_proto tile_editor::get_selected_perm()
+tile_image_proto ground_editor::get_selected_perm()
{
auto& [atlas, vec] = _permutation;
const auto N = (variant_t)atlas->num_tiles();
@@ -126,7 +126,7 @@ tile_image_proto tile_editor::get_selected_perm()
return {atlas, idx};
}
-tile_image_proto tile_editor::get_selected()
+tile_image_proto ground_editor::get_selected()
{
switch (_selection_mode)
{
@@ -142,14 +142,14 @@ tile_image_proto tile_editor::get_selected()
}
}
-void tile_editor::place_tile(world& world, global_coords pos, const tile_image_proto& img)
+void ground_editor::place_tile(world& world, global_coords pos, const tile_image_proto& img)
{
auto [c, t] = world[pos];
c.mark_ground_modified();
t.ground() = img;
}
-auto tile_editor::check_snap(int mods) const -> editor_snap_mode
+auto ground_editor::check_snap(int mods) const -> editor_snap_mode
{
const bool ctrl = mods & kmod_ctrl, shift = mods & kmod_shift;
diff --git a/editor/tile-editor.hpp b/editor/ground-editor.hpp
index a33ed848..46c9dc3a 100644
--- a/editor/tile-editor.hpp
+++ b/editor/ground-editor.hpp
@@ -12,18 +12,18 @@ namespace floormat {
struct world;
-class tile_editor final
+class ground_editor final
{
enum selection_mode : unsigned char {
sel_none, sel_tile, sel_perm,
};
struct tuple final {
- std::shared_ptr<tile_atlas> atlas;
+ std::shared_ptr<ground_atlas> atlas;
std::vector<decltype(tile_image_proto::variant)> variant;
};
- std::map<StringView, std::shared_ptr<tile_atlas>> _atlases;
+ std::map<StringView, std::shared_ptr<ground_atlas>> _atlases;
tile_image_proto _selected_tile;
tuple _permutation;
selection_mode _selection_mode = sel_none;
@@ -32,9 +32,9 @@ class tile_editor final
tile_image_proto get_selected_perm();
public:
- tile_editor();
- std::shared_ptr<tile_atlas> maybe_atlas(StringView str);
- std::shared_ptr<tile_atlas> atlas(StringView str);
+ ground_editor();
+ std::shared_ptr<ground_atlas> maybe_atlas(StringView str);
+ std::shared_ptr<ground_atlas> atlas(StringView str);
auto cbegin() const noexcept { return _atlases.cbegin(); }
auto cend() const noexcept { return _atlases.cend(); }
auto begin() const noexcept { return _atlases.cbegin(); }
@@ -42,11 +42,11 @@ public:
StringView name() const noexcept;
void clear_selection();
- void select_tile(const std::shared_ptr<tile_atlas>& atlas, size_t variant);
- void select_tile_permutation(const std::shared_ptr<tile_atlas>& atlas);
- bool is_tile_selected(const std::shared_ptr<const tile_atlas>& atlas, size_t variant) const;
- bool is_permutation_selected(const std::shared_ptr<const tile_atlas>& atlas) const;
- bool is_atlas_selected(const std::shared_ptr<const tile_atlas>& atlas) const;
+ void select_tile(const std::shared_ptr<ground_atlas>& atlas, size_t variant);
+ void select_tile_permutation(const std::shared_ptr<ground_atlas>& atlas);
+ bool is_tile_selected(const std::shared_ptr<const ground_atlas>& atlas, size_t variant) const;
+ bool is_permutation_selected(const std::shared_ptr<const ground_atlas>& atlas) const;
+ bool is_atlas_selected(const std::shared_ptr<const ground_atlas>& atlas) const;
bool is_anything_selected() const;
tile_image_proto get_selected();
void place_tile(world& world, global_coords pos, const tile_image_proto& img);
diff --git a/editor/imgui-editors.cpp b/editor/imgui-editors.cpp
index 4ffb74ba..2e585d6b 100644
--- a/editor/imgui-editors.cpp
+++ b/editor/imgui-editors.cpp
@@ -2,7 +2,7 @@
#include "compat/format.hpp"
#include "imgui-raii.hpp"
#include "src/anim-atlas.hpp"
-#include "src/tile-atlas.hpp"
+#include "src/ground-atlas.hpp"
#include "src/wall-atlas.hpp"
#include "loader/loader.hpp"
#include "floormat/main.hpp"
@@ -51,7 +51,7 @@ void select_tile(wall_editor& wa, const wall_info* sc) { wa.select_atlas(sc->atl
auto get_texcoords(const auto&, anim_atlas& atlas) { return atlas.texcoords_for_frame(atlas.first_rotation(), 0, !atlas.group(atlas.first_rotation()).mirror_from.isEmpty()); }
auto get_texcoords(const wall_info* w, wall_atlas& atlas) { auto sz = get_size(w, atlas); return Quads::texcoords_at({}, sz, atlas.image_size()); };
-void draw_editor_tile_pane_atlas(tile_editor& ed, StringView name, const std::shared_ptr<tile_atlas>& atlas, Vector2 dpi)
+void draw_editor_tile_pane_atlas(ground_editor& ed, StringView name, const std::shared_ptr<ground_atlas>& atlas, Vector2 dpi)
{
const auto b = push_id("tile-pane");
diff --git a/editor/update.cpp b/editor/update.cpp
index e80a5318..1140ad47 100644
--- a/editor/update.cpp
+++ b/editor/update.cpp
@@ -1,6 +1,6 @@
#include "app.hpp"
#include "src/world.hpp"
-#include "src/tile-atlas.hpp"
+#include "src/ground-atlas.hpp"
#include "src/anim-atlas.hpp"
#include "main/clickable.hpp"
#include "floormat/events.hpp"
@@ -17,10 +17,10 @@ namespace floormat {
void app::maybe_initialize_chunk_(const chunk_coords_& pos, chunk& c)
{
- auto floor1 = loader.tile_atlas("floor-tiles", {44, 4}, pass_mode::pass);
- auto floor2 = loader.tile_atlas("metal1", {2, 2}, pass_mode::pass);
- auto wall1 = loader.tile_atlas("wood2", {2, 1}, pass_mode::blocked);
- auto wall2 = loader.tile_atlas("wood1", {2, 1}, pass_mode::blocked);
+ auto floor1 = loader.ground_atlas("floor-tiles", { 44, 4 }, pass_mode::pass);
+ auto floor2 = loader.ground_atlas("metal1", { 2, 2 }, pass_mode::pass);
+ auto wall1 = loader.ground_atlas("wood2", { 2, 1 }, pass_mode::blocked);
+ auto wall2 = loader.ground_atlas("wood1", { 2, 1 }, pass_mode::blocked);
auto door = loader.anim_atlas("door-close", loader.SCENERY_PATH);
auto table = loader.anim_atlas("table", loader.SCENERY_PATH);
auto control_panel = loader.anim_atlas("control-panel", loader.SCENERY_PATH);
diff --git a/loader/atlas.cpp b/loader/atlas.cpp
index e2ecb956..c7bfbdbf 100644
--- a/loader/atlas.cpp
+++ b/loader/atlas.cpp
@@ -2,7 +2,7 @@
#include "compat/assert.hpp"
#include "compat/exception.hpp"
#include "src/emplacer.hpp"
-#include "src/tile-atlas.hpp"
+#include "src/ground-atlas.hpp"
#include "src/anim-atlas.hpp"
#include <cstdio>
#include <algorithm>
@@ -45,9 +45,9 @@ bool loader_::check_atlas_name(StringView str) noexcept
namespace floormat::loader_detail {
-std::shared_ptr<tile_atlas> loader_impl::tile_atlas(StringView name, Vector2ub size, pass_mode pass) noexcept(false)
+std::shared_ptr<ground_atlas> loader_impl::ground_atlas(StringView name, Vector2ub size, pass_mode pass) noexcept(false)
{
- if (auto it = tile_atlas_map.find(name); it != tile_atlas_map.end())
+ if (auto it = ground_atlas_map.find(name); it != ground_atlas_map.end())
{
fm_assert(it->second->pass_mode() == pass);
return it->second;
@@ -58,16 +58,16 @@ std::shared_ptr<tile_atlas> loader_impl::tile_atlas(StringView name, Vector2ub s
char buf[FILENAME_MAX];
auto path = make_atlas_path(buf, IMAGE_PATH, name);
- auto atlas = std::make_shared<class tile_atlas>(path, name, texture(""_s, path), size, pass);
- tile_atlas_map[atlas->name()] = atlas;
+ auto atlas = std::make_shared<class ground_atlas>(path, name, texture(""_s, path), size, pass);
+ ground_atlas_map[atlas->name()] = atlas;
return atlas;
}
-std::shared_ptr<class tile_atlas> loader_impl::tile_atlas(StringView filename) noexcept(false)
+std::shared_ptr<class ground_atlas> loader_impl::ground_atlas(StringView filename) noexcept(false)
{
- fm_assert(!tile_atlas_map.empty());
- auto it = tile_atlas_map.find(filename);
- if (it == tile_atlas_map.end())
+ fm_assert(!ground_atlas_map.empty());
+ auto it = ground_atlas_map.find(filename);
+ if (it == ground_atlas_map.end())
fm_throw("no such tile atlas '{}'"_cf, filename);
return it->second;
}
diff --git a/loader/impl.hpp b/loader/impl.hpp
index d88174ba..165b7c2f 100644
--- a/loader/impl.hpp
+++ b/loader/impl.hpp
@@ -59,12 +59,12 @@ struct loader_impl final : loader_
std::shared_ptr<class wall_atlas> get_wall_atlas(StringView name, StringView path);
// >-----> tile >----->
- tsl::robin_map<StringView, std::shared_ptr<class tile_atlas>> tile_atlas_map;
- std::vector<std::shared_ptr<class tile_atlas>> tile_atlas_array;
+ tsl::robin_map<StringView, std::shared_ptr<class ground_atlas>> ground_atlas_map;
+ std::vector<std::shared_ptr<class ground_atlas>> ground_atlas_array;
- ArrayView<const std::shared_ptr<class tile_atlas>> tile_atlases(StringView filename) noexcept(false) override;
- std::shared_ptr<class tile_atlas> tile_atlas(StringView filename, Vector2ub size, pass_mode pass) noexcept(false) override;
- std::shared_ptr<class tile_atlas> tile_atlas(StringView filename) noexcept(false) override;
+ ArrayView<const std::shared_ptr<class ground_atlas>> ground_atlases(StringView filename) noexcept(false) override;
+ std::shared_ptr<class ground_atlas> ground_atlas(StringView filename, Vector2ub size, pass_mode pass) noexcept(false) override;
+ std::shared_ptr<class ground_atlas> ground_atlas(StringView filename) noexcept(false) override;
// >-----> anim >----->
tsl::robin_map<StringView, std::shared_ptr<class anim_atlas>> anim_atlas_map;
diff --git a/loader/json.cpp b/loader/json.cpp
index 7cf24015..8e2f329f 100644
--- a/loader/json.cpp
+++ b/loader/json.cpp
@@ -1,10 +1,10 @@
#include "impl.hpp"
#include "compat/assert.hpp"
#include "compat/exception.hpp"
-#include "src/tile-atlas.hpp"
+#include "src/ground-atlas.hpp"
#include "serialize/json-helper.hpp"
#include "serialize/anim.hpp"
-#include "serialize/tile-atlas.hpp"
+#include "serialize/ground-atlas.hpp"
#include "serialize/scenery.hpp"
#include "loader/scenery.hpp"
#include <Corrade/Containers/ArrayViewStl.h>
@@ -53,14 +53,14 @@ const scenery_proto& loader_impl::scenery(StringView name) noexcept(false)
return it->second->proto;
}
-ArrayView<const std::shared_ptr<class tile_atlas>> loader_impl::tile_atlases(StringView filename)
+ArrayView<const std::shared_ptr<class ground_atlas>> loader_impl::ground_atlases(StringView filename) noexcept(false)
{
- if (!tile_atlas_array.empty()) [[likely]]
- return tile_atlas_array;
- tile_atlas_array = json_helper::from_json<std::vector<std::shared_ptr<class tile_atlas>>>(
+ if (!ground_atlas_array.empty()) [[likely]]
+ return ground_atlas_array;
+ ground_atlas_array = json_helper::from_json<std::vector<std::shared_ptr<class ground_atlas>>>(
Path::join(loader_::IMAGE_PATH, filename));
- fm_assert(!tile_atlas_array.empty());
- return tile_atlas_array;
+ fm_assert(!ground_atlas_array.empty());
+ return ground_atlas_array;
}
} // namespace floormat::loader_detail
diff --git a/loader/loader.hpp b/loader/loader.hpp
index f93e6967..63b5ea5c 100644
--- a/loader/loader.hpp
+++ b/loader/loader.hpp
@@ -13,7 +13,7 @@ using ImageData2D = ImageData<2>;
namespace floormat {
-class tile_atlas;
+class ground_atlas;
class anim_atlas;
class wall_atlas;
struct scenery_proto;
@@ -24,15 +24,15 @@ struct loader_
{
virtual StringView shader(StringView filename) noexcept = 0;
virtual Trade::ImageData2D texture(StringView prefix, StringView filename, bool fail_ok = true) noexcept(false) = 0;
- virtual std::shared_ptr<class tile_atlas> tile_atlas(StringView filename, Vector2ub size, pass_mode pass) noexcept(false) = 0;
- virtual std::shared_ptr<class tile_atlas> tile_atlas(StringView filename) noexcept(false) = 0;
+ virtual std::shared_ptr<class ground_atlas> ground_atlas(StringView filename, Vector2ub size, pass_mode pass) noexcept(false) = 0;
+ virtual std::shared_ptr<class ground_atlas> ground_atlas(StringView filename) noexcept(false) = 0;
virtual ArrayView<const String> anim_atlas_list() = 0;
virtual std::shared_ptr<class anim_atlas> anim_atlas(StringView name, StringView dir = ANIM_PATH) noexcept(false) = 0;
virtual std::shared_ptr<class wall_atlas> wall_atlas(StringView name, bool fail_ok = true) noexcept(false) = 0;
virtual ArrayView<const wall_info> wall_atlas_list() = 0;
static void destroy();
static loader_& default_loader() noexcept;
- virtual ArrayView<const std::shared_ptr<class tile_atlas>> tile_atlases(StringView filename) noexcept(false) = 0;
+ virtual ArrayView<const std::shared_ptr<class ground_atlas>> ground_atlases(StringView filename) noexcept(false) = 0;
virtual ArrayView<const serialized_scenery> sceneries() = 0;
virtual const scenery_proto& scenery(StringView name) noexcept(false) = 0;
virtual StringView startup_directory() noexcept = 0;
diff --git a/serialize/tile-atlas.cpp b/serialize/ground-atlas.cpp
index 88385339..76c8686e 100644
--- a/serialize/tile-atlas.cpp
+++ b/serialize/ground-atlas.cpp
@@ -1,5 +1,5 @@
-#include "src/tile-atlas.hpp"
-#include "serialize/tile-atlas.hpp"
+#include "src/ground-atlas.hpp"
+#include "serialize/ground-atlas.hpp"
#include "serialize/corrade-string.hpp"
#include "serialize/magnum-vector.hpp"
#include "loader/loader.hpp"
@@ -25,7 +25,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(proxy, name, size)
namespace nlohmann {
-void adl_serializer<std::shared_ptr<tile_atlas>>::to_json(json& j, const std::shared_ptr<const tile_atlas>& x)
+void adl_serializer<std::shared_ptr<ground_atlas>>::to_json(json& j, const std::shared_ptr<const ground_atlas>& x)
{
using nlohmann::to_json;
if (!x)
@@ -34,7 +34,7 @@ void adl_serializer<std::shared_ptr<tile_atlas>>::to_json(json& j, const std::sh
to_json(j, proxy{x->name(), x->num_tiles2(), x->pass_mode()});
}
-void adl_serializer<std::shared_ptr<tile_atlas>>::from_json(const json& j, std::shared_ptr<tile_atlas>& val)
+void adl_serializer<std::shared_ptr<ground_atlas>>::from_json(const json& j, std::shared_ptr<ground_atlas>& val)
{
if (j.is_null())
val = nullptr;
@@ -43,10 +43,10 @@ void adl_serializer<std::shared_ptr<tile_atlas>>::from_json(const json& j, std::
using nlohmann::from_json;
proxy x;
from_json(j, x);
- pass_mode p = tile_atlas::default_pass_mode;
+ pass_mode p = ground_atlas::default_pass_mode;
if (j.contains("pass-mode"))
p = j["pass-mode"];
- val = loader.tile_atlas(x.name, x.size, p);
+ val = loader.ground_atlas(x.name, x.size, p);
if (auto p2 = val->pass_mode(); p2 != p)
{
const auto name = val->name();
diff --git a/serialize/tile-atlas.hpp b/serialize/ground-atlas.hpp
index 0c65c55e..344e8714 100644
--- a/serialize/tile-atlas.hpp
+++ b/serialize/ground-atlas.hpp
@@ -1,14 +1,14 @@
#pragma once
-#include "src/tile-atlas.hpp"
+#include "src/ground-atlas.hpp"
#include <memory>
#include <nlohmann/json_fwd.hpp>
namespace nlohmann {
template<>
-struct adl_serializer<std::shared_ptr<floormat::tile_atlas>> final {
- static void to_json(json& j, const std::shared_ptr<const floormat::tile_atlas>& x);
- static void from_json(const json& j, std::shared_ptr<floormat::tile_atlas>& x);
+struct adl_serializer<std::shared_ptr<floormat::ground_atlas>> final {
+ static void to_json(json& j, const std::shared_ptr<const floormat::ground_atlas>& x);
+ static void from_json(const json& j, std::shared_ptr<floormat::ground_atlas>& x);
};
} // namespace nlohmann
diff --git a/serialize/tile.cpp b/serialize/tile.cpp
index 69cec8a2..cd9064a8 100644
--- a/serialize/tile.cpp
+++ b/serialize/tile.cpp
@@ -1,8 +1,8 @@
#include "serialize/tile.hpp"
#include "src/tile.hpp"
#include "src/global-coords.hpp"
-#include "serialize/tile-atlas.hpp"
-#include "src/tile-atlas.hpp"
+#include "serialize/ground-atlas.hpp"
+#include "src/ground-atlas.hpp"
#include <tuple>
#include <nlohmann/json.hpp>
diff --git a/serialize/world-reader.cpp b/serialize/world-reader.cpp
index 05b880b8..5e66616b 100644
--- a/serialize/world-reader.cpp
+++ b/serialize/world-reader.cpp
@@ -7,7 +7,7 @@
#include "src/light.hpp"
#include "loader/loader.hpp"
#include "loader/scenery.hpp"
-#include "src/tile-atlas.hpp"
+#include "src/ground-atlas.hpp"
#include "src/anim-atlas.hpp"
#include "src/chunk-scenery.hpp"
#include "compat/strerror.hpp"
@@ -215,9 +215,9 @@ void reader_state::read_chunks(reader_t& s)
? s.read<uint8_t>()
: uint8_t(s.read<uint16_t>());
auto name = lookup_atlas(id);
- if constexpr(std::is_same_v<tile_atlas, T>)
+ if constexpr(std::is_same_v<ground_atlas, T>)
{
- auto atlas = loader.tile_atlas(name);
+ auto atlas = loader.ground_atlas(name);
fm_soft_assert(v < atlas->num_tiles());
return { atlas, v };
}
@@ -232,7 +232,7 @@ void reader_state::read_chunks(reader_t& s)
SET_CHUNK_SIZE();
//t.passability() = pass_mode(flags & pass_mask);
if (flags & meta_ground)
- t.ground() = make_atlas.operator()<tile_atlas>();
+ t.ground() = make_atlas.operator()<ground_atlas>();
if (flags & meta_wall_n)
t.wall_north() = make_atlas.operator()<wall_atlas>();
if (flags & meta_wall_w)
diff --git a/serialize/world-writer.cpp b/serialize/world-writer.cpp
index a89f039a..e32d3cdf 100644
--- a/serialize/world-writer.cpp
+++ b/serialize/world-writer.cpp
@@ -1,6 +1,6 @@
#define FM_SERIALIZE_WORLD_IMPL
#include "world-impl.hpp"
-#include "src/tile-atlas.hpp"
+#include "src/ground-atlas.hpp"
#include "src/wall-atlas.hpp"
#include "binary-writer.inl"
#include "src/global-coords.hpp"
diff --git a/shaders/lightmap.cpp b/shaders/lightmap.cpp
index 1be58131..f1d0e088 100644
--- a/shaders/lightmap.cpp
+++ b/shaders/lightmap.cpp
@@ -3,7 +3,7 @@
#include "src/tile-defs.hpp"
#include "src/chunk.hpp"
#include "src/tile-bbox.hpp"
-#include "src/tile-atlas.hpp"
+#include "src/ground-atlas.hpp"
#include "src/wall-atlas.hpp"
#include "src/quads.hpp"
#include "src/object.hpp"
diff --git a/src/chunk-collision.cpp b/src/chunk-collision.cpp
index 4f94df6b..a6fd379d 100644
--- a/src/chunk-collision.cpp
+++ b/src/chunk-collision.cpp
@@ -1,5 +1,5 @@
#include "chunk.hpp"
-#include "tile-atlas.hpp"
+#include "ground-atlas.hpp"
#include "object.hpp"
#include "src/RTree-search.hpp"
#include "src/chunk-scenery.hpp"
diff --git a/src/chunk-render.cpp b/src/chunk-render.cpp
index d019a948..ffaa33ec 100644
--- a/src/chunk-render.cpp
+++ b/src/chunk-render.cpp
@@ -1,5 +1,5 @@
#include "chunk.hpp"
-#include "tile-atlas.hpp"
+#include "ground-atlas.hpp"
#include "quads.hpp"
#include "shaders/shader.hpp"
#include "compat/defs.hpp"
diff --git a/src/chunk.cpp b/src/chunk.cpp
index a49669c5..eaeb06e1 100644
--- a/src/chunk.cpp
+++ b/src/chunk.cpp
@@ -36,7 +36,7 @@ bool chunk::empty(bool force) const noexcept
return true;
}
-tile_atlas* chunk::ground_atlas_at(size_t i) const noexcept { return _ground ? _ground->atlases[i].get() : nullptr; }
+ground_atlas* chunk::ground_atlas_at(size_t i) const noexcept { return _ground ? _ground->atlases[i].get() : nullptr; }
tile_ref chunk::operator[](size_t idx) noexcept { return { *this, uint8_t(idx) }; }
tile_proto chunk::operator[](size_t idx) const noexcept { return tile_proto(tile_ref { *const_cast<chunk*>(this), uint8_t(idx) }); }
diff --git a/src/chunk.hpp b/src/chunk.hpp
index 3005475c..1f144ca7 100644
--- a/src/chunk.hpp
+++ b/src/chunk.hpp
@@ -103,7 +103,7 @@ struct chunk final
void ensure_alloc_ground();
void ensure_alloc_walls();
ground_mesh_tuple ensure_ground_mesh() noexcept;
- tile_atlas* ground_atlas_at(size_t i) const noexcept;
+ ground_atlas* ground_atlas_at(size_t i) const noexcept;
wall_atlas* wall_atlas_at(size_t i) const noexcept;
wall_mesh_tuple ensure_wall_mesh() noexcept;
@@ -129,7 +129,7 @@ struct chunk final
private:
struct ground_stuff
{
- std::array<std::shared_ptr<tile_atlas>, TILE_COUNT> atlases;
+ std::array<std::shared_ptr<ground_atlas>, TILE_COUNT> atlases;
std::array<uint8_t, TILE_COUNT> indexes = {};
std::array<variant_t, TILE_COUNT> variants = {};
};
diff --git a/src/tile-atlas.cpp b/src/ground-atlas.cpp
index 53156a84..a64264ff 100644
--- a/src/tile-atlas.cpp
+++ b/src/ground-atlas.cpp
@@ -1,4 +1,4 @@
-#include "tile-atlas.hpp"
+#include "ground-atlas.hpp"
#include "quads.hpp"
#include "compat/assert.hpp"
#include "tile-image.hpp"
@@ -12,7 +12,7 @@ namespace floormat {
using namespace floormat::Quads;
-tile_atlas::tile_atlas(StringView path, StringView name, const ImageView2D& image, Vector2ub tile_count, enum pass_mode p) :
+ground_atlas::ground_atlas(StringView path, StringView name, const ImageView2D& image, Vector2ub tile_count, enum pass_mode p) :
texcoords_{make_texcoords_array(Vector2ui(image.size()), tile_count)},
path_{path}, name_{name}, size_{image.size()}, dims_{tile_count}, passability{p}
{
@@ -30,13 +30,13 @@ tile_atlas::tile_atlas(StringView path, StringView name, const ImageView2D& imag
.setSubImage(0, {}, image);
}
-std::array<Vector2, 4> tile_atlas::texcoords_for_id(size_t i) const
+std::array<Vector2, 4> ground_atlas::texcoords_for_id(size_t i) const
{
fm_assert(i < num_tiles());
return texcoords_[i];
}
-auto tile_atlas::make_texcoords(Vector2ui pixel_size, Vector2ub tile_count, size_t i) -> texcoords
+auto ground_atlas::make_texcoords(Vector2ui pixel_size, Vector2ub tile_count, size_t i) -> texcoords
{
const auto sz = pixel_size/Vector2ui{tile_count};
const auto id = Vector2ui{ uint32_t(i % tile_count[0]), uint32_t(i / tile_count[0]) };
@@ -44,7 +44,7 @@ auto tile_atlas::make_texcoords(Vector2ui pixel_size, Vector2ub tile_count, size
return texcoords_at(p0, sz, pixel_size);
}
-auto tile_atlas::make_texcoords_array(Vector2ui pixel_size, Vector2ub tile_count) -> std::unique_ptr<const texcoords[]>
+auto ground_atlas::make_texcoords_array(Vector2ui pixel_size, Vector2ub tile_count) -> std::unique_ptr<const texcoords[]>
{
const size_t N = Vector2ui{tile_count}.product();
auto ptr = std::make_unique<std::array<Vector2, 4>[]>(N);
@@ -53,7 +53,7 @@ auto tile_atlas::make_texcoords_array(Vector2ui pixel_size, Vector2ub tile_count
return ptr;
}
-size_t tile_atlas::num_tiles() const { return Vector2ui{dims_}.product(); }
-enum pass_mode tile_atlas::pass_mode() const { return passability; }
+size_t ground_atlas::num_tiles() const { return Vector2ui{dims_}.product(); }
+enum pass_mode ground_atlas::pass_mode() const { return passability; }
} // namespace floormat
diff --git a/src/tile-atlas.hpp b/src/ground-atlas.hpp
index a4334b1a..e6e2d5ba 100644
--- a/src/tile-atlas.hpp
+++ b/src/ground-atlas.hpp
@@ -11,7 +11,7 @@
namespace floormat {
-class tile_atlas final
+class ground_atlas final
{
using quad = Quads::quad;
using texcoords = std::array<Vector2, 4>;
@@ -27,7 +27,7 @@ class tile_atlas final
enum pass_mode passability;
public:
- tile_atlas(StringView path, StringView name, const ImageView2D& img, Vector2ub tile_count, enum pass_mode pass_mode);
+ ground_atlas(StringView path, StringView name, const ImageView2D& img, Vector2ub tile_count, enum pass_mode pass_mode);
texcoords texcoords_for_id(size_t id) const;
diff --git a/src/tile-image.cpp b/src/tile-image.cpp
index 7bfea375..e2d84461 100644
--- a/src/tile-image.cpp
+++ b/src/tile-image.cpp
@@ -35,8 +35,8 @@ image_ref_<Atlas, Proto>& image_ref_<Atlas, Proto>::operator=(const Proto& proto
return *this;
}
-template struct image_proto_<tile_atlas>;
-template struct image_ref_<tile_atlas, tile_image_proto>;
+template struct image_proto_<ground_atlas>;
+template struct image_ref_<ground_atlas, tile_image_proto>;
template struct image_proto_<wall_atlas>;
template struct image_ref_<wall_atlas, wall_image_proto>;
diff --git a/src/tile-image.hpp b/src/tile-image.hpp
index facf9945..7292c5f0 100644
--- a/src/tile-image.hpp
+++ b/src/tile-image.hpp
@@ -4,7 +4,7 @@
namespace floormat {
-class tile_atlas;
+class ground_atlas;
class wall_atlas;
template<typename Atlas>
@@ -30,8 +30,8 @@ struct image_ref_ final
explicit operator bool() const noexcept;
};
-using tile_image_proto = image_proto_<tile_atlas>;
-using tile_image_ref = image_ref_<tile_atlas, tile_image_proto>;
+using tile_image_proto = image_proto_<ground_atlas>;
+using tile_image_ref = image_ref_<ground_atlas, tile_image_proto>;
using wall_image_proto = image_proto_<wall_atlas>;
using wall_image_ref = image_ref_<wall_atlas, wall_image_proto>;
diff --git a/src/tile.cpp b/src/tile.cpp
index ce21d506..c5eda401 100644
--- a/src/tile.cpp
+++ b/src/tile.cpp
@@ -18,13 +18,13 @@ wall_image_proto tile_proto::wall_west() const noexcept { return { wall_west_at
tile_ref::tile_ref(struct chunk& c, uint8_t i) noexcept : _chunk{&c}, i{i} {}
-std::shared_ptr<tile_atlas> tile_ref::ground_atlas() noexcept { return _chunk->_ground ? _chunk->_ground->atlases[i] : nullptr; }
-std::shared_ptr<wall_atlas> tile_ref::wall_north_atlas() noexcept { return _chunk->_walls ? _chunk->_walls->atlases[i*2+0] : nullptr; }
-std::shared_ptr<wall_atlas> tile_ref::wall_west_atlas() noexcept { return _chunk->_walls ? _chunk->_walls->atlases[i*2+1] : nullptr; }
+std::shared_ptr<class ground_atlas> tile_ref::ground_atlas() noexcept { return _chunk->_ground ? _chunk->_ground->atlases[i] : nullptr; }
+std::shared_ptr<class wall_atlas> tile_ref::wall_north_atlas() noexcept { return _chunk->_walls ? _chunk->_walls->atlases[i*2+0] : nullptr; }
+std::shared_ptr<class wall_atlas> tile_ref::wall_west_atlas() noexcept { return _chunk->_walls ? _chunk->_walls->atlases[i*2+1] : nullptr; }
-std::shared_ptr<const tile_atlas> tile_ref::ground_atlas() const noexcept { return _chunk->_ground ? _chunk->_ground->atlases[i] : nullptr; }
-std::shared_ptr<const wall_atlas> tile_ref::wall_north_atlas() const noexcept { return _chunk->_walls ? _chunk->_walls->atlases[i*2+0] : nullptr; }
-std::shared_ptr<const wall_atlas> tile_ref::wall_west_atlas() const noexcept { return _chunk->_walls ? _chunk->_walls->atlases[i*2+1] : nullptr; }
+std::shared_ptr<const class ground_atlas> tile_ref::ground_atlas() const noexcept { return _chunk->_ground ? _chunk->_ground->atlases[i] : nullptr; }
+std::shared_ptr<const class wall_atlas> tile_ref::wall_north_atlas() const noexcept { return _chunk->_walls ? _chunk->_walls->atlases[i*2+0] : nullptr; }
+std::shared_ptr<const class wall_atlas> tile_ref::wall_west_atlas() const noexcept { return _chunk->_walls ? _chunk->_walls->atlases[i*2+1] : nullptr; }
tile_image_ref tile_ref::ground() noexcept { _chunk->ensure_alloc_ground(); return {_chunk->_ground->atlases[i], _chunk->_ground->variants[i] }; }
wall_image_ref tile_ref::wall_north() noexcept { _chunk->ensure_alloc_walls(); return {_chunk->_walls->atlases[i*2+0], _chunk->_walls->variants[i*2+0] }; }
diff --git a/src/tile.hpp b/src/tile.hpp
index efdd331b..a195eec4 100644
--- a/src/tile.hpp
+++ b/src/tile.hpp
@@ -8,7 +8,7 @@ class anim_atlas;
struct tile_proto final
{
- std::shared_ptr<tile_atlas> ground_atlas;
+ std::shared_ptr<ground_atlas> ground_atlas;
std::shared_ptr<wall_atlas> wall_north_atlas, wall_west_atlas;
variant_t ground_variant = 0, wall_north_variant = 0, wall_west_variant = 0;
@@ -31,13 +31,13 @@ struct tile_ref final
wall_image_proto wall_north() const noexcept;
wall_image_proto wall_west() const noexcept;
- std::shared_ptr<tile_atlas> ground_atlas() noexcept;
- std::shared_ptr<wall_atlas> wall_north_atlas() noexcept;
- std::shared_ptr<wall_atlas> wall_west_atlas() noexcept;
+ std::shared_ptr<class ground_atlas> ground_atlas() noexcept;
+ std::shared_ptr<class wall_atlas> wall_north_atlas() noexcept;
+ std::shared_ptr<class wall_atlas> wall_west_atlas() noexcept;
- std::shared_ptr<const tile_atlas> ground_atlas() const noexcept;
- std::shared_ptr<const wall_atlas> wall_north_atlas() const noexcept;
- std::shared_ptr<const wall_atlas> wall_west_atlas() const noexcept;
+ std::shared_ptr<const class ground_atlas> ground_atlas() const noexcept;
+ std::shared_ptr<const class wall_atlas> wall_north_atlas() const noexcept;
+ std::shared_ptr<const class wall_atlas> wall_west_atlas() const noexcept;
explicit operator tile_proto() const noexcept;
diff --git a/test/json.cpp b/test/json.cpp
index b0ab9f0f..3d7a5f0f 100644
--- a/test/json.cpp
+++ b/test/json.cpp
@@ -1,10 +1,10 @@
#include "app.hpp"
#include "serialize/tile.hpp"
-#include "serialize/tile-atlas.hpp"
+#include "serialize/ground-atlas.hpp"
#include "serialize/magnum-vector.hpp"
#include "serialize/json-helper.hpp"
#include "compat/assert.hpp"
-#include "src/tile-atlas.hpp"
+#include "src/ground-atlas.hpp"
#include "src/tile.hpp"
#include "src/tile-iterator.hpp"
#include "src/chunk.hpp"
@@ -18,9 +18,9 @@ namespace floormat {
#if 0
static chunk make_test_chunk()
{
- auto metal1 = loader.tile_atlas("metal1", {2, 2}, pass_mode::pass),
- metal2 = loader.tile_atlas("metal2", {2, 2}, pass_mode::blocked),
- tiles = loader.tile_atlas("tiles", {8, 5}, pass_mode::pass);
+ auto metal1 = loader.ground_atlas("metal1", {2, 2}, pass_mode::pass),
+ metal2 = loader.ground_atlas("metal2", {2, 2}, pass_mode::blocked),
+ tiles = loader.ground_atlas("tiles", {8, 5}, pass_mode::pass);
constexpr auto N = TILE_MAX_DIM;
world w;
chunk c{w, {}};
@@ -41,7 +41,7 @@ void test_app::test_json() // NOLINT(readability-convert-member-functions-to-sta
fm_assert(Path::exists(Path::join(loader.TEMP_PATH, "CMakeCache.txt")));
const auto output_dir = Path::join(loader.TEMP_PATH, "test/."_s);
{
- auto atlas = loader.tile_atlas("metal1", {2, 2}, pass_mode::pass);
+ auto atlas = loader.ground_atlas("metal1", { 2, 2 }, pass_mode::pass);
json_helper::to_json(atlas, Path::join(output_dir, "atlas.json"));
}
{
diff --git a/test/loader.cpp b/test/loader.cpp
index b45d4f0e..88fa2b32 100644
--- a/test/loader.cpp
+++ b/test/loader.cpp
@@ -1,16 +1,16 @@
#include "app.hpp"
#include "compat/assert.hpp"
#include "loader/loader.hpp"
-#include "src/tile-atlas.hpp"
+#include "src/ground-atlas.hpp"
#include "loader/wall-info.hpp"
namespace floormat {
void test_app::test_loader()
{
- (void)loader.tile_atlases("floor.json");
- fm_assert(loader.tile_atlas("texel")->pass_mode() == pass_mode::blocked);
- fm_assert(loader.tile_atlas("metal1")->pass_mode() == pass_mode::pass);
+ (void)loader.ground_atlases("floor.json");
+ fm_assert(loader.ground_atlas("texel")->pass_mode() == pass_mode::blocked);
+ fm_assert(loader.ground_atlas("metal1")->pass_mode() == pass_mode::pass);
loader.sceneries();
for (StringView name : loader.anim_atlas_list())
loader.anim_atlas(name);
diff --git a/test/serializer.cpp b/test/serializer.cpp
index bf31e7f5..c768023e 100644
--- a/test/serializer.cpp
+++ b/test/serializer.cpp
@@ -4,7 +4,7 @@
#include "src/scenery.hpp"
#include "src/critter.hpp"
#include "src/light.hpp"
-#include "src/tile-atlas.hpp"
+#include "src/ground-atlas.hpp"
#include "src/anim-atlas.hpp"
#include "src/tile-iterator.hpp"
#include <Corrade/Utility/Path.h>
@@ -18,7 +18,7 @@ chunk& test_app::make_test_chunk(world& w, chunk_coords_ ch)
chunk& c = w[ch];
c.mark_modified();
auto metal2 = loader.wall_atlas("empty", false);
- auto tiles = loader.tile_atlas("tiles", {8, 5}, pass_mode::pass);
+ auto tiles = loader.ground_atlas("tiles", { 8, 5 }, pass_mode::pass);
constexpr auto N = TILE_MAX_DIM;
for (auto [x, k, pt] : c)
x.ground() = { tiles, variant_t(k % tiles->num_tiles()) };