From 03b71d3c30a92f7bdf13212510ed591f80a73637 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sun, 27 Jan 2019 15:19:48 +0400 Subject: [PATCH] Improve switchable nodes handling by optimizer --- components/sceneutil/optimizer.cpp | 17 ++++++++++++++++- components/sceneutil/optimizer.hpp | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/components/sceneutil/optimizer.cpp b/components/sceneutil/optimizer.cpp index f2717fea2..25ad03fba 100644 --- a/components/sceneutil/optimizer.cpp +++ b/components/sceneutil/optimizer.cpp @@ -737,6 +737,20 @@ bool Optimizer::CombineStaticTransformsVisitor::removeTransforms(osg::Node* node // RemoveEmptyNodes. //////////////////////////////////////////////////////////////////////////// +void Optimizer::RemoveEmptyNodesVisitor::apply(osg::Switch& switchNode) +{ + // We should keep all switch child nodes since they reflect different switch states. + for (unsigned int i=0; i0) @@ -1856,7 +1870,8 @@ bool Optimizer::MergeGeometryVisitor::mergePrimitive(osg::DrawElementsUInt& lhs, bool Optimizer::MergeGroupsVisitor::isOperationPermissible(osg::Group& node) { - return !node.asTransform() && + return !node.asSwitch() && + !node.asTransform() && !node.getCullCallback() && !node.getEventCallback() && !node.getUpdateCallback() && diff --git a/components/sceneutil/optimizer.hpp b/components/sceneutil/optimizer.hpp index 6dd4394d1..9974e7097 100644 --- a/components/sceneutil/optimizer.hpp +++ b/components/sceneutil/optimizer.hpp @@ -321,6 +321,8 @@ class Optimizer BaseOptimizerVisitor(optimizer, REMOVE_REDUNDANT_NODES) {} virtual void apply(osg::Group& group); + virtual void apply(osg::LOD& lod); + virtual void apply(osg::Switch& switchNode); void removeEmptyNodes();