Fix for "RigGeometry rendering with no skeleton" errors

coverity_scan^2
scrawl 9 years ago
parent b9b73d7b12
commit 8f62ea2e80

@ -7,6 +7,7 @@
#include <components/sceneutil/attach.hpp> #include <components/sceneutil/attach.hpp>
#include <components/sceneutil/visitor.hpp> #include <components/sceneutil/visitor.hpp>
#include <components/sceneutil/positionattitudetransform.hpp> #include <components/sceneutil/positionattitudetransform.hpp>
#include <components/sceneutil/skeleton.hpp>
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
@ -109,6 +110,8 @@ void CreatureWeaponAnimation::updatePart(PartHolderPtr& scene, int slot)
osg::ref_ptr<osg::Node> node = mResourceSystem->getSceneManager()->getInstance(item.getClass().getModel(item)); osg::ref_ptr<osg::Node> node = mResourceSystem->getSceneManager()->getInstance(item.getClass().getModel(item));
osg::ref_ptr<osg::Node> attached = SceneUtil::attach(node, mObjectRoot, bonename, bonename); osg::ref_ptr<osg::Node> attached = SceneUtil::attach(node, mObjectRoot, bonename, bonename);
mResourceSystem->getSceneManager()->notifyAttached(attached); mResourceSystem->getSceneManager()->notifyAttached(attached);
if (mSkeleton)
mSkeleton->markDirty();
scene.reset(new PartHolder(attached)); scene.reset(new PartHolder(attached));

@ -15,6 +15,7 @@
#include <components/resource/scenemanager.hpp> #include <components/resource/scenemanager.hpp>
#include <components/sceneutil/attach.hpp> #include <components/sceneutil/attach.hpp>
#include <components/sceneutil/visitor.hpp> #include <components/sceneutil/visitor.hpp>
#include <components/sceneutil/skeleton.hpp>
#include <components/nifosg/nifloader.hpp> // TextKeyMapHolder #include <components/nifosg/nifloader.hpp> // TextKeyMapHolder
@ -666,6 +667,8 @@ PartHolderPtr NpcAnimation::insertBoundedPart(const std::string& model, const st
{ {
osg::ref_ptr<osg::Node> instance = mResourceSystem->getSceneManager()->getInstance(model); osg::ref_ptr<osg::Node> instance = mResourceSystem->getSceneManager()->getInstance(model);
osg::ref_ptr<osg::Node> attached = SceneUtil::attach(instance, mObjectRoot, bonefilter, bonename); osg::ref_ptr<osg::Node> attached = SceneUtil::attach(instance, mObjectRoot, bonefilter, bonename);
if (mSkeleton)
mSkeleton->markDirty();
mResourceSystem->getSceneManager()->notifyAttached(attached); mResourceSystem->getSceneManager()->notifyAttached(attached);
if (enchantedGlow) if (enchantedGlow)
addGlow(attached, *glowColor); addGlow(attached, *glowColor);

@ -144,6 +144,12 @@ bool Skeleton::getActive() const
return mActive; return mActive;
} }
void Skeleton::markDirty()
{
mTraversedEvenFrame = false;
mTraversedOddFrame = false;
}
void Skeleton::traverse(osg::NodeVisitor& nv) void Skeleton::traverse(osg::NodeVisitor& nv)
{ {
if (!getActive() && nv.getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR if (!getActive() && nv.getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR

@ -53,6 +53,9 @@ namespace SceneUtil
bool getActive() const; bool getActive() const;
/// If a new RigGeometry is added after the Skeleton has already been rendered, you must call markDirty().
void markDirty();
void traverse(osg::NodeVisitor& nv); void traverse(osg::NodeVisitor& nv);
private: private:

Loading…
Cancel
Save