1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-03 17:37:18 +00:00

avoids virtual function calls in ComputeLightSpaceBounds (#3167)

osg::NodeVisitor is designed to recursively call virtual apply signatures until we find an implemented signature. Encountered nodes that we do not explicitely handle will trigger additional virtual function calls. With this PR we avoid these additional virtual function calls in the particularly costly ComputeLightSpaceBounds by adding some explicit signatures.
This commit is contained in:
Bo Svensson 2021-10-11 13:11:59 +00:00 committed by GitHub
parent ef906cbfa8
commit 93848ef01c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 5 deletions

View File

@ -378,6 +378,11 @@ void MWShadowTechnique::ComputeLightSpaceBounds::apply(osg::Node& node)
popCurrentMask();
}
void MWShadowTechnique::ComputeLightSpaceBounds::apply(osg::Group& node)
{
apply(static_cast<osg::Node&>(node));
}
void MWShadowTechnique::ComputeLightSpaceBounds::apply(osg::Drawable& drawable)
{
if (isCulled(drawable)) return;
@ -391,6 +396,11 @@ void MWShadowTechnique::ComputeLightSpaceBounds::apply(osg::Drawable& drawable)
popCurrentMask();
}
void MWShadowTechnique::ComputeLightSpaceBounds::apply(osg::Geometry& drawable)
{
apply(static_cast<osg::Drawable&>(drawable));
}
void MWShadowTechnique::ComputeLightSpaceBounds::apply(osg::Billboard&)
{
OSG_INFO << "Warning Billboards not yet supported" << std::endl;
@ -424,7 +434,11 @@ void MWShadowTechnique::ComputeLightSpaceBounds::apply(osg::Transform& transform
// pop the culling mode.
popCurrentMask();
}
void MWShadowTechnique::ComputeLightSpaceBounds::apply(osg::MatrixTransform& transform)
{
apply(static_cast<osg::Transform&>(transform));
}
void MWShadowTechnique::ComputeLightSpaceBounds::apply(osg::Camera&)

View File

@ -91,20 +91,21 @@ namespace SceneUtil {
public:
ComputeLightSpaceBounds();
void apply(osg::Node& node) override;
void apply(osg::Node& node) override final;
void apply(osg::Group& node) override;
void apply(osg::Drawable& drawable) override;
void apply(osg::Drawable& drawable) override final;
void apply(osg::Geometry& drawable) override;
void apply(osg::Billboard&) override;
void apply(osg::Projection&) override;
void apply(osg::Transform& transform) override;
void apply(osg::Transform& transform) override final;
void apply(osg::MatrixTransform& transform) override;
void apply(osg::Camera&) override;
using osg::NodeVisitor::apply;
void updateBound(const osg::BoundingBox& bb);
void update(const osg::Vec3& v);