Merge pull request #171 from lioncash/const

CPAS*: Minor cleanup
This commit is contained in:
Luke S 2020-02-28 10:37:36 -05:00 committed by GitHub
commit e7de5311c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 9 deletions

View File

@ -87,7 +87,7 @@ s32 CPASAnimState::PickRandomAnimation(CRandom16& rand) const {
std::pair<float, s32> CPASAnimState::FindBestAnimation(const rstl::reserved_vector<CPASAnimParm, 8>& parms, std::pair<float, s32> CPASAnimState::FindBestAnimation(const rstl::reserved_vector<CPASAnimParm, 8>& parms,
CRandom16& rand, s32 ignoreAnim) const { CRandom16& rand, s32 ignoreAnim) const {
const_cast<std::vector<s32>*>(&x24_selectionCache)->clear(); x24_selectionCache.clear();
float weight = -1.f; float weight = -1.f;
for (const CPASAnimInfo& info : x14_anims) { for (const CPASAnimInfo& info : x14_anims) {
@ -130,11 +130,11 @@ std::pair<float, s32> CPASAnimState::FindBestAnimation(const rstl::reserved_vect
calcWeight = 1.0f; calcWeight = 1.0f;
if (calcWeight > weight) { if (calcWeight > weight) {
const_cast<std::vector<s32>*>(&x24_selectionCache)->clear(); x24_selectionCache.clear();
const_cast<std::vector<s32>*>(&x24_selectionCache)->push_back(info.GetAnimId()); x24_selectionCache.push_back(info.GetAnimId());
weight = calcWeight; weight = calcWeight;
} else if (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; weight = calcWeight;
} }
} }

View File

@ -14,11 +14,11 @@ class CPASAnimState {
s32 x0_id; s32 x0_id;
std::vector<CPASParmInfo> x4_parms; std::vector<CPASParmInfo> x4_parms;
std::vector<CPASAnimInfo> x14_anims; std::vector<CPASAnimInfo> x14_anims;
std::vector<s32> x24_selectionCache; mutable std::vector<s32> x24_selectionCache;
public: public:
CPASAnimState(CInputStream& in); explicit CPASAnimState(CInputStream& in);
CPASAnimState(int stateId); explicit CPASAnimState(int stateId);
s32 GetStateId() const { return x0_id; } s32 GetStateId() const { return x0_id; }
s32 GetNumAnims() const { return x14_anims.size(); } s32 GetNumAnims() const { return x14_anims.size(); }
CPASAnimParm GetAnimParmData(s32, u32) const; CPASAnimParm GetAnimParmData(s32, u32) const;

View File

@ -18,7 +18,7 @@ class CPASDatabase {
void SetDefaultState(s32 state) { x10_defaultState = state; } void SetDefaultState(s32 state) { x10_defaultState = state; }
public: public:
CPASDatabase(CInputStream& in); explicit CPASDatabase(CInputStream& in);
std::pair<float, s32> FindBestAnimation(const CPASAnimParmData&, s32) const; std::pair<float, s32> FindBestAnimation(const CPASAnimParmData&, s32) const;
std::pair<float, s32> FindBestAnimation(const CPASAnimParmData&, CRandom16&, s32) const; std::pair<float, s32> FindBestAnimation(const CPASAnimParmData&, CRandom16&, s32) const;

View File

@ -9,6 +9,7 @@ class CPASParmInfo {
public: public:
enum class EWeightFunction { ExactMatch, PercentError, AngularPercent, NoWeight }; enum class EWeightFunction { ExactMatch, PercentError, AngularPercent, NoWeight };
private:
CPASAnimParm::EParmType x0_type; CPASAnimParm::EParmType x0_type;
EWeightFunction x4_weightFunction; EWeightFunction x4_weightFunction;
float x8_weight; float x8_weight;
@ -16,7 +17,7 @@ public:
CPASAnimParm::UParmValue x10_max; CPASAnimParm::UParmValue x10_max;
public: public:
CPASParmInfo(CInputStream& in); explicit CPASParmInfo(CInputStream& in);
CPASAnimParm::EParmType GetParameterType() const { return x0_type; } CPASAnimParm::EParmType GetParameterType() const { return x0_type; }
EWeightFunction GetWeightFunction() const { return x4_weightFunction; } EWeightFunction GetWeightFunction() const { return x4_weightFunction; }
float GetParameterWeight() const { return x8_weight; } float GetParameterWeight() const { return x8_weight; }