2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-04-16 21:49:47 +00:00
|
|
|
|
2019-09-15 22:56:13 +00:00
|
|
|
#include <array>
|
|
|
|
|
|
|
|
#include "Runtime/RetroTypes.hpp"
|
|
|
|
#include "Runtime/Collision/CMaterialFilter.hpp"
|
|
|
|
|
|
|
|
#include <zeus/CAABox.hpp>
|
2016-04-16 21:49:47 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2019-09-15 22:51:58 +00:00
|
|
|
enum class ESortedList { MinX, MinY, MinZ, MaxX, MaxY, MaxZ };
|
2016-04-16 21:49:47 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
struct SSortedList {
|
2021-06-06 23:53:41 +00:00
|
|
|
std::array<s16, kMaxEntities> x0_ids;
|
2018-12-08 05:30:43 +00:00
|
|
|
u32 x800_size = 0;
|
2019-09-15 22:56:13 +00:00
|
|
|
void Reset() { x0_ids.fill(-1); }
|
2018-12-08 05:30:43 +00:00
|
|
|
SSortedList() { Reset(); }
|
2016-04-16 21:49:47 +00:00
|
|
|
};
|
|
|
|
|
2017-01-04 04:08:30 +00:00
|
|
|
class CActor;
|
2018-12-08 05:30:43 +00:00
|
|
|
class CSortedListManager {
|
|
|
|
struct SNode {
|
|
|
|
const CActor* x0_actor = nullptr;
|
2019-02-24 07:15:54 +00:00
|
|
|
zeus::CAABox x4_box = zeus::skNullBox;
|
2019-09-15 22:56:13 +00:00
|
|
|
std::array<s16, 6> x1c_selfIdxs{-1, -1, -1, -1, -1, -1};
|
2018-12-08 05:30:43 +00:00
|
|
|
s16 x28_next = -1;
|
|
|
|
bool x2a_populated = false;
|
|
|
|
SNode() = default;
|
|
|
|
SNode(const CActor* act, const zeus::CAABox& aabb) : x0_actor(act), x4_box(aabb), x2a_populated(true) {}
|
|
|
|
};
|
2021-06-06 23:53:41 +00:00
|
|
|
std::array<SNode, kMaxEntities> x0_nodes;
|
2019-09-15 22:56:13 +00:00
|
|
|
std::array<SSortedList, 6> xb000_sortedLists;
|
2018-12-08 05:30:43 +00:00
|
|
|
void Reset();
|
2020-03-30 01:16:48 +00:00
|
|
|
void AddToLinkedList(s16 nodeId, s16& headId, s16& tailId);
|
|
|
|
void RemoveFromList(ESortedList list, s16 idx);
|
|
|
|
void MoveInList(ESortedList list, s16 idx);
|
|
|
|
void InsertInList(ESortedList list, SNode& node);
|
|
|
|
s16 FindInListUpper(ESortedList list, float value) const;
|
|
|
|
s16 FindInListLower(ESortedList list, float value) const;
|
|
|
|
s16 ConstructIntersectionArray(const zeus::CAABox& aabb);
|
|
|
|
s16 CalculateIntersections(ESortedList la, ESortedList lb, s16 a, s16 b, s16 c, s16 d, ESortedList slA,
|
|
|
|
ESortedList slB, ESortedList slC, ESortedList slD, const zeus::CAABox& aabb);
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2017-03-24 05:30:16 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CSortedListManager();
|
2021-06-07 19:29:18 +00:00
|
|
|
void BuildNearList(EntityList& out, const zeus::CVector3f& pos, const zeus::CVector3f& dir, float mag,
|
2020-03-30 01:20:46 +00:00
|
|
|
const CMaterialFilter& filter, const CActor* actor);
|
2021-06-07 19:29:18 +00:00
|
|
|
void BuildNearList(EntityList& out, const CActor& actor, const zeus::CAABox& aabb);
|
|
|
|
void BuildNearList(EntityList& out, const zeus::CAABox& aabb, const CMaterialFilter& filter, const CActor* actor);
|
2020-03-30 01:16:48 +00:00
|
|
|
void Remove(const CActor* actor);
|
|
|
|
void Move(const CActor* actor, const zeus::CAABox& aabb);
|
|
|
|
void Insert(const CActor* actor, const zeus::CAABox& aabb);
|
|
|
|
bool ActorInLists(const CActor* actor) const;
|
2016-04-16 21:49:47 +00:00
|
|
|
};
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|