MCPcopy Create free account
hub / github.com/OpenMW/openmw / optimize

Method optimize

components/sceneutil/optimizer.cpp:56–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56void Optimizer::optimize(osg::Node* node, unsigned int options)
57{
58 StatsVisitor stats;
59
60 if (osg::getNotifyLevel()>=osg::INFO)
61 {
62 node->accept(stats);
63 stats.totalUpStats();
64 OSG_NOTICE<<std::endl<<"Stats before:"<<std::endl;
65 stats.print(osg::notify(osg::NOTICE));
66 }
67
68 if (options & FLATTEN_STATIC_TRANSFORMS)
69 {
70 OSG_INFO<<"Optimizer::optimize() doing FLATTEN_STATIC_TRANSFORMS"<<std::endl;
71
72 int i=0;
73 bool result = false;
74 do
75 {
76 OSG_DEBUG << "** RemoveStaticTransformsVisitor *** Pass "<<i<<std::endl;
77 FlattenStaticTransformsVisitor fstv(this);
78 node->accept(fstv);
79 result = fstv.removeTransforms(node);
80 ++i;
81 } while (result);
82
83 // now combine any adjacent static transforms.
84 CombineStaticTransformsVisitor cstv(this);
85 node->accept(cstv);
86 cstv.removeTransforms(node);
87 }
88
89 if (options & SHARE_DUPLICATE_STATE && _sharedStateManager)
90 {
91 if (_sharedStateMutex) _sharedStateMutex->lock();
92 _sharedStateManager->share(node);
93 if (_sharedStateMutex) _sharedStateMutex->unlock();
94 }
95
96 if (options & REMOVE_REDUNDANT_NODES)
97 {
98 OSG_INFO<<"Optimizer::optimize() doing REMOVE_REDUNDANT_NODES"<<std::endl;
99
100 RemoveEmptyNodesVisitor renv(this);
101 node->accept(renv);
102 renv.removeEmptyNodes();
103
104 RemoveRedundantNodesVisitor rrnv(this);
105 node->accept(rrnv);
106 rrnv.removeRedundantNodes();
107
108 MergeGroupsVisitor mgrp(this);
109 node->accept(mgrp);
110 }
111
112 if (options & MERGE_GEOMETRY)
113 {

Callers 2

getTemplateMethod · 0.80
createChunkMethod · 0.80

Calls 11

removeTransformsMethod · 0.80
removeEmptyNodesMethod · 0.80
removeRedundantNodesMethod · 0.80
acceptMethod · 0.45
printMethod · 0.45
lockMethod · 0.45
unlockMethod · 0.45
setMergeAlphaBlendingMethod · 0.45
setViewPointMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected