summaryrefslogtreecommitdiffhomepage
path: root/src/chunk-bbox.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-12-06 22:30:06 +0100
committerStanislaw Halik <sthalik@misaki.pl>2022-12-06 22:30:06 +0100
commitef690aa28d8d12e2c998de94816a719170a5d696 (patch)
tree5e1f3227b8f062d0659db460527eb1929237d43f /src/chunk-bbox.cpp
parent646f9d9774d72e9459f50726b200a586d7e07614 (diff)
src/chunk: remove remaining lqt vector calls on 64-bit
Diffstat (limited to 'src/chunk-bbox.cpp')
-rw-r--r--src/chunk-bbox.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/chunk-bbox.cpp b/src/chunk-bbox.cpp
index 78c10a4f..50bbd56a 100644
--- a/src/chunk-bbox.cpp
+++ b/src/chunk-bbox.cpp
@@ -8,7 +8,7 @@
namespace floormat {
template<>
-struct chunk::insert_into_lqt<false>
+struct chunk::lqt_ops<false>
{
using BB = loose_quadtree::BoundingBox<std::int16_t>;
using TBBE = loose_quadtree::TrivialBBExtractor<std::int16_t>;
@@ -17,19 +17,29 @@ struct chunk::insert_into_lqt<false>
vec.push_back(bbox);
return &vec.back();
}
+ static void clear_vec(std::vector<BB>& vec)
+ {
+ vec.clear();
+ }
+ static void reserve_vec(std::vector<BB>& vec, std::size_t size)
+ {
+ vec.reserve(size);
+ }
};
template<>
-struct chunk::insert_into_lqt<true>
+struct chunk::lqt_ops<true>
{
using BB = loose_quadtree::BoundingBox<std::int16_t>;
- static compact_bb* insert(const BB& bbox, std::vector<void**>&)
+ static compact_bb* insert(const BB& bbox, unsigned char&)
{
if constexpr(sizeof(void*) >= sizeof(BB))
return std::bit_cast<compact_bb*>(bbox);
else
return {};
}
+ static void clear_vec(unsigned char&) {}
+ static void reserve_vec(unsigned char&, std::size_t) {}
};
struct collision_bbox final
@@ -67,12 +77,16 @@ void chunk::ensure_passability() noexcept
if (!_lqt_view)
_lqt_view = make_lqt();
+ using ops = lqt_ops<lqt_compact_bb>;
+
_lqt_move->Clear();
_lqt_shoot->Clear();
_lqt_view->Clear();
- _bboxes.clear();
+ ops::clear_vec(_bboxes);
- std::vector<collision_bbox> bboxes; bboxes.reserve(TILE_COUNT*4);
+ std::vector<collision_bbox> bboxes;
+ if constexpr(!lqt_compact_bb)
+ bboxes.reserve(TILE_COUNT*4);
constexpr auto whole_tile = [](std::size_t k, pass_mode p) constexpr -> collision_bbox {
auto start = tile_start(k);
@@ -106,12 +120,11 @@ void chunk::ensure_passability() noexcept
bboxes.push_back(wall_west(i, p));
}
- if constexpr (!lqt_compact_bb)
- _bboxes.reserve(bboxes.size());
+ ops::reserve_vec(_bboxes, bboxes.size());
for (const collision_bbox& bbox : bboxes)
{
- auto* ptr = insert_into_lqt<lqt_compact_bb>::insert(bbox, _bboxes);
+ auto* ptr = ops::insert(bbox, _bboxes);
switch (bbox.pass_mode)
{