Use the SceneManager's ShaderManager

pull/1225/head
scrawl 8 years ago
parent 0fc465da59
commit e323b2fa7b

@ -218,7 +218,7 @@ namespace MWRender
Settings::Manager::getBool("auto use terrain normal maps", "Shaders"),
Settings::Manager::getString("terrain specular map pattern", "Shaders"), Settings::Manager::getBool("auto use terrain specular maps", "Shaders"));
mTerrain.reset(new Terrain::TerrainGrid(sceneRoot, mResourceSystem, mViewer->getIncrementalCompileOperation(),
mTerrainStorage, Mask_Terrain, &mResourceSystem->getSceneManager()->getShaderManager()));
mTerrainStorage, Mask_Terrain));
mCamera.reset(new Camera(mViewer->getCamera()));

@ -44,7 +44,6 @@ ChunkManager::ChunkManager(Storage *storage, Resource::SceneManager *sceneMgr, T
, mStorage(storage)
, mSceneManager(sceneMgr)
, mTextureManager(textureManager)
, mShaderManager(NULL)
{
}
@ -66,11 +65,6 @@ osg::ref_ptr<osg::Node> ChunkManager::getChunk(float size, const osg::Vec2f &cen
}
}
void ChunkManager::setShaderManager(Shader::ShaderManager *shaderManager)
{
mShaderManager = shaderManager;
}
void ChunkManager::reportStats(unsigned int frameNumber, osg::Stats *stats) const
{
stats->setAttribute(frameNumber, "Terrain Chunk", mCache->getCacheSize());
@ -165,8 +159,10 @@ osg::ref_ptr<osg::Node> ChunkManager::createChunk(float chunkSize, const osg::Ve
float blendmapScale = mStorage->getBlendmapScale(chunkSize);
geometry->setPasses(createPasses(mShaderManager ? useShaders : false, mSceneManager->getForcePerPixelLighting(),
mSceneManager->getClampLighting(), mShaderManager, layers, blendmapTextures, blendmapScale, blendmapScale));
Shader::ShaderManager* shaderManager = &mSceneManager->getShaderManager();
geometry->setPasses(createPasses(useShaders, mSceneManager->getForcePerPixelLighting(),
mSceneManager->getClampLighting(), shaderManager, layers, blendmapTextures, blendmapScale, blendmapScale));
transform->addChild(geometry);

@ -20,11 +20,6 @@ namespace Resource
class SceneManager;
}
namespace Shader
{
class ShaderManager;
}
namespace Terrain
{
@ -39,9 +34,6 @@ namespace Terrain
osg::ref_ptr<osg::Node> getChunk(float size, const osg::Vec2f& center);
// Optional
void setShaderManager(Shader::ShaderManager* shaderManager);
virtual void reportStats(unsigned int frameNumber, osg::Stats* stats) const;
private:
@ -50,7 +42,6 @@ namespace Terrain
Terrain::Storage* mStorage;
Resource::SceneManager* mSceneManager;
TextureManager* mTextureManager;
Shader::ShaderManager* mShaderManager;
BufferCache mBufferCache;
};

@ -11,16 +11,13 @@
namespace Terrain
{
TerrainGrid::TerrainGrid(osg::Group* parent, Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico, Storage* storage, int nodeMask, Shader::ShaderManager* shaderManager)
TerrainGrid::TerrainGrid(osg::Group* parent, Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico, Storage* storage, int nodeMask)
: Terrain::World(parent, resourceSystem, ico, storage, nodeMask)
, mNumSplits(4)
, mShaderManager(shaderManager)
{
osg::ref_ptr<osg::Material> material (new osg::Material);
material->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
mTerrainRoot->getOrCreateStateSet()->setAttributeAndModes(material, osg::StateAttribute::ON);
mChunkManager->setShaderManager(mShaderManager);
}
TerrainGrid::~TerrainGrid()

@ -7,11 +7,6 @@
#include "world.hpp"
namespace Shader
{
class ShaderManager;
}
namespace osg
{
class Texture2D;
@ -24,7 +19,7 @@ namespace Terrain
class TerrainGrid : public Terrain::World
{
public:
TerrainGrid(osg::Group* parent, Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico, Storage* storage, int nodeMask, Shader::ShaderManager* shaderManager = NULL);
TerrainGrid(osg::Group* parent, Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico, Storage* storage, int nodeMask);
~TerrainGrid();
/// Load a terrain cell and store it in cache for later use.
@ -50,8 +45,6 @@ namespace Terrain
typedef std::map<std::pair<int, int>, osg::ref_ptr<osg::Node> > Grid;
Grid mGrid;
Shader::ShaderManager* mShaderManager;
};
}

Loading…
Cancel
Save