summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-02-25 07:11:10 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-02-25 07:11:10 +0100
commit7645616583a205e6d93c4531dfdafbff699068e7 (patch)
tree941d1384625aea2443b88ee96f9c95bc66f79b20
parentfbf24f274c81b260fb3d6689cd13086176f549a2 (diff)
cleanup includes
-rw-r--r--serialize/wall-atlas.cpp6
-rw-r--r--serialize/wall-atlas.hpp1
-rw-r--r--src/search-cache.cpp1
-rw-r--r--src/search-cache.hpp8
-rw-r--r--src/wall-atlas.hpp3
-rw-r--r--wall-tileset-tool/main.cpp19
6 files changed, 23 insertions, 15 deletions
diff --git a/serialize/wall-atlas.cpp b/serialize/wall-atlas.cpp
index b2e7c2f5..4e661674 100644
--- a/serialize/wall-atlas.cpp
+++ b/serialize/wall-atlas.cpp
@@ -45,7 +45,7 @@ struct direction_triple
{
Array<Direction> array;
std::array<DirArrayIndex, Direction_COUNT> map;
- std::bitset<Direction_COUNT> mask;
+ std::array<bool, Direction_COUNT> mask;
};
direction_triple read_all_directions(const json& jroot)
@@ -54,9 +54,7 @@ direction_triple read_all_directions(const json& jroot)
for (auto [str, _] : wall_atlas::directions)
if (jroot.contains(str))
count++;
- direction_triple ret = { Array<Direction>{count},
- std::array<DirArrayIndex, Direction_COUNT>{},
- std::bitset<Direction_COUNT>{0}, };
+ direction_triple ret = { Array<Direction>{count}, {}, {}, };
auto& [array, map, mask] = ret;
for (uint8_t i = 0, pos = 0; i < std::size(wall_atlas::directions); i++)
{
diff --git a/serialize/wall-atlas.hpp b/serialize/wall-atlas.hpp
index 1381591d..5ce61c74 100644
--- a/serialize/wall-atlas.hpp
+++ b/serialize/wall-atlas.hpp
@@ -1,6 +1,5 @@
#pragma once
#include "src/wall-atlas.hpp"
-#include <bitset>
#include <memory>
#include <Corrade/Containers/Array.h>
#include <nlohmann/json_fwd.hpp>
diff --git a/src/search-cache.cpp b/src/search-cache.cpp
index 511d72b4..dd73601f 100644
--- a/src/search-cache.cpp
+++ b/src/search-cache.cpp
@@ -1,5 +1,6 @@
#include "search-cache.hpp"
#include "search-constants.hpp"
+#include "point.hpp"
#include "world.hpp"
#include <bitset>
diff --git a/src/search-cache.hpp b/src/search-cache.hpp
index ee6f7537..c8fc8bbe 100644
--- a/src/search-cache.hpp
+++ b/src/search-cache.hpp
@@ -1,11 +1,15 @@
#pragma once
#include "compat/defs.hpp"
-#include "point.hpp"
#include <array>
#include <Corrade/Containers/Array.h>
#include <Magnum/Math/Vector2.h>
-namespace floormat { class world; class chunk; }
+namespace floormat {
+class world;
+class chunk;
+struct point;
+struct chunk_coords_;
+} // namespace floormat
namespace floormat::Search {
diff --git a/src/wall-atlas.hpp b/src/wall-atlas.hpp
index c1f60a03..2bc03dc0 100644
--- a/src/wall-atlas.hpp
+++ b/src/wall-atlas.hpp
@@ -4,7 +4,6 @@
#include "src/pass-mode.hpp"
#include "wall-defs.hpp"
#include <array>
-#include <bitset> // todo replace with array
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/String.h>
#include <Magnum/Math/Vector2.h>
@@ -97,7 +96,7 @@ struct wall_atlas_def final
Array<Wall::Frame> frames;
Array<Wall::Direction> direction_array;
std::array<Wall::DirArrayIndex, Wall::Direction_COUNT> direction_map;
- std::bitset<Wall::Direction_COUNT> direction_mask{0};
+ std::array<bool, Wall::Direction_COUNT> direction_mask{};
static wall_atlas_def deserialize(StringView filename);
void serialize(StringView filename) const;
diff --git a/wall-tileset-tool/main.cpp b/wall-tileset-tool/main.cpp
index f21368c2..62e29e0d 100644
--- a/wall-tileset-tool/main.cpp
+++ b/wall-tileset-tool/main.cpp
@@ -30,6 +30,9 @@ using namespace floormat::Wall;
namespace {
+struct resolution : Vector2i { using Vector2i::Vector2i; };
+constexpr inline int max_image_dimension = 4096;
+
const Direction& get_direction(const wall_atlas_def& atlas, size_t i)
{
fm_assert(atlas.direction_mask[i]);
@@ -50,8 +53,6 @@ auto asformat(Fmt&& fmt, Xs&&... args)
return ret;
}
-struct resolution : Vector2i { using Vector2i::Vector2i; };
-
Debug& operator<<(Debug& dbg, resolution res)
{
auto flags = dbg.flags();
@@ -62,7 +63,13 @@ Debug& operator<<(Debug& dbg, resolution res)
return dbg;
}
-constexpr inline int max_image_dimension = 4096;
+template<size_t N> constexpr bool any_bit_of(const std::array<bool, N>& array)
+{
+ for (auto x : array)
+ if (x)
+ return true;
+ return false;
+}
bool convert_to_bgra32(const cv::Mat& src, cv::Mat4b& dest)
{
@@ -276,7 +283,7 @@ bool do_direction(state& st, size_t i)
const auto dir_idx = atlas.direction_array.size();
fm_assert(dir_idx == (uint8_t)dir_idx);
- atlas.direction_mask[i] = 1;
+ atlas.direction_mask[i] = true;
atlas.direction_map[i] = DirArrayIndex{(uint8_t)dir_idx};
auto dir = Direction{};
@@ -300,13 +307,13 @@ bool do_input_file(state& st)
DBG << "input" << quoted(st.old_atlas.header.name) << colon(',') << quoted(st.opts.input_file);
fm_assert(loader.check_atlas_name(st.old_atlas.header.name));
- fm_assert(st.old_atlas.direction_mask.any());
+ fm_assert(any_bit_of(st.old_atlas.direction_mask));
auto& atlas = st.new_atlas;
atlas.header = std::move(const_cast<wall_atlas_def&>(st.old_atlas).header);
fm_assert(!atlas.frames.size());
- fm_assert(!atlas.direction_mask.any());
+ fm_assert(!any_bit_of(atlas.direction_mask));
fm_assert(atlas.direction_map == std::array<Wall::DirArrayIndex, Direction_COUNT>{});
fm_assert(atlas.direction_array.isEmpty());
arrayReserve(atlas.direction_array, Direction_COUNT);