From 98ad059806e1ec7d8fb3ff15d55658d2640c3930 Mon Sep 17 00:00:00 2001 From: Dave Corley Date: Tue, 2 Jan 2024 16:08:25 -0600 Subject: [PATCH] Cleanup(actoradapter): Use more explicit names & vec2 for racial height/weight --- apps/opencs/model/world/actoradapter.cpp | 14 ++++++------- apps/opencs/model/world/actoradapter.hpp | 26 ++++++++++++------------ apps/opencs/view/render/actor.cpp | 4 ++-- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/apps/opencs/model/world/actoradapter.cpp b/apps/opencs/model/world/actoradapter.cpp index f3c2161c73..40bfe17989 100644 --- a/apps/opencs/model/world/actoradapter.cpp +++ b/apps/opencs/model/world/actoradapter.cpp @@ -67,9 +67,9 @@ namespace CSMWorld return mMaleParts[ESM::getMeshPart(index)]; } - const std::pair& ActorAdapter::RaceData::getRaceAttributes(bool isFemale) + const osg::Vec2f& ActorAdapter::RaceData::getHeightWeight(bool isFemale) { - return isFemale == true ? mHeightsWeights.mFemaleAttributes : mHeightsWeights.mMaleAttributes; + return isFemale ? mHeightsWeights.mFemaleHeightWeight : mHeightsWeights.mMaleHeightWeight; } bool ActorAdapter::RaceData::hasDependency(const ESM::RefId& id) const @@ -95,7 +95,7 @@ namespace CSMWorld mDependencies.emplace(id); } - void ActorAdapter::RaceData::reset_data(const ESM::RefId& id, const BodyAttributes& raceStats, bool isBeast) + void ActorAdapter::RaceData::reset_data(const ESM::RefId& id, const HeightsWeights& raceStats, bool isBeast) { mId = id; mIsBeast = isBeast; @@ -169,9 +169,9 @@ namespace CSMWorld return it->second.first; } - const std::pair& ActorAdapter::ActorData::getRaceHeightWeight() const + const osg::Vec2f& ActorAdapter::ActorData::getRaceHeightWeight() const { - return mRaceData->getRaceAttributes(isFemale()); + return mRaceData->getHeightWeight(isFemale()); } bool ActorAdapter::ActorData::hasDependency(const ESM::RefId& id) const @@ -516,8 +516,8 @@ namespace CSMWorld auto& race = raceRecord.get(); - BodyAttributes scaleStats = BodyAttributes( - race.mData.mMaleHeight, race.mData.mMaleWeight, race.mData.mFemaleHeight, race.mData.mFemaleWeight); + HeightsWeights scaleStats = HeightsWeights(osg::Vec2f(race.mData.mMaleWeight, race.mData.mMaleHeight), + osg::Vec2f(race.mData.mFemaleWeight, race.mData.mFemaleHeight)); data->reset_data(id, scaleStats, race.mData.mFlags & ESM::Race::Beast); diff --git a/apps/opencs/model/world/actoradapter.hpp b/apps/opencs/model/world/actoradapter.hpp index 21298d33df..e516325455 100644 --- a/apps/opencs/model/world/actoradapter.hpp +++ b/apps/opencs/model/world/actoradapter.hpp @@ -41,22 +41,22 @@ namespace CSMWorld /// Tracks unique strings using RefIdSet = std::unordered_set; - class BodyAttributes + class HeightsWeights { public: - std::pair mMaleAttributes; - std::pair mFemaleAttributes; + osg::Vec2f mMaleHeightWeight; + osg::Vec2f mFemaleHeightWeight; - BodyAttributes() - : mMaleAttributes(std::make_pair(1.0f, 1.0f)) - , mFemaleAttributes(std::make_pair(1.0f, 1.0f)) + HeightsWeights() + : mMaleHeightWeight(osg::Vec2f(1.0f, 1.0f)) + , mFemaleHeightWeight(osg::Vec2f(1.0f, 1.0f)) { } - BodyAttributes(float maleHeight, float maleWeight, float femaleHeight, float femaleWeight) + HeightsWeights(const osg::Vec2f& maleHeightWeight, const osg::Vec2f& femaleHeightWeight) { - mMaleAttributes = std::make_pair(maleHeight, maleWeight); - mFemaleAttributes = std::make_pair(femaleHeight, femaleWeight); + mMaleHeightWeight = maleHeightWeight; + mFemaleHeightWeight = femaleHeightWeight; } }; @@ -77,7 +77,7 @@ namespace CSMWorld /// Retrieves the associated body part const ESM::RefId& getMalePart(ESM::PartReferenceType index) const; - const std::pair& getRaceAttributes(bool isFemale); + const osg::Vec2f& getHeightWeight(bool isFemale); /// Checks if the race has a data dependency bool hasDependency(const ESM::RefId& id) const; @@ -89,7 +89,7 @@ namespace CSMWorld void addOtherDependency(const ESM::RefId& id); /// Clears parts and dependencies void reset_data( - const ESM::RefId& raceId, const BodyAttributes& raceStats = BodyAttributes(), bool isBeast = false); + const ESM::RefId& raceId, const HeightsWeights& raceStats = HeightsWeights(), bool isBeast = false); private: bool handles(ESM::PartReferenceType type) const; @@ -97,7 +97,7 @@ namespace CSMWorld bool mIsBeast; RacePartList mFemaleParts; RacePartList mMaleParts; - BodyAttributes mHeightsWeights; + HeightsWeights mHeightsWeights; RefIdSet mDependencies; }; using RaceDataPtr = std::shared_ptr; @@ -120,7 +120,7 @@ namespace CSMWorld /// Retrieves the associated actor part ESM::RefId getPart(ESM::PartReferenceType index) const; - const std::pair& getRaceHeightWeight() const; + const osg::Vec2f& getRaceHeightWeight() const; /// Checks if the actor has a data dependency bool hasDependency(const ESM::RefId& id) const; diff --git a/apps/opencs/view/render/actor.cpp b/apps/opencs/view/render/actor.cpp index abe7b910de..e609efa5a1 100644 --- a/apps/opencs/view/render/actor.cpp +++ b/apps/opencs/view/render/actor.cpp @@ -63,9 +63,9 @@ namespace CSVRender // Attach parts to skeleton loadBodyParts(); - const std::pair attributes = mActorData.get()->getRaceHeightWeight(); + const osg::Vec2f& attributes = mActorData.get()->getRaceHeightWeight(); - mBaseNode->setScale(osg::Vec3d(attributes.second, attributes.second, attributes.first)); + mBaseNode->setScale(osg::Vec3d(attributes.x(), attributes.x(), attributes.y())); } else {