From ebfd845eae978639d0b9bd5e3aef78696ffe89b1 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 23 Feb 2017 20:27:01 +0100 Subject: [PATCH] optimizer: run MERGE_GEOMETRY after removing redundant nodes --- components/resource/scenemanager.cpp | 2 +- components/sceneutil/optimizer.cpp | 30 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index d0fd9f446..f35ff69c1 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -485,7 +485,7 @@ namespace Resource SceneUtil::Optimizer optimizer; optimizer.setIsOperationPermissibleForObjectCallback(new CanOptimizeCallback); - optimizer.optimize(loaded, SceneUtil::Optimizer::FLATTEN_STATIC_TRANSFORMS|SceneUtil::Optimizer::REMOVE_REDUNDANT_NODES); //MERGE_GEOMETRY + optimizer.optimize(loaded, SceneUtil::Optimizer::FLATTEN_STATIC_TRANSFORMS|SceneUtil::Optimizer::REMOVE_REDUNDANT_NODES|SceneUtil::Optimizer::MERGE_GEOMETRY); } if (mIncrementalCompileOperation) diff --git a/components/sceneutil/optimizer.cpp b/components/sceneutil/optimizer.cpp index 7b37564eb..011669a54 100644 --- a/components/sceneutil/optimizer.cpp +++ b/components/sceneutil/optimizer.cpp @@ -82,21 +82,6 @@ void Optimizer::optimize(osg::Node* node, unsigned int options) cstv.removeTransforms(node); } - if (options & MERGE_GEOMETRY) - { - OSG_INFO<<"Optimizer::optimize() doing MERGE_GEOMETRY"<tick(); - - MergeGeometryVisitor mgv(this); - mgv.setTargetMaximumNumberOfVertices(10000); - node->accept(mgv); - - osg::Timer_t endTick = osg::Timer::instance()->tick(); - - OSG_INFO<<"MERGE_GEOMETRY took "<delta_s(startTick,endTick)<accept(mgrp); } + if (options & MERGE_GEOMETRY) + { + OSG_INFO<<"Optimizer::optimize() doing MERGE_GEOMETRY"<tick(); + + MergeGeometryVisitor mgv(this); + mgv.setTargetMaximumNumberOfVertices(10000); + node->accept(mgv); + + osg::Timer_t endTick = osg::Timer::instance()->tick(); + + OSG_INFO<<"MERGE_GEOMETRY took "<delta_s(startTick,endTick)<