From 3b8fe52e0f801978f9e0b1a7174155c8686c61bd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 22 Feb 2024 18:36:42 +0100 Subject: editor: region test stub --- editor/tests-private.hpp | 4 ++- editor/tests/region.cpp | 73 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 editor/tests/region.cpp diff --git a/editor/tests-private.hpp b/editor/tests-private.hpp index c4acc80d..5e44879c 100644 --- a/editor/tests-private.hpp +++ b/editor/tests-private.hpp @@ -31,7 +31,7 @@ protected: }; enum class Test : uint32_t { - none, path, raycast, COUNT, + none, path, raycast, /*region,*/ COUNT, }; struct tests_data final : tests_data_ @@ -43,6 +43,7 @@ struct tests_data final : tests_data_ static Pointer make_test_none(); static Pointer make_test_path(); static Pointer make_test_raycast(); + static Pointer make_test_region(); Pointer current_test; Test current_index = Test::none; @@ -58,6 +59,7 @@ struct tests_data final : tests_data_ { "None"_s, Test::none, &tests_data::make_test_none, }, { "Path"_s, Test::path, &tests_data::make_test_path, }, { "Raycasting"_s, Test::raycast, &tests_data::make_test_raycast }, + //{ "Region extraction"_s, Test::region, &tests_data::make_test_region }, }; }; diff --git a/editor/tests/region.cpp b/editor/tests/region.cpp new file mode 100644 index 00000000..74a4523f --- /dev/null +++ b/editor/tests/region.cpp @@ -0,0 +1,73 @@ +#include "../tests-private.hpp" +#include "src/tile-constants.hpp" +#include + +namespace floormat::tests { + +namespace { + +constexpr int div_factor = 4; // from path-search.hpp +constexpr auto div_size = iTILE_SIZE2 / div_factor; +constexpr uint32_t chunk_nbits = TILE_MAX_DIM*TILE_MAX_DIM*uint32_t{div_factor*div_factor}; + +template constexpr inline auto tile_size = Math::Vector2{iTILE_SIZE2}; +template constexpr inline auto chunk_size = Math::Vector2{TILE_MAX_DIM} * tile_size; + +constexpr Vector2i chunk_offsets[3][3] = { // from src/raycast.cpp + { + { -chunk_size.x(), -chunk_size.y() }, + { -chunk_size.x(), 0 }, + { -chunk_size.x(), chunk_size.y() }, + }, + { + { 0, -chunk_size.y() }, + { 0, 0 }, + { 0, chunk_size.y() }, + }, + { + { chunk_size.x(), -chunk_size.y() }, + { chunk_size.x(), 0 }, + { chunk_size.x(), chunk_size.y() }, + }, +}; +//static_assert(chunk_offsets[0][0] == Vector2i(-1024, -1024)); +//static_assert(chunk_offsets[2][0] == Vector2i(1024, -1024)); + +constexpr int8_t div_min = -div_factor*2, div_max = div_factor*2; // from src/dijkstra.cpp +//for (int8_t y = div_min; y <= div_max; y++) +// for (int8_t x = div_min; x <= div_max; x++) + +struct pending_s +{ + chunk_coords_ c; +}; + +struct result_s +{ + chunk_coords_ c; + std::bitset is_passable; +}; + +#if 0 +struct region_test : base_test +{ + result_s result; + pending_s pending; + + ~region_test() noexcept override; + + bool handle_key(app&, const key_event&, bool) override; + bool handle_mouse_click(app& a, const mouse_button_event& e, bool is_down) override; + bool handle_mouse_move(app& a, const mouse_move_event& e) override; + void draw_overlay(app& a) override; + void draw_ui(app&, float) override; + void update_pre(app&) override; + void update_post(app& a) override; +}; +#endif + +} // namespace + +//Pointer tests_data::make_test_region() { return Pointer{InPlaceInit}; } + +} // namespace floormat::tests -- cgit v1.2.3