diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-01-11 14:29:53 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-01-11 14:45:29 +0100 |
commit | d74df1b763979d281f76f3f30543aee8d8a638b7 (patch) | |
tree | 08939a34160b261c37644595aa8702dd0689d74f | |
parent | 7867213a01fcabb1f05b1836c2ca59dc3bb2132f (diff) |
rename floor -> ground
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | bench/bitmask.cpp | 2 | ||||
-rw-r--r-- | draw/ground.cpp (renamed from draw/floor.cpp) | 8 | ||||
-rw-r--r-- | draw/ground.hpp (renamed from draw/floor.hpp) | 4 | ||||
-rw-r--r-- | editor/draw.cpp | 4 | ||||
-rw-r--r-- | editor/ground-editor.cpp | 4 | ||||
-rw-r--r-- | editor/update.cpp | 2 | ||||
-rw-r--r-- | floormat/main.hpp | 4 | ||||
-rw-r--r-- | ground/concrete1.tga (renamed from images/concrete1.tga) | bin | 110610 -> 110610 bytes | |||
-rw-r--r-- | ground/concrete6.tga (renamed from images/concrete6.tga) | bin | 193075 -> 193075 bytes | |||
-rw-r--r-- | ground/concrete7.tga (renamed from images/concrete7.tga) | bin | 49633 -> 49633 bytes | |||
-rw-r--r-- | ground/floor-tiles.tga (renamed from images/floor-tiles.tga) | bin | 8427493 -> 8427493 bytes | |||
-rw-r--r-- | ground/ground.json (renamed from images/floor.json) | 0 | ||||
-rw-r--r-- | ground/metal1.tga (renamed from images/metal1.tga) | bin | 49459 -> 49459 bytes | |||
-rw-r--r-- | ground/metal2.tga (renamed from images/metal2.tga) | bin | 1070043 -> 1070043 bytes | |||
-rw-r--r-- | ground/teak1.tga (renamed from images/teak1.tga) | bin | 49360 -> 49360 bytes | |||
-rw-r--r-- | ground/texel.tga (renamed from images/texel.tga) | bin | 663 -> 663 bytes | |||
-rw-r--r-- | ground/tiles.tga (renamed from images/tiles.tga) | bin | 492059 -> 492059 bytes | |||
-rw-r--r-- | ground/wall1.tga (renamed from images/wall1.tga) | bin | 140727 -> 140727 bytes | |||
-rw-r--r-- | ground/wood1.tga (renamed from images/wood1.tga) | bin | 12838 -> 12838 bytes | |||
-rw-r--r-- | ground/wood2.tga (renamed from images/wood2.tga) | bin | 12854 -> 12854 bytes | |||
-rw-r--r-- | loader/atlas.cpp | 6 | ||||
-rw-r--r-- | loader/impl.hpp | 6 | ||||
-rw-r--r-- | loader/json.cpp | 2 | ||||
-rw-r--r-- | loader/loader.cpp | 9 | ||||
-rw-r--r-- | loader/loader.hpp | 8 | ||||
-rw-r--r-- | loader/vobj.cpp | 2 | ||||
-rw-r--r-- | loader/wall-atlas.cpp | 4 | ||||
-rw-r--r-- | main/draw.cpp | 2 | ||||
-rw-r--r-- | main/main-impl.hpp | 4 | ||||
-rw-r--r-- | main/setup.cpp | 2 | ||||
-rw-r--r-- | test/bitmask.cpp | 2 | ||||
-rw-r--r-- | test/loader.cpp | 2 |
33 files changed, 42 insertions, 37 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c427b13b..6a050c7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -272,7 +272,7 @@ endfunction() function(fm_install_assets) set(CMAKE_INSTALL_MESSAGE NEVER) - foreach(subdir images anim scenery vobj walls) + foreach(subdir images anim scenery vobj ground walls) fm_install_kill_directory("${subdir}") install(DIRECTORY "${subdir}" DESTINATION "share/floormat") endforeach() diff --git a/bench/bitmask.cpp b/bench/bitmask.cpp index 9efa25a9..6f80e992 100644 --- a/bench/bitmask.cpp +++ b/bench/bitmask.cpp @@ -12,7 +12,7 @@ namespace { [[maybe_unused]] void Bitmask(benchmark::State& state) { - auto img = loader.texture(loader.SCENERY_PATH, "door-close"_s); + auto img = loader.texture(loader.SCENERY_PATH, "door-close"_s, false); auto bitmask = anim_atlas::make_bitmask(img); anim_atlas::make_bitmask_(img, bitmask); diff --git a/draw/floor.cpp b/draw/ground.cpp index a073f39f..515729b1 100644 --- a/draw/floor.cpp +++ b/draw/ground.cpp @@ -1,4 +1,4 @@ -#include "floor.hpp" +#include "ground.hpp" #include "shaders/shader.hpp" #include "src/chunk.hpp" #include "src/ground-atlas.hpp" @@ -7,9 +7,9 @@ namespace floormat { -floor_mesh::floor_mesh() = default; +ground_mesh::ground_mesh() = default; -void floor_mesh::draw(tile_shader& shader, chunk& c) +void ground_mesh::draw(tile_shader& shader, chunk& c) { constexpr int quad_index_count = 6; const auto [mesh_, ids, size] = c.ensure_ground_mesh(); @@ -42,7 +42,7 @@ void floor_mesh::draw(tile_shader& shader, chunk& c) //#define FM_DEBUG_DRAW_COUNT #ifdef FM_DEBUG_DRAW_COUNT if (draw_count) - fm_debug("floor draws: %zu", draw_count); + fm_debug("ground draws: %zu", draw_count); #endif } diff --git a/draw/floor.hpp b/draw/ground.hpp index 74547857..b960e8b1 100644 --- a/draw/floor.hpp +++ b/draw/ground.hpp @@ -5,9 +5,9 @@ namespace floormat { struct tile_shader; struct chunk; -struct floor_mesh final +struct ground_mesh final { - floor_mesh(); + ground_mesh(); void draw(tile_shader& shader, chunk& c); }; diff --git a/editor/draw.cpp b/editor/draw.cpp index c4f6a8a2..84ceef00 100644 --- a/editor/draw.cpp +++ b/editor/draw.cpp @@ -68,7 +68,7 @@ void app::draw_cursor() if (ed->is_anything_selected()) { shader.set_tint({1, 1, 1, 0.75f}); - auto [_f, _w, anim_mesh] = M->meshes(); + auto [_g, _w, anim_mesh] = M->meshes(); const auto offset = Vector3i(Vector2i(sel.offset), 0); const auto pos = Vector3i(tile)*iTILE_SIZE + offset; auto [ch, t] = w[tile]; @@ -86,7 +86,7 @@ void app::draw_cursor() const auto& atlas = vo->get_selected()->factory->atlas(); draw(_wireframe_quad, TILE_SIZE2); shader.set_tint({1, 1, 1, 0.75f}); - auto [_f, _w, anim_mesh] = M->meshes(); + auto [_g, _w, anim_mesh] = M->meshes(); const auto pos = Vector3i(tile)*iTILE_SIZE; anim_mesh.draw(shader, *atlas, rotation::N, 0, Vector3(pos), 1); } diff --git a/editor/ground-editor.cpp b/editor/ground-editor.cpp index 0f67853e..2a74952c 100644 --- a/editor/ground-editor.cpp +++ b/editor/ground-editor.cpp @@ -17,7 +17,7 @@ ground_editor::ground_editor() void ground_editor::load_atlases() { - for (const auto& atlas : loader.ground_atlases("floor.json"_s)) + for (const auto& atlas : loader.ground_atlases("ground.json"_s)) { auto& [_, vec] = _permutation; vec.reserve(atlas->num_tiles()); @@ -41,7 +41,7 @@ std::shared_ptr<ground_atlas> ground_editor::atlas(StringView str) fm_throw("no such atlas: {}"_cf, str); } -StringView ground_editor::name() const noexcept { return "floor"_s; } +StringView ground_editor::name() const noexcept { return "ground"_s; } void ground_editor::clear_selection() { diff --git a/editor/update.cpp b/editor/update.cpp index 1140ad47..6ecffc80 100644 --- a/editor/update.cpp +++ b/editor/update.cpp @@ -17,7 +17,7 @@ namespace floormat { void app::maybe_initialize_chunk_(const chunk_coords_& pos, chunk& c) { - auto floor1 = loader.ground_atlas("floor-tiles", { 44, 4 }, pass_mode::pass); + auto floor1 = loader.ground_atlas("ground-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); diff --git a/floormat/main.hpp b/floormat/main.hpp index 1604ad22..27404fe3 100644 --- a/floormat/main.hpp +++ b/floormat/main.hpp @@ -17,7 +17,7 @@ struct world; struct scenery; class anim_atlas; struct clickable; -struct floor_mesh; +struct ground_mesh; struct wall_mesh; struct anim_mesh; struct texture_unit_cache; @@ -28,7 +28,7 @@ struct floormat_main { struct draw_bounds final { int16_t minx, maxx, miny, maxy; }; struct meshes final { - floor_mesh& floor; + ground_mesh& ground; wall_mesh& wall; anim_mesh& anim; }; diff --git a/images/concrete1.tga b/ground/concrete1.tga Binary files differindex e7856645..e7856645 100644 --- a/images/concrete1.tga +++ b/ground/concrete1.tga diff --git a/images/concrete6.tga b/ground/concrete6.tga Binary files differindex 91b332dd..91b332dd 100644 --- a/images/concrete6.tga +++ b/ground/concrete6.tga diff --git a/images/concrete7.tga b/ground/concrete7.tga Binary files differindex 476dcec0..476dcec0 100644 --- a/images/concrete7.tga +++ b/ground/concrete7.tga diff --git a/images/floor-tiles.tga b/ground/floor-tiles.tga Binary files differindex 1a0a6d79..1a0a6d79 100644 --- a/images/floor-tiles.tga +++ b/ground/floor-tiles.tga diff --git a/images/floor.json b/ground/ground.json index 9d9e0c2e..9d9e0c2e 100644 --- a/images/floor.json +++ b/ground/ground.json diff --git a/images/metal1.tga b/ground/metal1.tga Binary files differindex d305638d..d305638d 100644 --- a/images/metal1.tga +++ b/ground/metal1.tga diff --git a/images/metal2.tga b/ground/metal2.tga Binary files differindex 6e9b64e9..6e9b64e9 100644 --- a/images/metal2.tga +++ b/ground/metal2.tga diff --git a/images/teak1.tga b/ground/teak1.tga Binary files differindex df1927c6..df1927c6 100644 --- a/images/teak1.tga +++ b/ground/teak1.tga diff --git a/images/texel.tga b/ground/texel.tga Binary files differindex 99314406..99314406 100644 --- a/images/texel.tga +++ b/ground/texel.tga diff --git a/images/tiles.tga b/ground/tiles.tga Binary files differindex 1376a27c..1376a27c 100644 --- a/images/tiles.tga +++ b/ground/tiles.tga diff --git a/images/wall1.tga b/ground/wall1.tga Binary files differindex 44f3566d..44f3566d 100644 --- a/images/wall1.tga +++ b/ground/wall1.tga diff --git a/images/wood1.tga b/ground/wood1.tga Binary files differindex 6c28183c..6c28183c 100644 --- a/images/wood1.tga +++ b/ground/wood1.tga diff --git a/images/wood2.tga b/ground/wood2.tga Binary files differindex e8c689d2..e8c689d2 100644 --- a/images/wood2.tga +++ b/ground/wood2.tga diff --git a/loader/atlas.cpp b/loader/atlas.cpp index c7bfbdbf..eb368952 100644 --- a/loader/atlas.cpp +++ b/loader/atlas.cpp @@ -56,9 +56,9 @@ std::shared_ptr<ground_atlas> loader_impl::ground_atlas(StringView name, Vector2 fm_soft_assert(check_atlas_name(name)); char buf[FILENAME_MAX]; - auto path = make_atlas_path(buf, IMAGE_PATH, name); + auto path = make_atlas_path(buf, GROUND_TILESET_PATH, name); - auto atlas = std::make_shared<class ground_atlas>(path, name, texture(""_s, path), size, pass); + auto atlas = std::make_shared<class ground_atlas>(path, name, texture(""_s, path, false), size, pass); ground_atlas_map[atlas->name()] = atlas; return atlas; } @@ -107,7 +107,7 @@ std::shared_ptr<anim_atlas> loader_impl::anim_atlas(StringView name, StringView } } - auto tex = texture(""_s, path); + auto tex = texture(""_s, path, false); fm_soft_assert(!anim_info.object_name.isEmpty()); fm_soft_assert(anim_info.pixel_size.product() > 0); diff --git a/loader/impl.hpp b/loader/impl.hpp index 165b7c2f..ad82e46d 100644 --- a/loader/impl.hpp +++ b/loader/impl.hpp @@ -42,7 +42,7 @@ struct loader_impl final : loader_ StringView shader(StringView filename) noexcept override; Trade::ImageData2D make_error_texture(Vector2ui size); - Trade::ImageData2D texture(StringView prefix, StringView filename, bool fail_ok = true) noexcept(false) override; + Trade::ImageData2D texture(StringView prefix, StringView filename) noexcept(false) override; // >-----> walls >-----> struct wall_index { uint32_t val = (uint32_t)-1; }; @@ -55,7 +55,7 @@ struct loader_impl final : loader_ std::shared_ptr<class wall_atlas> wall_atlas(StringView name, bool fail_ok = true) override; ArrayView<const wall_info> wall_atlas_list() override; void get_wall_atlas_list(); - const wall_info& make_invalid_wall_atlas(); + const wall_info& make_invalid_wall_atlas() noexcept override; std::shared_ptr<class wall_atlas> get_wall_atlas(StringView name, StringView path); // >-----> tile >-----> @@ -64,7 +64,7 @@ struct loader_impl final : loader_ 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; + std::shared_ptr<class ground_atlas> ground_atlas(StringView filename, bool fail_ok) 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 8e2f329f..ed15edbc 100644 --- a/loader/json.cpp +++ b/loader/json.cpp @@ -58,7 +58,7 @@ ArrayView<const std::shared_ptr<class ground_atlas>> loader_impl::ground_atlases 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)); + Path::join(loader_::GROUND_TILESET_PATH, filename)); fm_assert(!ground_atlas_array.empty()); return ground_atlas_array; } diff --git a/loader/loader.cpp b/loader/loader.cpp index 71be9b16..80599c3d 100644 --- a/loader/loader.cpp +++ b/loader/loader.cpp @@ -24,24 +24,27 @@ loader_::~loader_() noexcept = default; StringView loader_::strip_prefix(StringView name) { - if (name.hasPrefix(IMAGE_PATH)) - return name.exceptPrefix(IMAGE_PATH.size()); + if (name.hasPrefix(IMAGE_PATH_)) + return name.exceptPrefix(IMAGE_PATH_.size()); if (name.hasPrefix(ANIM_PATH)) return name.exceptPrefix(ANIM_PATH.size()); if (name.hasPrefix(SCENERY_PATH)) return name.exceptPrefix(SCENERY_PATH.size()); if (name.hasPrefix(VOBJ_PATH)) return name.exceptPrefix(VOBJ_PATH.size()); + if (name.hasPrefix(GROUND_TILESET_PATH)) + return name.exceptPrefix(GROUND_TILESET_PATH.size()); if (name.hasPrefix(WALL_TILESET_PATH)) return name.exceptPrefix(WALL_TILESET_PATH.size()); return name; } -const StringView loader_::IMAGE_PATH = "images/"_s; +const StringView loader_::IMAGE_PATH_ = "images/"_s; const StringView loader_::ANIM_PATH = "anim/"_s; const StringView loader_::SCENERY_PATH = "scenery/"_s; const StringView loader_::TEMP_PATH = "../../../"_s; const StringView loader_::VOBJ_PATH = "vobj/"_s; +const StringView loader_::GROUND_TILESET_PATH = "ground/"_s; const StringView loader_::WALL_TILESET_PATH = "walls/"_s; } // namespace floormat diff --git a/loader/loader.hpp b/loader/loader.hpp index 63b5ea5c..fc58e61a 100644 --- a/loader/loader.hpp +++ b/loader/loader.hpp @@ -23,11 +23,12 @@ struct wall_info; 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 Trade::ImageData2D texture(StringView prefix, 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 std::shared_ptr<class ground_atlas> ground_atlas(StringView filename, bool fail_ok = false) 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 const wall_info& make_invalid_wall_atlas() noexcept = 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(); @@ -47,11 +48,12 @@ struct loader_ virtual ~loader_() noexcept; - static const StringView IMAGE_PATH; + static const StringView IMAGE_PATH_; static const StringView ANIM_PATH; static const StringView SCENERY_PATH; static const StringView TEMP_PATH; static const StringView VOBJ_PATH; + static const StringView GROUND_TILESET_PATH; static const StringView WALL_TILESET_PATH; protected: diff --git a/loader/vobj.cpp b/loader/vobj.cpp index 9aa6fb39..a309fd6a 100644 --- a/loader/vobj.cpp +++ b/loader/vobj.cpp @@ -46,7 +46,7 @@ namespace floormat::loader_detail { std::shared_ptr<class anim_atlas> loader_impl::make_vobj_anim_atlas(StringView name, StringView image_filename) { - auto tex = texture(VOBJ_PATH, image_filename); + auto tex = texture(VOBJ_PATH, image_filename, false); anim_def def; def.object_name = name; const auto size = tex.pixels().size(); diff --git a/loader/wall-atlas.cpp b/loader/wall-atlas.cpp index 66dc3ba5..7d423b26 100644 --- a/loader/wall-atlas.cpp +++ b/loader/wall-atlas.cpp @@ -46,7 +46,7 @@ std::shared_ptr<wall_atlas> loader_impl::get_wall_atlas(StringView name, StringV char buf[FILENAME_MAX]; auto filename = make_atlas_path(buf, path, name); auto def = wall_atlas_def::deserialize(""_s.join({filename, ".json"_s})); - auto tex = texture(""_s, filename, false); + auto tex = texture(""_s, filename); fm_soft_assert(name == def.header.name); fm_soft_assert(!def.frames.empty()); @@ -54,7 +54,7 @@ std::shared_ptr<wall_atlas> loader_impl::get_wall_atlas(StringView name, StringV return atlas; } -const wall_info& loader_impl::make_invalid_wall_atlas() +const wall_info& loader_impl::make_invalid_wall_atlas() noexcept { if (invalid_wall_atlas) [[likely]] return *invalid_wall_atlas; diff --git a/main/draw.cpp b/main/draw.cpp index 98fd861e..4de42473 100644 --- a/main/draw.cpp +++ b/main/draw.cpp @@ -178,7 +178,7 @@ void main_impl::draw_world() noexcept const with_shifted_camera_offset o{_shader, ch, {minx, miny}, {maxx, maxy}}; if (check_chunk_visible(_shader.camera_offset(), sz)) { - _floor_mesh.draw(_shader, c); + _ground_mesh.draw(_shader, c); _wall_mesh.draw(_shader, c); } } diff --git a/main/main-impl.hpp b/main/main-impl.hpp index f66b0248..8aaf6312 100644 --- a/main/main-impl.hpp +++ b/main/main-impl.hpp @@ -2,7 +2,7 @@ #include "floormat/main.hpp" #include "floormat/settings.hpp" #include "src/world.hpp" -#include "draw/floor.hpp" +#include "draw/ground.hpp" #include "draw/wall.hpp" #include "draw/anim.hpp" #include "shaders/texture-unit-cache.hpp" @@ -111,7 +111,7 @@ private: struct world _world{}; Magnum::Timeline timeline; uint32_t _mouse_cursor = (uint32_t)-1; - floor_mesh _floor_mesh; + ground_mesh _ground_mesh; wall_mesh _wall_mesh; anim_mesh _anim_mesh; #ifdef FM_USE_DEPTH32 diff --git a/main/setup.cpp b/main/setup.cpp index 15b34b2b..45f941cb 100644 --- a/main/setup.cpp +++ b/main/setup.cpp @@ -100,7 +100,7 @@ void main_impl::update_window_state() auto main_impl::meshes() noexcept -> struct meshes { - return { _floor_mesh, _wall_mesh, _anim_mesh, }; + return { _ground_mesh, _wall_mesh, _anim_mesh, }; }; struct world& main_impl::reset_world() noexcept diff --git a/test/bitmask.cpp b/test/bitmask.cpp index ef8f3b1c..0fae6a23 100644 --- a/test/bitmask.cpp +++ b/test/bitmask.cpp @@ -23,7 +23,7 @@ static_assert(data_nbytes == 128); void bitmask_test() { - auto img = loader.texture(loader.SCENERY_PATH, "door-close"_s); + auto img = loader.texture(loader.SCENERY_PATH, "door-close"_s, false); auto bitmask = anim_atlas::make_bitmask(img); fm_assert(img.pixelSize() == 4 && (size_t)img.size().product() >= data_nbytes); #ifdef DO_GENERATE diff --git a/test/loader.cpp b/test/loader.cpp index 88fa2b32..f400ecb3 100644 --- a/test/loader.cpp +++ b/test/loader.cpp @@ -8,7 +8,7 @@ namespace floormat { void test_app::test_loader() { - (void)loader.ground_atlases("floor.json"); + (void)loader.ground_atlases("ground.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(); |