summaryrefslogtreecommitdiffhomepage
path: root/editor/tests
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-02-29 00:39:41 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-02-29 00:39:41 +0100
commit0b09ee33c25e8ae8f1a7aa6b05e9453a82c65689 (patch)
tree3a9938551e923cb3e569db096a2be9c94fb29857 /editor/tests
parent3b03a82fb6db0a3fda4d711456fc89e7d21bfe26 (diff)
always collect timing info on pathfinding/raycasting
Diffstat (limited to 'editor/tests')
-rw-r--r--editor/tests/raycast-test.cpp8
-rw-r--r--editor/tests/region-test.cpp19
2 files changed, 7 insertions, 20 deletions
diff --git a/editor/tests/raycast-test.cpp b/editor/tests/raycast-test.cpp
index 76fdde8b..13199244 100644
--- a/editor/tests/raycast-test.cpp
+++ b/editor/tests/raycast-test.cpp
@@ -10,7 +10,6 @@
#include <array>
#include <vector>
#include <mg/Color.h>
-#include <mg/Timeline.h>
namespace floormat::tests {
@@ -57,7 +56,6 @@ struct raycast_test final : base_test
raycast_result_s result;
pending_s pending;
raycast_diag_s diag;
- float time = 0;
~raycast_test() noexcept override;
@@ -70,7 +68,6 @@ struct raycast_test final : base_test
{
if (e.button == mouse_button_left && is_down)
{
- time = 0;
auto& M = a.main();
auto& w = M.world();
if (auto pt_ = a.cursor_state().point())
@@ -250,7 +247,7 @@ struct raycast_test final : base_test
text(buf);
do_column("time");
- std::snprintf(buf, std::size(buf), "%.3f ms", (double)(1000 * time));
+ std::snprintf(buf, std::size(buf), "%.3f ms", (double)(1000 * result.time));
text(buf);
}
}
@@ -270,10 +267,7 @@ struct raycast_test final : base_test
fm_warn("raycast: wrong Z value");
return;
}
- Timeline timeline;
- timeline.start();
result = raycast_with_diag(diag, a.main().world(), pending.from, pending.to, pending.self);
- time = timeline.currentFrameDuration();
}
}
};
diff --git a/editor/tests/region-test.cpp b/editor/tests/region-test.cpp
index 895604fb..55602d98 100644
--- a/editor/tests/region-test.cpp
+++ b/editor/tests/region-test.cpp
@@ -8,7 +8,6 @@
#include "floormat/main.hpp"
#include <bitset>
#include <mg/Vector2.h>
-#include <mg/Timeline.h>
namespace floormat::tests {
@@ -29,9 +28,8 @@ struct pending_s
struct result_s
{
- std::bitset<chunk_bits> is_passable;
+ chunk::pass_region region;
chunk_coords_ c;
- float time = 0;
bool exists : 1 = false;
};
@@ -73,7 +71,7 @@ void region_test::draw_overlay(app& a)
for (int i = 0; i < div_count.x(); i++)
{
auto index = (uint32_t)j * div_count.x() + (uint32_t)i;
- if (result.is_passable[index])
+ if (result.region.bits[index])
continue;
auto pos = div_min + div_size * Vector2i{i, j};
auto pt = object::normalize_coords(start, pos);
@@ -107,17 +105,17 @@ void region_test::draw_ui(app&, float)
text(buf);
do_column("passable");
- std::snprintf(buf, sizeof buf, "%zu", result.is_passable.count());
+ std::snprintf(buf, sizeof buf, "%zu", result.region.bits.count());
//{ auto b = push_style_color(ImGuiCol_Text, 0x00ff00ff_rgbaf); text(buf); }
text(buf);
do_column("blocked");
- std::snprintf(buf, sizeof buf, "%zu", result.is_passable.size() - result.is_passable.count());
+ std::snprintf(buf, sizeof buf, "%zu", result.region.bits.size() - result.region.bits.count());
//{ auto b = push_style_color(ImGuiCol_Text, 0xffff00ff_rgbaf); text(buf); }
text(buf);
do_column("time");
- std::snprintf(buf, sizeof buf, "%.1f ms", (double)(1000 * result.time));
+ std::snprintf(buf, sizeof buf, "%.1f ms", (double)(1000 * result.region.time));
text(buf);
}
}
@@ -157,16 +155,11 @@ void region_test::update_post(app& a)
void region_test::do_region_extraction(world& w, chunk_coords_ coord)
{
if (auto* c = w.at(coord))
- {
- Timeline timeline;
- timeline.start();
result = {
- .is_passable = c->make_pass_region(true).bits,
+ .region = c->make_pass_region(true),
.c = coord,
- .time = timeline.currentFrameDuration(),
.exists = true,
};
- }
}
} // namespace