From 87598f9419ff7622ad1207cf346f596ea1f56b8d Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sun, 27 Jan 2019 15:18:57 +0400 Subject: [PATCH 1/2] Fill Switch and LOD nodes names --- components/nifosg/nifloader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 0ed485862..fd5190861 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -325,6 +325,7 @@ namespace NifOsg osg::ref_ptr handleLodNode(const Nif::NiLODNode* niLodNode) { osg::ref_ptr lod (new osg::LOD); + lod->setName(niLodNode->name); lod->setCenterMode(osg::LOD::USER_DEFINED_CENTER); lod->setCenter(niLodNode->lodCenter); for (unsigned int i=0; ilodLevels.size(); ++i) @@ -339,6 +340,7 @@ namespace NifOsg osg::ref_ptr handleSwitchNode(const Nif::NiSwitchNode* niSwitchNode) { osg::ref_ptr switchNode (new osg::Switch); + switchNode->setName(niSwitchNode->name); switchNode->setNewChildDefaultValue(false); return switchNode; } From 03b71d3c30a92f7bdf13212510ed591f80a73637 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sun, 27 Jan 2019 15:19:48 +0400 Subject: [PATCH 2/2] 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();