| 54 | } |
| 55 | |
| 56 | void 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 | { |
no test coverage detected