diff --git a/components/terrain/chunkmanager.cpp b/components/terrain/chunkmanager.cpp index 3eb48d88f9..b0860ecf28 100644 --- a/components/terrain/chunkmanager.cpp +++ b/components/terrain/chunkmanager.cpp @@ -27,6 +27,7 @@ ChunkManager::ChunkManager(Storage *storage, Resource::SceneManager *sceneMgr, T , mTextureManager(textureManager) , mCompositeMapRenderer(renderer) , mCompositeMapSize(512) + , mCullingActive(true) { } @@ -53,6 +54,11 @@ void ChunkManager::reportStats(unsigned int frameNumber, osg::Stats *stats) cons stats->setAttribute(frameNumber, "Terrain Chunk", mCache->getCacheSize()); } +void ChunkManager::setCullingActive(bool active) +{ + mCullingActive = active; +} + osg::ref_ptr ChunkManager::createCompositeMapRTT() { osg::ref_ptr texture = new osg::Texture2D; @@ -207,6 +213,12 @@ osg::ref_ptr ChunkManager::createChunk(float chunkSize, const osg::Ve transform->addChild(geometry); + if (!mCullingActive) + { + transform->setCullingActive(false); + geometry->setCullingActive(false); + } + if (mSceneManager->getIncrementalCompileOperation()) { mSceneManager->getIncrementalCompileOperation()->add(geometry); diff --git a/components/terrain/chunkmanager.hpp b/components/terrain/chunkmanager.hpp index 08cf2d70cf..58db98dc9c 100644 --- a/components/terrain/chunkmanager.hpp +++ b/components/terrain/chunkmanager.hpp @@ -39,6 +39,8 @@ namespace Terrain virtual void reportStats(unsigned int frameNumber, osg::Stats* stats) const; + void setCullingActive(bool active); + private: osg::ref_ptr createChunk(float size, const osg::Vec2f& center, int lod, unsigned int lodFlags); @@ -55,6 +57,8 @@ namespace Terrain BufferCache mBufferCache; unsigned int mCompositeMapSize; + + bool mCullingActive; }; } diff --git a/components/terrain/quadtreeworld.cpp b/components/terrain/quadtreeworld.cpp index 649496e8d1..d65b1d5ed2 100644 --- a/components/terrain/quadtreeworld.cpp +++ b/components/terrain/quadtreeworld.cpp @@ -240,6 +240,8 @@ QuadTreeWorld::QuadTreeWorld(osg::Group *parent, osg::Group *compileRoot, Resour , mViewDataMap(new ViewDataMap) , mQuadTreeBuilt(false) { + // No need for culling on the Drawable / Transform level as the quad tree performs the culling already. + mChunkManager->setCullingActive(false); } QuadTreeWorld::~QuadTreeWorld() diff --git a/components/terrain/terraindrawable.cpp b/components/terrain/terraindrawable.cpp index b5934eb128..8557233ed6 100644 --- a/components/terrain/terraindrawable.cpp +++ b/components/terrain/terraindrawable.cpp @@ -43,7 +43,7 @@ void TerrainDrawable::cull(osgUtil::CullVisitor *cv) { const osg::BoundingBox& bb = getBoundingBox(); - if (cv->isCulled(getBoundingBox())) + if (_cullingActive && cv->isCulled(getBoundingBox())) return; osg::RefMatrix& matrix = *cv->getModelViewMatrix();