1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-07-12 10:41:43 +00:00

Switch height/weight in names and make the stats a simple struct instead

This commit is contained in:
Dave Corley 2024-02-14 16:41:24 -06:00
parent 98ad059806
commit 1b1f0c4971
3 changed files with 17 additions and 31 deletions

View file

@ -67,9 +67,9 @@ namespace CSMWorld
return mMaleParts[ESM::getMeshPart(index)]; return mMaleParts[ESM::getMeshPart(index)];
} }
const osg::Vec2f& ActorAdapter::RaceData::getHeightWeight(bool isFemale) const osg::Vec2f& ActorAdapter::RaceData::getGenderWeightHeight(bool isFemale)
{ {
return isFemale ? mHeightsWeights.mFemaleHeightWeight : mHeightsWeights.mMaleHeightWeight; return isFemale ? mWeightsHeights.mFemaleWeightHeight : mWeightsHeights.mMaleWeightHeight;
} }
bool ActorAdapter::RaceData::hasDependency(const ESM::RefId& id) const bool ActorAdapter::RaceData::hasDependency(const ESM::RefId& id) const
@ -95,11 +95,11 @@ namespace CSMWorld
mDependencies.emplace(id); mDependencies.emplace(id);
} }
void ActorAdapter::RaceData::reset_data(const ESM::RefId& id, const HeightsWeights& raceStats, bool isBeast) void ActorAdapter::RaceData::reset_data(const ESM::RefId& id, const WeightsHeights& raceStats, bool isBeast)
{ {
mId = id; mId = id;
mIsBeast = isBeast; mIsBeast = isBeast;
mHeightsWeights = raceStats; mWeightsHeights = raceStats;
for (auto& str : mFemaleParts) for (auto& str : mFemaleParts)
str = ESM::RefId(); str = ESM::RefId();
for (auto& str : mMaleParts) for (auto& str : mMaleParts)
@ -169,9 +169,9 @@ namespace CSMWorld
return it->second.first; return it->second.first;
} }
const osg::Vec2f& ActorAdapter::ActorData::getRaceHeightWeight() const const osg::Vec2f& ActorAdapter::ActorData::getRaceWeightHeight() const
{ {
return mRaceData->getHeightWeight(isFemale()); return mRaceData->getGenderWeightHeight(isFemale());
} }
bool ActorAdapter::ActorData::hasDependency(const ESM::RefId& id) const bool ActorAdapter::ActorData::hasDependency(const ESM::RefId& id) const
@ -516,8 +516,8 @@ namespace CSMWorld
auto& race = raceRecord.get(); auto& race = raceRecord.get();
HeightsWeights scaleStats = HeightsWeights(osg::Vec2f(race.mData.mMaleWeight, race.mData.mMaleHeight), WeightsHeights scaleStats = { osg::Vec2f(race.mData.mMaleWeight, race.mData.mMaleHeight),
osg::Vec2f(race.mData.mFemaleWeight, race.mData.mFemaleHeight)); osg::Vec2f(race.mData.mFemaleWeight, race.mData.mFemaleHeight) };
data->reset_data(id, scaleStats, race.mData.mFlags & ESM::Race::Beast); data->reset_data(id, scaleStats, race.mData.mFlags & ESM::Race::Beast);

View file

@ -41,23 +41,10 @@ namespace CSMWorld
/// Tracks unique strings /// Tracks unique strings
using RefIdSet = std::unordered_set<ESM::RefId>; using RefIdSet = std::unordered_set<ESM::RefId>;
class HeightsWeights struct WeightsHeights
{ {
public: osg::Vec2f mMaleWeightHeight;
osg::Vec2f mMaleHeightWeight; osg::Vec2f mFemaleWeightHeight;
osg::Vec2f mFemaleHeightWeight;
HeightsWeights()
: mMaleHeightWeight(osg::Vec2f(1.0f, 1.0f))
, mFemaleHeightWeight(osg::Vec2f(1.0f, 1.0f))
{
}
HeightsWeights(const osg::Vec2f& maleHeightWeight, const osg::Vec2f& femaleHeightWeight)
{
mMaleHeightWeight = maleHeightWeight;
mFemaleHeightWeight = femaleHeightWeight;
}
}; };
/// Contains base race data shared between actors /// Contains base race data shared between actors
@ -77,7 +64,7 @@ namespace CSMWorld
/// Retrieves the associated body part /// Retrieves the associated body part
const ESM::RefId& getMalePart(ESM::PartReferenceType index) const; const ESM::RefId& getMalePart(ESM::PartReferenceType index) const;
const osg::Vec2f& getHeightWeight(bool isFemale); const osg::Vec2f& getGenderWeightHeight(bool isFemale);
/// Checks if the race has a data dependency /// Checks if the race has a data dependency
bool hasDependency(const ESM::RefId& id) const; bool hasDependency(const ESM::RefId& id) const;
@ -88,8 +75,8 @@ namespace CSMWorld
/// Marks an additional dependency /// Marks an additional dependency
void addOtherDependency(const ESM::RefId& id); void addOtherDependency(const ESM::RefId& id);
/// Clears parts and dependencies /// Clears parts and dependencies
void reset_data( void reset_data(const ESM::RefId& raceId,
const ESM::RefId& raceId, const HeightsWeights& raceStats = HeightsWeights(), bool isBeast = false); const WeightsHeights& raceStats = { osg::Vec2f(1.f, 1.f), osg::Vec2f(1.f, 1.f) }, bool isBeast = false);
private: private:
bool handles(ESM::PartReferenceType type) const; bool handles(ESM::PartReferenceType type) const;
@ -97,7 +84,7 @@ namespace CSMWorld
bool mIsBeast; bool mIsBeast;
RacePartList mFemaleParts; RacePartList mFemaleParts;
RacePartList mMaleParts; RacePartList mMaleParts;
HeightsWeights mHeightsWeights; WeightsHeights mWeightsHeights;
RefIdSet mDependencies; RefIdSet mDependencies;
}; };
using RaceDataPtr = std::shared_ptr<RaceData>; using RaceDataPtr = std::shared_ptr<RaceData>;
@ -120,7 +107,7 @@ namespace CSMWorld
/// Retrieves the associated actor part /// Retrieves the associated actor part
ESM::RefId getPart(ESM::PartReferenceType index) const; ESM::RefId getPart(ESM::PartReferenceType index) const;
const osg::Vec2f& getRaceHeightWeight() const; const osg::Vec2f& getRaceWeightHeight() const;
/// Checks if the actor has a data dependency /// Checks if the actor has a data dependency
bool hasDependency(const ESM::RefId& id) const; bool hasDependency(const ESM::RefId& id) const;

View file

@ -21,7 +21,6 @@
#include <components/sceneutil/attach.hpp> #include <components/sceneutil/attach.hpp>
#include <components/sceneutil/skeleton.hpp> #include <components/sceneutil/skeleton.hpp>
#include "../../model/world/columns.hpp"
#include "../../model/world/data.hpp" #include "../../model/world/data.hpp"
namespace CSVRender namespace CSVRender
@ -63,7 +62,7 @@ namespace CSVRender
// Attach parts to skeleton // Attach parts to skeleton
loadBodyParts(); loadBodyParts();
const osg::Vec2f& attributes = mActorData.get()->getRaceHeightWeight(); const osg::Vec2f& attributes = mActorData->getRaceWeightHeight();
mBaseNode->setScale(osg::Vec3d(attributes.x(), attributes.x(), attributes.y())); mBaseNode->setScale(osg::Vec3d(attributes.x(), attributes.x(), attributes.y()));
} }