openscenegraph
Optimizer
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSGUTIL_OPTIMIZER
15#define OSGUTIL_OPTIMIZER
16
17#include <osg/NodeVisitor>
18#include <osg/Matrix>
19#include <osg/Geometry>
20#include <osg/Transform>
21#include <osg/Texture2D>
22
23#include <osgUtil/Export>
24
25#include <set>
26
27namespace osgUtil {
28
29// forward declare
30class Optimizer;
31
34{
35 public:
36
37 BaseOptimizerVisitor(Optimizer* optimizer, unsigned int operation):
38 osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
39 _optimizer(optimizer),
40 _operationType(operation)
41 {
42 setNodeMaskOverride(0xffffffff);
43 }
44
45 inline bool isOperationPermissibleForObject(const osg::StateSet* object) const;
46 inline bool isOperationPermissibleForObject(const osg::StateAttribute* object) const;
47 inline bool isOperationPermissibleForObject(const osg::Drawable* object) const;
48 inline bool isOperationPermissibleForObject(const osg::Node* object) const;
49
50 protected:
51
53 unsigned int _operationType;
54};
55
61{
62
63 public:
64
66 virtual ~Optimizer() {}
67
69 {
70 FLATTEN_STATIC_TRANSFORMS = (1 << 0),
71 REMOVE_REDUNDANT_NODES = (1 << 1),
72 REMOVE_LOADED_PROXY_NODES = (1 << 2),
73 COMBINE_ADJACENT_LODS = (1 << 3),
74 SHARE_DUPLICATE_STATE = (1 << 4),
75 MERGE_GEOMETRY = (1 << 5),
76 CHECK_GEOMETRY = (1 << 6), // deprecated, currently no-op
77 MAKE_FAST_GEOMETRY = (1 << 7),
78 SPATIALIZE_GROUPS = (1 << 8),
79 COPY_SHARED_NODES = (1 << 9),
80 TRISTRIP_GEOMETRY = (1 << 10),
81 TESSELLATE_GEOMETRY = (1 << 11),
82 OPTIMIZE_TEXTURE_SETTINGS = (1 << 12),
83 MERGE_GEODES = (1 << 13),
84 FLATTEN_BILLBOARDS = (1 << 14),
85 TEXTURE_ATLAS_BUILDER = (1 << 15),
86 STATIC_OBJECT_DETECTION = (1 << 16),
87 FLATTEN_STATIC_TRANSFORMS_DUPLICATING_SHARED_SUBGRAPHS = (1 << 17),
88 INDEX_MESH = (1 << 18),
89 VERTEX_POSTTRANSFORM = (1 << 19),
90 VERTEX_PRETRANSFORM = (1 << 20),
91 BUFFER_OBJECT_SETTINGS = (1 << 21),
92 DEFAULT_OPTIMIZATIONS = FLATTEN_STATIC_TRANSFORMS |
93 REMOVE_REDUNDANT_NODES |
94 REMOVE_LOADED_PROXY_NODES |
95 COMBINE_ADJACENT_LODS |
96 SHARE_DUPLICATE_STATE |
97 MERGE_GEOMETRY |
98 MAKE_FAST_GEOMETRY |
99 CHECK_GEOMETRY |
100 OPTIMIZE_TEXTURE_SETTINGS |
101 STATIC_OBJECT_DETECTION,
102 ALL_OPTIMIZATIONS = FLATTEN_STATIC_TRANSFORMS_DUPLICATING_SHARED_SUBGRAPHS |
103 REMOVE_REDUNDANT_NODES |
104 REMOVE_LOADED_PROXY_NODES |
105 COMBINE_ADJACENT_LODS |
106 SHARE_DUPLICATE_STATE |
107 MERGE_GEODES |
108 MERGE_GEOMETRY |
109 MAKE_FAST_GEOMETRY |
110 CHECK_GEOMETRY |
111 SPATIALIZE_GROUPS |
112 COPY_SHARED_NODES |
113 TRISTRIP_GEOMETRY |
114 OPTIMIZE_TEXTURE_SETTINGS |
115 TEXTURE_ATLAS_BUILDER |
116 STATIC_OBJECT_DETECTION |
117 BUFFER_OBJECT_SETTINGS
118 };
119
121 void reset();
122
125 void optimize(osg::Node* node);
126
127 template<class T> void optimize(const osg::ref_ptr<T>& node) { optimize(node.get()); }
128
131 virtual void optimize(osg::Node* node, unsigned int options);
132
133 template<class T> void optimize(const osg::ref_ptr<T>& node, unsigned int options) { optimize(node.get(), options); }
134
135
138 {
139 virtual bool isOperationPermissibleForObjectImplementation(const Optimizer* optimizer, const osg::StateSet* stateset,unsigned int option) const
140 {
141 return optimizer->isOperationPermissibleForObjectImplementation(stateset,option);
142 }
143
144 virtual bool isOperationPermissibleForObjectImplementation(const Optimizer* optimizer, const osg::StateAttribute* attribute,unsigned int option) const
145 {
146 return optimizer->isOperationPermissibleForObjectImplementation(attribute,option);
147 }
148
149 virtual bool isOperationPermissibleForObjectImplementation(const Optimizer* optimizer, const osg::Drawable* drawable,unsigned int option) const
150 {
151 return optimizer->isOperationPermissibleForObjectImplementation(drawable,option);
152 }
153
154 virtual bool isOperationPermissibleForObjectImplementation(const Optimizer* optimizer, const osg::Node* node,unsigned int option) const
155 {
156 return optimizer->isOperationPermissibleForObjectImplementation(node,option);
157 }
158
159 };
160
162 void setIsOperationPermissibleForObjectCallback(IsOperationPermissibleForObjectCallback* callback) { _isOperationPermissibleForObjectCallback=callback; }
163
165 IsOperationPermissibleForObjectCallback* getIsOperationPermissibleForObjectCallback() { return _isOperationPermissibleForObjectCallback.get(); }
166
168 const IsOperationPermissibleForObjectCallback* getIsOperationPermissibleForObjectCallback() const { return _isOperationPermissibleForObjectCallback.get(); }
169
170
171 inline void setPermissibleOptimizationsForObject(const osg::Object* object, unsigned int options)
172 {
173 _permissibleOptimizationsMap[object] = options;
174 }
175
176 inline unsigned int getPermissibleOptimizationsForObject(const osg::Object* object) const
177 {
178 PermissibleOptimizationsMap::const_iterator itr = _permissibleOptimizationsMap.find(object);
179 if (itr!=_permissibleOptimizationsMap.end()) return itr->second;
180 else return 0xffffffff;
181 }
182
183
184 inline bool isOperationPermissibleForObject(const osg::StateSet* object, unsigned int option) const
185 {
186 if (_isOperationPermissibleForObjectCallback.valid())
187 return _isOperationPermissibleForObjectCallback->isOperationPermissibleForObjectImplementation(this,object,option);
188 else
189 return isOperationPermissibleForObjectImplementation(object,option);
190 }
191
192 inline bool isOperationPermissibleForObject(const osg::StateAttribute* object, unsigned int option) const
193 {
194 if (_isOperationPermissibleForObjectCallback.valid())
195 return _isOperationPermissibleForObjectCallback->isOperationPermissibleForObjectImplementation(this,object,option);
196 else
197 return isOperationPermissibleForObjectImplementation(object,option);
198 }
199
200 inline bool isOperationPermissibleForObject(const osg::Drawable* object, unsigned int option) const
201 {
202 if (_isOperationPermissibleForObjectCallback.valid())
203 return _isOperationPermissibleForObjectCallback->isOperationPermissibleForObjectImplementation(this,object,option);
204 else
205 return isOperationPermissibleForObjectImplementation(object,option);
206 }
207
208 inline bool isOperationPermissibleForObject(const osg::Node* object, unsigned int option) const
209 {
210 if (_isOperationPermissibleForObjectCallback.valid())
211 return _isOperationPermissibleForObjectCallback->isOperationPermissibleForObjectImplementation(this,object,option);
212 else
213 return isOperationPermissibleForObjectImplementation(object,option);
214 }
215
216 bool isOperationPermissibleForObjectImplementation(const osg::StateSet* stateset, unsigned int option) const
217 {
218 return (option & getPermissibleOptimizationsForObject(stateset))!=0;
219 }
220
221 bool isOperationPermissibleForObjectImplementation(const osg::StateAttribute* attribute, unsigned int option) const
222 {
223 return (option & getPermissibleOptimizationsForObject(attribute))!=0;
224 }
225
226 bool isOperationPermissibleForObjectImplementation(const osg::Drawable* drawable, unsigned int option) const
227 {
228 if (option & (REMOVE_REDUNDANT_NODES|MERGE_GEOMETRY))
229 {
230 if (drawable->getUserData()) return false;
231 if (drawable->getUpdateCallback()) return false;
232 if (drawable->getEventCallback()) return false;
233 if (drawable->getCullCallback()) return false;
234 }
235 return (option & getPermissibleOptimizationsForObject(drawable))!=0;
236 }
237
238 bool isOperationPermissibleForObjectImplementation(const osg::Node* node, unsigned int option) const
239 {
240 if (option & (REMOVE_REDUNDANT_NODES|COMBINE_ADJACENT_LODS|FLATTEN_STATIC_TRANSFORMS))
241 {
242 if (node->getUserData()) return false;
243 if (node->getUpdateCallback()) return false;
244 if (node->getEventCallback()) return false;
245 if (node->getCullCallback()) return false;
246 if (node->getNumDescriptions()>0) return false;
247 if (node->getStateSet()) return false;
248 if (node->getNodeMask()!=0xffffffff) return false;
249 // if (!node->getName().empty()) return false;
250 }
251
252 return (option & getPermissibleOptimizationsForObject(node))!=0;
253 }
254
255 protected:
256
258
259 typedef std::map<const osg::Object*,unsigned int> PermissibleOptimizationsMap;
261
262 public:
263
271 {
272 public:
273
275 BaseOptimizerVisitor(optimizer, FLATTEN_STATIC_TRANSFORMS) {}
276
277 virtual void apply(osg::Node& geode);
278 virtual void apply(osg::Drawable& drawable);
279 virtual void apply(osg::Billboard& geode);
280 virtual void apply(osg::ProxyNode& node);
281 virtual void apply(osg::PagedLOD& node);
282 virtual void apply(osg::Transform& transform);
283
284 bool removeTransforms(osg::Node* nodeWeCannotRemove);
285
286 protected:
287
288 typedef std::vector<osg::Transform*> TransformStack;
289 typedef std::set<osg::Drawable*> DrawableSet;
290 typedef std::set<osg::Billboard*> BillboardSet;
291 typedef std::set<osg::Node* > NodeSet;
292 typedef std::set<osg::Transform*> TransformSet;
293
299 };
300
309 {
310 public:
311
313 BaseOptimizerVisitor(optimizer, FLATTEN_STATIC_TRANSFORMS_DUPLICATING_SHARED_SUBGRAPHS) {}
314
315 virtual void reset();
316
317 virtual void apply(osg::Group& group);
318 virtual void apply(osg::Transform& transform);
319 virtual void apply(osg::LOD& lod);
320 virtual void apply(osg::Geode& geode);
321 virtual void apply(osg::Billboard& billboard);
322
323 protected:
324
328
329 std::vector<osg::Matrix> _matrixStack;
330
331 };
332
335 {
336 public:
337
339 BaseOptimizerVisitor(optimizer, FLATTEN_STATIC_TRANSFORMS) {}
340
341 virtual void apply(osg::MatrixTransform& transform);
342
343 bool removeTransforms(osg::Node* nodeWeCannotRemove);
344
345 protected:
346
347 typedef std::set<osg::MatrixTransform*> TransformSet;
349 };
350
353 {
354 public:
355
356
357 typedef std::set<osg::Node*> NodeList;
359
361 BaseOptimizerVisitor(optimizer, REMOVE_REDUNDANT_NODES) {}
362
363 virtual void apply(osg::Group& group);
364
366
367 };
368
371 {
372 public:
373
374 typedef std::set<osg::Node*> NodeList;
376
378 BaseOptimizerVisitor(optimizer, REMOVE_REDUNDANT_NODES) {}
379
380 virtual void apply(osg::Group& group);
381 virtual void apply(osg::Transform& transform);
382
384
386
387 };
388
391 {
392 public:
393
394 typedef std::set<osg::Node*> NodeList;
396
398 BaseOptimizerVisitor(optimizer, REMOVE_LOADED_PROXY_NODES) {}
399
400 virtual void apply(osg::ProxyNode& group);
401
403
404 };
405
408 {
409 public:
410
411 typedef std::set<osg::Group*> GroupList;
413
415 BaseOptimizerVisitor(optimizer, TESSELLATE_GEOMETRY) {}
416
417 virtual void apply(osg::Geometry& geom);
418
419 };
420
424 {
425 public:
426
427 typedef std::set<osg::Group*> GroupList;
429
431 BaseOptimizerVisitor(optimizer, COMBINE_ADJACENT_LODS) {}
432
433 virtual void apply(osg::LOD& lod);
434
436
437 };
438
443 {
444 public:
445
447 StateVisitor(bool combineDynamicState,
448 bool combineStaticState,
449 bool combineUnspecifiedState,
450 Optimizer* optimizer=0):
451 BaseOptimizerVisitor(optimizer, SHARE_DUPLICATE_STATE)
452 {
453 _optimize[osg::Object::DYNAMIC] = combineDynamicState;
454 _optimize[osg::Object::STATIC] = combineStaticState;
455 _optimize[osg::Object::UNSPECIFIED] = combineUnspecifiedState;
456 }
457
459 virtual void reset();
460
461 virtual void apply(osg::Node& node);
462
463 void optimize();
464
465 protected:
466
467 void addStateSet(osg::StateSet* stateset, osg::Node* node);
468
470 {
471 return _optimize[variance];
472 }
473
474 typedef std::set<osg::Node*> NodeSet;
475 typedef std::map<osg::StateSet*, NodeSet> StateSetMap;
476
477 // note, one element for DYNAMIC, STATIC and UNSPECIFIED
478 bool _optimize[3];
479
481
482 };
483
487 {
488 public:
489
492 BaseOptimizerVisitor(optimizer, MERGE_GEODES) {}
493
494 virtual void apply(osg::Group& group);
495
497
498 protected:
499
501
502 };
503
505 {
506 public:
507
510 BaseOptimizerVisitor(optimizer, MAKE_FAST_GEOMETRY) {}
511
512 virtual void apply(osg::Geometry& geom);
513
514 };
515
517 {
518 public:
519
522 BaseOptimizerVisitor(optimizer, MERGE_GEOMETRY),
523 _targetMaximumNumberOfVertices(10000) {}
524
525 void setTargetMaximumNumberOfVertices(unsigned int num)
526 {
527 _targetMaximumNumberOfVertices = num;
528 }
529
531 {
532 return _targetMaximumNumberOfVertices;
533 }
534
535 virtual void apply(osg::Group& group) { mergeGroup(group); traverse(group); }
536 virtual void apply(osg::Billboard&) { /* don't do anything*/ }
537
538 bool mergeGroup(osg::Group& group);
539
541
543
549
550 protected:
551
553
554 };
555
558 {
559 public:
560
562 BaseOptimizerVisitor(optimizer, SPATIALIZE_GROUPS) {}
563
564 virtual void apply(osg::Group& group);
565 virtual void apply(osg::Geode& geode);
566
567 bool divide(unsigned int maxNumTreesPerCell=8);
568
569 bool divide(osg::Group* group, unsigned int maxNumTreesPerCell);
570 bool divide(osg::Geode* geode, unsigned int maxNumTreesPerCell);
571
572 typedef std::set<osg::Group*> GroupsToDivideList;
574
575 typedef std::set<osg::Geode*> GeodesToDivideList;
577 };
578
581 {
582 public:
583
585 BaseOptimizerVisitor(optimizer, COPY_SHARED_NODES) {}
586
587 virtual void apply(osg::Node& node);
588
590
591 typedef std::set<osg::Node*> SharedNodeList;
593
594 };
595
596
599 {
600 public:
601
602 TextureVisitor(bool changeAutoUnRef, bool valueAutoUnRef,
603 bool changeClientImageStorage, bool valueClientImageStorage,
604 bool changeAnisotropy, float valueAnisotropy,
605 Optimizer* optimizer=0):
606 BaseOptimizerVisitor(optimizer, OPTIMIZE_TEXTURE_SETTINGS),
607 _changeAutoUnRef(changeAutoUnRef), _valueAutoUnRef(valueAutoUnRef),
608 _changeClientImageStorage(changeClientImageStorage), _valueClientImageStorage(valueClientImageStorage),
609 _changeAnisotropy(changeAnisotropy), _valueAnisotropy(valueAnisotropy) {}
610
611 virtual void apply(osg::Node& node);
612
613 void apply(osg::StateSet& stateset);
614 void apply(osg::Texture& texture);
615
616 bool _changeAutoUnRef, _valueAutoUnRef;
617 bool _changeClientImageStorage, _valueClientImageStorage;
620
621 };
622
625 {
626 public:
628 BaseOptimizerVisitor(optimizer, FLATTEN_BILLBOARDS) {}
629
630 typedef std::vector<osg::NodePath> NodePathList;
631 typedef std::map<osg::Billboard*, NodePathList > BillboardNodePathMap;
632
633 virtual void reset();
634
635 virtual void apply(osg::Billboard& billboard);
636
637 void process();
638
640
641 };
642
646 {
647 public:
649
650 void reset();
651
652 void setMaximumAtlasSize(int width, int height);
653
654 int getMaximumAtlasWidth() const { return _maximumAtlasWidth; }
655 int getMaximumAtlasHeight() const { return _maximumAtlasHeight; }
656
657 void setMargin(int margin);
658 int getMargin() const { return _margin; }
659
660 void addSource(const osg::Image* image);
661 void addSource(const osg::Texture2D* texture);
662
663 unsigned int getNumSources() const { return _sourceList.size(); }
664 const osg::Image* getSourceImage(unsigned int i) { return _sourceList[i]->_image.get(); }
665 const osg::Texture2D* getSourceTexture(unsigned int i) { return _sourceList[i]->_texture.get(); }
666
668 osg::Image* getImageAtlas(unsigned int i);
671
675
679
680 protected:
681
685
686
687 // forward declare
688 class Atlas;
689
690 class Source : public osg::Referenced
691 {
692 public:
694 _x(0),_y(0),_atlas(0) {}
695
696 Source(const osg::Image* image):
697 _x(0),_y(0),_atlas(0),_image(image) {}
698
699 Source(const osg::Texture2D* texture):
700 _x(0),_y(0),_atlas(0),_texture(texture) { if (texture) _image = texture->getImage(); }
701
702 int _x;
703 int _y;
705
708
709 bool suitableForAtlas(int maximumAtlasWidth, int maximumAtlasHeight, int margin);
711
712
713 protected:
714
715 virtual ~Source() {}
716 };
717
718 typedef std::vector< osg::ref_ptr<Source> > SourceList;
719
720 class Atlas : public osg::Referenced
721 {
722 public:
723 Atlas(int width, int height, int margin):
724 _maximumAtlasWidth(width),
725 _maximumAtlasHeight(height),
726 _margin(margin),
727 _x(0),
728 _y(0),
729 _width(0),
730 _height(0),
731 _indexFirstOfRow(0){}
732
736
739
741
742 int _x;
743 int _y;
746 unsigned int _indexFirstOfRow;
754 bool addSource(Source* source);
757
758 protected:
759 virtual ~Atlas() {}
760 };
761
762 typedef std::vector< osg::ref_ptr<Atlas> > AtlasList;
763
766
769 private:
770 struct CompareSrc
771 {
772 bool operator()(osg::ref_ptr<Source> src1, osg::ref_ptr<Source> src2) const
773 {
774 return src1->_image->t() > src2->_image->t();
775 }
776 };
777 void completeRow(unsigned int indexAtlas);
778 };
779
780
785 {
786 public:
787
790 BaseOptimizerVisitor(optimizer, TEXTURE_ATLAS_BUILDER) {}
791
792
794
796 virtual void reset();
797
798 virtual void apply(osg::Node& node);
799 virtual void apply(osg::Drawable& node);
800
801 void optimize();
802
803 protected:
804
807
808 typedef std::set<osg::Drawable*> Drawables;
809 typedef std::map<osg::StateSet*, Drawables> StateSetMap;
810 typedef std::set<osg::Texture2D*> Textures;
811 typedef std::vector<osg::StateSet*> StateSetStack;
812
814
818
819 };
820
824 {
825 public:
826
829 BaseOptimizerVisitor(optimizer, STATIC_OBJECT_DETECTION) {}
830
831 virtual void apply(osg::Node& node);
832 virtual void apply(osg::Drawable& drawable);
833
834 protected:
835
837
838 };
839
842 {
843 public:
844
845 BufferObjectVisitor(bool changeVBO, bool valueVBO,
846 bool changeVertexArrayObject, bool valueVertexArrayObject,
847 bool changeDisplayList, bool valueDisplayList,
848 Optimizer* optimizer=0):
849 BaseOptimizerVisitor(optimizer, BUFFER_OBJECT_SETTINGS),
850 _changeVertexBufferObject(changeVBO), _valueVertexBufferObject(valueVBO),
851 _changeVertexArrayObject(changeVertexArrayObject), _valueVertexArrayObject(valueVertexArrayObject),
852 _changeDisplayList(changeDisplayList), _valueDisplayList(valueDisplayList) {}
853
854 virtual void apply(osg::Geometry& geometry);
855
856 bool _changeVertexBufferObject, _valueVertexBufferObject;
857 bool _changeVertexArrayObject, _valueVertexArrayObject;
858 bool _changeDisplayList, _valueDisplayList;
859
860 };
861};
862
867
872
877
882
883}
884
885#endif
Definition Optimizer:34
bool isOperationPermissibleForObject(const osg::StateSet *object) const
Definition Optimizer:863
BaseOptimizerVisitor(Optimizer *optimizer, unsigned int operation)
Definition Optimizer:37
Optimizer * _optimizer
Definition Optimizer:52
unsigned int _operationType
Definition Optimizer:53
BufferObjectVisitor(bool changeVBO, bool valueVBO, bool changeVertexArrayObject, bool valueVertexArrayObject, bool changeDisplayList, bool valueDisplayList, Optimizer *optimizer=0)
Definition Optimizer:845
bool _changeVertexArrayObject
Definition Optimizer:857
bool _changeVertexBufferObject
Definition Optimizer:856
virtual void apply(osg::Geometry &geometry)
bool _changeDisplayList
Definition Optimizer:858
std::set< osg::Group * > GroupList
Definition Optimizer:427
CombineLODsVisitor(Optimizer *optimizer=0)
Definition Optimizer:430
virtual void apply(osg::LOD &lod)
GroupList _groupList
Definition Optimizer:428
std::set< osg::MatrixTransform * > TransformSet
Definition Optimizer:347
bool removeTransforms(osg::Node *nodeWeCannotRemove)
TransformSet _transformSet
Definition Optimizer:348
virtual void apply(osg::MatrixTransform &transform)
CombineStaticTransformsVisitor(Optimizer *optimizer=0)
Definition Optimizer:338
std::set< osg::Node * > SharedNodeList
Definition Optimizer:591
SharedNodeList _sharedNodeList
Definition Optimizer:592
CopySharedSubgraphsVisitor(Optimizer *optimizer=0)
Definition Optimizer:584
std::vector< osg::NodePath > NodePathList
Definition Optimizer:630
std::map< osg::Billboard *, NodePathList > BillboardNodePathMap
Definition Optimizer:631
virtual void apply(osg::Billboard &billboard)
BillboardNodePathMap _billboards
Definition Optimizer:639
FlattenBillboardVisitor(Optimizer *optimizer=0)
Definition Optimizer:627
FlattenStaticTransformsDuplicatingSharedSubgraphsVisitor(Optimizer *optimizer=0)
Definition Optimizer:312
std::vector< osg::Matrix > _matrixStack
Definition Optimizer:329
bool removeTransforms(osg::Node *nodeWeCannotRemove)
FlattenStaticTransformsVisitor(Optimizer *optimizer=0)
Definition Optimizer:274
virtual void apply(osg::Transform &transform)
BillboardSet _billboardSet
Definition Optimizer:297
virtual void apply(osg::Drawable &drawable)
virtual void apply(osg::ProxyNode &node)
std::vector< osg::Transform * > TransformStack
Definition Optimizer:288
TransformSet _transformSet
Definition Optimizer:298
DrawableSet _drawableSet
Definition Optimizer:296
virtual void apply(osg::PagedLOD &node)
NodeSet _excludedNodeSet
Definition Optimizer:295
TransformStack _transformStack
Definition Optimizer:294
std::set< osg::Node * > NodeSet
Definition Optimizer:291
virtual void apply(osg::Billboard &geode)
std::set< osg::Transform * > TransformSet
Definition Optimizer:292
std::set< osg::Billboard * > BillboardSet
Definition Optimizer:290
std::set< osg::Drawable * > DrawableSet
Definition Optimizer:289
virtual void apply(osg::Geometry &geom)
MakeFastGeometryVisitor(Optimizer *optimizer=0)
default to traversing all children.
Definition Optimizer:509
MergeGeodesVisitor(Optimizer *optimizer=0)
default to traversing all children.
Definition Optimizer:491
bool mergeGeode(osg::Geode &lhs, osg::Geode &rhs)
bool mergeGeodes(osg::Group &group)
virtual void apply(osg::Group &group)
void setTargetMaximumNumberOfVertices(unsigned int num)
Definition Optimizer:525
unsigned int _targetMaximumNumberOfVertices
Definition Optimizer:552
static bool geometryContainsSharedArrays(osg::Geometry &geom)
MergeGeometryVisitor(Optimizer *optimizer=0)
default to traversing all children.
Definition Optimizer:521
static bool mergePrimitive(osg::DrawElementsUByte &lhs, osg::DrawElementsUByte &rhs)
static bool mergeGeometry(osg::Geometry &lhs, osg::Geometry &rhs)
unsigned int getTargetMaximumNumberOfVertices() const
Definition Optimizer:530
static bool mergePrimitive(osg::DrawArrays &lhs, osg::DrawArrays &rhs)
virtual void apply(osg::Billboard &)
Definition Optimizer:536
static bool mergePrimitive(osg::DrawElementsUInt &lhs, osg::DrawElementsUInt &rhs)
virtual void apply(osg::Group &group)
Definition Optimizer:535
static bool mergePrimitive(osg::DrawElementsUShort &lhs, osg::DrawElementsUShort &rhs)
static bool mergePrimitive(osg::DrawArrayLengths &lhs, osg::DrawArrayLengths &rhs)
RemoveEmptyNodesVisitor(Optimizer *optimizer=0)
Definition Optimizer:360
virtual void apply(osg::Group &group)
NodeList _redundantNodeList
Definition Optimizer:358
std::set< osg::Node * > NodeList
Definition Optimizer:357
RemoveLoadedProxyNodesVisitor(Optimizer *optimizer=0)
Definition Optimizer:397
virtual void apply(osg::ProxyNode &group)
std::set< osg::Node * > NodeList
Definition Optimizer:394
NodeList _redundantNodeList
Definition Optimizer:395
std::set< osg::Node * > NodeList
Definition Optimizer:374
virtual void apply(osg::Transform &transform)
virtual void apply(osg::Group &group)
NodeList _redundantNodeList
Definition Optimizer:375
RemoveRedundantNodesVisitor(Optimizer *optimizer=0)
Definition Optimizer:377
bool divide(osg::Group *group, unsigned int maxNumTreesPerCell)
virtual void apply(osg::Geode &geode)
std::set< osg::Geode * > GeodesToDivideList
Definition Optimizer:575
GeodesToDivideList _geodesToDivideList
Definition Optimizer:576
virtual void apply(osg::Group &group)
std::set< osg::Group * > GroupsToDivideList
Definition Optimizer:572
SpatializeGroupsVisitor(Optimizer *optimizer=0)
Definition Optimizer:561
GroupsToDivideList _groupsToDivideList
Definition Optimizer:573
bool divide(osg::Geode *geode, unsigned int maxNumTreesPerCell)
bool divide(unsigned int maxNumTreesPerCell=8)
Definition Optimizer:443
std::map< osg::StateSet *, NodeSet > StateSetMap
Definition Optimizer:475
bool optimize(osg::Object::DataVariance variance)
Definition Optimizer:469
void addStateSet(osg::StateSet *stateset, osg::Node *node)
StateVisitor(bool combineDynamicState, bool combineStaticState, bool combineUnspecifiedState, Optimizer *optimizer=0)
default to traversing all children.
Definition Optimizer:447
std::set< osg::Node * > NodeSet
Definition Optimizer:474
StateSetMap _statesets
Definition Optimizer:480
virtual void apply(osg::Node &node)
void applyStateSet(osg::StateSet &stateset)
virtual void apply(osg::Drawable &drawable)
StaticObjectDetectionVisitor(Optimizer *optimizer=0)
default to traversing all children.
Definition Optimizer:828
TessellateVisitor(Optimizer *optimizer=0)
Definition Optimizer:414
GroupList _groupList
Definition Optimizer:412
virtual void apply(osg::Geometry &geom)
std::set< osg::Group * > GroupList
Definition Optimizer:411
int _maximumAtlasHeight
Definition Optimizer:734
Atlas(int width, int height, int margin)
Definition Optimizer:723
unsigned int _indexFirstOfRow
Contain the index of the first element of the last row.
Definition Optimizer:746
osg::ref_ptr< osg::Texture2D > _texture
Definition Optimizer:737
virtual ~Atlas()
Definition Optimizer:759
int _maximumAtlasWidth
Definition Optimizer:733
SourceList _sourceList
Definition Optimizer:740
osg::ref_ptr< osg::Image > _image
Definition Optimizer:738
@ DOES_NOT_FIT_IN_ANY_ROW
Definition Optimizer:749
@ FITS_IN_CURRENT_ROW
Definition Optimizer:750
Source(const osg::Texture2D *texture)
Definition Optimizer:699
Atlas * _atlas
Definition Optimizer:704
osg::ref_ptr< const osg::Image > _image
Definition Optimizer:706
bool suitableForAtlas(int maximumAtlasWidth, int maximumAtlasHeight, int margin)
osg::ref_ptr< const osg::Texture2D > _texture
Definition Optimizer:707
Source(const osg::Image *image)
Definition Optimizer:696
virtual ~Source()
Definition Optimizer:715
void addSource(const osg::Texture2D *texture)
void addSource(const osg::Image *image)
osg::Matrix getTextureMatrix(const osg::Texture2D *texture)
int getMargin() const
Definition Optimizer:658
int getMaximumAtlasWidth() const
Definition Optimizer:654
int _margin
Definition Optimizer:684
osg::Texture2D * getTextureAtlas(const osg::Image *image)
osg::Image * getImageAtlas(const osg::Image *image)
const osg::Texture2D * getSourceTexture(unsigned int i)
Definition Optimizer:665
int _maximumAtlasHeight
Definition Optimizer:683
void setMaximumAtlasSize(int width, int height)
std::vector< osg::ref_ptr< Atlas > > AtlasList
Definition Optimizer:762
AtlasList _atlasList
Definition Optimizer:768
osg::Matrix getTextureMatrix(unsigned int i)
const osg::Image * getSourceImage(unsigned int i)
Definition Optimizer:664
int getMaximumAtlasHeight() const
Definition Optimizer:655
std::vector< osg::ref_ptr< Source > > SourceList
Definition Optimizer:718
int _maximumAtlasWidth
Definition Optimizer:682
osg::Image * getImageAtlas(unsigned int i)
unsigned int getNumSources() const
Definition Optimizer:663
Source * getSource(const osg::Image *image)
Source * getSource(const osg::Texture2D *texture)
osg::Matrix getTextureMatrix(const osg::Image *image)
osg::Texture2D * getTextureAtlas(const osg::Texture2D *texture)
osg::Image * getImageAtlas(const osg::Texture2D *textue)
SourceList _sourceList
Definition Optimizer:767
osg::Texture2D * getTextureAtlas(unsigned int i)
virtual void apply(osg::Node &node)
std::map< osg::StateSet *, Drawables > StateSetMap
Definition Optimizer:809
TextureAtlasBuilder _builder
Definition Optimizer:813
std::set< osg::Drawable * > Drawables
Definition Optimizer:808
StateSetMap _statesetMap
Definition Optimizer:815
TextureAtlasBuilder & getTextureAtlasBuilder()
Definition Optimizer:793
Textures _textures
Definition Optimizer:817
std::vector< osg::StateSet * > StateSetStack
Definition Optimizer:811
StateSetStack _statesetStack
Definition Optimizer:816
std::set< osg::Texture2D * > Textures
Definition Optimizer:810
bool pushStateSet(osg::StateSet *stateset)
TextureAtlasVisitor(Optimizer *optimizer=0)
default to traversing all children.
Definition Optimizer:789
virtual void apply(osg::Drawable &node)
Definition Optimizer:599
float _valueAnisotropy
Definition Optimizer:619
virtual void apply(osg::Node &node)
void apply(osg::StateSet &stateset)
bool _changeAnisotropy
Definition Optimizer:618
bool _changeClientImageStorage
Definition Optimizer:617
bool _changeAutoUnRef
Definition Optimizer:616
void apply(osg::Texture &texture)
TextureVisitor(bool changeAutoUnRef, bool valueAutoUnRef, bool changeClientImageStorage, bool valueClientImageStorage, bool changeAnisotropy, float valueAnisotropy, Optimizer *optimizer=0)
Definition Optimizer:602
Definition Optimizer:61
bool isOperationPermissibleForObject(const osg::Node *object, unsigned int option) const
Definition Optimizer:208
bool isOperationPermissibleForObject(const osg::StateSet *object, unsigned int option) const
Definition Optimizer:184
const IsOperationPermissibleForObjectCallback * getIsOperationPermissibleForObjectCallback() const
Definition Optimizer:168
void setIsOperationPermissibleForObjectCallback(IsOperationPermissibleForObjectCallback *callback)
Definition Optimizer:162
virtual ~Optimizer()
Definition Optimizer:66
virtual void optimize(osg::Node *node, unsigned int options)
void optimize(osg::Node *node)
std::map< const osg::Object *, unsigned int > PermissibleOptimizationsMap
Definition Optimizer:259
bool isOperationPermissibleForObjectImplementation(const osg::Node *node, unsigned int option) const
Definition Optimizer:238
Optimizer()
Definition Optimizer:65
osg::ref_ptr< IsOperationPermissibleForObjectCallback > _isOperationPermissibleForObjectCallback
Definition Optimizer:257
IsOperationPermissibleForObjectCallback * getIsOperationPermissibleForObjectCallback()
Definition Optimizer:165
unsigned int getPermissibleOptimizationsForObject(const osg::Object *object) const
Definition Optimizer:176
bool isOperationPermissibleForObjectImplementation(const osg::StateAttribute *attribute, unsigned int option) const
Definition Optimizer:221
void optimize(const osg::ref_ptr< T > &node, unsigned int options)
Definition Optimizer:133
OptimizationOptions
Definition Optimizer:69
void optimize(const osg::ref_ptr< T > &node)
Definition Optimizer:127
bool isOperationPermissibleForObject(const osg::StateAttribute *object, unsigned int option) const
Definition Optimizer:192
bool isOperationPermissibleForObjectImplementation(const osg::Drawable *drawable, unsigned int option) const
Definition Optimizer:226
bool isOperationPermissibleForObjectImplementation(const osg::StateSet *stateset, unsigned int option) const
Definition Optimizer:216
void setPermissibleOptimizationsForObject(const osg::Object *object, unsigned int options)
Definition Optimizer:171
bool isOperationPermissibleForObject(const osg::Drawable *object, unsigned int option) const
Definition Optimizer:200
PermissibleOptimizationsMap _permissibleOptimizationsMap
Definition Optimizer:260
Definition Billboard:27
Definition PrimitiveSet:278
Definition PrimitiveSet:222
Definition PrimitiveSet:372
Definition PrimitiveSet:502
Definition PrimitiveSet:435
Definition Drawable:89
Definition Geode:29
Definition Geometry:31
Definition Group:29
Definition Image:179
Definition LOD:36
Definition MatrixTransform:26
Definition Matrixd:27
Definition NodeVisitor:82
Definition Node:72
unsigned int getNumDescriptions() const
NodeMask getNodeMask() const
Definition Node:367
osg::StateSet * getStateSet()
Definition Node:382
Callback * getUpdateCallback()
Definition Node:211
Callback * getCullCallback()
Definition Node:293
Callback * getEventCallback()
Definition Node:252
Definition Object:61
DataVariance
Definition Object:217
@ DYNAMIC
Definition Object:218
@ STATIC
Definition Object:219
@ UNSPECIFIED
Definition Object:220
virtual Referenced * getUserData()
Definition PagedLOD:24
Definition ProxyNode:24
Definition Referenced:44
Definition StateAttribute:77
Definition StateSet:46
Definition Texture2D:25
Image * getImage()
Definition Texture2D:58
Definition Texture:422
Definition Transform:75
Definition ref_ptr:32
T * get() const
Definition ref_ptr:117
Shader generator framework.
Definition NodeVisitor:25
author: Julien Valentin 2017 (mp3butcher@hotmail.com)
Definition AlphaFunc:19
#define OSGUTIL_EXPORT
Definition osgUtil/Export:40
virtual bool isOperationPermissibleForObjectImplementation(const Optimizer *optimizer, const osg::StateSet *stateset, unsigned int option) const
Definition Optimizer:139
virtual bool isOperationPermissibleForObjectImplementation(const Optimizer *optimizer, const osg::Drawable *drawable, unsigned int option) const
Definition Optimizer:149
virtual bool isOperationPermissibleForObjectImplementation(const Optimizer *optimizer, const osg::Node *node, unsigned int option) const
Definition Optimizer:154
virtual bool isOperationPermissibleForObjectImplementation(const Optimizer *optimizer, const osg::StateAttribute *attribute, unsigned int option) const
Definition Optimizer:144