1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-12 04:14:05 +00:00

Rename old shadow class to shadow manager

This commit is contained in:
AnyOldName3 2018-02-26 14:29:31 +00:00
parent ce02c83089
commit 02d0ee3485
7 changed files with 25 additions and 25 deletions

View File

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

View File

@ -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); lightSource->setStateSetModes(*stateset, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
SceneUtil::MWShadow::disableShadowsForStateSet(stateset); SceneUtil::ShadowManager::disableShadowsForStateSet(stateset);
camera->addChild(lightSource); camera->addChild(lightSource);
camera->setStateSet(stateset); camera->setStateSet(stateset);

View File

@ -211,9 +211,9 @@ namespace MWRender
shadowCastingTraversalMask |= Mask_Player; shadowCastingTraversalMask |= Mask_Player;
if (Settings::Manager::getBool("terrain shadows", "Shadows")) if (Settings::Manager::getBool("terrain shadows", "Shadows"))
shadowCastingTraversalMask |= Mask_Terrain; 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->setShadowTechnique(tech);
shadowedScene->addChild(sceneRoot); shadowedScene->addChild(sceneRoot);

View File

@ -1124,7 +1124,7 @@ SkyManager::SkyManager(osg::Group* parentNode, Resource::SceneManager* sceneMana
// Assign empty program to specify we don't want shaders // Assign empty program to specify we don't want shaders
// The shaders generated by the SceneManager can't handle everything we need // 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); 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); skyroot->setNodeMask(Mask_Sky);
parentNode->addChild(skyroot); parentNode->addChild(skyroot);

View File

@ -51,7 +51,7 @@ namespace SceneUtil
#endif #endif
"} \n"; "} \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")) if (!Settings::Manager::getBool("enable shadows", "Shadows"))
return; return;
@ -72,7 +72,7 @@ namespace SceneUtil
settings->setTextureSize(osg::Vec2s(mapres, mapres)); 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 numberOfShadowMapsPerLight = Settings::Manager::getInt("number of shadow maps", "Shadows");
int baseShadowTextureUnit = 8 - numberOfShadowMapsPerLight; int baseShadowTextureUnit = 8 - numberOfShadowMapsPerLight;
@ -87,7 +87,7 @@ namespace SceneUtil
stateset->setTextureAttributeAndModes(i, fakeShadowMapTexture, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE | osg::StateAttribute::PROTECTED); 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")), numberOfShadowMapsPerLight(Settings::Manager::getInt("number of shadow maps", "Shadows")),
baseShadowTextureUnit(8 - numberOfShadowMapsPerLight), baseShadowTextureUnit(8 - numberOfShadowMapsPerLight),
debugHud(Settings::Manager::getBool("enable debug hud", "Shadows")), 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) osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN)
{ {
setCullingMode(osg::CullSettings::VIEW_FRUSTUM_CULLING); setCullingMode(osg::CullSettings::VIEW_FRUSTUM_CULLING);
@ -237,7 +237,7 @@ namespace SceneUtil
pushModelViewMatrix(new osg::RefMatrix(viewMatrix), osg::Transform::ABSOLUTE_RF); 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; if (isCulled(node)) return;
@ -250,7 +250,7 @@ namespace SceneUtil
popCurrentMask(); popCurrentMask();
} }
void MWShadow::ComputeLightSpaceBounds::apply(osg::Geode& node) void ShadowManager::ComputeLightSpaceBounds::apply(osg::Geode& node)
{ {
if (isCulled(node)) return; if (isCulled(node)) return;
@ -269,7 +269,7 @@ namespace SceneUtil
popCurrentMask(); popCurrentMask();
} }
void MWShadow::ComputeLightSpaceBounds::apply(osg::Drawable& drawable) void ShadowManager::ComputeLightSpaceBounds::apply(osg::Drawable& drawable)
{ {
if (isCulled(drawable)) return; if (isCulled(drawable)) return;
@ -282,7 +282,7 @@ namespace SceneUtil
popCurrentMask(); 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. // 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)); 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; OSG_INFO << "Warning Billboards not yet supported" << std::endl;
return; 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 // projection nodes won't affect a shadow map so their subgraphs should be ignored
return; return;
} }
void MWShadow::ComputeLightSpaceBounds::apply(osg::Transform& transform) void ShadowManager::ComputeLightSpaceBounds::apply(osg::Transform& transform)
{ {
if (isCulled(transform)) return; 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 // camera nodes won't affect a shadow map so their subgraphs should be ignored
return; return;
} }
void MWShadow::ComputeLightSpaceBounds::updateBound(const osg::BoundingBox& bb) void ShadowManager::ComputeLightSpaceBounds::updateBound(const osg::BoundingBox& bb)
{ {
if (!bb.valid()) return; if (!bb.valid()) return;
@ -348,7 +348,7 @@ namespace SceneUtil
update(bb.corner(7) * matrix); 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) if (v.z()<-1.0f)
{ {
@ -364,7 +364,7 @@ namespace SceneUtil
_bb.expandBy(osg::Vec3(x, y, v.z())); _bb.expandBy(osg::Vec3(x, y, v.z()));
} }
void MWShadow::cull(osgUtil::CullVisitor& cv) void ShadowManager::cull(osgUtil::CullVisitor& cv)
{ {
if (!enableShadows) if (!enableShadows)
{ {
@ -851,7 +851,7 @@ namespace SceneUtil
// OSG_NOTICE<<"End of shadow setup Projection matrix "<<*cv.getProjectionMatrix()<<std::endl; // OSG_NOTICE<<"End of shadow setup Projection matrix "<<*cv.getProjectionMatrix()<<std::endl;
} }
Shader::ShaderManager::DefineMap MWShadow::getShadowDefines() Shader::ShaderManager::DefineMap ShadowManager::getShadowDefines()
{ {
if (!enableShadows) if (!enableShadows)
return getShadowsDisabledDefines(); return getShadowsDisabledDefines();
@ -866,7 +866,7 @@ namespace SceneUtil
return definesWithShadows; return definesWithShadows;
} }
Shader::ShaderManager::DefineMap MWShadow::getShadowsDisabledDefines() Shader::ShaderManager::DefineMap ShadowManager::getShadowsDisabledDefines()
{ {
Shader::ShaderManager::DefineMap definesWithShadows; Shader::ShaderManager::DefineMap definesWithShadows;
definesWithShadows.insert(std::make_pair(std::string("shadows_enabled"), std::string("0"))); definesWithShadows.insert(std::make_pair(std::string("shadows_enabled"), std::string("0")));

View File

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

View File

@ -347,7 +347,7 @@ void QuadTreeWorld::accept(osg::NodeVisitor &nv)
{ {
if (nv.getVisitorType() != osg::NodeVisitor::CULL_VISITOR && nv.getVisitorType() != osg::NodeVisitor::INTERSECTION_VISITOR) 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) if (shadowBoundsVisitor)
shadowBoundsVisitor->apply(*this); shadowBoundsVisitor->apply(*this);
return; return;