1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-20 11:53:52 +00:00

Move the declaration of ComputeLightSpaceBounds to the header so that it can be accessed from other compilation units.

(cherry picked from commit 8ac4fb208897a18da4934dd6f2fe84560b44ba9d)
This commit is contained in:
AnyOldName3 2018-02-04 23:27:45 +00:00
parent 6251e0519e
commit cb6767b4fc
2 changed files with 140 additions and 120 deletions

View file

@ -227,10 +227,7 @@ namespace SceneUtil
} }
} }
class ComputeLightSpaceBounds : public osg::NodeVisitor, public osg::CullStack MWShadow::ComputeLightSpaceBounds::ComputeLightSpaceBounds(osg::Viewport* viewport, const osg::Matrixd& projectionMatrix, osg::Matrixd& viewMatrix) :
{
public:
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);
@ -240,7 +237,7 @@ namespace SceneUtil
pushModelViewMatrix(new osg::RefMatrix(viewMatrix), osg::Transform::ABSOLUTE_RF); pushModelViewMatrix(new osg::RefMatrix(viewMatrix), osg::Transform::ABSOLUTE_RF);
} }
void apply(osg::Node& node) void MWShadow::ComputeLightSpaceBounds::apply(osg::Node& node)
{ {
if (isCulled(node)) return; if (isCulled(node)) return;
@ -253,7 +250,7 @@ namespace SceneUtil
popCurrentMask(); popCurrentMask();
} }
void apply(osg::Geode& node) void MWShadow::ComputeLightSpaceBounds::apply(osg::Geode& node)
{ {
if (isCulled(node)) return; if (isCulled(node)) return;
@ -272,7 +269,7 @@ namespace SceneUtil
popCurrentMask(); popCurrentMask();
} }
void apply(osg::Drawable& drawable) void MWShadow::ComputeLightSpaceBounds::apply(osg::Drawable& drawable)
{ {
if (isCulled(drawable)) return; if (isCulled(drawable)) return;
@ -285,19 +282,19 @@ namespace SceneUtil
popCurrentMask(); popCurrentMask();
} }
void apply(osg::Billboard&) void MWShadow::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 apply(osg::Projection&) void MWShadow::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 apply(osg::Transform& transform) void MWShadow::ComputeLightSpaceBounds::apply(osg::Transform& transform)
{ {
if (isCulled(transform)) return; if (isCulled(transform)) return;
@ -321,13 +318,13 @@ namespace SceneUtil
} }
void apply(osg::Camera&) void MWShadow::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 updateBound(const osg::BoundingBox& bb) void MWShadow::ComputeLightSpaceBounds::updateBound(const osg::BoundingBox& bb)
{ {
if (!bb.valid()) return; if (!bb.valid()) return;
@ -343,7 +340,7 @@ namespace SceneUtil
update(bb.corner(7) * matrix); update(bb.corner(7) * matrix);
} }
void update(const osg::Vec3& v) void MWShadow::ComputeLightSpaceBounds::update(const osg::Vec3& v)
{ {
if (v.z()<-1.0f) if (v.z()<-1.0f)
{ {
@ -359,9 +356,6 @@ namespace SceneUtil
_bb.expandBy(osg::Vec3(x, y, v.z())); _bb.expandBy(osg::Vec3(x, y, v.z()));
} }
osg::BoundingBox _bb;
};
void MWShadow::cull(osgUtil::CullVisitor& cv) void MWShadow::cull(osgUtil::CullVisitor& cv)
{ {
if (!enableShadows) if (!enableShadows)

View file

@ -22,6 +22,32 @@ namespace SceneUtil
virtual Shader::ShaderManager::DefineMap getShadowDefines(); virtual Shader::ShaderManager::DefineMap getShadowDefines();
virtual Shader::ShaderManager::DefineMap getShadowsDisabledDefines(); virtual Shader::ShaderManager::DefineMap getShadowsDisabledDefines();
class ComputeLightSpaceBounds : public osg::NodeVisitor, public osg::CullStack
{
public:
ComputeLightSpaceBounds(osg::Viewport* viewport, const osg::Matrixd& projectionMatrix, osg::Matrixd& viewMatrix);
void apply(osg::Node& node);
void apply(osg::Geode& node);
void apply(osg::Drawable& drawable);
void apply(osg::Billboard&);
void apply(osg::Projection&);
void apply(osg::Transform& transform);
void apply(osg::Camera&);
void updateBound(const osg::BoundingBox& bb);
void update(const osg::Vec3& v);
osg::BoundingBox _bb;
};
protected: protected:
const int debugTextureUnit; const int debugTextureUnit;