mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-25 18:11:34 +00:00
actoranimation.cpp faster getbonebyname (#3099)
This commit is contained in:
parent
afba1884ab
commit
c284d0cf5c
1 changed files with 11 additions and 13 deletions
|
@ -67,17 +67,14 @@ ActorAnimation::~ActorAnimation()
|
||||||
|
|
||||||
PartHolderPtr ActorAnimation::attachMesh(const std::string& model, const std::string& bonename, bool enchantedGlow, osg::Vec4f* glowColor)
|
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();
|
const NodeMap& nodeMap = getNodeMap();
|
||||||
NodeMap::const_iterator found = nodeMap.find(Misc::StringUtils::lowerCase(bonename));
|
NodeMap::const_iterator found = nodeMap.find(Misc::StringUtils::lowerCase(bonename));
|
||||||
if (found == nodeMap.end())
|
if (found == nodeMap.end())
|
||||||
return PartHolderPtr();
|
return PartHolderPtr();
|
||||||
|
|
||||||
|
osg::Group* parent = found->second;
|
||||||
|
osg::ref_ptr<osg::Node> instance = mResourceSystem->getSceneManager()->getInstance(model, parent);
|
||||||
|
|
||||||
if (enchantedGlow)
|
if (enchantedGlow)
|
||||||
mGlowUpdater = SceneUtil::addEnchantedGlow(instance, mResourceSystem, *glowColor);
|
mGlowUpdater = SceneUtil::addEnchantedGlow(instance, mResourceSystem, *glowColor);
|
||||||
|
|
||||||
|
@ -136,9 +133,9 @@ bool ActorAnimation::updateCarriedLeftVisible(const int weaptype) const
|
||||||
MWMechanics::CreatureStats &stats = cls.getCreatureStats(mPtr);
|
MWMechanics::CreatureStats &stats = cls.getCreatureStats(mPtr);
|
||||||
if (cls.hasInventoryStore(mPtr) && weaptype != ESM::Weapon::Spell)
|
if (cls.hasInventoryStore(mPtr) && weaptype != ESM::Weapon::Spell)
|
||||||
{
|
{
|
||||||
SceneUtil::FindByNameVisitor findVisitor ("Bip01 AttachShield");
|
osg::Group* foundNode = getBoneByName ("Bip01 AttachShield");
|
||||||
mObjectRoot->accept(findVisitor);
|
|
||||||
if (findVisitor.mFoundNode || (mPtr == MWMechanics::getPlayer() && mPtr.isInCell() && MWBase::Environment::get().getWorld()->isFirstPerson()))
|
if (foundNode || (mPtr == MWMechanics::getPlayer() && mPtr.isInCell() && MWBase::Environment::get().getWorld()->isFirstPerson()))
|
||||||
{
|
{
|
||||||
const MWWorld::InventoryStore& inv = cls.getInventoryStore(mPtr);
|
const MWWorld::InventoryStore& inv = cls.getInventoryStore(mPtr);
|
||||||
const MWWorld::ConstContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
const MWWorld::ConstContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||||
|
@ -276,10 +273,11 @@ osg::Group* ActorAnimation::getBoneByName(const std::string& boneName)
|
||||||
if (!mObjectRoot)
|
if (!mObjectRoot)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
SceneUtil::FindByNameVisitor findVisitor (boneName);
|
const NodeMap& nodeMap = getNodeMap();
|
||||||
mObjectRoot->accept(findVisitor);
|
NodeMap::const_iterator found = nodeMap.find(Misc::StringUtils::lowerCase(boneName));
|
||||||
|
if (found == nodeMap.end())
|
||||||
return findVisitor.mFoundNode;
|
return nullptr;
|
||||||
|
return found->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ActorAnimation::getHolsteredWeaponBoneName(const MWWorld::ConstPtr& weapon)
|
std::string ActorAnimation::getHolsteredWeaponBoneName(const MWWorld::ConstPtr& weapon)
|
||||||
|
|
Loading…
Reference in a new issue