mirror of https://github.com/AxioDL/metaforce.git
CMaterialFilter: Make interface constexpr
A few instances of CMaterialFilter are constructed at file-scope using the Make* functions and the constructor. Given these aren't constexpr, this means these are technically runtime function calls. We can make these constexpr to allow the initialization to be done at compile-time, slightly improving startup time.
This commit is contained in:
parent
0e39c64bfc
commit
2d8111531f
|
@ -3,38 +3,4 @@
|
|||
namespace urde {
|
||||
const CMaterialFilter CMaterialFilter::skPassEverything({0x00000000FFFFFFFF}, {0},
|
||||
CMaterialFilter::EFilterType::Always);
|
||||
|
||||
CMaterialFilter::CMaterialFilter(const CMaterialList& include, const CMaterialList& exclude,
|
||||
CMaterialFilter::EFilterType type)
|
||||
: x0_include(include), x8_exclude(exclude), x10_type(type) {}
|
||||
|
||||
CMaterialFilter CMaterialFilter::MakeInclude(const CMaterialList& include) {
|
||||
return CMaterialFilter(include, {0ull}, EFilterType::Include);
|
||||
}
|
||||
|
||||
CMaterialFilter CMaterialFilter::MakeExclude(const CMaterialList& exclude) {
|
||||
return CMaterialFilter({u64(0x00000000FFFFFFFF)}, exclude, EFilterType::Exclude);
|
||||
}
|
||||
|
||||
CMaterialFilter CMaterialFilter::MakeIncludeExclude(const CMaterialList& include, const CMaterialList& exclude) {
|
||||
return CMaterialFilter(include, exclude, EFilterType::IncludeExclude);
|
||||
}
|
||||
|
||||
bool CMaterialFilter::Passes(const CMaterialList& list) const {
|
||||
switch (x10_type) {
|
||||
case EFilterType::Always:
|
||||
return true;
|
||||
case EFilterType::Include:
|
||||
return (list.x0_list & x0_include.x0_list) != 0;
|
||||
case EFilterType::Exclude:
|
||||
return (list.x0_list & x8_exclude.x0_list) == 0;
|
||||
case EFilterType::IncludeExclude:
|
||||
if ((list.x0_list & x0_include.x0_list) == 0)
|
||||
return false;
|
||||
return (list.x0_list & x8_exclude.x0_list) == 0;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace urde
|
||||
|
|
|
@ -15,18 +15,42 @@ private:
|
|||
public:
|
||||
static const CMaterialFilter skPassEverything;
|
||||
|
||||
CMaterialFilter(const CMaterialList& include, const CMaterialList& exclude, EFilterType type);
|
||||
constexpr CMaterialFilter(const CMaterialList& include, const CMaterialList& exclude, EFilterType type) noexcept
|
||||
: x0_include(include), x8_exclude(exclude), x10_type(type) {}
|
||||
|
||||
static CMaterialFilter MakeInclude(const CMaterialList& include);
|
||||
static constexpr CMaterialFilter MakeInclude(const CMaterialList& include) noexcept {
|
||||
return CMaterialFilter(include, {}, EFilterType::Include);
|
||||
}
|
||||
|
||||
static CMaterialFilter MakeExclude(const CMaterialList& exclude);
|
||||
static constexpr CMaterialFilter MakeExclude(const CMaterialList& exclude) noexcept {
|
||||
return CMaterialFilter({u64(0x00000000FFFFFFFF)}, exclude, EFilterType::Exclude);
|
||||
}
|
||||
|
||||
static CMaterialFilter MakeIncludeExclude(const CMaterialList& include, const CMaterialList& exclude);
|
||||
static constexpr CMaterialFilter MakeIncludeExclude(const CMaterialList& include,
|
||||
const CMaterialList& exclude) noexcept {
|
||||
return CMaterialFilter(include, exclude, EFilterType::IncludeExclude);
|
||||
}
|
||||
|
||||
const CMaterialList& GetIncludeList() const { return x0_include; }
|
||||
const CMaterialList& GetExcludeList() const { return x8_exclude; }
|
||||
CMaterialList& IncludeList() { return x0_include; }
|
||||
CMaterialList& ExcludeList() { return x8_exclude; }
|
||||
bool Passes(const CMaterialList&) const;
|
||||
constexpr const CMaterialList& GetIncludeList() const noexcept { return x0_include; }
|
||||
constexpr const CMaterialList& GetExcludeList() const noexcept { return x8_exclude; }
|
||||
constexpr CMaterialList& IncludeList() noexcept { return x0_include; }
|
||||
constexpr CMaterialList& ExcludeList() noexcept { return x8_exclude; }
|
||||
|
||||
constexpr bool Passes(const CMaterialList& list) const noexcept {
|
||||
switch (x10_type) {
|
||||
case EFilterType::Always:
|
||||
return true;
|
||||
case EFilterType::Include:
|
||||
return (list.x0_list & x0_include.x0_list) != 0;
|
||||
case EFilterType::Exclude:
|
||||
return (list.x0_list & x8_exclude.x0_list) == 0;
|
||||
case EFilterType::IncludeExclude:
|
||||
if ((list.x0_list & x0_include.x0_list) == 0)
|
||||
return false;
|
||||
return (list.x0_list & x8_exclude.x0_list) == 0;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace urde
|
||||
|
|
Loading…
Reference in New Issue