From 8f62ea2e807935939ea60aaee512b1b3f9ee8219 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 2 Jul 2016 20:19:55 +0200 Subject: [PATCH] Fix for "RigGeometry rendering with no skeleton" errors --- apps/openmw/mwrender/creatureanimation.cpp | 3 +++ apps/openmw/mwrender/npcanimation.cpp | 3 +++ components/sceneutil/skeleton.cpp | 6 ++++++ components/sceneutil/skeleton.hpp | 3 +++ 4 files changed, 15 insertions(+) diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index d4e48e1fd..669d0d8a1 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "../mwbase/world.hpp" @@ -109,6 +110,8 @@ void CreatureWeaponAnimation::updatePart(PartHolderPtr& scene, int slot) osg::ref_ptr node = mResourceSystem->getSceneManager()->getInstance(item.getClass().getModel(item)); osg::ref_ptr attached = SceneUtil::attach(node, mObjectRoot, bonename, bonename); mResourceSystem->getSceneManager()->notifyAttached(attached); + if (mSkeleton) + mSkeleton->markDirty(); scene.reset(new PartHolder(attached)); diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index e44e2fb30..b1f506e11 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include // TextKeyMapHolder @@ -666,6 +667,8 @@ PartHolderPtr NpcAnimation::insertBoundedPart(const std::string& model, const st { osg::ref_ptr instance = mResourceSystem->getSceneManager()->getInstance(model); osg::ref_ptr attached = SceneUtil::attach(instance, mObjectRoot, bonefilter, bonename); + if (mSkeleton) + mSkeleton->markDirty(); mResourceSystem->getSceneManager()->notifyAttached(attached); if (enchantedGlow) addGlow(attached, *glowColor); diff --git a/components/sceneutil/skeleton.cpp b/components/sceneutil/skeleton.cpp index 08ac72e91..390a8e823 100644 --- a/components/sceneutil/skeleton.cpp +++ b/components/sceneutil/skeleton.cpp @@ -144,6 +144,12 @@ bool Skeleton::getActive() const return mActive; } +void Skeleton::markDirty() +{ + mTraversedEvenFrame = false; + mTraversedOddFrame = false; +} + void Skeleton::traverse(osg::NodeVisitor& nv) { if (!getActive() && nv.getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR diff --git a/components/sceneutil/skeleton.hpp b/components/sceneutil/skeleton.hpp index 835ab6617..764b7f645 100644 --- a/components/sceneutil/skeleton.hpp +++ b/components/sceneutil/skeleton.hpp @@ -53,6 +53,9 @@ namespace SceneUtil 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); private: