Skip to content

Commit

Permalink
Fix the optimizer messing up LOD node's children (Fixes #4301)
Browse files Browse the repository at this point in the history
  • Loading branch information
scrawl committed Jan 29, 2018
1 parent 89c6b59 commit 25a6a67
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions components/sceneutil/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,13 @@ bool Optimizer::RemoveRedundantNodesVisitor::isOperationPermissible(osg::Node& n
isOperationPermissibleForObject(&node);
}

void Optimizer::RemoveRedundantNodesVisitor::apply(osg::LOD& lod)
{
// don't remove any direct children of the LOD because they are used to define each LOD level.
for (unsigned int i=0; i<lod.getNumChildren(); ++i)
traverse(*lod.getChild(i));
}

void Optimizer::RemoveRedundantNodesVisitor::apply(osg::Group& group)
{
if (typeid(group)==typeid(osg::Group) &&
Expand Down Expand Up @@ -1849,6 +1856,12 @@ bool Optimizer::MergeGroupsVisitor::isOperationPermissible(osg::Group& node)
isOperationPermissibleForObject(&node);
}

void Optimizer::MergeGroupsVisitor::apply(osg::LOD &lod)
{
// don't merge the direct children of the LOD because they are used to define each LOD level.
traverse(lod);
}

void Optimizer::MergeGroupsVisitor::apply(osg::Group &group)
{
if (group.getNumChildren() <= 1)
Expand Down
2 changes: 2 additions & 0 deletions components/sceneutil/optimizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ class Optimizer

virtual void apply(osg::Group& group);
virtual void apply(osg::Transform& transform);
virtual void apply(osg::LOD& lod);

bool isOperationPermissible(osg::Node& node);

Expand All @@ -358,6 +359,7 @@ class Optimizer
bool isOperationPermissible(osg::Group& node);

virtual void apply(osg::Group& group);
virtual void apply(osg::LOD& lod);
};

class MergeGeometryVisitor : public BaseOptimizerVisitor
Expand Down

0 comments on commit 25a6a67

Please sign in to comment.