Skip to content

Commit

Permalink
actoranimation.cpp faster getbonebyname (#3099)
Browse files Browse the repository at this point in the history
  • Loading branch information
bosvensson1 committed Sep 9, 2021
1 parent afba188 commit c284d0c
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions apps/openmw/mwrender/actoranimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,14 @@ ActorAnimation::~ActorAnimation()

PartHolderPtr ActorAnimation::attachMesh(const std::string& model, const std::string& bonename, bool enchantedGlow, osg::Vec4f* glowColor)
{
osg::Group* parent = getBoneByName(bonename);
if (!parent)
return nullptr;

osg::ref_ptr<osg::Node> instance = mResourceSystem->getSceneManager()->getInstance(model, parent);

const NodeMap& nodeMap = getNodeMap();
NodeMap::const_iterator found = nodeMap.find(Misc::StringUtils::lowerCase(bonename));
if (found == nodeMap.end())
return PartHolderPtr();

osg::Group* parent = found->second;
osg::ref_ptr<osg::Node> instance = mResourceSystem->getSceneManager()->getInstance(model, parent);

if (enchantedGlow)
mGlowUpdater = SceneUtil::addEnchantedGlow(instance, mResourceSystem, *glowColor);

Expand Down Expand Up @@ -136,9 +133,9 @@ bool ActorAnimation::updateCarriedLeftVisible(const int weaptype) const
MWMechanics::CreatureStats &stats = cls.getCreatureStats(mPtr);
if (cls.hasInventoryStore(mPtr) && weaptype != ESM::Weapon::Spell)
{
SceneUtil::FindByNameVisitor findVisitor ("Bip01 AttachShield");
mObjectRoot->accept(findVisitor);
if (findVisitor.mFoundNode || (mPtr == MWMechanics::getPlayer() && mPtr.isInCell() && MWBase::Environment::get().getWorld()->isFirstPerson()))
osg::Group* foundNode = getBoneByName ("Bip01 AttachShield");

if (foundNode || (mPtr == MWMechanics::getPlayer() && mPtr.isInCell() && MWBase::Environment::get().getWorld()->isFirstPerson()))
{
const MWWorld::InventoryStore& inv = cls.getInventoryStore(mPtr);
const MWWorld::ConstContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
Expand Down Expand Up @@ -276,10 +273,11 @@ osg::Group* ActorAnimation::getBoneByName(const std::string& boneName)
if (!mObjectRoot)
return nullptr;

SceneUtil::FindByNameVisitor findVisitor (boneName);
mObjectRoot->accept(findVisitor);

return findVisitor.mFoundNode;
const NodeMap& nodeMap = getNodeMap();
NodeMap::const_iterator found = nodeMap.find(Misc::StringUtils::lowerCase(boneName));
if (found == nodeMap.end())
return nullptr;
return found->second;
}

std::string ActorAnimation::getHolsteredWeaponBoneName(const MWWorld::ConstPtr& weapon)
Expand Down

0 comments on commit c284d0c

Please sign in to comment.