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);
mCompositeMapRenderer->addCompositeMap(compositeMapNode, true);
mCompositeMapRenderer->addCompositeMap(compositeMapNode, false);
std::vector<osg::ref_ptr<osg::StateSet> > passes2;
passes2.push_back(new osg::StateSet);
passes2[0]->setTextureAttributeAndModes(0, compositeMap, osg::StateAttribute::ON);
geometry->setPasses(passes2);
transform->getOrCreateUserDataContainer()->addUserObject(compositeMapNode);
}
else
{

@ -8,6 +8,7 @@
#include "storage.hpp"
#include "viewdata.hpp"
#include "chunkmanager.hpp"
#include "compositemaprenderer.hpp"
namespace
{
@ -314,7 +315,19 @@ void QuadTreeWorld::accept(osg::NodeVisitor &nv)
}
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);
}
}
vd->reset(nv.getTraversalNumber());

@ -27,15 +27,14 @@ World::World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSyst
mTerrainRoot->setName("Terrain Root");
osg::ref_ptr<CompositeMapRenderer> renderer (new CompositeMapRenderer);
renderer->setNodeMask(preCompileMask);
compileRoot->addChild(renderer);
mCompositeMapRenderer = renderer;
mCompositeMapRenderer = new CompositeMapRenderer;
mCompositeMapRenderer->setNodeMask(preCompileMask);
compileRoot->addChild(mCompositeMapRenderer);
mParent->addChild(mTerrainRoot);
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(mTextureManager.get());

@ -26,6 +26,7 @@ namespace Terrain
class TextureManager;
class ChunkManager;
class CompositeMapRenderer;
/**
* @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> mTerrainRoot;
osg::ref_ptr<osg::Node> mCompositeMapRenderer;
osg::ref_ptr<CompositeMapRenderer> mCompositeMapRenderer;
Resource::ResourceSystem* mResourceSystem;

Loading…
Cancel
Save