Skip light collection for far away terrain

0.6.1
scrawl 8 years ago
parent 0782839a42
commit 9e9c028f1d

@ -10,6 +10,7 @@
#include <components/resource/scenemanager.hpp>
#include <components/sceneutil/positionattitudetransform.hpp>
#include <components/sceneutil/lightmanager.hpp>
#include "terraindrawable.hpp"
#include "material.hpp"
@ -178,6 +179,9 @@ osg::ref_ptr<osg::Node> ChunkManager::createChunk(float chunkSize, const osg::Ve
geometry->setUseDisplayList(false);
geometry->setUseVertexBufferObjects(true);
if (chunkSize <= 2.f)
geometry->setLightListCallback(new SceneUtil::LightListCallback);
unsigned int numVerts = (mStorage->getCellVertices()-1) * chunkSize / (1 << lod) + 1;
geometry->addPrimitiveSet(mBufferCache.getIndexBuffer(numVerts, lodFlags));

@ -9,7 +9,6 @@ namespace Terrain
TerrainDrawable::TerrainDrawable()
{
mLightListCallback = new SceneUtil::LightListCallback;
}
TerrainDrawable::TerrainDrawable(const TerrainDrawable &copy, const osg::CopyOp &copyop)
@ -52,7 +51,7 @@ void TerrainDrawable::cull(osgUtil::CullVisitor *cv)
if (osg::isNaN(depth))
return;
bool pushedLight = mLightListCallback->pushLightState(this, cv);
bool pushedLight = mLightListCallback && mLightListCallback->pushLightState(this, cv);
for (PassVector::const_iterator it = mPasses.begin(); it != mPasses.end(); ++it)
{
@ -70,6 +69,11 @@ void TerrainDrawable::setPasses(const TerrainDrawable::PassVector &passes)
mPasses = passes;
}
void TerrainDrawable::setLightListCallback(SceneUtil::LightListCallback *lightListCallback)
{
mLightListCallback = lightListCallback;
}
void TerrainDrawable::compileGLObjects(osg::RenderInfo &renderInfo) const
{
for (PassVector::const_iterator it = mPasses.begin(); it != mPasses.end(); ++it)

@ -37,6 +37,8 @@ namespace Terrain
typedef std::vector<osg::ref_ptr<osg::StateSet> > PassVector;
void setPasses (const PassVector& passes);
void setLightListCallback(SceneUtil::LightListCallback* lightListCallback);
virtual void compileGLObjects(osg::RenderInfo& renderInfo) const;
private:

Loading…
Cancel
Save