Rename old shadow class to shadow manager

pull/1547/head
AnyOldName3 7 years ago
parent ce02c83089
commit 02d0ee3485

@ -151,7 +151,7 @@ namespace MWRender
defaultMat->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4f(0.f, 0.f, 0.f, 0.f));
stateset->setAttribute(defaultMat);
SceneUtil::MWShadow::disableShadowsForStateSet(stateset);
SceneUtil::ShadowManager::disableShadowsForStateSet(stateset);
// assign large value to effectively turn off fog
// shaders don't respect glDisable(GL_FOG)

@ -202,7 +202,7 @@ osg::ref_ptr<osg::Camera> LocalMap::createOrthographicCamera(float x, float y, f
lightSource->setStateSetModes(*stateset, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
SceneUtil::MWShadow::disableShadowsForStateSet(stateset);
SceneUtil::ShadowManager::disableShadowsForStateSet(stateset);
camera->addChild(lightSource);
camera->setStateSet(stateset);

@ -211,9 +211,9 @@ namespace MWRender
shadowCastingTraversalMask |= Mask_Player;
if (Settings::Manager::getBool("terrain shadows", "Shadows"))
shadowCastingTraversalMask |= Mask_Terrain;
SceneUtil::MWShadow::setupShadowSettings(shadowedScene->getShadowSettings(), shadowCastingTraversalMask);
SceneUtil::ShadowManager::setupShadowSettings(shadowedScene->getShadowSettings(), shadowCastingTraversalMask);
SceneUtil::MWShadow* tech = new SceneUtil::MWShadow();
SceneUtil::ShadowManager* tech = new SceneUtil::ShadowManager();
shadowedScene->setShadowTechnique(tech);
shadowedScene->addChild(sceneRoot);

@ -1124,7 +1124,7 @@ SkyManager::SkyManager(osg::Group* parentNode, Resource::SceneManager* sceneMana
// Assign empty program to specify we don't want shaders
// The shaders generated by the SceneManager can't handle everything we need
skyroot->getOrCreateStateSet()->setAttributeAndModes(new osg::Program(), osg::StateAttribute::OVERRIDE|osg::StateAttribute::PROTECTED|osg::StateAttribute::ON);
SceneUtil::MWShadow::disableShadowsForStateSet(skyroot->getOrCreateStateSet());
SceneUtil::ShadowManager::disableShadowsForStateSet(skyroot->getOrCreateStateSet());
skyroot->setNodeMask(Mask_Sky);
parentNode->addChild(skyroot);

@ -51,7 +51,7 @@ namespace SceneUtil
#endif
"} \n";
void MWShadow::setupShadowSettings(osg::ref_ptr<osgShadow::ShadowSettings> settings, int castsShadowMask)
void ShadowManager::setupShadowSettings(osg::ref_ptr<osgShadow::ShadowSettings> settings, int castsShadowMask)
{
if (!Settings::Manager::getBool("enable shadows", "Shadows"))
return;
@ -72,7 +72,7 @@ namespace SceneUtil
settings->setTextureSize(osg::Vec2s(mapres, mapres));
}
void MWShadow::disableShadowsForStateSet(osg::ref_ptr<osg::StateSet> stateset)
void ShadowManager::disableShadowsForStateSet(osg::ref_ptr<osg::StateSet> stateset)
{
int numberOfShadowMapsPerLight = Settings::Manager::getInt("number of shadow maps", "Shadows");
int baseShadowTextureUnit = 8 - numberOfShadowMapsPerLight;
@ -87,7 +87,7 @@ namespace SceneUtil
stateset->setTextureAttributeAndModes(i, fakeShadowMapTexture, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE | osg::StateAttribute::PROTECTED);
}
MWShadow::MWShadow() : enableShadows(Settings::Manager::getBool("enable shadows", "Shadows")),
ShadowManager::ShadowManager() : enableShadows(Settings::Manager::getBool("enable shadows", "Shadows")),
numberOfShadowMapsPerLight(Settings::Manager::getInt("number of shadow maps", "Shadows")),
baseShadowTextureUnit(8 - numberOfShadowMapsPerLight),
debugHud(Settings::Manager::getBool("enable debug hud", "Shadows")),
@ -227,7 +227,7 @@ namespace SceneUtil
}
}
MWShadow::ComputeLightSpaceBounds::ComputeLightSpaceBounds(osg::Viewport* viewport, const osg::Matrixd& projectionMatrix, osg::Matrixd& viewMatrix) :
ShadowManager::ComputeLightSpaceBounds::ComputeLightSpaceBounds(osg::Viewport* viewport, const osg::Matrixd& projectionMatrix, osg::Matrixd& viewMatrix) :
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN)
{
setCullingMode(osg::CullSettings::VIEW_FRUSTUM_CULLING);
@ -237,7 +237,7 @@ namespace SceneUtil
pushModelViewMatrix(new osg::RefMatrix(viewMatrix), osg::Transform::ABSOLUTE_RF);
}
void MWShadow::ComputeLightSpaceBounds::apply(osg::Node& node)
void ShadowManager::ComputeLightSpaceBounds::apply(osg::Node& node)
{
if (isCulled(node)) return;
@ -250,7 +250,7 @@ namespace SceneUtil
popCurrentMask();
}
void MWShadow::ComputeLightSpaceBounds::apply(osg::Geode& node)
void ShadowManager::ComputeLightSpaceBounds::apply(osg::Geode& node)
{
if (isCulled(node)) return;
@ -269,7 +269,7 @@ namespace SceneUtil
popCurrentMask();
}
void MWShadow::ComputeLightSpaceBounds::apply(osg::Drawable& drawable)
void ShadowManager::ComputeLightSpaceBounds::apply(osg::Drawable& drawable)
{
if (isCulled(drawable)) return;
@ -282,7 +282,7 @@ namespace SceneUtil
popCurrentMask();
}
void MWShadow::ComputeLightSpaceBounds::apply(Terrain::QuadTreeWorld & quadTreeWorld)
void ShadowManager::ComputeLightSpaceBounds::apply(Terrain::QuadTreeWorld & quadTreeWorld)
{
// For now, just expand the bounds fully as terrain will fill them up and possible ways to detect which terrain definitely won't cast shadows aren't implemented.
@ -290,19 +290,19 @@ namespace SceneUtil
update(osg::Vec3(1.0, 1.0, 0.0));
}
void MWShadow::ComputeLightSpaceBounds::apply(osg::Billboard&)
void ShadowManager::ComputeLightSpaceBounds::apply(osg::Billboard&)
{
OSG_INFO << "Warning Billboards not yet supported" << std::endl;
return;
}
void MWShadow::ComputeLightSpaceBounds::apply(osg::Projection&)
void ShadowManager::ComputeLightSpaceBounds::apply(osg::Projection&)
{
// projection nodes won't affect a shadow map so their subgraphs should be ignored
return;
}
void MWShadow::ComputeLightSpaceBounds::apply(osg::Transform& transform)
void ShadowManager::ComputeLightSpaceBounds::apply(osg::Transform& transform)
{
if (isCulled(transform)) return;
@ -326,13 +326,13 @@ namespace SceneUtil
}
void MWShadow::ComputeLightSpaceBounds::apply(osg::Camera&)
void ShadowManager::ComputeLightSpaceBounds::apply(osg::Camera&)
{
// camera nodes won't affect a shadow map so their subgraphs should be ignored
return;
}
void MWShadow::ComputeLightSpaceBounds::updateBound(const osg::BoundingBox& bb)
void ShadowManager::ComputeLightSpaceBounds::updateBound(const osg::BoundingBox& bb)
{
if (!bb.valid()) return;
@ -348,7 +348,7 @@ namespace SceneUtil
update(bb.corner(7) * matrix);
}
void MWShadow::ComputeLightSpaceBounds::update(const osg::Vec3& v)
void ShadowManager::ComputeLightSpaceBounds::update(const osg::Vec3& v)
{
if (v.z()<-1.0f)
{
@ -364,7 +364,7 @@ namespace SceneUtil
_bb.expandBy(osg::Vec3(x, y, v.z()));
}
void MWShadow::cull(osgUtil::CullVisitor& cv)
void ShadowManager::cull(osgUtil::CullVisitor& cv)
{
if (!enableShadows)
{
@ -851,7 +851,7 @@ namespace SceneUtil
// OSG_NOTICE<<"End of shadow setup Projection matrix "<<*cv.getProjectionMatrix()<<std::endl;
}
Shader::ShaderManager::DefineMap MWShadow::getShadowDefines()
Shader::ShaderManager::DefineMap ShadowManager::getShadowDefines()
{
if (!enableShadows)
return getShadowsDisabledDefines();
@ -866,7 +866,7 @@ namespace SceneUtil
return definesWithShadows;
}
Shader::ShaderManager::DefineMap MWShadow::getShadowsDisabledDefines()
Shader::ShaderManager::DefineMap ShadowManager::getShadowsDisabledDefines()
{
Shader::ShaderManager::DefineMap definesWithShadows;
definesWithShadows.insert(std::make_pair(std::string("shadows_enabled"), std::string("0")));

@ -9,14 +9,14 @@
namespace SceneUtil
{
class MWShadow : public osgShadow::ViewDependentShadowMap
class ShadowManager : public osgShadow::ViewDependentShadowMap
{
public:
static void setupShadowSettings(osg::ref_ptr<osgShadow::ShadowSettings> settings, int castsShadowMask);
static void disableShadowsForStateSet(osg::ref_ptr<osg::StateSet> stateSet);
MWShadow();
ShadowManager();
virtual void cull(osgUtil::CullVisitor& cv) override;

@ -347,7 +347,7 @@ void QuadTreeWorld::accept(osg::NodeVisitor &nv)
{
if (nv.getVisitorType() != osg::NodeVisitor::CULL_VISITOR && nv.getVisitorType() != osg::NodeVisitor::INTERSECTION_VISITOR)
{
SceneUtil::MWShadow::ComputeLightSpaceBounds* shadowBoundsVisitor = dynamic_cast<SceneUtil::MWShadow::ComputeLightSpaceBounds *>(&nv);
SceneUtil::ShadowManager::ComputeLightSpaceBounds* shadowBoundsVisitor = dynamic_cast<SceneUtil::ShadowManager::ComputeLightSpaceBounds *>(&nv);
if (shadowBoundsVisitor)
shadowBoundsVisitor->apply(*this);
return;

Loading…
Cancel
Save