mirror of https://github.com/AxioDL/metaforce.git
CPASAnimState: Make use of size_t for indices
Same behavior, but plays nicer with containers. This can technically result in less zero-extensions with regards to memory indexing and registers, but this wasn't the underlying reason for the change.
This commit is contained in:
parent
4043b63721
commit
0b74a3e995
|
@ -5,15 +5,18 @@ namespace urde {
|
|||
CPASAnimInfo::CPASAnimInfo(u32 id, rstl::reserved_vector<CPASAnimParm::UParmValue, 8>&& parms)
|
||||
: x0_id(id), x4_parms(std::move(parms)) {}
|
||||
|
||||
CPASAnimParm::UParmValue CPASAnimInfo::GetAnimParmValue(u32 idx) const {
|
||||
if (idx >= x4_parms.size())
|
||||
CPASAnimParm::UParmValue CPASAnimInfo::GetAnimParmValue(size_t idx) const {
|
||||
if (idx >= x4_parms.size()) {
|
||||
return CPASAnimParm::UParmValue{};
|
||||
}
|
||||
return x4_parms[idx];
|
||||
}
|
||||
|
||||
CPASAnimParm CPASAnimInfo::GetAnimParmData(u32 idx, CPASAnimParm::EParmType type) const {
|
||||
if (idx >= x4_parms.size())
|
||||
CPASAnimParm CPASAnimInfo::GetAnimParmData(size_t idx, CPASAnimParm::EParmType type) const {
|
||||
if (idx >= x4_parms.size()) {
|
||||
return CPASAnimParm::NoParameter();
|
||||
}
|
||||
|
||||
const CPASAnimParm::UParmValue& parm = x4_parms[idx];
|
||||
|
||||
switch (type) {
|
||||
|
|
|
@ -14,8 +14,8 @@ public:
|
|||
explicit CPASAnimInfo(u32 id) : x0_id(id) {}
|
||||
explicit CPASAnimInfo(u32 id, rstl::reserved_vector<CPASAnimParm::UParmValue, 8>&& parms);
|
||||
u32 GetAnimId() const { return x0_id; }
|
||||
CPASAnimParm::UParmValue GetAnimParmValue(u32 idx) const;
|
||||
CPASAnimParm GetAnimParmData(u32, CPASAnimParm::EParmType) const;
|
||||
CPASAnimParm::UParmValue GetAnimParmValue(size_t idx) const;
|
||||
CPASAnimParm GetAnimParmData(size_t idx, CPASAnimParm::EParmType type) const;
|
||||
};
|
||||
|
||||
} // namespace urde
|
||||
|
|
|
@ -100,7 +100,7 @@ std::pair<float, s32> CPASAnimState::FindBestAnimation(const rstl::reserved_vect
|
|||
|
||||
u32 unweightedCount = 0;
|
||||
|
||||
for (u32 i = 0; i < x4_parms.size(); ++i) {
|
||||
for (size_t i = 0; i < x4_parms.size(); ++i) {
|
||||
CPASAnimParm::UParmValue val = info.GetAnimParmValue(i);
|
||||
const CPASParmInfo& parmInfo = x4_parms[i];
|
||||
float parmWeight = parmInfo.GetParameterWeight();
|
||||
|
@ -142,7 +142,7 @@ std::pair<float, s32> CPASAnimState::FindBestAnimation(const rstl::reserved_vect
|
|||
return {weight, PickRandomAnimation(rand)};
|
||||
}
|
||||
|
||||
float CPASAnimState::ComputeExactMatchWeight(u32, const CPASAnimParm& parm, CPASAnimParm::UParmValue parmVal) const {
|
||||
float CPASAnimState::ComputeExactMatchWeight(size_t, const CPASAnimParm& parm, CPASAnimParm::UParmValue parmVal) const {
|
||||
switch (parm.GetParameterType()) {
|
||||
case CPASAnimParm::EParmType::Int32:
|
||||
return (parm.GetInt32Value() == parmVal.m_int ? 1.f : 0.f);
|
||||
|
@ -161,7 +161,7 @@ float CPASAnimState::ComputeExactMatchWeight(u32, const CPASAnimParm& parm, CPAS
|
|||
return 0.f;
|
||||
}
|
||||
|
||||
float CPASAnimState::ComputePercentErrorWeight(u32 idx, const CPASAnimParm& parm,
|
||||
float CPASAnimState::ComputePercentErrorWeight(size_t idx, const CPASAnimParm& parm,
|
||||
CPASAnimParm::UParmValue parmVal) const {
|
||||
float range = 0.f;
|
||||
float val = 0.f;
|
||||
|
@ -205,7 +205,7 @@ float CPASAnimState::ComputePercentErrorWeight(u32 idx, const CPASAnimParm& parm
|
|||
return (val < FLT_EPSILON ? 1.f : 0.f);
|
||||
}
|
||||
|
||||
float CPASAnimState::ComputeAngularPercentErrorWeight(u32 idx, const CPASAnimParm& parm,
|
||||
float CPASAnimState::ComputeAngularPercentErrorWeight(size_t idx, const CPASAnimParm& parm,
|
||||
CPASAnimParm::UParmValue parmVal) const {
|
||||
float range = 0.f;
|
||||
float val = 0.f;
|
||||
|
|
|
@ -16,9 +16,9 @@ class CPASAnimState {
|
|||
std::vector<CPASAnimInfo> x14_anims;
|
||||
mutable std::vector<s32> x24_selectionCache;
|
||||
|
||||
float ComputeExactMatchWeight(u32 idx, const CPASAnimParm& parm, CPASAnimParm::UParmValue parmVal) const;
|
||||
float ComputePercentErrorWeight(u32 idx, const CPASAnimParm& parm, CPASAnimParm::UParmValue parmVal) const;
|
||||
float ComputeAngularPercentErrorWeight(u32 idx, const CPASAnimParm& parm, CPASAnimParm::UParmValue parmVal) const;
|
||||
float ComputeExactMatchWeight(size_t idx, const CPASAnimParm& parm, CPASAnimParm::UParmValue parmVal) const;
|
||||
float ComputePercentErrorWeight(size_t idx, const CPASAnimParm& parm, CPASAnimParm::UParmValue parmVal) const;
|
||||
float ComputeAngularPercentErrorWeight(size_t idx, const CPASAnimParm& parm, CPASAnimParm::UParmValue parmVal) const;
|
||||
|
||||
public:
|
||||
explicit CPASAnimState(CInputStream& in);
|
||||
|
|
Loading…
Reference in New Issue