mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 22:15:32 +00:00
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)
|
, mTextureManager(textureManager)
|
||||||
, mCompositeMapRenderer(renderer)
|
, mCompositeMapRenderer(renderer)
|
||||||
, mCompositeMapSize(512)
|
, 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());
|
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> ChunkManager::createCompositeMapRTT()
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
|
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);
|
transform->addChild(geometry);
|
||||||
|
|
||||||
|
if (!mCullingActive)
|
||||||
|
{
|
||||||
|
transform->setCullingActive(false);
|
||||||
|
geometry->setCullingActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
if (mSceneManager->getIncrementalCompileOperation())
|
if (mSceneManager->getIncrementalCompileOperation())
|
||||||
{
|
{
|
||||||
mSceneManager->getIncrementalCompileOperation()->add(geometry);
|
mSceneManager->getIncrementalCompileOperation()->add(geometry);
|
||||||
|
|
|
@ -39,6 +39,8 @@ namespace Terrain
|
||||||
|
|
||||||
virtual void reportStats(unsigned int frameNumber, osg::Stats* stats) const;
|
virtual void reportStats(unsigned int frameNumber, osg::Stats* stats) const;
|
||||||
|
|
||||||
|
void setCullingActive(bool active);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
osg::ref_ptr<osg::Node> createChunk(float size, const osg::Vec2f& center, int lod, unsigned int lodFlags);
|
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;
|
BufferCache mBufferCache;
|
||||||
|
|
||||||
unsigned int mCompositeMapSize;
|
unsigned int mCompositeMapSize;
|
||||||
|
|
||||||
|
bool mCullingActive;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,6 +240,8 @@ QuadTreeWorld::QuadTreeWorld(osg::Group *parent, osg::Group *compileRoot, Resour
|
||||||
, mViewDataMap(new ViewDataMap)
|
, mViewDataMap(new ViewDataMap)
|
||||||
, mQuadTreeBuilt(false)
|
, mQuadTreeBuilt(false)
|
||||||
{
|
{
|
||||||
|
// No need for culling on the Drawable / Transform level as the quad tree performs the culling already.
|
||||||
|
mChunkManager->setCullingActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QuadTreeWorld::~QuadTreeWorld()
|
QuadTreeWorld::~QuadTreeWorld()
|
||||||
|
|
|
@ -43,7 +43,7 @@ void TerrainDrawable::cull(osgUtil::CullVisitor *cv)
|
||||||
{
|
{
|
||||||
const osg::BoundingBox& bb = getBoundingBox();
|
const osg::BoundingBox& bb = getBoundingBox();
|
||||||
|
|
||||||
if (cv->isCulled(getBoundingBox()))
|
if (_cullingActive && cv->isCulled(getBoundingBox()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
osg::RefMatrix& matrix = *cv->getModelViewMatrix();
|
osg::RefMatrix& matrix = *cv->getModelViewMatrix();
|
||||||
|
|
Loading…
Reference in a new issue