forked from mirror/openmw-tes3mp
Avoid redundant culling tests on the transform/drawable
This commit is contained in:
parent
fb8ac06524
commit
0782839a42
4 changed files with 19 additions and 1 deletions
|
@ -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<osg::Texture2D> ChunkManager::createCompositeMapRTT()
|
||||
{
|
||||
osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
|
||||
|
@ -207,6 +213,12 @@ osg::ref_ptr<osg::Node> 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);
|
||||
|
|
|
@ -39,6 +39,8 @@ namespace Terrain
|
|||
|
||||
virtual void reportStats(unsigned int frameNumber, osg::Stats* stats) const;
|
||||
|
||||
void setCullingActive(bool active);
|
||||
|
||||
private:
|
||||
osg::ref_ptr<osg::Node> 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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue