summaryrefslogtreecommitdiffhomepage
path: root/src
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 /src
parent3b03a82fb6db0a3fda4d711456fc89e7d21bfe26 (diff)
always collect timing info on pathfinding/raycasting
Diffstat (limited to 'src')
-rw-r--r--src/chunk-region.cpp10
-rw-r--r--src/chunk-region.hpp1
-rw-r--r--src/raycast.cpp21
-rw-r--r--src/raycast.hpp1
4 files changed, 21 insertions, 12 deletions
diff --git a/src/chunk-region.cpp b/src/chunk-region.cpp
index 4bb2be7b..62fee2c4 100644
--- a/src/chunk-region.cpp
+++ b/src/chunk-region.cpp
@@ -139,8 +139,7 @@ auto chunk::make_pass_region(bool debug) -> pass_region
auto chunk::make_pass_region(const pred& f, bool debug) -> pass_region
{
Timeline timeline;
- if (debug) [[unlikely]]
- timeline.start();
+ timeline.start();
pass_region ret;
auto& tmp = get_tmp();
@@ -184,11 +183,10 @@ auto chunk::make_pass_region(const pred& f, bool debug) -> pass_region
do_pixel.operator()<D, false>(p);
}
+ ret.time = timeline.currentFrameTime();
+
if (debug) [[unlikely]]
- {
- const auto time = timeline.currentFrameTime();
- DBG_nospace << "region: generating for " << _coord << " took " << fraction(1e3f*time, 3) << " ms";
- }
+ DBG_nospace << "region: generating for " << _coord << " took " << fraction(1e3f*ret.time, 3) << " ms";
return ret;
}
diff --git a/src/chunk-region.hpp b/src/chunk-region.hpp
index a7281c50..df2149bc 100644
--- a/src/chunk-region.hpp
+++ b/src/chunk-region.hpp
@@ -8,6 +8,7 @@ namespace floormat {
struct chunk::pass_region
{
std::bitset<Search::div_count.product()> bits;
+ float time = 0;
};
} // namespace floormat
diff --git a/src/raycast.cpp b/src/raycast.cpp
index 603b7606..bfc41296 100644
--- a/src/raycast.cpp
+++ b/src/raycast.cpp
@@ -6,10 +6,11 @@
#include "RTree-search.hpp"
#include <cfloat>
#include <bit>
-#include <Corrade/Containers/StructuredBindings.h>
-#include <Corrade/Containers/GrowableArray.h>
-#include <Magnum/Math/Functions.h>
-#include <Magnum/Math/Vector2.h>
+#include <cr/StructuredBindings.h>
+#include <cr/GrowableArray.h>
+#include <mg/Math.h>
+#include <mg/Vector2.h>
+#include <mg/Timeline.h>
namespace floormat::rc {
@@ -310,12 +311,20 @@ raycast_result_s do_raycasting(std::conditional_t<EnableDiagnostics, raycast_dia
raycast_result_s raycast(world& w, point from, point to, object_id self)
{
- return do_raycasting<false>(nullptr, w, from, to, self);
+ Timeline timeline;
+ timeline.start();
+ auto ret = do_raycasting<false>(nullptr, w, from, to, self);
+ ret.time = timeline.currentFrameDuration();
+ return ret;
}
raycast_result_s raycast_with_diag(raycast_diag_s& diag, world& w, point from, point to, object_id self)
{
- return do_raycasting<true>(diag, w, from, to, self);
+ Timeline timeline;
+ timeline.start();
+ auto ret = do_raycasting<true>(diag, w, from, to, self);
+ ret.time = timeline.currentFrameDuration();
+ return ret;
}
} // namespace floormat::rc
diff --git a/src/raycast.hpp b/src/raycast.hpp
index 3871c42f..6463a143 100644
--- a/src/raycast.hpp
+++ b/src/raycast.hpp
@@ -17,6 +17,7 @@ struct raycast_result_s
{
point from, to, collision;
collision_data collider;
+ float time = 0;
bool has_result : 1 = false,
success : 1 = false;
};