From 58f95047db869bf14b8b1dda0240ac50a8d340c2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 6 Feb 2024 21:29:09 +0100 Subject: src: move tile defs that need Vector2 into their own file --- bench/raycast.cpp | 1 + draw/anim.cpp | 1 + editor/camera.cpp | 1 + editor/draw.cpp | 1 + editor/imgui-editors.cpp | 1 + editor/imgui.cpp | 1 + loader/ground-atlas.cpp | 1 + loader/wall-atlas.cpp | 1 + main/draw.cpp | 1 + src/camera-offset.cpp | 2 +- src/chunk-render.cpp | 1 + src/chunk-scenery.cpp | 1 + src/critter.cpp | 1 + src/light.cpp | 1 + src/object.cpp | 1 + src/object.hpp | 2 +- src/path-search.hpp | 1 + src/raycast.cpp | 1 + src/scenery.cpp | 1 + src/tile-bbox.hpp | 4 ++-- src/tile-constants.hpp | 16 ++++++++++++++++ src/tile-defs.hpp | 13 ++----------- src/tile.cpp | 1 + src/wall-atlas.cpp | 2 +- test/raycast.cpp | 1 + test/wall-atlas2.cpp | 2 +- wall-tileset-tool/main.cpp | 2 +- 27 files changed, 44 insertions(+), 18 deletions(-) create mode 100644 src/tile-constants.hpp 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 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 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 #include @@ -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 +#include + +namespace floormat { + +constexpr inline auto TILE_MAX_DIM20d = Magnum::Math::Vector3 { TILE_MAX_DIM, TILE_MAX_DIM, 0 }; +constexpr inline auto iTILE_SIZE = Magnum::Math::Vector3 { tile_size_xy, tile_size_xy, tile_size_z }; +constexpr inline auto iTILE_SIZE2 = Magnum::Math::Vector2 { iTILE_SIZE.x(), iTILE_SIZE.y() }; +constexpr inline auto TILE_SIZE = Magnum::Math::Vector3 { iTILE_SIZE }; +constexpr inline auto dTILE_SIZE = Magnum::Math::Vector3 { iTILE_SIZE }; +constexpr inline auto TILE_SIZE2 = Magnum::Math::Vector2 { iTILE_SIZE2 }; +constexpr inline auto TILE_SIZE20 = Magnum::Math::Vector3 { (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 -#include 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 { TILE_MAX_DIM, TILE_MAX_DIM, 0 }; -constexpr inline auto iTILE_SIZE = Magnum::Math::Vector3 { 64, 64, 192 }; -constexpr inline auto iTILE_SIZE2 = Magnum::Math::Vector2 { iTILE_SIZE.x(), iTILE_SIZE.y() }; -constexpr inline auto TILE_SIZE = Magnum::Math::Vector3 { iTILE_SIZE }; -constexpr inline auto dTILE_SIZE = Magnum::Math::Vector3 { iTILE_SIZE }; -constexpr inline auto TILE_SIZE2 = Magnum::Math::Vector2 { iTILE_SIZE2 }; -constexpr inline auto TILE_SIZE20 = Magnum::Math::Vector3 { (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 #include #include 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" -- cgit v1.2.3