forked from mirror/openmw-tes3mp
Improvements to ignored light list setting
The pointer to the LightListCallback is now stored in the Animation, which eliminates the need for dynamic_cast. Also, when the object root is recreated, the previously used LightListCallback will be reused, so we no longer need the objectRootReset() notifier. Finally, there was a bug when saving and reloading the game, the getIgnoredLightSources() were not being set, as the ActorAnimation constructor completes before the NpcAnimation sets the ObjectRoot. This was solved by creating the LightListCallback in advance in the Animation constructor.
This commit is contained in:
parent
11565b5966
commit
1893617ec9
4 changed files with 12 additions and 33 deletions
|
@ -83,17 +83,6 @@ void ActorAnimation::itemRemoved(const MWWorld::ConstPtr& item, int /*count*/)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActorAnimation::objectRootReset()
|
|
||||||
{
|
|
||||||
if (SceneUtil::LightListCallback* callback = findLightListCallback())
|
|
||||||
{
|
|
||||||
for (ItemLightMap::iterator iter = mItemLights.begin(); iter != mItemLights.end(); ++iter)
|
|
||||||
{
|
|
||||||
callback->getIgnoredLightSources().insert(iter->second);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ActorAnimation::addHiddenItemLight(const MWWorld::ConstPtr& item, const ESM::Light* esmLight)
|
void ActorAnimation::addHiddenItemLight(const MWWorld::ConstPtr& item, const ESM::Light* esmLight)
|
||||||
{
|
{
|
||||||
if (mItemLights.find(item) != mItemLights.end())
|
if (mItemLights.find(item) != mItemLights.end())
|
||||||
|
@ -115,7 +104,7 @@ void ActorAnimation::addHiddenItemLight(const MWWorld::ConstPtr& item, const ESM
|
||||||
|
|
||||||
mInsert->addChild(lightSource);
|
mInsert->addChild(lightSource);
|
||||||
|
|
||||||
if (SceneUtil::LightListCallback* callback = findLightListCallback())
|
if (SceneUtil::LightListCallback* callback = mLightListCallback)
|
||||||
callback->getIgnoredLightSources().insert(lightSource.get());
|
callback->getIgnoredLightSources().insert(lightSource.get());
|
||||||
|
|
||||||
mItemLights.insert(std::make_pair(item, lightSource));
|
mItemLights.insert(std::make_pair(item, lightSource));
|
||||||
|
@ -127,7 +116,7 @@ void ActorAnimation::removeHiddenItemLight(const MWWorld::ConstPtr& item)
|
||||||
if (iter == mItemLights.end())
|
if (iter == mItemLights.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (SceneUtil::LightListCallback* callback = findLightListCallback())
|
if (SceneUtil::LightListCallback* callback = mLightListCallback)
|
||||||
{
|
{
|
||||||
std::set<SceneUtil::LightSource*>::iterator ignoredIter = callback->getIgnoredLightSources().find(iter->second.get());
|
std::set<SceneUtil::LightSource*>::iterator ignoredIter = callback->getIgnoredLightSources().find(iter->second.get());
|
||||||
if (ignoredIter != callback->getIgnoredLightSources().end())
|
if (ignoredIter != callback->getIgnoredLightSources().end())
|
||||||
|
@ -138,18 +127,4 @@ void ActorAnimation::removeHiddenItemLight(const MWWorld::ConstPtr& item)
|
||||||
mItemLights.erase(iter);
|
mItemLights.erase(iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneUtil::LightListCallback* ActorAnimation::findLightListCallback()
|
|
||||||
{
|
|
||||||
if (osg::Callback* callback = mObjectRoot->getCullCallback())
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (SceneUtil::LightListCallback* lightListCallback = dynamic_cast<SceneUtil::LightListCallback *>(callback))
|
|
||||||
return lightListCallback;
|
|
||||||
}
|
|
||||||
while ((callback = callback->getNestedCallback()));
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,15 +38,10 @@ class ActorAnimation : public Animation, public MWWorld::ContainerStoreListener
|
||||||
virtual void itemAdded(const MWWorld::ConstPtr& item, int count);
|
virtual void itemAdded(const MWWorld::ConstPtr& item, int count);
|
||||||
virtual void itemRemoved(const MWWorld::ConstPtr& item, int count);
|
virtual void itemRemoved(const MWWorld::ConstPtr& item, int count);
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void objectRootReset();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addHiddenItemLight(const MWWorld::ConstPtr& item, const ESM::Light* esmLight);
|
void addHiddenItemLight(const MWWorld::ConstPtr& item, const ESM::Light* esmLight);
|
||||||
void removeHiddenItemLight(const MWWorld::ConstPtr& item);
|
void removeHiddenItemLight(const MWWorld::ConstPtr& item);
|
||||||
|
|
||||||
SceneUtil::LightListCallback* findLightListCallback();
|
|
||||||
|
|
||||||
typedef std::map<MWWorld::ConstPtr, osg::ref_ptr<SceneUtil::LightSource> > ItemLightMap;
|
typedef std::map<MWWorld::ConstPtr, osg::ref_ptr<SceneUtil::LightSource> > ItemLightMap;
|
||||||
ItemLightMap mItemLights;
|
ItemLightMap mItemLights;
|
||||||
|
|
||||||
|
|
|
@ -429,6 +429,8 @@ namespace MWRender
|
||||||
{
|
{
|
||||||
for(size_t i = 0;i < sNumBlendMasks;i++)
|
for(size_t i = 0;i < sNumBlendMasks;i++)
|
||||||
mAnimationTimePtr[i].reset(new AnimationTime);
|
mAnimationTimePtr[i].reset(new AnimationTime);
|
||||||
|
|
||||||
|
mLightListCallback = new SceneUtil::LightListCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
Animation::~Animation()
|
Animation::~Animation()
|
||||||
|
@ -1095,6 +1097,8 @@ namespace MWRender
|
||||||
osg::ref_ptr<osg::StateSet> previousStateset;
|
osg::ref_ptr<osg::StateSet> previousStateset;
|
||||||
if (mObjectRoot)
|
if (mObjectRoot)
|
||||||
{
|
{
|
||||||
|
if (mLightListCallback)
|
||||||
|
mObjectRoot->removeCullCallback(mLightListCallback);
|
||||||
previousStateset = mObjectRoot->getStateSet();
|
previousStateset = mObjectRoot->getStateSet();
|
||||||
mObjectRoot->getParent(0)->removeChild(mObjectRoot);
|
mObjectRoot->getParent(0)->removeChild(mObjectRoot);
|
||||||
}
|
}
|
||||||
|
@ -1150,7 +1154,9 @@ namespace MWRender
|
||||||
removeTriBipVisitor.remove();
|
removeTriBipVisitor.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
mObjectRoot->addCullCallback(new SceneUtil::LightListCallback);
|
if (!mLightListCallback)
|
||||||
|
mLightListCallback = new SceneUtil::LightListCallback;
|
||||||
|
mObjectRoot->addCullCallback(mLightListCallback);
|
||||||
|
|
||||||
objectRootReset();
|
objectRootReset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ namespace NifOsg
|
||||||
namespace SceneUtil
|
namespace SceneUtil
|
||||||
{
|
{
|
||||||
class LightSource;
|
class LightSource;
|
||||||
|
class LightListCallback;
|
||||||
class Skeleton;
|
class Skeleton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,6 +274,8 @@ protected:
|
||||||
|
|
||||||
float mAlpha;
|
float mAlpha;
|
||||||
|
|
||||||
|
osg::ref_ptr<SceneUtil::LightListCallback> mLightListCallback;
|
||||||
|
|
||||||
const NodeMap& getNodeMap() const;
|
const NodeMap& getNodeMap() const;
|
||||||
|
|
||||||
/* Sets the appropriate animations on the bone groups based on priority.
|
/* Sets the appropriate animations on the bone groups based on priority.
|
||||||
|
|
Loading…
Reference in a new issue