summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-02-06 21:29:09 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-02-07 00:45:24 +0100
commit58f95047db869bf14b8b1dda0240ac50a8d340c2 (patch)
tree39920782964047f2e21133d1428b61cb861465af /src
parent5a48da35d255753010ea9f9937050c06982a6d40 (diff)
src: move tile defs that need Vector2 into their own file
Diffstat (limited to 'src')
-rw-r--r--src/camera-offset.cpp2
-rw-r--r--src/chunk-render.cpp1
-rw-r--r--src/chunk-scenery.cpp1
-rw-r--r--src/critter.cpp1
-rw-r--r--src/light.cpp1
-rw-r--r--src/object.cpp1
-rw-r--r--src/object.hpp2
-rw-r--r--src/path-search.hpp1
-rw-r--r--src/raycast.cpp1
-rw-r--r--src/scenery.cpp1
-rw-r--r--src/tile-bbox.hpp4
-rw-r--r--src/tile-constants.hpp16
-rw-r--r--src/tile-defs.hpp13
-rw-r--r--src/tile.cpp1
-rw-r--r--src/wall-atlas.cpp2
15 files changed, 32 insertions, 16 deletions
diff --git a/src/camera-offset.cpp b/src/camera-offset.cpp
index 25b0a3bb..46582539 100644
--- a/src/camera-offset.cpp
+++ b/src/camera-offset.cpp
@@ -1,5 +1,5 @@
#include "camera-offset.hpp"
-#include "tile-defs.hpp"
+#include "tile-constants.hpp"
#include "shaders/shader.hpp"
namespace floormat {
diff --git a/src/chunk-render.cpp b/src/chunk-render.cpp
index b445eff9..efcacb88 100644
--- a/src/chunk-render.cpp
+++ b/src/chunk-render.cpp
@@ -1,4 +1,5 @@
#include "chunk.hpp"
+#include "tile-constants.hpp"
#include "ground-atlas.hpp"
#include "quads.hpp"
#include "shaders/shader.hpp"
diff --git a/src/chunk-scenery.cpp b/src/chunk-scenery.cpp
index 7b4905dd..2d950854 100644
--- a/src/chunk-scenery.cpp
+++ b/src/chunk-scenery.cpp
@@ -1,4 +1,5 @@
#include "chunk-scenery.hpp"
+#include "tile-constants.hpp"
#include "shaders/shader.hpp"
#include "object.hpp"
#include "anim-atlas.hpp"
diff --git a/src/critter.cpp b/src/critter.cpp
index 97a0850f..c8bb2e4f 100644
--- a/src/critter.cpp
+++ b/src/critter.cpp
@@ -1,4 +1,5 @@
#include "critter.hpp"
+#include "tile-constants.hpp"
#include "src/anim-atlas.hpp"
#include "loader/loader.hpp"
#include "src/world.hpp"
diff --git a/src/light.cpp b/src/light.cpp
index 878a5f19..675646eb 100644
--- a/src/light.cpp
+++ b/src/light.cpp
@@ -1,4 +1,5 @@
#include "light.hpp"
+#include "tile-constants.hpp"
#include "shaders/shader.hpp"
#include "loader/loader.hpp"
#include <cmath>
diff --git a/src/object.cpp b/src/object.cpp
index b079c9ef..52244121 100644
--- a/src/object.cpp
+++ b/src/object.cpp
@@ -1,4 +1,5 @@
#include "object.hpp"
+#include "tile-constants.hpp"
#include "world.hpp"
#include "rotation.inl"
#include "anim-atlas.hpp"
diff --git a/src/object.hpp b/src/object.hpp
index 6db9d8bc..10a900d1 100644
--- a/src/object.hpp
+++ b/src/object.hpp
@@ -19,7 +19,7 @@ struct object_proto
{
std::shared_ptr<anim_atlas> atlas;
Vector2b offset, bbox_offset;
- Vector2ub bbox_size = Vector2ub(iTILE_SIZE2);
+ Vector2ub bbox_size = Vector2ub(tile_size_xy);
uint16_t delta = 0, frame = 0;
object_type type : 3 = object_type::none;
rotation r : rotation_BITS = rotation::N;
diff --git a/src/path-search.hpp b/src/path-search.hpp
index 36c25497..b448afe8 100644
--- a/src/path-search.hpp
+++ b/src/path-search.hpp
@@ -1,4 +1,5 @@
#pragma once
+#include "tile-constants.hpp"
#include "global-coords.hpp"
#include "object-id.hpp"
#include "rotation.hpp"
diff --git a/src/raycast.cpp b/src/raycast.cpp
index 1ca75db2..3e77ecd0 100644
--- a/src/raycast.cpp
+++ b/src/raycast.cpp
@@ -1,4 +1,5 @@
#include "raycast-diag.hpp"
+#include "tile-constants.hpp"
#include "pass-mode.hpp"
#include "src/world.hpp"
#include "src/object.hpp"
diff --git a/src/scenery.cpp b/src/scenery.cpp
index 9adae347..1e13d2df 100644
--- a/src/scenery.cpp
+++ b/src/scenery.cpp
@@ -1,4 +1,5 @@
#include "scenery.hpp"
+#include "tile-constants.hpp"
#include "anim-atlas.hpp"
#include "chunk.hpp"
#include "compat/assert.hpp"
diff --git a/src/tile-bbox.hpp b/src/tile-bbox.hpp
index 95dd2284..c126184c 100644
--- a/src/tile-bbox.hpp
+++ b/src/tile-bbox.hpp
@@ -1,5 +1,5 @@
#pragma once
-#include "src/tile-defs.hpp"
+#include "tile-constants.hpp"
#include "src/local-coords.hpp"
#include <Corrade/Containers/Pair.h>
#include <Magnum/Magnum.h>
@@ -9,7 +9,7 @@ namespace floormat {
constexpr Vector2 tile_start(size_t k)
{
- constexpr auto half_tile = Vector2(TILE_SIZE2)/2;
+ constexpr auto half_tile = Vector2(tile_size_xy)/2;
const local_coords coord{k};
return TILE_SIZE2 * Vector2(coord) - half_tile;
}
diff --git a/src/tile-constants.hpp b/src/tile-constants.hpp
new file mode 100644
index 00000000..0b2f49eb
--- /dev/null
+++ b/src/tile-constants.hpp
@@ -0,0 +1,16 @@
+#pragma once
+#include "tile-defs.hpp"
+#include <Magnum/Math/Vector2.h>
+#include <Magnum/Math/Vector3.h>
+
+namespace floormat {
+
+constexpr inline auto TILE_MAX_DIM20d = Magnum::Math::Vector3<double> { TILE_MAX_DIM, TILE_MAX_DIM, 0 };
+constexpr inline auto iTILE_SIZE = Magnum::Math::Vector3<Int> { tile_size_xy, tile_size_xy, tile_size_z };
+constexpr inline auto iTILE_SIZE2 = Magnum::Math::Vector2<Int> { iTILE_SIZE.x(), iTILE_SIZE.y() };
+constexpr inline auto TILE_SIZE = Magnum::Math::Vector3<float> { iTILE_SIZE };
+constexpr inline auto dTILE_SIZE = Magnum::Math::Vector3<double> { iTILE_SIZE };
+constexpr inline auto TILE_SIZE2 = Magnum::Math::Vector2<float> { iTILE_SIZE2 };
+constexpr inline auto TILE_SIZE20 = Magnum::Math::Vector3<float> { (float)iTILE_SIZE.x(), (float)iTILE_SIZE.y(), 0 };
+
+} // namespace floormat
diff --git a/src/tile-defs.hpp b/src/tile-defs.hpp
index 2a8a7865..0853552b 100644
--- a/src/tile-defs.hpp
+++ b/src/tile-defs.hpp
@@ -1,20 +1,11 @@
#pragma once
-#include <Magnum/Math/Vector2.h>
-#include <Magnum/Math/Vector3.h>
namespace floormat {
using variant_t = uint16_t;
-
constexpr inline uint32_t TILE_MAX_DIM = 16;
constexpr inline size_t TILE_COUNT = size_t{TILE_MAX_DIM}*size_t{TILE_MAX_DIM};
-
-constexpr inline auto TILE_MAX_DIM20d = Magnum::Math::Vector3<double> { TILE_MAX_DIM, TILE_MAX_DIM, 0 };
-constexpr inline auto iTILE_SIZE = Magnum::Math::Vector3<Int> { 64, 64, 192 };
-constexpr inline auto iTILE_SIZE2 = Magnum::Math::Vector2<Int> { iTILE_SIZE.x(), iTILE_SIZE.y() };
-constexpr inline auto TILE_SIZE = Magnum::Math::Vector3<float> { iTILE_SIZE };
-constexpr inline auto dTILE_SIZE = Magnum::Math::Vector3<double> { iTILE_SIZE };
-constexpr inline auto TILE_SIZE2 = Magnum::Math::Vector2<float> { iTILE_SIZE2 };
-constexpr inline auto TILE_SIZE20 = Magnum::Math::Vector3<float> { (float)iTILE_SIZE.x(), (float)iTILE_SIZE.y(), 0 };
+constexpr inline int32_t tile_size_xy = 64;
+constexpr inline int32_t tile_size_z = 192;
} // namespace floormat
diff --git a/src/tile.cpp b/src/tile.cpp
index 1f36d5b4..07f162e6 100644
--- a/src/tile.cpp
+++ b/src/tile.cpp
@@ -1,4 +1,5 @@
#include "tile.hpp"
+#include "tile-constants.hpp"
#include "chunk.hpp"
#include "src/ground-atlas.hpp"
diff --git a/src/wall-atlas.cpp b/src/wall-atlas.cpp
index 60568751..b7ff68d9 100644
--- a/src/wall-atlas.cpp
+++ b/src/wall-atlas.cpp
@@ -1,6 +1,6 @@
#include "wall-atlas.hpp"
+#include "tile-constants.hpp"
#include "compat/exception.hpp"
-#include "src/tile-defs.hpp"
#include <utility>
#include <Corrade/Containers/StridedArrayView.h>
#include <Magnum/ImageView.h>