1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-15 16:39:41 +00:00

Remove redundant bool argument from ActorAnimation::attachMesh

This commit is contained in:
elsid 2024-09-19 00:13:41 +02:00
parent d7e99f988b
commit 8ba4ff9946
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625
2 changed files with 11 additions and 16 deletions

View file

@ -67,7 +67,7 @@ namespace MWRender
} }
PartHolderPtr ActorAnimation::attachMesh( PartHolderPtr ActorAnimation::attachMesh(
VFS::Path::NormalizedView model, std::string_view bonename, bool enchantedGlow, osg::Vec4f* glowColor) VFS::Path::NormalizedView model, std::string_view bonename, const osg::Vec4f* glowColor)
{ {
osg::Group* parent = getBoneByName(bonename); osg::Group* parent = getBoneByName(bonename);
if (!parent) if (!parent)
@ -80,7 +80,7 @@ namespace MWRender
if (found == nodeMap.end()) if (found == nodeMap.end())
return {}; return {};
if (enchantedGlow) if (glowColor != nullptr)
mGlowUpdater = SceneUtil::addEnchantedGlow(instance, mResourceSystem, *glowColor); mGlowUpdater = SceneUtil::addEnchantedGlow(instance, mResourceSystem, *glowColor);
return std::make_unique<PartHolder>(instance); return std::make_unique<PartHolder>(instance);
@ -221,15 +221,15 @@ namespace MWRender
return; return;
constexpr std::string_view boneName = "Bip01 AttachShield"; constexpr std::string_view boneName = "Bip01 AttachShield";
osg::Vec4f glowColor = shield->getClass().getEnchantmentColor(*shield); const bool isEnchanted = !shield->getClass().getEnchantment(*shield).empty();
const osg::Vec4f glowColor = isEnchanted ? shield->getClass().getEnchantmentColor(*shield) : osg::Vec4f();
const VFS::Path::Normalized holsteredName = addSuffixBeforeExtension(mesh, "_sh"); const VFS::Path::Normalized holsteredName = addSuffixBeforeExtension(mesh, "_sh");
bool isEnchanted = !shield->getClass().getEnchantment(*shield).empty();
// If we have no dedicated sheath model, use basic shield model as fallback. // If we have no dedicated sheath model, use basic shield model as fallback.
if (!mResourceSystem->getVFS()->exists(holsteredName)) if (!mResourceSystem->getVFS()->exists(holsteredName))
mHolsteredShield = attachMesh(mesh, boneName, isEnchanted, &glowColor); mHolsteredShield = attachMesh(mesh, boneName, isEnchanted ? &glowColor : nullptr);
else else
mHolsteredShield = attachMesh(holsteredName, boneName, isEnchanted, &glowColor); mHolsteredShield = attachMesh(holsteredName, boneName, isEnchanted ? &glowColor : nullptr);
if (!mHolsteredShield) if (!mHolsteredShield)
return; return;
@ -348,13 +348,14 @@ namespace MWRender
// If the scabbard is not found, use the weapon mesh as fallback. // If the scabbard is not found, use the weapon mesh as fallback.
const VFS::Path::Normalized scabbardName = addSuffixBeforeExtension(mesh, "_sh"); const VFS::Path::Normalized scabbardName = addSuffixBeforeExtension(mesh, "_sh");
bool isEnchanted = !weapon->getClass().getEnchantment(*weapon).empty(); const bool isEnchanted = !weapon->getClass().getEnchantment(*weapon).empty();
if (!mResourceSystem->getVFS()->exists(scabbardName)) if (!mResourceSystem->getVFS()->exists(scabbardName))
{ {
if (showHolsteredWeapons) if (showHolsteredWeapons)
{ {
osg::Vec4f glowColor = weapon->getClass().getEnchantmentColor(*weapon); const osg::Vec4f glowColor
mScabbard = attachMesh(mesh, boneName, isEnchanted, &glowColor); = isEnchanted ? weapon->getClass().getEnchantmentColor(*weapon) : osg::Vec4f();
mScabbard = attachMesh(mesh, boneName, isEnchanted ? &glowColor : nullptr);
if (mScabbard) if (mScabbard)
resetControllers(mScabbard->getNode()); resetControllers(mScabbard->getNode());
} }

View file

@ -55,13 +55,7 @@ namespace MWRender
virtual std::string_view getHolsteredWeaponBoneName(const MWWorld::ConstPtr& weapon); virtual std::string_view getHolsteredWeaponBoneName(const MWWorld::ConstPtr& weapon);
PartHolderPtr attachMesh( PartHolderPtr attachMesh(
VFS::Path::NormalizedView model, std::string_view bonename, bool enchantedGlow, osg::Vec4f* glowColor); VFS::Path::NormalizedView model, std::string_view bonename, const osg::Vec4f* glowColor = nullptr);
PartHolderPtr attachMesh(VFS::Path::NormalizedView model, std::string_view bonename)
{
osg::Vec4f stubColor = osg::Vec4f(0, 0, 0, 0);
return attachMesh(model, bonename, false, &stubColor);
}
osg::ref_ptr<osg::Node> attach( osg::ref_ptr<osg::Node> attach(
VFS::Path::NormalizedView model, std::string_view bonename, std::string_view bonefilter, bool isLight); VFS::Path::NormalizedView model, std::string_view bonename, std::string_view bonefilter, bool isLight);