summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-02-24 21:25:51 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-02-24 21:25:51 +0100
commit4251d32844db32330942ed49b38b28aad5dcc34e (patch)
treedfd2611486456357f1ea06fcaeaefad185e46743 /src
parentfb0201967310fbaf4f6ddbeebb269acef8951363 (diff)
collision bbox WIP
Diffstat (limited to 'src')
-rw-r--r--src/chunk-bbox.cpp8
-rw-r--r--src/chunk.hpp10
-rw-r--r--src/collision.cpp8
-rw-r--r--src/collision.hpp10
-rw-r--r--src/scenery.cpp2
-rw-r--r--src/scenery.hpp10
6 files changed, 7 insertions, 41 deletions
diff --git a/src/chunk-bbox.cpp b/src/chunk-bbox.cpp
index b951da10..291056a8 100644
--- a/src/chunk-bbox.cpp
+++ b/src/chunk-bbox.cpp
@@ -47,10 +47,8 @@ void chunk::ensure_passability() noexcept
_lqt_view->Clear();
std::vector<collision_bbox> bboxes;
-#ifndef FLOORMAT_64
_bboxes.clear();
bboxes.reserve(TILE_COUNT*4);
-#endif
constexpr auto whole_tile = [](std::size_t k, pass_mode p) constexpr -> collision_bbox {
auto start = tile_start(k);
@@ -84,18 +82,12 @@ void chunk::ensure_passability() noexcept
bboxes.push_back(wall_west(i, p));
}
-#ifndef FLOORMAT_64
_bboxes.reserve(bboxes.size());
-#endif
for (const collision_bbox& bbox : bboxes)
{
-#ifdef FLOORMAT_64
- auto* ptr = std::bit_cast<compact_bb*>(collision_bbox::BB(bbox));
-#else
_bboxes.push_back(bbox);
auto* ptr = &_bboxes.back();
-#endif
switch (bbox.pass_mode)
{
diff --git a/src/chunk.hpp b/src/chunk.hpp
index 78412220..09af9bdb 100644
--- a/src/chunk.hpp
+++ b/src/chunk.hpp
@@ -23,11 +23,6 @@ template<typename Num, typename BB, typename BBE> struct collision_iterator;
template<typename Num, typename BB, typename BBE> struct collision_query;
struct collision_bbox;
-#ifdef FLOORMAT_64
-struct compact_bb;
-struct compact_bb_extractor;
-#endif
-
enum class collision : std::uint8_t {
view, shoot, move,
};
@@ -93,13 +88,8 @@ struct chunk final
void ensure_passability() noexcept;
-#ifdef FLOORMAT_64
- using BB = compact_bb;
- using BBE = compact_bb_extractor;
-#else
using BB = loose_quadtree::BoundingBox<std::int16_t>;
using BBE = loose_quadtree::TrivialBBExtractor<std::int16_t>;
-#endif
using lqt = loose_quadtree::LooseQuadtree<std::int16_t, BB, BBE>;
using Query = collision_query<std::int16_t, BB, BBE>;
diff --git a/src/collision.cpp b/src/collision.cpp
index 42ed2344..e2e4974d 100644
--- a/src/collision.cpp
+++ b/src/collision.cpp
@@ -3,12 +3,4 @@
namespace floormat {
-#ifdef FLOORMAT_64
-void compact_bb_extractor::ExtractBoundingBox(compact_bb* object, BB* bbox)
-{
- if constexpr(sizeof(void*) >= 8)
- *bbox = std::bit_cast<loose_quadtree::BoundingBox<std::int16_t>>((void*)object);
-}
-#endif
-
} // namespace floormat
diff --git a/src/collision.hpp b/src/collision.hpp
index 20ebedb8..086369fb 100644
--- a/src/collision.hpp
+++ b/src/collision.hpp
@@ -5,16 +5,6 @@
namespace floormat {
-#ifdef FLOORMAT_64
-struct compact_bb;
-
-struct compact_bb_extractor final
-{
- using BB = loose_quadtree::BoundingBox<std::int16_t>;
- [[maybe_unused]] static void ExtractBoundingBox(compact_bb* object, BB* bbox);
-};
-#endif
-
template<typename Num, typename BB, typename BBE>
struct collision_iterator final
{
diff --git a/src/scenery.cpp b/src/scenery.cpp
index 848029da..1a6be03e 100644
--- a/src/scenery.cpp
+++ b/src/scenery.cpp
@@ -28,8 +28,6 @@ scenery_ref& scenery_ref::operator=(const scenery_proto& proto) noexcept
scenery_ref::operator scenery_proto() const noexcept { return { atlas, frame }; }
scenery_ref::operator bool() const noexcept { return atlas != nullptr; }
-scenery::scenery() noexcept : scenery{none_tag_t{}} {}
-scenery::scenery(none_tag_t) noexcept {}
scenery::scenery(generic_tag_t, const anim_atlas& atlas, rotation r, frame_t frame,
pass_mode pass, bool active, bool interactive) :
frame{frame}, r{r}, type{scenery_type::generic},
diff --git a/src/scenery.hpp b/src/scenery.hpp
index ca577bc6..9186f9cf 100644
--- a/src/scenery.hpp
+++ b/src/scenery.hpp
@@ -1,5 +1,6 @@
#pragma once
#include "pass-mode.hpp"
+#include "tile-defs.hpp"
#include <cstdint>
#include <memory>
#include <type_traits>
@@ -36,7 +37,7 @@ struct scenery final
std::uint16_t delta = 0;
frame_t frame = 0;
- Vector2b offset;
+ Vector2b offset, bbox_size{iTILE_SIZE2/2}, bbox_offset;
rotation r : 3 = rotation::N;
scenery_type type : 3 = scenery_type::none;
pass_mode passability : 2 = pass_mode::shoot_through;
@@ -44,8 +45,8 @@ struct scenery final
std::uint8_t closing : 1 = false;
std::uint8_t interactive : 1 = false;
- scenery() noexcept;
- scenery(none_tag_t) noexcept;
+ constexpr scenery() noexcept;
+ constexpr scenery(none_tag_t) noexcept;
scenery(generic_tag_t, const anim_atlas& atlas, rotation r, frame_t frame = 0,
pass_mode passability = pass_mode::shoot_through, bool active = false, bool interactive = false);
scenery(door_tag_t, const anim_atlas& atlas, rotation r, bool is_open = false);
@@ -57,6 +58,9 @@ struct scenery final
void update(float dt, const anim_atlas& anim);
};
+constexpr scenery::scenery() noexcept : scenery{scenery::none_tag_t{}} {}
+constexpr scenery::scenery(none_tag_t) noexcept {}
+
struct scenery_proto final
{
std::shared_ptr<anim_atlas> atlas;