mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 20:53:50 +00:00
Move IncrementalCompileOperation to SceneManager
This commit is contained in:
parent
5de24552a8
commit
723beb1cac
6 changed files with 25 additions and 23 deletions
|
@ -181,7 +181,8 @@ namespace MWGui
|
|||
|
||||
void LoadingScreen::setProgress (size_t value)
|
||||
{
|
||||
if (value - mProgress < mProgressBar->getScrollRange()/100.f)
|
||||
// skip expensive update if there isn't enough visible progress
|
||||
if (value - mProgress < mProgressBar->getScrollRange()/200.f)
|
||||
return;
|
||||
mProgress = value;
|
||||
mProgressBar->setScrollPosition(0);
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
#include <osg/PositionAttitudeTransform>
|
||||
#include <osg/UserDataContainer>
|
||||
|
||||
#include <osgUtil/IncrementalCompileOperation>
|
||||
|
||||
#include <osgParticle/ParticleSystem>
|
||||
#include <osgParticle/ParticleProcessor>
|
||||
|
||||
|
@ -81,11 +79,6 @@ Objects::~Objects()
|
|||
mCellSceneNodes.clear();
|
||||
}
|
||||
|
||||
void Objects::setIncrementalCompileOperation(osgUtil::IncrementalCompileOperation *ico)
|
||||
{
|
||||
mIncrementalCompileOperation = ico;
|
||||
}
|
||||
|
||||
void Objects::insertBegin(const MWWorld::Ptr& ptr)
|
||||
{
|
||||
osg::ref_ptr<osg::Group> cellnode;
|
||||
|
@ -118,9 +111,6 @@ void Objects::insertModel(const MWWorld::Ptr &ptr, const std::string &mesh, bool
|
|||
|
||||
std::auto_ptr<ObjectAnimation> anim (new ObjectAnimation(ptr, mesh, mResourceSystem, allowLight));
|
||||
|
||||
if (mIncrementalCompileOperation && anim->getObjectRoot())
|
||||
mIncrementalCompileOperation->add(anim->getObjectRoot());
|
||||
|
||||
if (!allowLight)
|
||||
{
|
||||
RemoveParticlesVisitor visitor;
|
||||
|
@ -144,9 +134,6 @@ void Objects::insertCreature(const MWWorld::Ptr &ptr, const std::string &mesh, b
|
|||
else
|
||||
anim.reset(new CreatureAnimation(ptr, mesh, mResourceSystem));
|
||||
|
||||
if (mIncrementalCompileOperation && anim->getObjectRoot())
|
||||
mIncrementalCompileOperation->add(anim->getObjectRoot());
|
||||
|
||||
mObjects.insert(std::make_pair(ptr, anim.release()));
|
||||
}
|
||||
|
||||
|
@ -157,9 +144,6 @@ void Objects::insertNPC(const MWWorld::Ptr &ptr)
|
|||
|
||||
std::auto_ptr<NpcAnimation> anim (new NpcAnimation(ptr, osg::ref_ptr<osg::Group>(ptr.getRefData().getBaseNode()), mResourceSystem, 0));
|
||||
|
||||
if (mIncrementalCompileOperation && anim->getObjectRoot())
|
||||
mIncrementalCompileOperation->add(anim->getObjectRoot());
|
||||
|
||||
mObjects.insert(std::make_pair(ptr, anim.release()));
|
||||
}
|
||||
|
||||
|
|
|
@ -69,14 +69,10 @@ class Objects{
|
|||
|
||||
Resource::ResourceSystem* mResourceSystem;
|
||||
|
||||
osg::ref_ptr<osgUtil::IncrementalCompileOperation> mIncrementalCompileOperation;
|
||||
|
||||
public:
|
||||
Objects(Resource::ResourceSystem* resourceSystem, osg::ref_ptr<osg::Group> rootNode);
|
||||
~Objects();
|
||||
|
||||
void setIncrementalCompileOperation(osgUtil::IncrementalCompileOperation* ico);
|
||||
|
||||
/// @param animated Attempt to load separate keyframes from a .kf file matching the model file?
|
||||
/// @param allowLight If false, no lights will be created, and particles systems will be removed.
|
||||
void insertModel(const MWWorld::Ptr& ptr, const std::string &model, bool animated=false, bool allowLight=true);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include <components/resource/resourcesystem.hpp>
|
||||
#include <components/resource/texturemanager.hpp>
|
||||
#include <components/resource/scenemanager.hpp>
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
|
@ -101,7 +102,7 @@ namespace MWRender
|
|||
|
||||
mViewer->setIncrementalCompileOperation(new osgUtil::IncrementalCompileOperation);
|
||||
|
||||
mObjects->setIncrementalCompileOperation(mViewer->getIncrementalCompileOperation());
|
||||
mResourceSystem->getSceneManager()->setIncrementalCompileOperation(mViewer->getIncrementalCompileOperation());
|
||||
|
||||
mEffectManager.reset(new EffectManager(mRootNode, mResourceSystem));
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#include <osgParticle/ParticleSystem>
|
||||
|
||||
#include <osgUtil/IncrementalCompileOperation>
|
||||
|
||||
#include <components/nifosg/nifloader.hpp>
|
||||
#include <components/nif/niffile.hpp>
|
||||
|
||||
|
@ -88,7 +90,10 @@ namespace Resource
|
|||
// TODO: add support for non-NIF formats
|
||||
|
||||
NifOsg::Loader loader;
|
||||
osg::ref_ptr<const osg::Node> loaded = loader.load(Nif::NIFFilePtr(new Nif::NIFFile(file, normalized)), mTextureManager);
|
||||
osg::ref_ptr<osg::Node> loaded = loader.load(Nif::NIFFilePtr(new Nif::NIFFile(file, normalized)), mTextureManager);
|
||||
|
||||
if (mIncrementalCompileOperation)
|
||||
mIncrementalCompileOperation->add(loaded);
|
||||
|
||||
mIndex[normalized] = loaded;
|
||||
return loaded;
|
||||
|
@ -147,6 +152,11 @@ namespace Resource
|
|||
}
|
||||
}
|
||||
|
||||
void SceneManager::setIncrementalCompileOperation(osgUtil::IncrementalCompileOperation *ico)
|
||||
{
|
||||
mIncrementalCompileOperation = ico;
|
||||
}
|
||||
|
||||
const VFS::Manager* SceneManager::getVFS() const
|
||||
{
|
||||
return mVFS;
|
||||
|
|
|
@ -24,6 +24,11 @@ namespace NifOsg
|
|||
class KeyframeHolder;
|
||||
}
|
||||
|
||||
namespace osgUtil
|
||||
{
|
||||
class IncrementalCompileOperation;
|
||||
}
|
||||
|
||||
namespace Resource
|
||||
{
|
||||
|
||||
|
@ -56,6 +61,9 @@ namespace Resource
|
|||
/// in cases where multiple contexts are used over the lifetime of the application.
|
||||
void releaseGLObjects(osg::State* state);
|
||||
|
||||
/// Set up an IncrementalCompileOperation for background compiling of loaded scenes.
|
||||
void setIncrementalCompileOperation(osgUtil::IncrementalCompileOperation* ico);
|
||||
|
||||
const VFS::Manager* getVFS() const;
|
||||
|
||||
Resource::TextureManager* getTextureManager();
|
||||
|
@ -64,6 +72,8 @@ namespace Resource
|
|||
const VFS::Manager* mVFS;
|
||||
Resource::TextureManager* mTextureManager;
|
||||
|
||||
osg::ref_ptr<osgUtil::IncrementalCompileOperation> mIncrementalCompileOperation;
|
||||
|
||||
// observer_ptr?
|
||||
typedef std::map<std::string, osg::ref_ptr<const osg::Node> > Index;
|
||||
Index mIndex;
|
||||
|
|
Loading…
Reference in a new issue