summaryrefslogtreecommitdiffhomepage
path: root/editor/tests
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-02-03 21:10:47 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-02-03 21:10:47 +0100
commit879b4d9c629b59388caa202bfd72e1ca1c5992fa (patch)
tree60d654b7a30b4091c8cd0b098aebbe74c61eac0c /editor/tests
parentf9ada1a260aa978261512573c73f00987a4f875b (diff)
a
Diffstat (limited to 'editor/tests')
-rw-r--r--editor/tests/path-test.cpp2
-rw-r--r--editor/tests/raycast-test.cpp33
2 files changed, 20 insertions, 15 deletions
diff --git a/editor/tests/path-test.cpp b/editor/tests/path-test.cpp
index 703a0f3a..43e2b041 100644
--- a/editor/tests/path-test.cpp
+++ b/editor/tests/path-test.cpp
@@ -157,7 +157,7 @@ void path_test::update_post(app& a)
(void)a;
}
-void path_test::draw_ui(app& a, float width)
+void path_test::draw_ui(app&, float)
{
constexpr ImGuiTableFlags table_flags = ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_ScrollY;
constexpr auto colflags_1 = ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_NoReorder | ImGuiTableColumnFlags_NoSort;
diff --git a/editor/tests/raycast-test.cpp b/editor/tests/raycast-test.cpp
index c813feac..06126354 100644
--- a/editor/tests/raycast-test.cpp
+++ b/editor/tests/raycast-test.cpp
@@ -438,6 +438,24 @@ struct raycast_test : base_test
);
auto signs = ray_aabb_signs(dir_inv_norm);
+ const auto do_check_collider = [&](Vector2 origin, uint64_t data, const Rect& r, bool& b)
+ {
+ auto x = std::bit_cast<collision_data>(data);
+ if (x.data == self || x.pass == (uint64_t)pass_mode::pass)
+ return true;
+ //Debug{} << "item" << Vector2(origin) << Vector2(r.m_min[0], r.m_min[1]);
+ auto ret = ray_aabb_intersection(origin, dir_inv_norm,
+ {{{r.m_min[0], r.m_min[1]},{r.m_max[0], r.m_max[1]}}},
+ signs);
+ if (ret.result)
+ {
+ result.collision = object::normalize_coords(from, Vector2i(dir * (double)ret.tmin));
+ result.collider = x;
+ return b = false;
+ }
+ return true;
+ };
+
for (auto k = 0u; k < nsteps; k++)
{
auto u = Vector2i(Math::round(V * k/(double)nsteps));
@@ -469,20 +487,7 @@ struct raycast_test : base_test
auto ch_off = (chunk_coords(last_ch) - from.chunk()) * chunk_size<int>;
auto origin = Vector2((Vector2i(from.local()) * tile_size<int>) + Vector2i(from.offset()) - ch_off);
r->Search(fmin.data(), fmax.data(), [&](uint64_t data, const Rect& r) {
- auto x = std::bit_cast<collision_data>(data);
- if (x.data == self || x.pass == (uint64_t)pass_mode::pass)
- return true;
- //Debug{} << "item" << Vector2(origin) << Vector2(r.m_min[0], r.m_min[1]);
- auto ret = ray_aabb_intersection(origin, dir_inv_norm,
- {{{r.m_min[0], r.m_min[1]},{r.m_max[0], r.m_max[1]}}},
- signs);
- if (ret.result)
- {
- result.collision = object::normalize_coords(from, Vector2i(dir * (double)ret.tmin));
- result.collider = x;
- return b = false;
- }
- return true;
+ return do_check_collider(origin, data, r, b);
});
if (!b)
goto last;