mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 08:27:42 +00:00
CPASAnimState: Remove const_cast usages
A cache is typically a use case for mutable (as the outside user of the class wouldn't directly rely on the cache as part of the API, this would only function to assist the API perform better), so we can mark the selection cache as mutable and make the code nicer to read overall.
This commit is contained in:
@@ -87,7 +87,7 @@ s32 CPASAnimState::PickRandomAnimation(CRandom16& rand) const {
|
||||
|
||||
std::pair<float, s32> CPASAnimState::FindBestAnimation(const rstl::reserved_vector<CPASAnimParm, 8>& parms,
|
||||
CRandom16& rand, s32 ignoreAnim) const {
|
||||
const_cast<std::vector<s32>*>(&x24_selectionCache)->clear();
|
||||
x24_selectionCache.clear();
|
||||
float weight = -1.f;
|
||||
|
||||
for (const CPASAnimInfo& info : x14_anims) {
|
||||
@@ -130,11 +130,11 @@ std::pair<float, s32> CPASAnimState::FindBestAnimation(const rstl::reserved_vect
|
||||
calcWeight = 1.0f;
|
||||
|
||||
if (calcWeight > weight) {
|
||||
const_cast<std::vector<s32>*>(&x24_selectionCache)->clear();
|
||||
const_cast<std::vector<s32>*>(&x24_selectionCache)->push_back(info.GetAnimId());
|
||||
x24_selectionCache.clear();
|
||||
x24_selectionCache.push_back(info.GetAnimId());
|
||||
weight = calcWeight;
|
||||
} else if (weight == calcWeight) {
|
||||
const_cast<std::vector<s32>*>(&x24_selectionCache)->push_back(info.GetAnimId());
|
||||
x24_selectionCache.push_back(info.GetAnimId());
|
||||
weight = calcWeight;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class CPASAnimState {
|
||||
s32 x0_id;
|
||||
std::vector<CPASParmInfo> x4_parms;
|
||||
std::vector<CPASAnimInfo> x14_anims;
|
||||
std::vector<s32> x24_selectionCache;
|
||||
mutable std::vector<s32> x24_selectionCache;
|
||||
|
||||
public:
|
||||
CPASAnimState(CInputStream& in);
|
||||
|
||||
Reference in New Issue
Block a user