Enable lazy compiling of composite maps

pull/1225/head
scrawl 8 years ago
parent 99e18f0d68
commit 5a3c645c89

@ -201,12 +201,14 @@ osg::ref_ptr<osg::Node> ChunkManager::createChunk(float chunkSize, const osg::Ve
compositeMapNode->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); compositeMapNode->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
mCompositeMapRenderer->addCompositeMap(compositeMapNode, true); mCompositeMapRenderer->addCompositeMap(compositeMapNode, false);
std::vector<osg::ref_ptr<osg::StateSet> > passes2; std::vector<osg::ref_ptr<osg::StateSet> > passes2;
passes2.push_back(new osg::StateSet); passes2.push_back(new osg::StateSet);
passes2[0]->setTextureAttributeAndModes(0, compositeMap, osg::StateAttribute::ON); passes2[0]->setTextureAttributeAndModes(0, compositeMap, osg::StateAttribute::ON);
geometry->setPasses(passes2); geometry->setPasses(passes2);
transform->getOrCreateUserDataContainer()->addUserObject(compositeMapNode);
} }
else else
{ {

@ -8,6 +8,7 @@
#include "storage.hpp" #include "storage.hpp"
#include "viewdata.hpp" #include "viewdata.hpp"
#include "chunkmanager.hpp" #include "chunkmanager.hpp"
#include "compositemaprenderer.hpp"
namespace namespace
{ {
@ -314,7 +315,19 @@ void QuadTreeWorld::accept(osg::NodeVisitor &nv)
} }
if (entry.mVisible) if (entry.mVisible)
{
osg::UserDataContainer* udc = entry.mRenderingNode->getUserDataContainer();
if (udc && udc->getNumUserObjects() > 0)
{
osg::Node* compositeMapNode = udc->getUserObject(0)->asNode();
if (compositeMapNode)
{
mCompositeMapRenderer->setImmediate(compositeMapNode);
udc->removeUserObject(0);
}
}
entry.mRenderingNode->accept(nv); entry.mRenderingNode->accept(nv);
}
} }
vd->reset(nv.getTraversalNumber()); vd->reset(nv.getTraversalNumber());

@ -27,15 +27,14 @@ World::World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSyst
mTerrainRoot->setName("Terrain Root"); mTerrainRoot->setName("Terrain Root");
osg::ref_ptr<CompositeMapRenderer> renderer (new CompositeMapRenderer); mCompositeMapRenderer = new CompositeMapRenderer;
renderer->setNodeMask(preCompileMask); mCompositeMapRenderer->setNodeMask(preCompileMask);
compileRoot->addChild(renderer); compileRoot->addChild(mCompositeMapRenderer);
mCompositeMapRenderer = renderer;
mParent->addChild(mTerrainRoot); mParent->addChild(mTerrainRoot);
mTextureManager.reset(new TextureManager(mResourceSystem->getSceneManager())); mTextureManager.reset(new TextureManager(mResourceSystem->getSceneManager()));
mChunkManager.reset(new ChunkManager(mStorage, mResourceSystem->getSceneManager(), mTextureManager.get(), renderer)); mChunkManager.reset(new ChunkManager(mStorage, mResourceSystem->getSceneManager(), mTextureManager.get(), mCompositeMapRenderer));
mResourceSystem->addResourceManager(mChunkManager.get()); mResourceSystem->addResourceManager(mChunkManager.get());
mResourceSystem->addResourceManager(mTextureManager.get()); mResourceSystem->addResourceManager(mTextureManager.get());

@ -26,6 +26,7 @@ namespace Terrain
class TextureManager; class TextureManager;
class ChunkManager; class ChunkManager;
class CompositeMapRenderer;
/** /**
* @brief The basic interface for a terrain world. How the terrain chunks are paged and displayed * @brief The basic interface for a terrain world. How the terrain chunks are paged and displayed
@ -70,7 +71,7 @@ namespace Terrain
osg::ref_ptr<osg::Group> mParent; osg::ref_ptr<osg::Group> mParent;
osg::ref_ptr<osg::Group> mTerrainRoot; osg::ref_ptr<osg::Group> mTerrainRoot;
osg::ref_ptr<osg::Node> mCompositeMapRenderer; osg::ref_ptr<CompositeMapRenderer> mCompositeMapRenderer;
Resource::ResourceSystem* mResourceSystem; Resource::ResourceSystem* mResourceSystem;

Loading…
Cancel
Save