mirror of
https://github.com/OpenMW/openmw.git
synced 2025-05-01 06:11:25 +00:00
Support not only StringRefId for checking first person body part
This commit is contained in:
parent
e6cf516e12
commit
04d7781424
11 changed files with 40 additions and 21 deletions
|
@ -425,11 +425,6 @@ namespace CSMWorld
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ActorAdapter::is1stPersonPart(const std::string& name) const
|
|
||||||
{
|
|
||||||
return name.size() >= 4 && name.find(".1st", name.size() - 4) != std::string::npos;
|
|
||||||
}
|
|
||||||
|
|
||||||
ActorAdapter::RaceDataPtr ActorAdapter::getRaceData(const ESM::RefId& id)
|
ActorAdapter::RaceDataPtr ActorAdapter::getRaceData(const ESM::RefId& id)
|
||||||
{
|
{
|
||||||
// Return cached race data if it exists
|
// Return cached race data if it exists
|
||||||
|
@ -519,8 +514,7 @@ namespace CSMWorld
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& part = partRecord.get();
|
auto& part = partRecord.get();
|
||||||
if (part.mRace == id && part.mData.mType == ESM::BodyPart::MT_Skin
|
if (part.mRace == id && part.mData.mType == ESM::BodyPart::MT_Skin && !ESM::isFirstPersonBodyPart(part))
|
||||||
&& !is1stPersonPart(part.mId.getRefIdString()))
|
|
||||||
{
|
{
|
||||||
auto type = (ESM::BodyPart::MeshPart)part.mData.mPart;
|
auto type = (ESM::BodyPart::MeshPart)part.mData.mPart;
|
||||||
bool female = part.mData.mFlags & ESM::BodyPart::BPF_Female;
|
bool female = part.mData.mFlags & ESM::BodyPart::BPF_Female;
|
||||||
|
|
|
@ -149,7 +149,6 @@ namespace CSMWorld
|
||||||
ActorAdapter& operator=(const ActorAdapter&) = delete;
|
ActorAdapter& operator=(const ActorAdapter&) = delete;
|
||||||
|
|
||||||
QModelIndex getHighestIndex(QModelIndex) const;
|
QModelIndex getHighestIndex(QModelIndex) const;
|
||||||
bool is1stPersonPart(const std::string& id) const;
|
|
||||||
|
|
||||||
RaceDataPtr getRaceData(const ESM::RefId& raceId);
|
RaceDataPtr getRaceData(const ESM::RefId& raceId);
|
||||||
|
|
||||||
|
|
|
@ -321,7 +321,6 @@ namespace MWGui
|
||||||
|
|
||||||
for (const ESM::BodyPart& bodypart : store)
|
for (const ESM::BodyPart& bodypart : store)
|
||||||
{
|
{
|
||||||
const std::string& idString = bodypart.mId.getRefIdString();
|
|
||||||
if (bodypart.mData.mFlags & ESM::BodyPart::BPF_NotPlayable)
|
if (bodypart.mData.mFlags & ESM::BodyPart::BPF_NotPlayable)
|
||||||
continue;
|
continue;
|
||||||
if (bodypart.mData.mType != ESM::BodyPart::MT_Skin)
|
if (bodypart.mData.mType != ESM::BodyPart::MT_Skin)
|
||||||
|
@ -330,8 +329,7 @@ namespace MWGui
|
||||||
continue;
|
continue;
|
||||||
if (mGenderIndex != (bodypart.mData.mFlags & ESM::BodyPart::BPF_Female))
|
if (mGenderIndex != (bodypart.mData.mFlags & ESM::BodyPart::BPF_Female))
|
||||||
continue;
|
continue;
|
||||||
bool firstPerson = Misc::StringUtils::ciEndsWith(idString, "1st");
|
if (ESM::isFirstPersonBodyPart(bodypart))
|
||||||
if (firstPerson)
|
|
||||||
continue;
|
continue;
|
||||||
if (bodypart.mRace == mCurrentRaceId)
|
if (bodypart.mRace == mCurrentRaceId)
|
||||||
out.push_back(bodypart.mId);
|
out.push_back(bodypart.mId);
|
||||||
|
|
|
@ -85,7 +85,6 @@ namespace
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
|
|
||||||
class HeadAnimationTime : public SceneUtil::ControllerSource
|
class HeadAnimationTime : public SceneUtil::ControllerSource
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -761,12 +760,6 @@ namespace MWRender
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NpcAnimation::isFirstPersonPart(const ESM::BodyPart* bodypart)
|
|
||||||
{
|
|
||||||
std::string_view partName = bodypart->mId.getRefIdString();
|
|
||||||
return partName.size() >= 3 && partName.substr(partName.size() - 3, 3) == "1st";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NpcAnimation::isFemalePart(const ESM::BodyPart* bodypart)
|
bool NpcAnimation::isFemalePart(const ESM::BodyPart* bodypart)
|
||||||
{
|
{
|
||||||
return bodypart->mData.mFlags & ESM::BodyPart::BPF_Female;
|
return bodypart->mData.mFlags & ESM::BodyPart::BPF_Female;
|
||||||
|
@ -1220,7 +1213,7 @@ namespace MWRender
|
||||||
if (!(bodypart.mRace == race))
|
if (!(bodypart.mRace == race))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool partFirstPerson = isFirstPersonPart(&bodypart);
|
const bool partFirstPerson = ESM::isFirstPersonBodyPart(bodypart);
|
||||||
|
|
||||||
bool isHand = bodypart.mData.mPart == ESM::BodyPart::MP_Hand
|
bool isHand = bodypart.mData.mPart == ESM::BodyPart::MP_Hand
|
||||||
|| bodypart.mData.mPart == ESM::BodyPart::MP_Wrist
|
|| bodypart.mData.mPart == ESM::BodyPart::MP_Wrist
|
||||||
|
@ -1277,7 +1270,7 @@ namespace MWRender
|
||||||
parts[bIt->second] = &bodypart;
|
parts[bIt->second] = &bodypart;
|
||||||
|
|
||||||
// If we have 3d person fallback bodypart for hand and 1st person fallback found (2)
|
// If we have 3d person fallback bodypart for hand and 1st person fallback found (2)
|
||||||
else if (isHand && !isFirstPersonPart(parts[bIt->second]) && partFirstPerson)
|
else if (isHand && !ESM::isFirstPersonBodyPart(*parts[bIt->second]) && partFirstPerson)
|
||||||
parts[bIt->second] = &bodypart;
|
parts[bIt->second] = &bodypart;
|
||||||
|
|
||||||
++bIt;
|
++bIt;
|
||||||
|
|
|
@ -99,7 +99,6 @@ namespace MWRender
|
||||||
|
|
||||||
osg::ref_ptr<RotateController> mFirstPersonNeckController;
|
osg::ref_ptr<RotateController> mFirstPersonNeckController;
|
||||||
|
|
||||||
static bool isFirstPersonPart(const ESM::BodyPart* bodypart);
|
|
||||||
static bool isFemalePart(const ESM::BodyPart* bodypart);
|
static bool isFemalePart(const ESM::BodyPart* bodypart);
|
||||||
static NpcType getNpcType(const MWWorld::Ptr& ptr);
|
static NpcType getNpcType(const MWWorld::Ptr& ptr);
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,19 @@ namespace ESM
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct EndsWith
|
||||||
|
{
|
||||||
|
const std::string_view mSuffix;
|
||||||
|
|
||||||
|
bool operator()(StringRefId v) const { return v.endsWith(mSuffix); }
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
bool operator()(const T& /*v*/) const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct Contains
|
struct Contains
|
||||||
{
|
{
|
||||||
const std::string_view mSubString;
|
const std::string_view mSubString;
|
||||||
|
@ -155,6 +168,11 @@ namespace ESM
|
||||||
return std::visit(StartsWith{ prefix }, mValue);
|
return std::visit(StartsWith{ prefix }, mValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RefId::endsWith(std::string_view suffix) const
|
||||||
|
{
|
||||||
|
return std::visit(EndsWith{ suffix }, mValue);
|
||||||
|
}
|
||||||
|
|
||||||
bool RefId::contains(std::string_view subString) const
|
bool RefId::contains(std::string_view subString) const
|
||||||
{
|
{
|
||||||
return std::visit(Contains{ subString }, mValue);
|
return std::visit(Contains{ subString }, mValue);
|
||||||
|
|
|
@ -104,6 +104,10 @@ namespace ESM
|
||||||
// Otherwise returns false.
|
// Otherwise returns false.
|
||||||
bool startsWith(std::string_view prefix) const;
|
bool startsWith(std::string_view prefix) const;
|
||||||
|
|
||||||
|
// Returns true if underlying value is StringRefId and its underlying std::string ends with given suffix.
|
||||||
|
// Otherwise returns false.
|
||||||
|
bool endsWith(std::string_view suffix) const;
|
||||||
|
|
||||||
// Returns true if underlying value is StringRefId and its underlying std::string contains given subString.
|
// Returns true if underlying value is StringRefId and its underlying std::string contains given subString.
|
||||||
// Otherwise returns false.
|
// Otherwise returns false.
|
||||||
bool contains(std::string_view subString) const;
|
bool contains(std::string_view subString) const;
|
||||||
|
|
|
@ -81,6 +81,11 @@ namespace ESM
|
||||||
return Misc::StringUtils::ciStartsWith(*mValue, prefix);
|
return Misc::StringUtils::ciStartsWith(*mValue, prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool StringRefId::endsWith(std::string_view suffix) const
|
||||||
|
{
|
||||||
|
return Misc::StringUtils::ciEndsWith(*mValue, suffix);
|
||||||
|
}
|
||||||
|
|
||||||
bool StringRefId::contains(std::string_view subString) const
|
bool StringRefId::contains(std::string_view subString) const
|
||||||
{
|
{
|
||||||
return Misc::StringUtils::ciFind(*mValue, subString) != std::string_view::npos;
|
return Misc::StringUtils::ciFind(*mValue, subString) != std::string_view::npos;
|
||||||
|
|
|
@ -27,6 +27,8 @@ namespace ESM
|
||||||
|
|
||||||
bool startsWith(std::string_view prefix) const;
|
bool startsWith(std::string_view prefix) const;
|
||||||
|
|
||||||
|
bool endsWith(std::string_view suffix) const;
|
||||||
|
|
||||||
bool contains(std::string_view subString) const;
|
bool contains(std::string_view subString) const;
|
||||||
|
|
||||||
bool operator==(StringRefId rhs) const noexcept { return mValue == rhs.mValue; }
|
bool operator==(StringRefId rhs) const noexcept { return mValue == rhs.mValue; }
|
||||||
|
|
|
@ -73,4 +73,9 @@ namespace ESM
|
||||||
mModel.clear();
|
mModel.clear();
|
||||||
mRace = ESM::RefId();
|
mRace = ESM::RefId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isFirstPersonBodyPart(const BodyPart& value)
|
||||||
|
{
|
||||||
|
return value.mId.endsWith("1st");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,5 +72,7 @@ namespace ESM
|
||||||
void blank();
|
void blank();
|
||||||
///< Set record to default state (does not touch the ID).
|
///< Set record to default state (does not touch the ID).
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool isFirstPersonBodyPart(const BodyPart& value);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue