summaryrefslogtreecommitdiffhomepage
path: root/bench/raycast.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-02-04 20:33:58 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-02-04 20:33:58 +0100
commitf7784afa0f42ac81696a03e64fa0a2fefd7cf748 (patch)
treef5d571a6097a34cbbc09c3dde059c3e3fa8f13f9 /bench/raycast.cpp
parentd3a5002c3049d3e91540b8b351df36bb3f3fc961 (diff)
a
Diffstat (limited to 'bench/raycast.cpp')
-rw-r--r--bench/raycast.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/bench/raycast.cpp b/bench/raycast.cpp
index b19b007c..79b4ff9d 100644
--- a/bench/raycast.cpp
+++ b/bench/raycast.cpp
@@ -9,8 +9,6 @@ namespace floormat {
namespace {
-#pragma message("TODO!")
-
world make_world()
{
constexpr auto var = (variant_t)-1;
@@ -37,6 +35,10 @@ world make_world()
w[global_coords{{0, 2, 0}, { 9, 0}}].t.wall_north() = wall1;
w[global_coords{{0, 2, 0}, {10, 0}}].t.wall_north() = wall1;
+ for (int16_t i = -10; i <= 10; i++)
+ for (int16_t j = -10; j <= 10; j++)
+ w[{{i, j}, 0}].mark_modified();
+
return w;
}
@@ -45,25 +47,38 @@ world make_world()
constexpr auto run1 = [](world& w, point to, bool b, float len = 0)
{
constexpr auto from = point{{0, 0, 0}, {11,12}, {1,-32}};
- constexpr float fuzz = 8;
+ constexpr float fuzz = iTILE_SIZE2.x();
auto diag = rc::raycast_diag_s{};
auto res = raycast_with_diag(diag, w, from, to, 0);
- fm_assert(res.success == b);
+ if (res.success != b)
+ {
+ fm_error("success != %s", b ? "true" : "false");
+ return false;
+ }
if (len > 0)
{
auto tmin = res.success ? diag.V.length() : diag.tmin;
fm_assert(len > 1e-6f);
auto diff = Math::abs(tmin - len);
if (diff > fuzz)
- fm_abort("|tmin=%f - len=%f| > %f",
+ {
+ fm_error("|tmin=%f - len=%f| > %f",
(double)tmin, (double)len, (double)fuzz);
+ return false;
+ }
}
+ return true;
};
auto w = make_world();
const auto run = [&] {
- run1(w, point{{1, 3, 0}, {0,1}, {-21,23}}, false, 2288);
+ fm_assert(run1(w, point{{ 1, 3, 0}, { 0, 1}, {-21, 23}}, false, 2288));
+ fm_assert(run1(w, point{{ 1, 3, 0}, { 8, 10}, {- 9, -13}}, true, 3075));
+ fm_assert(run1(w, point{{ 0, 3, 0}, {14, 4}, { 3, 15}}, true, 2614));
+ fm_assert(run1(w, point{{ 0, 1, 0}, { 8, 12}, {-27, -19}}, false, 752));
+ //fm_assert(run1(w, point{{ 0, 1, 0}, { 7, 11}, {- 8, -21}}, false, 908));
+ fm_assert(run1(w, point{{ 2, 33, 0}, {15, 11}, {- 4, 29}}, true, 33809));
};
run();