diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-06 21:29:09 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-07 00:45:24 +0100 |
commit | 58f95047db869bf14b8b1dda0240ac50a8d340c2 (patch) | |
tree | 39920782964047f2e21133d1428b61cb861465af | |
parent | 5a48da35d255753010ea9f9937050c06982a6d40 (diff) |
src: move tile defs that need Vector2 into their own file
-rw-r--r-- | bench/raycast.cpp | 1 | ||||
-rw-r--r-- | draw/anim.cpp | 1 | ||||
-rw-r--r-- | editor/camera.cpp | 1 | ||||
-rw-r--r-- | editor/draw.cpp | 1 | ||||
-rw-r--r-- | editor/imgui-editors.cpp | 1 | ||||
-rw-r--r-- | editor/imgui.cpp | 1 | ||||
-rw-r--r-- | loader/ground-atlas.cpp | 1 | ||||
-rw-r--r-- | loader/wall-atlas.cpp | 1 | ||||
-rw-r--r-- | main/draw.cpp | 1 | ||||
-rw-r--r-- | src/camera-offset.cpp | 2 | ||||
-rw-r--r-- | src/chunk-render.cpp | 1 | ||||
-rw-r--r-- | src/chunk-scenery.cpp | 1 | ||||
-rw-r--r-- | src/critter.cpp | 1 | ||||
-rw-r--r-- | src/light.cpp | 1 | ||||
-rw-r--r-- | src/object.cpp | 1 | ||||
-rw-r--r-- | src/object.hpp | 2 | ||||
-rw-r--r-- | src/path-search.hpp | 1 | ||||
-rw-r--r-- | src/raycast.cpp | 1 | ||||
-rw-r--r-- | src/scenery.cpp | 1 | ||||
-rw-r--r-- | src/tile-bbox.hpp | 4 | ||||
-rw-r--r-- | src/tile-constants.hpp | 16 | ||||
-rw-r--r-- | src/tile-defs.hpp | 13 | ||||
-rw-r--r-- | src/tile.cpp | 1 | ||||
-rw-r--r-- | src/wall-atlas.cpp | 2 | ||||
-rw-r--r-- | test/raycast.cpp | 1 | ||||
-rw-r--r-- | test/wall-atlas2.cpp | 2 | ||||
-rw-r--r-- | wall-tileset-tool/main.cpp | 2 |
27 files changed, 44 insertions, 18 deletions
diff --git a/bench/raycast.cpp b/bench/raycast.cpp index cdcf71f7..d77bee85 100644 --- a/bench/raycast.cpp +++ b/bench/raycast.cpp @@ -1,4 +1,5 @@ #include "src/raycast-diag.hpp" +#include "src/tile-constants.hpp" #include "src/world.hpp" #include "src/wall-atlas.hpp" #include "loader/loader.hpp" diff --git a/draw/anim.cpp b/draw/anim.cpp index 56824cf1..c6632fa1 100644 --- a/draw/anim.cpp +++ b/draw/anim.cpp @@ -1,4 +1,5 @@ #include "anim.hpp" +#include "src/tile-constants.hpp" #include "src/anim-atlas.hpp" #include "src/chunk.hpp" #include "shaders/shader.hpp" diff --git a/editor/camera.cpp b/editor/camera.cpp index 696c5348..e919f937 100644 --- a/editor/camera.cpp +++ b/editor/camera.cpp @@ -1,4 +1,5 @@ #include "app.hpp" +#include "src/tile-constants.hpp" #include "src/global-coords.hpp" #include "shaders/shader.hpp" #include "floormat/main.hpp" diff --git a/editor/draw.cpp b/editor/draw.cpp index 535882e5..844d26b3 100644 --- a/editor/draw.cpp +++ b/editor/draw.cpp @@ -1,4 +1,5 @@ #include "app.hpp" +#include "src/tile-constants.hpp" #include "floormat/main.hpp" #include "floormat/settings.hpp" #include "shaders/shader.hpp" diff --git a/editor/imgui-editors.cpp b/editor/imgui-editors.cpp index ad71ea0a..570094bc 100644 --- a/editor/imgui-editors.cpp +++ b/editor/imgui-editors.cpp @@ -1,4 +1,5 @@ #include "app.hpp" +#include "src/tile-constants.hpp" #include "compat/format.hpp" #include "imgui-raii.hpp" #include "ground-editor.hpp" diff --git a/editor/imgui.cpp b/editor/imgui.cpp index f974ec6b..62a0850d 100644 --- a/editor/imgui.cpp +++ b/editor/imgui.cpp @@ -1,4 +1,5 @@ #include "app.hpp" +#include "src/tile-constants.hpp" #include "compat/format.hpp" #include "editor.hpp" #include "ground-editor.hpp" diff --git a/loader/ground-atlas.cpp b/loader/ground-atlas.cpp index 43fb2e7a..b5e3d546 100644 --- a/loader/ground-atlas.cpp +++ b/loader/ground-atlas.cpp @@ -1,4 +1,5 @@ #include "impl.hpp" +#include "src/tile-constants.hpp" #include "src/ground-atlas.hpp" #include "compat/exception.hpp" #include "serialize/json-helper.hpp" diff --git a/loader/wall-atlas.cpp b/loader/wall-atlas.cpp index fa8aabc4..ee33e052 100644 --- a/loader/wall-atlas.cpp +++ b/loader/wall-atlas.cpp @@ -1,4 +1,5 @@ #include "loader/impl.hpp" +#include "src/tile-constants.hpp" #include "wall-info.hpp" #include "compat/assert.hpp" #include "compat/exception.hpp" diff --git a/main/draw.cpp b/main/draw.cpp index dc476fe8..6346be18 100644 --- a/main/draw.cpp +++ b/main/draw.cpp @@ -1,4 +1,5 @@ #include "main-impl.hpp" +#include "src/tile-constants.hpp" #include "floormat/app.hpp" #include "src/camera-offset.hpp" #include "src/anim-atlas.hpp" 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> diff --git a/test/raycast.cpp b/test/raycast.cpp index 3c8a4ce5..23b03926 100644 --- a/test/raycast.cpp +++ b/test/raycast.cpp @@ -1,4 +1,5 @@ #include "app.hpp" +#include "src/tile-constants.hpp" #include "src/raycast-diag.hpp" #include "src/world.hpp" #include "loader/loader.hpp" diff --git a/test/wall-atlas2.cpp b/test/wall-atlas2.cpp index 665f0570..fc875767 100644 --- a/test/wall-atlas2.cpp +++ b/test/wall-atlas2.cpp @@ -1,6 +1,6 @@ #include "app.hpp" #include "compat/assert.hpp" -#include "src/tile-defs.hpp" +#include "src/tile-constants.hpp" #include "src/wall-atlas.hpp" #include "loader/loader.hpp" #include "loader/wall-info.hpp" diff --git a/wall-tileset-tool/main.cpp b/wall-tileset-tool/main.cpp index 6287066c..fba34797 100644 --- a/wall-tileset-tool/main.cpp +++ b/wall-tileset-tool/main.cpp @@ -4,8 +4,8 @@ #include "compat/fix-argv0.hpp" #include "compat/format.hpp" #include "compat/debug.hpp" +#include "src/tile-constants.hpp" #include "src/wall-atlas.hpp" -#include "src/tile-defs.hpp" #include "serialize/wall-atlas.hpp" //#include "serialize/json-helper.hpp" #include "loader/loader.hpp" |