From 8c2c66d59e033c6ae8467ad04f6f791d9721d38d Mon Sep 17 00:00:00 2001 From: Sam Hellawell Date: Thu, 11 Apr 2024 02:16:06 +0100 Subject: [PATCH] .nif check, matrix mult feedback, auto usage, reuse NodeMap typedef --- apps/openmw/mwrender/animation.cpp | 2 +- apps/openmw/mwrender/rotatecontroller.cpp | 6 +++--- components/resource/scenemanager.cpp | 4 +--- components/sceneutil/visitor.hpp | 12 ++++-------- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 82081658a6..31b5d36c79 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -1491,7 +1491,7 @@ namespace MWRender // osgAnimation formats with skeletons should have their nodemap be bone instances // FIXME: better way to detect osgAnimation here instead of relying on extension? - mRequiresBoneMap = mSkeleton != nullptr && !Misc::StringUtils::ciEndsWith(model, "nif"); + mRequiresBoneMap = mSkeleton != nullptr && !Misc::StringUtils::ciEndsWith(model, ".nif"); if (previousStateset) mObjectRoot->setStateSet(previousStateset); diff --git a/apps/openmw/mwrender/rotatecontroller.cpp b/apps/openmw/mwrender/rotatecontroller.cpp index 47b271c40d..61a2a2628a 100644 --- a/apps/openmw/mwrender/rotatecontroller.cpp +++ b/apps/openmw/mwrender/rotatecontroller.cpp @@ -50,9 +50,9 @@ namespace MWRender { osgAnimation::Bone* parent = b->getBoneParent(); if (parent) - b->setMatrixInSkeletonSpace(matrix * parent->getMatrixInSkeletonSpace()); - else - b->setMatrixInSkeletonSpace(matrix); + matrix *= parent->getMatrixInSkeletonSpace(); + + b->setMatrixInSkeletonSpace(matrix); } traverse(node, nv); diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index bf2674a98f..4bdd620819 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -399,9 +399,7 @@ namespace Resource osg::Callback* cb = node.getUpdateCallback(); while (cb) { - osgAnimation::AnimationUpdateCallback* animCb - = dynamic_cast*>(cb); - + auto animCb = dynamic_cast*>(cb); if (animCb) animCb->setName(Misc::StringUtils::underscoresToSpaces(animCb->getName())); diff --git a/components/sceneutil/visitor.hpp b/components/sceneutil/visitor.hpp index a5af88d7de..a9a943423c 100644 --- a/components/sceneutil/visitor.hpp +++ b/components/sceneutil/visitor.hpp @@ -50,14 +50,14 @@ namespace SceneUtil std::vector mFoundNodes; }; + typedef std::unordered_map, Misc::StringUtils::CiHash, + Misc::StringUtils::CiEqual> + NodeMap; + /// Maps names to nodes class NodeMapVisitor : public osg::NodeVisitor { public: - typedef std::unordered_map, Misc::StringUtils::CiHash, - Misc::StringUtils::CiEqual> - NodeMap; - NodeMapVisitor(NodeMap& map) : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) , mMap(map) @@ -74,10 +74,6 @@ namespace SceneUtil class NodeMapVisitorBoneOnly : public osg::NodeVisitor { public: - typedef std::unordered_map, Misc::StringUtils::CiHash, - Misc::StringUtils::CiEqual> - NodeMap; - NodeMapVisitorBoneOnly(NodeMap& map) : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) , mMap(map)