2022-10-09 05:13:17 +00:00
|
|
|
#ifndef _CSORTEDLISTS
|
|
|
|
#define _CSORTEDLISTS
|
2022-08-13 02:48:34 +00:00
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
|
|
|
|
#include "MetroidPrime/CObjectList.hpp"
|
|
|
|
|
|
|
|
#include "Kyoto/Math/CAABox.hpp"
|
|
|
|
|
|
|
|
class CActor;
|
|
|
|
|
|
|
|
namespace SL {
|
2023-11-13 23:41:51 +00:00
|
|
|
enum ESortedLists {
|
|
|
|
kSL_MinX,
|
|
|
|
kSL_MinY,
|
|
|
|
kSL_MinZ,
|
|
|
|
kSL_MaxX,
|
|
|
|
kSL_MaxY,
|
|
|
|
kSL_MaxZ,
|
|
|
|
};
|
|
|
|
|
2022-08-13 02:48:34 +00:00
|
|
|
struct SNode {
|
|
|
|
CActor* x0_actor;
|
|
|
|
CAABox x4_box;
|
2022-10-09 05:37:23 +00:00
|
|
|
short x1c_selfIdxs[6];
|
|
|
|
short x28_next;
|
2022-08-13 02:48:34 +00:00
|
|
|
bool x2a_populated;
|
2023-11-13 23:41:51 +00:00
|
|
|
|
|
|
|
SNode();
|
|
|
|
SNode(CActor* actor, const CAABox& box);
|
2022-08-13 02:48:34 +00:00
|
|
|
};
|
|
|
|
CHECK_SIZEOF(SNode, 0x2c);
|
|
|
|
|
|
|
|
struct SSortedList {
|
2022-10-09 05:37:23 +00:00
|
|
|
short x0_ids[kMaxObjects];
|
2022-09-05 04:01:13 +00:00
|
|
|
uint x800_size;
|
2023-11-13 23:41:51 +00:00
|
|
|
|
|
|
|
SSortedList() : x800_size(0) {
|
|
|
|
for (int i = 0; i < kMaxObjects; ++i) {
|
|
|
|
x0_ids[i] = -1;
|
|
|
|
}
|
|
|
|
}
|
2022-08-13 02:48:34 +00:00
|
|
|
};
|
|
|
|
CHECK_SIZEOF(SSortedList, 0x804);
|
|
|
|
|
|
|
|
class CSortedListManager {
|
2022-11-15 01:08:30 +00:00
|
|
|
public:
|
|
|
|
CSortedListManager();
|
2023-11-13 23:41:51 +00:00
|
|
|
void Reset();
|
|
|
|
bool ActorInLists(const CActor* actor) const;
|
|
|
|
short FindInListLower(ESortedLists list, f32 value) const;
|
|
|
|
short FindInListUpper(ESortedLists list, f32 value) const;
|
|
|
|
void InsertInList(ESortedLists list, SNode& node);
|
|
|
|
void RemoveFromList(ESortedLists list, short idx);
|
|
|
|
void MoveInList(ESortedLists list, short idx);
|
|
|
|
void Insert(CActor* actor, const CAABox& box);
|
|
|
|
void Remove(const CActor* actor);
|
|
|
|
void Move(const CActor* actor, const CAABox& box);
|
|
|
|
void AddToLinkedList(short nodeId, short& headId, short& tailId) const;
|
|
|
|
short CalculateIntersections(ESortedLists la, ESortedLists lb, short a, short b, short c, short d,
|
|
|
|
ESortedLists slA, ESortedLists slB, ESortedLists slC,
|
|
|
|
ESortedLists slD, const CAABox& aabb) const;
|
|
|
|
short ConstructIntersectionArray(const CAABox& aabb) const;
|
|
|
|
void BuildNearList(rstl::reserved_vector< TUniqueId, 1024 >& nearListOut, const CAABox& box,
|
|
|
|
const CMaterialFilter& filter, const CActor* actor) const;
|
|
|
|
|
|
|
|
void BuildNearList(rstl::reserved_vector< TUniqueId, 1024 >& nearListOut, const CActor& actor,
|
|
|
|
const CAABox& box) const;
|
|
|
|
void BuildNearList(rstl::reserved_vector< TUniqueId, 1024 >& nearListOut, const CVector3f& pos,
|
|
|
|
const CVector3f& dir, f32 mag, const CMaterialFilter& filter,
|
|
|
|
const CActor* actor) const;
|
2022-11-15 01:08:30 +00:00
|
|
|
|
|
|
|
private:
|
2022-08-13 02:48:34 +00:00
|
|
|
SNode x0_nodes[kMaxObjects];
|
|
|
|
SSortedList xb000_sortedLists[6];
|
|
|
|
};
|
|
|
|
CHECK_SIZEOF(CSortedListManager, 0xe018);
|
|
|
|
} // namespace SL
|
|
|
|
|
2022-10-09 05:13:17 +00:00
|
|
|
#endif // _CSORTEDLISTS
|