summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--compat/LooseQuadtree-impl.h5
-rw-r--r--compat/LooseQuadtree.h2
-rw-r--r--src/chunk-bbox.cpp6
-rw-r--r--src/chunk.hpp4
-rw-r--r--src/collision.hpp3
-rw-r--r--test/quadtree.cpp2
6 files changed, 11 insertions, 11 deletions
diff --git a/compat/LooseQuadtree-impl.h b/compat/LooseQuadtree-impl.h
index 08591072..26bddac1 100644
--- a/compat/LooseQuadtree-impl.h
+++ b/compat/LooseQuadtree-impl.h
@@ -1265,9 +1265,10 @@ void LooseQuadtree<NumberT, ObjectT, BoundingBoxExtractorT>::Query::Next() {
}
-template <typename NumberT>
+template <typename Src>
struct TrivialBBExtractor {
- static void ExtractBoundingBox(const BoundingBox<NumberT> *object, BoundingBox<NumberT> *bbox)
+ template<typename Dst = Src>
+ static void ExtractBoundingBox(const BoundingBox<Src> *object, BoundingBox<Dst> *bbox)
{
bbox->left = object->left;
bbox->top = object->top;
diff --git a/compat/LooseQuadtree.h b/compat/LooseQuadtree.h
index a8544346..507a92fa 100644
--- a/compat/LooseQuadtree.h
+++ b/compat/LooseQuadtree.h
@@ -22,7 +22,7 @@
* - This library is not thread-safe but multiple queries can be run at once
*
* Generic parameters are:
- * - NumberT generic number type allows its floating- and fixed-point usage
+ * - Src generic number type allows its floating- and fixed-point usage
* - ObjectT* only pointer is stored, no object copying is done, not an inclusive container
* - BoundingBoxExtractorT allows using your own bounding box type/source, needs
* BoundingBoxExtractor::ExtractBoundingBox(ObjectT* in, BoundingBox<Number>* out) implemented
diff --git a/src/chunk-bbox.cpp b/src/chunk-bbox.cpp
index 382e4abb..52be8635 100644
--- a/src/chunk-bbox.cpp
+++ b/src/chunk-bbox.cpp
@@ -117,7 +117,7 @@ void chunk::ensure_passability() noexcept
auto chunk::query_collisions(Vector4s vec, collision type) const -> Query
{
const_cast<chunk&>(*this).ensure_passability();
- loose_quadtree::BoundingBox<std::int16_t> bbox { vec[0], vec[1], vec[2], vec[3] };
+ loose_quadtree::BoundingBox<float> bbox ( vec[0], vec[1], vec[2], vec[3] );
return { lqt_from_collision_type(type)->QueryIntersectsRegion(bbox) };
}
@@ -126,7 +126,7 @@ auto chunk::query_collisions(Vector2s position, Vector2us size, collision type)
const_cast<chunk&>(*this).ensure_passability();
constexpr auto half = sTILE_SIZE2/2;
const auto start = position - half;
- loose_quadtree::BoundingBox<std::int16_t> bbox {start[0], start[1], (Short)size[0], (Short)size[1] };
+ loose_quadtree::BoundingBox<float> bbox ( start[0], start[1], (Short)size[0], (Short)size[1] );
return { lqt_from_collision_type(type)->QueryIntersectsRegion(bbox) };
}
@@ -135,7 +135,7 @@ auto chunk::query_collisions(local_coords p, Vector2us size, Vector2s offset, co
const_cast<chunk&>(*this).ensure_passability();
const auto pos = Vector2s(p.x, p.y) * sTILE_SIZE2 + offset;
const auto start = pos - Vector2s(size/2);
- loose_quadtree::BoundingBox<std::int16_t> bbox { start[0], start[1], (Short)size[0], (Short)size[1] };
+ loose_quadtree::BoundingBox<float> bbox ( start[0], start[1], (Short)size[0], (Short)size[1] );
return { lqt_from_collision_type(type)->QueryIntersectsRegion(bbox) };
}
diff --git a/src/chunk.hpp b/src/chunk.hpp
index 09af9bdb..2f257c38 100644
--- a/src/chunk.hpp
+++ b/src/chunk.hpp
@@ -90,8 +90,8 @@ struct chunk final
using BB = loose_quadtree::BoundingBox<std::int16_t>;
using BBE = loose_quadtree::TrivialBBExtractor<std::int16_t>;
- using lqt = loose_quadtree::LooseQuadtree<std::int16_t, BB, BBE>;
- using Query = collision_query<std::int16_t, BB, BBE>;
+ using lqt = loose_quadtree::LooseQuadtree<float, BB, BBE>;
+ using Query = collision_query<float, BB, BBE>;
Query query_collisions(Vector2s position, Vector2us size, collision type) const;
Query query_collisions(local_coords p, Vector2us size, Vector2s offset, collision type) const;
diff --git a/src/collision.hpp b/src/collision.hpp
index 086369fb..0568cc39 100644
--- a/src/collision.hpp
+++ b/src/collision.hpp
@@ -1,14 +1,13 @@
#pragma once
#include "compat/LooseQuadtree-impl.h"
#include "src/pass-mode.hpp"
-#include <cinttypes>
namespace floormat {
template<typename Num, typename BB, typename BBE>
struct collision_iterator final
{
- using Query = typename loose_quadtree::LooseQuadtree<std::int16_t, BB, BBE>::Query;
+ using Query = typename loose_quadtree::LooseQuadtree<Num, BB, BBE>::Query;
explicit collision_iterator() noexcept : q{nullptr} {}
explicit collision_iterator(Query* q) noexcept : q{q} {}
diff --git a/test/quadtree.cpp b/test/quadtree.cpp
index 4ad90acc..f1a3ab6f 100644
--- a/test/quadtree.cpp
+++ b/test/quadtree.cpp
@@ -699,7 +699,7 @@ void RunTests(const char* type_str)
TestContainer<NumberT>();
TestQueries<NumberT>();
#ifndef FM_NO_QUADTREE_BENCHMARK
- StressTest<NumberT>();
+ StressTest<Src>();
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double, std::milli> time = end - start;
printf(": %.1f ms\n", time.count());