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.
pull/3169/head
Bo Svensson 3 years ago committed by GitHub
parent ef906cbfa8
commit 93848ef01c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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&)

@ -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);

Loading…
Cancel
Save