Initial CSortedLists matching

Former-commit-id: a322c29e91f35ad778af21b670d594dfd868dd9e
This commit is contained in:
Phillip Stephens 2023-11-13 15:41:51 -08:00
parent 9843c3b263
commit 01b60994cb
4 changed files with 172 additions and 4 deletions

View File

@ -7391,7 +7391,7 @@ FindInListLower__Q22SL18CSortedListManagerCFQ22SL12ESortedListsf = .text:0x8014A
ActorInLists__Q22SL18CSortedListManagerCFPC6CActor = .text:0x8014A4EC; // type:function size:0x34 scope:global ActorInLists__Q22SL18CSortedListManagerCFPC6CActor = .text:0x8014A4EC; // type:function size:0x34 scope:global
Reset__Q22SL18CSortedListManagerFv = .text:0x8014A520; // type:function size:0x508 scope:global Reset__Q22SL18CSortedListManagerFv = .text:0x8014A520; // type:function size:0x508 scope:global
__ct__Q22SL18CSortedListManagerFv = .text:0x8014AA28; // type:function size:0x6C scope:global __ct__Q22SL18CSortedListManagerFv = .text:0x8014AA28; // type:function size:0x6C scope:global
__ct__Q22SL11SSortedListFv = .text:0x8014AA94; // type:function size:0xA4 scope:global __ct__Q22SL11SSortedListFv = .text:0x8014AA94; // type:function size:0xA4 scope:weak
__ct__Q22SL5SNodeFP6CActorRC6CAABox = .text:0x8014AB38; // type:function size:0x60 scope:global __ct__Q22SL5SNodeFP6CActorRC6CAABox = .text:0x8014AB38; // type:function size:0x60 scope:global
__ct__Q22SL5SNodeFv = .text:0x8014AB98; // type:function size:0x4C scope:global __ct__Q22SL5SNodeFv = .text:0x8014AB98; // type:function size:0x4C scope:global
__dt__26CScriptDebugCameraWaypointFv = .text:0x8014ABE4; // type:function size:0x60 scope:global __dt__26CScriptDebugCameraWaypointFv = .text:0x8014ABE4; // type:function size:0x60 scope:global
@ -10404,7 +10404,7 @@ OnSliderChanged__14COptionsScreenFP15CGuiSliderGroupf = .text:0x8024309C; // typ
UpdateOptionView__14COptionsScreenFv = .text:0x80243100; // type:function size:0x248 scope:global UpdateOptionView__14COptionsScreenFv = .text:0x80243100; // type:function size:0x248 scope:global
ResetOptionWidgetVisibility__14COptionsScreenFv = .text:0x80243348; // type:function size:0x74 scope:global ResetOptionWidgetVisibility__14COptionsScreenFv = .text:0x80243348; // type:function size:0x74 scope:global
RightTableSelectionChanged__14COptionsScreenFii = .text:0x802433BC; // type:function size:0x20 scope:global RightTableSelectionChanged__14COptionsScreenFii = .text:0x802433BC; // type:function size:0x20 scope:global
ChangedMode__14COptionsScreenQ216CPauseScreenBase5EMode = .text:0x802433DC; // type:function size:0x6C scope:global ChangedMode__14COptionsScreenFQ216CPauseScreenBase5EMode = .text:0x802433DC; // type:function size:0x6C scope:global
UpdateRightTable__14COptionsScreenFv = .text:0x80243448; // type:function size:0xDC scope:global UpdateRightTable__14COptionsScreenFv = .text:0x80243448; // type:function size:0xDC scope:global
GetRightTableCount__14COptionsScreenCFv = .text:0x80243524; // type:function size:0x1C scope:global GetRightTableCount__14COptionsScreenCFv = .text:0x80243524; // type:function size:0x1C scope:global
ShouldLeftTableAdvance__14COptionsScreenFv = .text:0x80243540; // type:function size:0x1C scope:global ShouldLeftTableAdvance__14COptionsScreenFv = .text:0x80243540; // type:function size:0x1C scope:global

View File

@ -7394,7 +7394,7 @@ FindInListLower__Q22SL18CSortedListManagerCFQ22SL12ESortedListsf = .text:0x8014A
ActorInLists__Q22SL18CSortedListManagerCFPC6CActor = .text:0x8014A568; // type:function size:0x34 scope:global ActorInLists__Q22SL18CSortedListManagerCFPC6CActor = .text:0x8014A568; // type:function size:0x34 scope:global
Reset__Q22SL18CSortedListManagerFv = .text:0x8014A59C; // type:function size:0x508 scope:global Reset__Q22SL18CSortedListManagerFv = .text:0x8014A59C; // type:function size:0x508 scope:global
__ct__Q22SL18CSortedListManagerFv = .text:0x8014AAA4; // type:function size:0x6C scope:global __ct__Q22SL18CSortedListManagerFv = .text:0x8014AAA4; // type:function size:0x6C scope:global
__ct__Q22SL11SSortedListFv = .text:0x8014AB10; // type:function size:0xA4 scope:global __ct__Q22SL11SSortedListFv = .text:0x8014AB10; // type:function size:0xA4 scope:weak
__ct__Q22SL5SNodeFP6CActorRC6CAABox = .text:0x8014ABB4; // type:function size:0x60 scope:global __ct__Q22SL5SNodeFP6CActorRC6CAABox = .text:0x8014ABB4; // type:function size:0x60 scope:global
__ct__Q22SL5SNodeFv = .text:0x8014AC14; // type:function size:0x4C scope:global __ct__Q22SL5SNodeFv = .text:0x8014AC14; // type:function size:0x4C scope:global
__dt__26CScriptDebugCameraWaypointFv = .text:0x8014AC60; // type:function size:0x60 scope:global __dt__26CScriptDebugCameraWaypointFv = .text:0x8014AC60; // type:function size:0x60 scope:global
@ -10414,7 +10414,7 @@ OnSliderChanged__14COptionsScreenFP15CGuiSliderGroupf = .text:0x80243118; // typ
UpdateOptionView__14COptionsScreenFv = .text:0x8024317C; // type:function size:0x248 scope:global UpdateOptionView__14COptionsScreenFv = .text:0x8024317C; // type:function size:0x248 scope:global
ResetOptionWidgetVisibility__14COptionsScreenFv = .text:0x802433C4; // type:function size:0x74 scope:global ResetOptionWidgetVisibility__14COptionsScreenFv = .text:0x802433C4; // type:function size:0x74 scope:global
RightTableSelectionChanged__14COptionsScreenFii = .text:0x80243438; // type:function size:0x20 scope:global RightTableSelectionChanged__14COptionsScreenFii = .text:0x80243438; // type:function size:0x20 scope:global
ChangedMode__14COptionsScreenQ216CPauseScreenBase5EMode = .text:0x80243458; // type:function size:0x6C scope:global ChangedMode__14COptionsScreenFQ216CPauseScreenBase5EMode = .text:0x80243458; // type:function size:0x6C scope:global
UpdateRightTable__14COptionsScreenFv = .text:0x802434C4; // type:function size:0xDC scope:global UpdateRightTable__14COptionsScreenFv = .text:0x802434C4; // type:function size:0xDC scope:global
GetRightTableCount__14COptionsScreenCFv = .text:0x802435A0; // type:function size:0x1C scope:global GetRightTableCount__14COptionsScreenCFv = .text:0x802435A0; // type:function size:0x1C scope:global
ShouldLeftTableAdvance__14COptionsScreenFv = .text:0x802435BC; // type:function size:0x1C scope:global ShouldLeftTableAdvance__14COptionsScreenFv = .text:0x802435BC; // type:function size:0x1C scope:global

View File

@ -10,24 +10,65 @@
class CActor; class CActor;
namespace SL { namespace SL {
enum ESortedLists {
kSL_MinX,
kSL_MinY,
kSL_MinZ,
kSL_MaxX,
kSL_MaxY,
kSL_MaxZ,
};
struct SNode { struct SNode {
CActor* x0_actor; CActor* x0_actor;
CAABox x4_box; CAABox x4_box;
short x1c_selfIdxs[6]; short x1c_selfIdxs[6];
short x28_next; short x28_next;
bool x2a_populated; bool x2a_populated;
SNode();
SNode(CActor* actor, const CAABox& box);
}; };
CHECK_SIZEOF(SNode, 0x2c); CHECK_SIZEOF(SNode, 0x2c);
struct SSortedList { struct SSortedList {
short x0_ids[kMaxObjects]; short x0_ids[kMaxObjects];
uint x800_size; uint x800_size;
SSortedList() : x800_size(0) {
for (int i = 0; i < kMaxObjects; ++i) {
x0_ids[i] = -1;
}
}
}; };
CHECK_SIZEOF(SSortedList, 0x804); CHECK_SIZEOF(SSortedList, 0x804);
class CSortedListManager { class CSortedListManager {
public: public:
CSortedListManager(); CSortedListManager();
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;
private: private:
SNode x0_nodes[kMaxObjects]; SNode x0_nodes[kMaxObjects];

View File

@ -0,0 +1,127 @@
#include <MetroidPrime/CActor.hpp>
#include <MetroidPrime/CSortedLists.hpp>
namespace SL {
SNode::SNode()
: x0_actor(nullptr), x4_box(CAABox::Identity()), x28_next(-1), x2a_populated(false) {}
SNode::SNode(CActor* actor, const CAABox& box)
: x0_actor(actor), x4_box(box), x28_next(-1), x2a_populated(true) {
for (int i = 0; i < 6; ++i) {
x1c_selfIdxs[i] = -1;
}
}
CSortedListManager::CSortedListManager() { Reset(); }
void CSortedListManager::Reset() {
SNode node;
for (uint i = 0; i < kMaxObjects; ++i) {
x0_nodes[i] = node;
}
for (int i = 0; i < 6; ++i) {
xb000_sortedLists[i] = SSortedList();
}
}
bool CSortedListManager::ActorInLists(const CActor* actor) const {
bool ret = false;
if (actor != nullptr && x0_nodes[actor->GetUniqueId().Value()].x2a_populated) {
ret = true;
}
return ret;
}
short CSortedListManager::FindInListLower(ESortedLists list, f32 value) const {}
short CSortedListManager::FindInListUpper(ESortedLists list, f32 value) const {}
void CSortedListManager::InsertInList(ESortedLists list, SNode& node) {}
void CSortedListManager::RemoveFromList(ESortedLists list, short idx) {}
void CSortedListManager::MoveInList(ESortedLists list, short idx) {}
void CSortedListManager::Insert(CActor* actor, const CAABox& box) {
if (x0_nodes[actor->GetUniqueId().Value()].x2a_populated) {
Move(actor, box);
return;
}
SNode node(actor, box);
InsertInList(kSL_MinX, node);
InsertInList(kSL_MaxX, node);
InsertInList(kSL_MinY, node);
InsertInList(kSL_MaxY, node);
InsertInList(kSL_MinZ, node);
InsertInList(kSL_MaxZ, node);
x0_nodes[actor->GetUniqueId().Value()] = node;
}
void CSortedListManager::Remove(const CActor* actor) {
if (actor == nullptr) {
return;
}
SNode& node = x0_nodes[actor->GetUniqueId().Value()];
if (node.x2a_populated) {
RemoveFromList(kSL_MinX, node.x1c_selfIdxs[kSL_MinX]);
RemoveFromList(kSL_MaxX, node.x1c_selfIdxs[kSL_MaxX]);
RemoveFromList(kSL_MinY, node.x1c_selfIdxs[kSL_MinY]);
RemoveFromList(kSL_MaxY, node.x1c_selfIdxs[kSL_MaxY]);
RemoveFromList(kSL_MinZ, node.x1c_selfIdxs[kSL_MinZ]);
RemoveFromList(kSL_MaxZ, node.x1c_selfIdxs[kSL_MaxZ]);
node.x2a_populated = false;
}
}
void CSortedListManager::Move(const CActor* actor, const CAABox& box) {
SNode& node = x0_nodes[actor->GetUniqueId().Value()];
node.x4_box = box;
MoveInList(kSL_MinX, node.x1c_selfIdxs[kSL_MinX]);
MoveInList(kSL_MaxX, node.x1c_selfIdxs[kSL_MaxX]);
MoveInList(kSL_MinY, node.x1c_selfIdxs[kSL_MinY]);
MoveInList(kSL_MaxY, node.x1c_selfIdxs[kSL_MaxY]);
MoveInList(kSL_MinZ, node.x1c_selfIdxs[kSL_MinZ]);
MoveInList(kSL_MaxZ, node.x1c_selfIdxs[kSL_MaxZ]);
}
void CSortedListManager::AddToLinkedList(short nodeId, short& headId, short& tailId) const {
if (headId == -1) {
const_cast<SNode&>(x0_nodes[nodeId]).x28_next = headId;
tailId = nodeId;
headId = nodeId;
return;
}
if (x0_nodes[nodeId].x28_next != -1) {
return;
}
if (nodeId == tailId) {
return;
}
const_cast<SNode&>(x0_nodes[nodeId]).x28_next = headId;
headId = nodeId;
}
short CSortedListManager::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 CSortedListManager::ConstructIntersectionArray(const CAABox& aabb) const {}
void CSortedListManager::BuildNearList(rstl::reserved_vector< TUniqueId, 1024 >& nearListOut,
const CAABox& box, const CMaterialFilter& filter,
const CActor* actor) const {}
void CSortedListManager::BuildNearList(rstl::reserved_vector< TUniqueId, 1024 >& nearListOut,
const CActor& actor, const CAABox& box) const {}
void CSortedListManager::BuildNearList(rstl::reserved_vector< TUniqueId, 1024 >& nearListOut,
const CVector3f& pos, const CVector3f& dir, f32 mag,
const CMaterialFilter& filter, const CActor* actor) const {}
} // namespace SL