Match and link CMaterialList, nearly match CMaterialFilter

Former-commit-id: e25205bd69
This commit is contained in:
Phillip Stephens 2022-10-06 10:00:17 -07:00
parent 291515c5ee
commit 569b210e37
5 changed files with 46 additions and 3 deletions

View File

@ -28,6 +28,7 @@ COMPLETE_OBJECTS = [
"MetroidPrime/HUD/CHUDMemoParms", "MetroidPrime/HUD/CHUDMemoParms",
"MetroidPrime/ScriptObjects/CScriptDebugCameraWaypoint", "MetroidPrime/ScriptObjects/CScriptDebugCameraWaypoint",
"Weapons/IWeaponRenderer", "Weapons/IWeaponRenderer",
"Collision/CMaterialList",
"Collision/CMRay", "Collision/CMRay",
"Kyoto/Basics/CStopwatch", "Kyoto/Basics/CStopwatch",
"Kyoto/Basics/COsContextDolphin", "Kyoto/Basics/COsContextDolphin",

View File

@ -6,6 +6,7 @@
#include "Collision/CMaterialList.hpp" #include "Collision/CMaterialList.hpp"
class CMaterialFilter { class CMaterialFilter {
static const CMaterialFilter skPassEverything;
public: public:
enum EFilterType { enum EFilterType {
kFT_Always, kFT_Always,
@ -14,7 +15,7 @@ public:
kFT_IncludeExclude, kFT_IncludeExclude,
}; };
CMaterialFilter() : type(kFT_Always) {} CMaterialFilter() : include(0x00000000FFFFFFFF), exclude(0), type(kFT_Always) {}
CMaterialFilter(const CMaterialList& include, const CMaterialList& exclude, EFilterType type) CMaterialFilter(const CMaterialList& include, const CMaterialList& exclude, EFilterType type)
: include(include), exclude(exclude), type(type) {} : include(include), exclude(exclude), type(type) {}
@ -29,6 +30,8 @@ public:
return CMaterialFilter(include, exclude, kFT_IncludeExclude); return CMaterialFilter(include, exclude, kFT_IncludeExclude);
} }
bool Passes(const CMaterialList& other) const;
private: private:
CMaterialList include; CMaterialList include;
CMaterialList exclude; CMaterialList exclude;

View File

@ -116,9 +116,11 @@ public:
// HasMaterials__13CMaterialListCFv weak // HasMaterials__13CMaterialListCFv weak
// GetField__13CMaterialListCFUxUx weak // GetField__13CMaterialListCFUxUx weak
// Intersection__13CMaterialListCFRC13CMaterialList weak // Intersection__13CMaterialListCFRC13CMaterialList weak
// BitPosition__13CMaterialListFUx global static s32 BitPosition(u64 flags);
// GetMaterialString__13CMaterialListCFv weak // GetMaterialString__13CMaterialListCFv weak
// SharesMaterials__13CMaterialListCFRC13CMaterialList weak u64 SharesMaterials(const CMaterialList& other) const {
return (other.value & value);
}
private: private:
u64 value; u64 value;

View File

@ -0,0 +1,25 @@
#include "Collision/CMaterialFilter.hpp"
const CMaterialFilter CMaterialFilter::skPassEverything;
bool CMaterialFilter::Passes(const CMaterialList& other) const {
switch (type) {
case kFT_Always:
return true;
case kFT_Include:
return other.SharesMaterials(include) != 0 ? true : false;
case kFT_Exclude:
return other.SharesMaterials(exclude) == 0;
case kFT_IncludeExclude: {
bool ret = false;
if (other.SharesMaterials(include) != 0) {
if (other.SharesMaterials(exclude) == 0) {
ret = true;
}
}
return ret;
}
default:
return true;
}
}

View File

@ -0,0 +1,12 @@
#include "Collision/CMaterialList.hpp"
s32 CMaterialList::BitPosition(u64 flags) {
for (int ret = 0, i = 0; i < 32; ++i) {
if ((flags & 1) != 0) {
return ret;
}
flags >>= 1;
++ret;
}
return -1;
}