Optimizer
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGUTIL_OPTIMIZER
#define OSGUTIL_OPTIMIZER
#include <osg/NodeVisitor>
#include <osg/Matrix>
#include <osg/Geometry>
#include <osg/Transform>
#include <osg/Texture2D>
#include <osgUtil/Export>
#include <set>
namespace osgUtil {
// forward declare
class Optimizer;
class OSGUTIL_EXPORT BaseOptimizerVisitor : public osg::NodeVisitor
{
public:
BaseOptimizerVisitor(Optimizer* optimizer, unsigned int operation):
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
_optimizer(optimizer),
_operationType(operation)
{
setNodeMaskOverride(0xffffffff);
}
inline bool isOperationPermissibleForObject(const osg::StateSet* object) const;
inline bool isOperationPermissibleForObject(const osg::StateAttribute* object) const;
inline bool isOperationPermissibleForObject(const osg::Drawable* object) const;
inline bool isOperationPermissibleForObject(const osg::Node* object) const;
protected:
Optimizer* _optimizer;
unsigned int _operationType;
};
class OSGUTIL_EXPORT Optimizer
{
public:
Optimizer() {}
virtual ~Optimizer() {}
enum OptimizationOptions
{
FLATTEN_STATIC_TRANSFORMS = (1 << 0),
REMOVE_REDUNDANT_NODES = (1 << 1),
REMOVE_LOADED_PROXY_NODES = (1 << 2),
COMBINE_ADJACENT_LODS = (1 << 3),
SHARE_DUPLICATE_STATE = (1 << 4),
MERGE_GEOMETRY = (1 << 5),
CHECK_GEOMETRY = (1 << 6), // deprecated, currently no-op
MAKE_FAST_GEOMETRY = (1 << 7),
SPATIALIZE_GROUPS = (1 << 8),
COPY_SHARED_NODES = (1 << 9),
TRISTRIP_GEOMETRY = (1 << 10),
TESSELLATE_GEOMETRY = (1 << 11),
OPTIMIZE_TEXTURE_SETTINGS = (1 << 12),
MERGE_GEODES = (1 << 13),
FLATTEN_BILLBOARDS = (1 << 14),
TEXTURE_ATLAS_BUILDER = (1 << 15),
STATIC_OBJECT_DETECTION = (1 << 16),
FLATTEN_STATIC_TRANSFORMS_DUPLICATING_SHARED_SUBGRAPHS = (1 << 17),
INDEX_MESH = (1 << 18),
VERTEX_POSTTRANSFORM = (1 << 19),
VERTEX_PRETRANSFORM = (1 << 20),
BUFFER_OBJECT_SETTINGS = (1 << 21),
DEFAULT_OPTIMIZATIONS = FLATTEN_STATIC_TRANSFORMS |
REMOVE_REDUNDANT_NODES |
REMOVE_LOADED_PROXY_NODES |
COMBINE_ADJACENT_LODS |
SHARE_DUPLICATE_STATE |
MERGE_GEOMETRY |
MAKE_FAST_GEOMETRY |
CHECK_GEOMETRY |
OPTIMIZE_TEXTURE_SETTINGS |
STATIC_OBJECT_DETECTION,
ALL_OPTIMIZATIONS = FLATTEN_STATIC_TRANSFORMS_DUPLICATING_SHARED_SUBGRAPHS |
REMOVE_REDUNDANT_NODES |
REMOVE_LOADED_PROXY_NODES |
COMBINE_ADJACENT_LODS |
SHARE_DUPLICATE_STATE |
MERGE_GEODES |
MERGE_GEOMETRY |
MAKE_FAST_GEOMETRY |
CHECK_GEOMETRY |
SPATIALIZE_GROUPS |
COPY_SHARED_NODES |
TRISTRIP_GEOMETRY |
OPTIMIZE_TEXTURE_SETTINGS |
TEXTURE_ATLAS_BUILDER |
STATIC_OBJECT_DETECTION |
BUFFER_OBJECT_SETTINGS
};
void reset();
void optimize(osg::Node* node);
template<class T> void optimize(const osg::ref_ptr<T>& node) { optimize(node.get()); }
virtual void optimize(osg::Node* node, unsigned int options);
template<class T> void optimize(const osg::ref_ptr<T>& node, unsigned int options) { optimize(node.get(), options); }
struct IsOperationPermissibleForObjectCallback : public osg::Referenced
{
virtual bool isOperationPermissibleForObjectImplementation(const Optimizer* optimizer, const osg::StateSet* stateset,unsigned int option) const
{
return optimizer->isOperationPermissibleForObjectImplementation(stateset,option);
}
virtual bool isOperationPermissibleForObjectImplementation(const Optimizer* optimizer, const osg::StateAttribute* attribute,unsigned int option) const
{
return optimizer->isOperationPermissibleForObjectImplementation(attribute,option);
}
virtual bool isOperationPermissibleForObjectImplementation(const Optimizer* optimizer, const osg::Drawable* drawable,unsigned int option) const
{
return optimizer->isOperationPermissibleForObjectImplementation(drawable,option);
}
virtual bool isOperationPermissibleForObjectImplementation(const Optimizer* optimizer, const osg::Node* node,unsigned int option) const
{
return optimizer->isOperationPermissibleForObjectImplementation(node,option);
}
};
void setIsOperationPermissibleForObjectCallback(IsOperationPermissibleForObjectCallback* callback) { _isOperationPermissibleForObjectCallback=callback; }
IsOperationPermissibleForObjectCallback* getIsOperationPermissibleForObjectCallback() { return _isOperationPermissibleForObjectCallback.get(); }
const IsOperationPermissibleForObjectCallback* getIsOperationPermissibleForObjectCallback() const { return _isOperationPermissibleForObjectCallback.get(); }
inline void setPermissibleOptimizationsForObject(const osg::Object* object, unsigned int options)
{
_permissibleOptimizationsMap[object] = options;
}
inline unsigned int getPermissibleOptimizationsForObject(const osg::Object* object) const
{
PermissibleOptimizationsMap::const_iterator itr = _permissibleOptimizationsMap.find(object);
if (itr!=_permissibleOptimizationsMap.end()) return itr->second;
else return 0xffffffff;
}
inline bool isOperationPermissibleForObject(const osg::StateSet* object, unsigned int option) const
{
if (_isOperationPermissibleForObjectCallback.valid())
return _isOperationPermissibleForObjectCallback->isOperationPermissibleForObjectImplementation(this,object,option);
else
return isOperationPermissibleForObjectImplementation(object,option);
}
inline bool isOperationPermissibleForObject(const osg::StateAttribute* object, unsigned int option) const
{
if (_isOperationPermissibleForObjectCallback.valid())
return _isOperationPermissibleForObjectCallback->isOperationPermissibleForObjectImplementation(this,object,option);
else
return isOperationPermissibleForObjectImplementation(object,option);
}
inline bool isOperationPermissibleForObject(const osg::Drawable* object, unsigned int option) const
{
if (_isOperationPermissibleForObjectCallback.valid())
return _isOperationPermissibleForObjectCallback->isOperationPermissibleForObjectImplementation(this,object,option);
else
return isOperationPermissibleForObjectImplementation(object,option);
}
inline bool isOperationPermissibleForObject(const osg::Node* object, unsigned int option) const
{
if (_isOperationPermissibleForObjectCallback.valid())
return _isOperationPermissibleForObjectCallback->isOperationPermissibleForObjectImplementation(this,object,option);
else
return isOperationPermissibleForObjectImplementation(object,option);
}
bool isOperationPermissibleForObjectImplementation(const osg::StateSet* stateset, unsigned int option) const
{
return (option & getPermissibleOptimizationsForObject(stateset))!=0;
}
bool isOperationPermissibleForObjectImplementation(const osg::StateAttribute* attribute, unsigned int option) const
{
return (option & getPermissibleOptimizationsForObject(attribute))!=0;
}
bool isOperationPermissibleForObjectImplementation(const osg::Drawable* drawable, unsigned int option) const
{
if (option & (REMOVE_REDUNDANT_NODES|MERGE_GEOMETRY))
{
if (drawable->getUserData()) return false;
if (drawable->getUpdateCallback()) return false;
if (drawable->getEventCallback()) return false;
if (drawable->getCullCallback()) return false;
}
return (option & getPermissibleOptimizationsForObject(drawable))!=0;
}
bool isOperationPermissibleForObjectImplementation(const osg::Node* node, unsigned int option) const
{
if (option & (REMOVE_REDUNDANT_NODES|COMBINE_ADJACENT_LODS|FLATTEN_STATIC_TRANSFORMS))
{
if (node->getUserData()) return false;
if (node->getUpdateCallback()) return false;
if (node->getEventCallback()) return false;
if (node->getCullCallback()) return false;
if (node->getNumDescriptions()>0) return false;
if (node->getStateSet()) return false;
if (node->getNodeMask()!=0xffffffff) return false;
// if (!node->getName().empty()) return false;
}
return (option & getPermissibleOptimizationsForObject(node))!=0;
}
protected:
osg::ref_ptr<IsOperationPermissibleForObjectCallback> _isOperationPermissibleForObjectCallback;
typedef std::map<const osg::Object*,unsigned int> PermissibleOptimizationsMap;
PermissibleOptimizationsMap _permissibleOptimizationsMap;
public:
class OSGUTIL_EXPORT FlattenStaticTransformsVisitor : public BaseOptimizerVisitor
{
public:
FlattenStaticTransformsVisitor(Optimizer* optimizer=0):
BaseOptimizerVisitor(optimizer, FLATTEN_STATIC_TRANSFORMS) {}
virtual void apply(osg::Node& geode);
virtual void apply(osg::Drawable& drawable);
virtual void apply(osg::Billboard& geode);
virtual void apply(osg::ProxyNode& node);
virtual void apply(osg::PagedLOD& node);
virtual void apply(osg::Transform& transform);
bool removeTransforms(osg::Node* nodeWeCannotRemove);
protected:
typedef std::vector<osg::Transform*> TransformStack;
typedef std::set<osg::Drawable*> DrawableSet;
typedef std::set<osg::Billboard*> BillboardSet;
typedef std::set<osg::Node* > NodeSet;
typedef std::set<osg::Transform*> TransformSet;
TransformStack _transformStack;
NodeSet _excludedNodeSet;
DrawableSet _drawableSet;
BillboardSet _billboardSet;
TransformSet _transformSet;
};
class OSGUTIL_EXPORT FlattenStaticTransformsDuplicatingSharedSubgraphsVisitor : public BaseOptimizerVisitor
{
public:
FlattenStaticTransformsDuplicatingSharedSubgraphsVisitor(Optimizer* optimizer=0):
BaseOptimizerVisitor(optimizer, FLATTEN_STATIC_TRANSFORMS_DUPLICATING_SHARED_SUBGRAPHS) {}
virtual void reset();
virtual void apply(osg::Group& group);
virtual void apply(osg::Transform& transform);
virtual void apply(osg::LOD& lod);
virtual void apply(osg::Geode& geode);
virtual void apply(osg::Billboard& billboard);
protected:
void transformGeode(osg::Geode& geode);
void transformDrawable(osg::Drawable& drawable);
void transformBillboard(osg::Billboard& billboard);
std::vector<osg::Matrix> _matrixStack;
};
class OSGUTIL_EXPORT CombineStaticTransformsVisitor : public BaseOptimizerVisitor
{
public:
CombineStaticTransformsVisitor(Optimizer* optimizer=0):
BaseOptimizerVisitor(optimizer, FLATTEN_STATIC_TRANSFORMS) {}
virtual void apply(osg::MatrixTransform& transform);
bool removeTransforms(osg::Node* nodeWeCannotRemove);
protected:
typedef std::set<osg::MatrixTransform*> TransformSet;
TransformSet _transformSet;
};
class OSGUTIL_EXPORT RemoveEmptyNodesVisitor : public BaseOptimizerVisitor
{
public:
typedef std::set<osg::Node*> NodeList;
NodeList _redundantNodeList;
RemoveEmptyNodesVisitor(Optimizer* optimizer=0):
BaseOptimizerVisitor(optimizer, REMOVE_REDUNDANT_NODES) {}
virtual void apply(osg::Group& group);
void removeEmptyNodes();
};
class OSGUTIL_EXPORT RemoveRedundantNodesVisitor : public BaseOptimizerVisitor
{
public:
typedef std::set<osg::Node*> NodeList;
NodeList _redundantNodeList;
RemoveRedundantNodesVisitor(Optimizer* optimizer=0):
BaseOptimizerVisitor(optimizer, REMOVE_REDUNDANT_NODES) {}
virtual void apply(osg::Group& group);
virtual void apply(osg::Transform& transform);
bool isOperationPermissible(osg::Node& node);
void removeRedundantNodes();
};
class OSGUTIL_EXPORT RemoveLoadedProxyNodesVisitor : public BaseOptimizerVisitor
{
public:
typedef std::set<osg::Node*> NodeList;
NodeList _redundantNodeList;
RemoveLoadedProxyNodesVisitor(Optimizer* optimizer=0):
BaseOptimizerVisitor(optimizer, REMOVE_LOADED_PROXY_NODES) {}
virtual void apply(osg::ProxyNode& group);
void removeRedundantNodes();
};
class OSGUTIL_EXPORT TessellateVisitor : public BaseOptimizerVisitor
{
public:
typedef std::set<osg::Group*> GroupList;
GroupList _groupList;
TessellateVisitor(Optimizer* optimizer=0):
BaseOptimizerVisitor(optimizer, TESSELLATE_GEOMETRY) {}
virtual void apply(osg::Geometry& geom);
};
class OSGUTIL_EXPORT CombineLODsVisitor : public BaseOptimizerVisitor
{
public:
typedef std::set<osg::Group*> GroupList;
GroupList _groupList;
CombineLODsVisitor(Optimizer* optimizer=0):
BaseOptimizerVisitor(optimizer, COMBINE_ADJACENT_LODS) {}
virtual void apply(osg::LOD& lod);
void combineLODs();
};
class OSGUTIL_EXPORT StateVisitor : public BaseOptimizerVisitor
{
public:
StateVisitor(bool combineDynamicState,
bool combineStaticState,
bool combineUnspecifiedState,
Optimizer* optimizer=0):
BaseOptimizerVisitor(optimizer, SHARE_DUPLICATE_STATE)
{
_optimize[osg::Object::DYNAMIC] = combineDynamicState;
_optimize[osg::Object::STATIC] = combineStaticState;
_optimize[osg::Object::UNSPECIFIED] = combineUnspecifiedState;
}
virtual void reset();
virtual void apply(osg::Node& node);
void optimize();
protected:
void addStateSet(osg::StateSet* stateset, osg::Node* node);
inline bool optimize(osg::Object::DataVariance variance)
{
return _optimize[variance];
}
typedef std::set<osg::Node*> NodeSet;
typedef std::map<osg::StateSet*, NodeSet> StateSetMap;
// note, one element for DYNAMIC, STATIC and UNSPECIFIED
bool _optimize[3];
StateSetMap _statesets;
};
class OSGUTIL_EXPORT MergeGeodesVisitor : public BaseOptimizerVisitor
{
public:
MergeGeodesVisitor(Optimizer* optimizer=0):
BaseOptimizerVisitor(optimizer, MERGE_GEODES) {}
virtual void apply(osg::Group& group);
bool mergeGeodes(osg::Group& group);
protected:
bool mergeGeode(osg::Geode& lhs, osg::Geode& rhs);
};
class OSGUTIL_EXPORT MakeFastGeometryVisitor : public BaseOptimizerVisitor
{
public:
MakeFastGeometryVisitor(Optimizer* optimizer=0):
BaseOptimizerVisitor(optimizer, MAKE_FAST_GEOMETRY) {}
virtual void apply(osg::Geometry& geom);
};
class OSGUTIL_EXPORT MergeGeometryVisitor : public BaseOptimizerVisitor
{
public:
MergeGeometryVisitor(Optimizer* optimizer=0) :
BaseOptimizerVisitor(optimizer, MERGE_GEOMETRY),
_targetMaximumNumberOfVertices(10000) {}
void setTargetMaximumNumberOfVertices(unsigned int num)
{
_targetMaximumNumberOfVertices = num;
}
unsigned int getTargetMaximumNumberOfVertices() const
{
return _targetMaximumNumberOfVertices;
}
virtual void apply(osg::Group& group) { mergeGroup(group); traverse(group); }
virtual void apply(osg::Billboard&) { /* don't do anything*/ }
bool mergeGroup(osg::Group& group);
static bool geometryContainsSharedArrays(osg::Geometry& geom);
static bool mergeGeometry(osg::Geometry& lhs,osg::Geometry& rhs);
static bool mergePrimitive(osg::DrawArrays& lhs,osg::DrawArrays& rhs);
static bool mergePrimitive(osg::DrawArrayLengths& lhs,osg::DrawArrayLengths& rhs);
static bool mergePrimitive(osg::DrawElementsUByte& lhs,osg::DrawElementsUByte& rhs);
static bool mergePrimitive(osg::DrawElementsUShort& lhs,osg::DrawElementsUShort& rhs);
static bool mergePrimitive(osg::DrawElementsUInt& lhs,osg::DrawElementsUInt& rhs);
protected:
unsigned int _targetMaximumNumberOfVertices;
};
class OSGUTIL_EXPORT SpatializeGroupsVisitor : public BaseOptimizerVisitor
{
public:
SpatializeGroupsVisitor(Optimizer* optimizer=0):
BaseOptimizerVisitor(optimizer, SPATIALIZE_GROUPS) {}
virtual void apply(osg::Group& group);
virtual void apply(osg::Geode& geode);
bool divide(unsigned int maxNumTreesPerCell=8);
bool divide(osg::Group* group, unsigned int maxNumTreesPerCell);
bool divide(osg::Geode* geode, unsigned int maxNumTreesPerCell);
typedef std::set<osg::Group*> GroupsToDivideList;
GroupsToDivideList _groupsToDivideList;
typedef std::set<osg::Geode*> GeodesToDivideList;
GeodesToDivideList _geodesToDivideList;
};
class OSGUTIL_EXPORT CopySharedSubgraphsVisitor : public BaseOptimizerVisitor
{
public:
CopySharedSubgraphsVisitor(Optimizer* optimizer=0):
BaseOptimizerVisitor(optimizer, COPY_SHARED_NODES) {}
virtual void apply(osg::Node& node);
void copySharedNodes();
typedef std::set<osg::Node*> SharedNodeList;
SharedNodeList _sharedNodeList;
};
class OSGUTIL_EXPORT TextureVisitor : public BaseOptimizerVisitor
{
public:
TextureVisitor(bool changeAutoUnRef, bool valueAutoUnRef,
bool changeClientImageStorage, bool valueClientImageStorage,
bool changeAnisotropy, float valueAnisotropy,
Optimizer* optimizer=0):
BaseOptimizerVisitor(optimizer, OPTIMIZE_TEXTURE_SETTINGS),
_changeAutoUnRef(changeAutoUnRef), _valueAutoUnRef(valueAutoUnRef),
_changeClientImageStorage(changeClientImageStorage), _valueClientImageStorage(valueClientImageStorage),
_changeAnisotropy(changeAnisotropy), _valueAnisotropy(valueAnisotropy) {}
virtual void apply(osg::Node& node);
void apply(osg::StateSet& stateset);
void apply(osg::Texture& texture);
bool _changeAutoUnRef, _valueAutoUnRef;
bool _changeClientImageStorage, _valueClientImageStorage;
bool _changeAnisotropy;
float _valueAnisotropy;
};
class OSGUTIL_EXPORT FlattenBillboardVisitor : public BaseOptimizerVisitor
{
public:
FlattenBillboardVisitor(Optimizer* optimizer=0):
BaseOptimizerVisitor(optimizer, FLATTEN_BILLBOARDS) {}
typedef std::vector<osg::NodePath> NodePathList;
typedef std::map<osg::Billboard*, NodePathList > BillboardNodePathMap;
virtual void reset();
virtual void apply(osg::Billboard& billboard);
void process();
BillboardNodePathMap _billboards;
};
class OSGUTIL_EXPORT TextureAtlasBuilder
{
public:
TextureAtlasBuilder();
void reset();
void setMaximumAtlasSize(int width, int height);
int getMaximumAtlasWidth() const { return _maximumAtlasWidth; }
int getMaximumAtlasHeight() const { return _maximumAtlasHeight; }
void setMargin(int margin);
int getMargin() const { return _margin; }
void addSource(const osg::Image* image);
void addSource(const osg::Texture2D* texture);
unsigned int getNumSources() const { return _sourceList.size(); }
const osg::Image* getSourceImage(unsigned int i) { return _sourceList[i]->_image.get(); }
const osg::Texture2D* getSourceTexture(unsigned int i) { return _sourceList[i]->_texture.get(); }
void buildAtlas();
osg::Image* getImageAtlas(unsigned int i);
osg::Texture2D* getTextureAtlas(unsigned int i);
osg::Matrix getTextureMatrix(unsigned int i);
osg::Image* getImageAtlas(const osg::Image* image);
osg::Texture2D* getTextureAtlas(const osg::Image* image);
osg::Matrix getTextureMatrix(const osg::Image* image);
osg::Image* getImageAtlas(const osg::Texture2D* textue);
osg::Texture2D* getTextureAtlas(const osg::Texture2D* texture);
osg::Matrix getTextureMatrix(const osg::Texture2D* texture);
protected:
int _maximumAtlasWidth;
int _maximumAtlasHeight;
int _margin;
// forward declare
class Atlas;
class Source : public osg::Referenced
{
public:
Source():
_x(0),_y(0),_atlas(0) {}
Source(const osg::Image* image):
_x(0),_y(0),_atlas(0),_image(image) {}
Source(const osg::Texture2D* texture):
_x(0),_y(0),_atlas(0),_texture(texture) { if (texture) _image = texture->getImage(); }
int _x;
int _y;
Atlas* _atlas;
osg::ref_ptr<const osg::Image> _image;
osg::ref_ptr<const osg::Texture2D> _texture;
bool suitableForAtlas(int maximumAtlasWidth, int maximumAtlasHeight, int margin);
osg::Matrix computeTextureMatrix() const;
protected:
virtual ~Source() {}
};
typedef std::vector< osg::ref_ptr<Source> > SourceList;
class Atlas : public osg::Referenced
{
public:
Atlas(int width, int height, int margin):
_maximumAtlasWidth(width),
_maximumAtlasHeight(height),
_margin(margin),
_x(0),
_y(0),
_width(0),
_height(0),
_indexFirstOfRow(0){}
int _maximumAtlasWidth;
int _maximumAtlasHeight;
int _margin;
osg::ref_ptr<osg::Texture2D> _texture;
osg::ref_ptr<osg::Image> _image;
SourceList _sourceList;
int _x;
int _y;
int _width;
int _height;
unsigned int _indexFirstOfRow;
enum FitsIn
{
DOES_NOT_FIT_IN_ANY_ROW,
FITS_IN_CURRENT_ROW,
IN_NEXT_ROW
};
FitsIn doesSourceFit(Source* source);
bool addSource(Source* source);
void clampToNearestPowerOfTwoSize();
void copySources();
protected:
virtual ~Atlas() {}
};
typedef std::vector< osg::ref_ptr<Atlas> > AtlasList;
Source* getSource(const osg::Image* image);
Source* getSource(const osg::Texture2D* texture);
SourceList _sourceList;
AtlasList _atlasList;
private:
struct CompareSrc
{
bool operator()(osg::ref_ptr<Source> src1, osg::ref_ptr<Source> src2) const
{
return src1->_image->t() > src2->_image->t();
}
};
void completeRow(unsigned int indexAtlas);
};
class OSGUTIL_EXPORT TextureAtlasVisitor : public BaseOptimizerVisitor
{
public:
TextureAtlasVisitor(Optimizer* optimizer=0):
BaseOptimizerVisitor(optimizer, TEXTURE_ATLAS_BUILDER) {}
TextureAtlasBuilder& getTextureAtlasBuilder() { return _builder; }
virtual void reset();
virtual void apply(osg::Node& node);
virtual void apply(osg::Drawable& node);
void optimize();
protected:
bool pushStateSet(osg::StateSet* stateset);
void popStateSet();
typedef std::set<osg::Drawable*> Drawables;
typedef std::map<osg::StateSet*, Drawables> StateSetMap;
typedef std::set<osg::Texture2D*> Textures;
typedef std::vector<osg::StateSet*> StateSetStack;
TextureAtlasBuilder _builder;
StateSetMap _statesetMap;
StateSetStack _statesetStack;
Textures _textures;
};
class OSGUTIL_EXPORT StaticObjectDetectionVisitor : public BaseOptimizerVisitor
{
public:
StaticObjectDetectionVisitor(Optimizer* optimizer=0):
BaseOptimizerVisitor(optimizer, STATIC_OBJECT_DETECTION) {}
virtual void apply(osg::Node& node);
virtual void apply(osg::Drawable& drawable);
protected:
void applyStateSet(osg::StateSet& stateset);
};
class OSGUTIL_EXPORT BufferObjectVisitor : public BaseOptimizerVisitor
{
public:
BufferObjectVisitor(bool changeVBO, bool valueVBO,
bool changeVertexArrayObject, bool valueVertexArrayObject,
bool changeDisplayList, bool valueDisplayList,
Optimizer* optimizer=0):
BaseOptimizerVisitor(optimizer, BUFFER_OBJECT_SETTINGS),
_changeVertexBufferObject(changeVBO), _valueVertexBufferObject(valueVBO),
_changeVertexArrayObject(changeVertexArrayObject), _valueVertexArrayObject(valueVertexArrayObject),
_changeDisplayList(changeDisplayList), _valueDisplayList(valueDisplayList) {}
virtual void apply(osg::Geometry& geometry);
bool _changeVertexBufferObject, _valueVertexBufferObject;
bool _changeVertexArrayObject, _valueVertexArrayObject;
bool _changeDisplayList, _valueDisplayList;
};
};
inline bool BaseOptimizerVisitor::isOperationPermissibleForObject(const osg::StateSet* object) const
{
return _optimizer ? _optimizer->isOperationPermissibleForObject(object,_operationType) : true;
}
inline bool BaseOptimizerVisitor::isOperationPermissibleForObject(const osg::StateAttribute* object) const
{
return _optimizer ? _optimizer->isOperationPermissibleForObject(object,_operationType) : true;
}
inline bool BaseOptimizerVisitor::isOperationPermissibleForObject(const osg::Drawable* object) const
{
return _optimizer ? _optimizer->isOperationPermissibleForObject(object,_operationType) : true;
}
inline bool BaseOptimizerVisitor::isOperationPermissibleForObject(const osg::Node* object) const
{
return _optimizer ? _optimizer->isOperationPermissibleForObject(object,_operationType) : true;
}
}
#endif
Geometry
Matrix
NodeVisitor
Texture2D
Transform
osgUtil::BaseOptimizerVisitor::isOperationPermissibleForObject
bool isOperationPermissibleForObject(const osg::StateSet *object) const
Definition Optimizer:863
osgUtil::BaseOptimizerVisitor::BaseOptimizerVisitor
BaseOptimizerVisitor(Optimizer *optimizer, unsigned int operation)
Definition Optimizer:37
osgUtil::BaseOptimizerVisitor::_optimizer
Optimizer * _optimizer
Definition Optimizer:52
osgUtil::BaseOptimizerVisitor::_operationType
unsigned int _operationType
Definition Optimizer:53
osgUtil::Optimizer::BufferObjectVisitor::_valueVertexBufferObject
bool _valueVertexBufferObject
Definition Optimizer:856
osgUtil::Optimizer::BufferObjectVisitor::BufferObjectVisitor
BufferObjectVisitor(bool changeVBO, bool valueVBO, bool changeVertexArrayObject, bool valueVertexArrayObject, bool changeDisplayList, bool valueDisplayList, Optimizer *optimizer=0)
Definition Optimizer:845
osgUtil::Optimizer::BufferObjectVisitor::_changeVertexArrayObject
bool _changeVertexArrayObject
Definition Optimizer:857
osgUtil::Optimizer::BufferObjectVisitor::_changeVertexBufferObject
bool _changeVertexBufferObject
Definition Optimizer:856
osgUtil::Optimizer::BufferObjectVisitor::_valueVertexArrayObject
bool _valueVertexArrayObject
Definition Optimizer:857
osgUtil::Optimizer::BufferObjectVisitor::apply
virtual void apply(osg::Geometry &geometry)
osgUtil::Optimizer::BufferObjectVisitor::_changeDisplayList
bool _changeDisplayList
Definition Optimizer:858
osgUtil::Optimizer::BufferObjectVisitor::_valueDisplayList
bool _valueDisplayList
Definition Optimizer:858
osgUtil::Optimizer::CombineLODsVisitor::GroupList
std::set< osg::Group * > GroupList
Definition Optimizer:427
osgUtil::Optimizer::CombineLODsVisitor::CombineLODsVisitor
CombineLODsVisitor(Optimizer *optimizer=0)
Definition Optimizer:430
osgUtil::Optimizer::CombineLODsVisitor::combineLODs
void combineLODs()
osgUtil::Optimizer::CombineLODsVisitor::apply
virtual void apply(osg::LOD &lod)
osgUtil::Optimizer::CombineLODsVisitor::_groupList
GroupList _groupList
Definition Optimizer:428
osgUtil::Optimizer::CombineStaticTransformsVisitor::TransformSet
std::set< osg::MatrixTransform * > TransformSet
Definition Optimizer:347
osgUtil::Optimizer::CombineStaticTransformsVisitor::removeTransforms
bool removeTransforms(osg::Node *nodeWeCannotRemove)
osgUtil::Optimizer::CombineStaticTransformsVisitor::_transformSet
TransformSet _transformSet
Definition Optimizer:348
osgUtil::Optimizer::CombineStaticTransformsVisitor::apply
virtual void apply(osg::MatrixTransform &transform)
osgUtil::Optimizer::CombineStaticTransformsVisitor::CombineStaticTransformsVisitor
CombineStaticTransformsVisitor(Optimizer *optimizer=0)
Definition Optimizer:338
osgUtil::Optimizer::CopySharedSubgraphsVisitor::SharedNodeList
std::set< osg::Node * > SharedNodeList
Definition Optimizer:591
osgUtil::Optimizer::CopySharedSubgraphsVisitor::_sharedNodeList
SharedNodeList _sharedNodeList
Definition Optimizer:592
osgUtil::Optimizer::CopySharedSubgraphsVisitor::CopySharedSubgraphsVisitor
CopySharedSubgraphsVisitor(Optimizer *optimizer=0)
Definition Optimizer:584
osgUtil::Optimizer::CopySharedSubgraphsVisitor::copySharedNodes
void copySharedNodes()
osgUtil::Optimizer::CopySharedSubgraphsVisitor::apply
virtual void apply(osg::Node &node)
osgUtil::Optimizer::FlattenBillboardVisitor::process
void process()
osgUtil::Optimizer::FlattenBillboardVisitor::NodePathList
std::vector< osg::NodePath > NodePathList
Definition Optimizer:630
osgUtil::Optimizer::FlattenBillboardVisitor::BillboardNodePathMap
std::map< osg::Billboard *, NodePathList > BillboardNodePathMap
Definition Optimizer:631
osgUtil::Optimizer::FlattenBillboardVisitor::reset
virtual void reset()
osgUtil::Optimizer::FlattenBillboardVisitor::apply
virtual void apply(osg::Billboard &billboard)
osgUtil::Optimizer::FlattenBillboardVisitor::_billboards
BillboardNodePathMap _billboards
Definition Optimizer:639
osgUtil::Optimizer::FlattenBillboardVisitor::FlattenBillboardVisitor
FlattenBillboardVisitor(Optimizer *optimizer=0)
Definition Optimizer:627
osgUtil::Optimizer::FlattenStaticTransformsDuplicatingSharedSubgraphsVisitor::FlattenStaticTransformsDuplicatingSharedSubgraphsVisitor
FlattenStaticTransformsDuplicatingSharedSubgraphsVisitor(Optimizer *optimizer=0)
Definition Optimizer:312
osgUtil::Optimizer::FlattenStaticTransformsDuplicatingSharedSubgraphsVisitor::apply
virtual void apply(osg::Geode &geode)
osgUtil::Optimizer::FlattenStaticTransformsDuplicatingSharedSubgraphsVisitor::_matrixStack
std::vector< osg::Matrix > _matrixStack
Definition Optimizer:329
osgUtil::Optimizer::FlattenStaticTransformsDuplicatingSharedSubgraphsVisitor::reset
virtual void reset()
osgUtil::Optimizer::FlattenStaticTransformsDuplicatingSharedSubgraphsVisitor::apply
virtual void apply(osg::Group &group)
osgUtil::Optimizer::FlattenStaticTransformsDuplicatingSharedSubgraphsVisitor::apply
virtual void apply(osg::Transform &transform)
osgUtil::Optimizer::FlattenStaticTransformsDuplicatingSharedSubgraphsVisitor::apply
virtual void apply(osg::Billboard &billboard)
osgUtil::Optimizer::FlattenStaticTransformsDuplicatingSharedSubgraphsVisitor::transformBillboard
void transformBillboard(osg::Billboard &billboard)
osgUtil::Optimizer::FlattenStaticTransformsDuplicatingSharedSubgraphsVisitor::transformDrawable
void transformDrawable(osg::Drawable &drawable)
osgUtil::Optimizer::FlattenStaticTransformsDuplicatingSharedSubgraphsVisitor::transformGeode
void transformGeode(osg::Geode &geode)
osgUtil::Optimizer::FlattenStaticTransformsDuplicatingSharedSubgraphsVisitor::apply
virtual void apply(osg::LOD &lod)
osgUtil::Optimizer::FlattenStaticTransformsVisitor::removeTransforms
bool removeTransforms(osg::Node *nodeWeCannotRemove)
osgUtil::Optimizer::FlattenStaticTransformsVisitor::FlattenStaticTransformsVisitor
FlattenStaticTransformsVisitor(Optimizer *optimizer=0)
Definition Optimizer:274
osgUtil::Optimizer::FlattenStaticTransformsVisitor::apply
virtual void apply(osg::Transform &transform)
osgUtil::Optimizer::FlattenStaticTransformsVisitor::_billboardSet
BillboardSet _billboardSet
Definition Optimizer:297
osgUtil::Optimizer::FlattenStaticTransformsVisitor::apply
virtual void apply(osg::Drawable &drawable)
osgUtil::Optimizer::FlattenStaticTransformsVisitor::apply
virtual void apply(osg::ProxyNode &node)
osgUtil::Optimizer::FlattenStaticTransformsVisitor::TransformStack
std::vector< osg::Transform * > TransformStack
Definition Optimizer:288
osgUtil::Optimizer::FlattenStaticTransformsVisitor::_transformSet
TransformSet _transformSet
Definition Optimizer:298
osgUtil::Optimizer::FlattenStaticTransformsVisitor::_drawableSet
DrawableSet _drawableSet
Definition Optimizer:296
osgUtil::Optimizer::FlattenStaticTransformsVisitor::apply
virtual void apply(osg::PagedLOD &node)
osgUtil::Optimizer::FlattenStaticTransformsVisitor::_excludedNodeSet
NodeSet _excludedNodeSet
Definition Optimizer:295
osgUtil::Optimizer::FlattenStaticTransformsVisitor::_transformStack
TransformStack _transformStack
Definition Optimizer:294
osgUtil::Optimizer::FlattenStaticTransformsVisitor::NodeSet
std::set< osg::Node * > NodeSet
Definition Optimizer:291
osgUtil::Optimizer::FlattenStaticTransformsVisitor::apply
virtual void apply(osg::Billboard &geode)
osgUtil::Optimizer::FlattenStaticTransformsVisitor::TransformSet
std::set< osg::Transform * > TransformSet
Definition Optimizer:292
osgUtil::Optimizer::FlattenStaticTransformsVisitor::BillboardSet
std::set< osg::Billboard * > BillboardSet
Definition Optimizer:290
osgUtil::Optimizer::FlattenStaticTransformsVisitor::apply
virtual void apply(osg::Node &geode)
osgUtil::Optimizer::FlattenStaticTransformsVisitor::DrawableSet
std::set< osg::Drawable * > DrawableSet
Definition Optimizer:289
osgUtil::Optimizer::MakeFastGeometryVisitor::apply
virtual void apply(osg::Geometry &geom)
osgUtil::Optimizer::MakeFastGeometryVisitor::MakeFastGeometryVisitor
MakeFastGeometryVisitor(Optimizer *optimizer=0)
default to traversing all children.
Definition Optimizer:509
osgUtil::Optimizer::MergeGeodesVisitor::MergeGeodesVisitor
MergeGeodesVisitor(Optimizer *optimizer=0)
default to traversing all children.
Definition Optimizer:491
osgUtil::Optimizer::MergeGeodesVisitor::mergeGeode
bool mergeGeode(osg::Geode &lhs, osg::Geode &rhs)
osgUtil::Optimizer::MergeGeodesVisitor::mergeGeodes
bool mergeGeodes(osg::Group &group)
osgUtil::Optimizer::MergeGeodesVisitor::apply
virtual void apply(osg::Group &group)
osgUtil::Optimizer::MergeGeometryVisitor::setTargetMaximumNumberOfVertices
void setTargetMaximumNumberOfVertices(unsigned int num)
Definition Optimizer:525
osgUtil::Optimizer::MergeGeometryVisitor::_targetMaximumNumberOfVertices
unsigned int _targetMaximumNumberOfVertices
Definition Optimizer:552
osgUtil::Optimizer::MergeGeometryVisitor::geometryContainsSharedArrays
static bool geometryContainsSharedArrays(osg::Geometry &geom)
osgUtil::Optimizer::MergeGeometryVisitor::MergeGeometryVisitor
MergeGeometryVisitor(Optimizer *optimizer=0)
default to traversing all children.
Definition Optimizer:521
osgUtil::Optimizer::MergeGeometryVisitor::mergePrimitive
static bool mergePrimitive(osg::DrawElementsUByte &lhs, osg::DrawElementsUByte &rhs)
osgUtil::Optimizer::MergeGeometryVisitor::mergeGeometry
static bool mergeGeometry(osg::Geometry &lhs, osg::Geometry &rhs)
osgUtil::Optimizer::MergeGeometryVisitor::getTargetMaximumNumberOfVertices
unsigned int getTargetMaximumNumberOfVertices() const
Definition Optimizer:530
osgUtil::Optimizer::MergeGeometryVisitor::mergePrimitive
static bool mergePrimitive(osg::DrawArrays &lhs, osg::DrawArrays &rhs)
osgUtil::Optimizer::MergeGeometryVisitor::apply
virtual void apply(osg::Billboard &)
Definition Optimizer:536
osgUtil::Optimizer::MergeGeometryVisitor::mergePrimitive
static bool mergePrimitive(osg::DrawElementsUInt &lhs, osg::DrawElementsUInt &rhs)
osgUtil::Optimizer::MergeGeometryVisitor::mergeGroup
bool mergeGroup(osg::Group &group)
osgUtil::Optimizer::MergeGeometryVisitor::apply
virtual void apply(osg::Group &group)
Definition Optimizer:535
osgUtil::Optimizer::MergeGeometryVisitor::mergePrimitive
static bool mergePrimitive(osg::DrawElementsUShort &lhs, osg::DrawElementsUShort &rhs)
osgUtil::Optimizer::MergeGeometryVisitor::mergePrimitive
static bool mergePrimitive(osg::DrawArrayLengths &lhs, osg::DrawArrayLengths &rhs)
osgUtil::Optimizer::RemoveEmptyNodesVisitor::RemoveEmptyNodesVisitor
RemoveEmptyNodesVisitor(Optimizer *optimizer=0)
Definition Optimizer:360
osgUtil::Optimizer::RemoveEmptyNodesVisitor::apply
virtual void apply(osg::Group &group)
osgUtil::Optimizer::RemoveEmptyNodesVisitor::_redundantNodeList
NodeList _redundantNodeList
Definition Optimizer:358
osgUtil::Optimizer::RemoveEmptyNodesVisitor::NodeList
std::set< osg::Node * > NodeList
Definition Optimizer:357
osgUtil::Optimizer::RemoveEmptyNodesVisitor::removeEmptyNodes
void removeEmptyNodes()
osgUtil::Optimizer::RemoveLoadedProxyNodesVisitor::RemoveLoadedProxyNodesVisitor
RemoveLoadedProxyNodesVisitor(Optimizer *optimizer=0)
Definition Optimizer:397
osgUtil::Optimizer::RemoveLoadedProxyNodesVisitor::apply
virtual void apply(osg::ProxyNode &group)
osgUtil::Optimizer::RemoveLoadedProxyNodesVisitor::NodeList
std::set< osg::Node * > NodeList
Definition Optimizer:394
osgUtil::Optimizer::RemoveLoadedProxyNodesVisitor::removeRedundantNodes
void removeRedundantNodes()
osgUtil::Optimizer::RemoveLoadedProxyNodesVisitor::_redundantNodeList
NodeList _redundantNodeList
Definition Optimizer:395
osgUtil::Optimizer::RemoveRedundantNodesVisitor::NodeList
std::set< osg::Node * > NodeList
Definition Optimizer:374
osgUtil::Optimizer::RemoveRedundantNodesVisitor::removeRedundantNodes
void removeRedundantNodes()
osgUtil::Optimizer::RemoveRedundantNodesVisitor::apply
virtual void apply(osg::Transform &transform)
osgUtil::Optimizer::RemoveRedundantNodesVisitor::apply
virtual void apply(osg::Group &group)
osgUtil::Optimizer::RemoveRedundantNodesVisitor::_redundantNodeList
NodeList _redundantNodeList
Definition Optimizer:375
osgUtil::Optimizer::RemoveRedundantNodesVisitor::RemoveRedundantNodesVisitor
RemoveRedundantNodesVisitor(Optimizer *optimizer=0)
Definition Optimizer:377
osgUtil::Optimizer::RemoveRedundantNodesVisitor::isOperationPermissible
bool isOperationPermissible(osg::Node &node)
osgUtil::Optimizer::SpatializeGroupsVisitor::divide
bool divide(osg::Group *group, unsigned int maxNumTreesPerCell)
osgUtil::Optimizer::SpatializeGroupsVisitor::apply
virtual void apply(osg::Geode &geode)
osgUtil::Optimizer::SpatializeGroupsVisitor::GeodesToDivideList
std::set< osg::Geode * > GeodesToDivideList
Definition Optimizer:575
osgUtil::Optimizer::SpatializeGroupsVisitor::_geodesToDivideList
GeodesToDivideList _geodesToDivideList
Definition Optimizer:576
osgUtil::Optimizer::SpatializeGroupsVisitor::apply
virtual void apply(osg::Group &group)
osgUtil::Optimizer::SpatializeGroupsVisitor::GroupsToDivideList
std::set< osg::Group * > GroupsToDivideList
Definition Optimizer:572
osgUtil::Optimizer::SpatializeGroupsVisitor::SpatializeGroupsVisitor
SpatializeGroupsVisitor(Optimizer *optimizer=0)
Definition Optimizer:561
osgUtil::Optimizer::SpatializeGroupsVisitor::_groupsToDivideList
GroupsToDivideList _groupsToDivideList
Definition Optimizer:573
osgUtil::Optimizer::SpatializeGroupsVisitor::divide
bool divide(osg::Geode *geode, unsigned int maxNumTreesPerCell)
osgUtil::Optimizer::SpatializeGroupsVisitor::divide
bool divide(unsigned int maxNumTreesPerCell=8)
osgUtil::Optimizer::StateVisitor::StateSetMap
std::map< osg::StateSet *, NodeSet > StateSetMap
Definition Optimizer:475
osgUtil::Optimizer::StateVisitor::optimize
bool optimize(osg::Object::DataVariance variance)
Definition Optimizer:469
osgUtil::Optimizer::StateVisitor::addStateSet
void addStateSet(osg::StateSet *stateset, osg::Node *node)
osgUtil::Optimizer::StateVisitor::_optimize
bool _optimize[3]
Definition Optimizer:478
osgUtil::Optimizer::StateVisitor::StateVisitor
StateVisitor(bool combineDynamicState, bool combineStaticState, bool combineUnspecifiedState, Optimizer *optimizer=0)
default to traversing all children.
Definition Optimizer:447
osgUtil::Optimizer::StateVisitor::optimize
void optimize()
osgUtil::Optimizer::StateVisitor::NodeSet
std::set< osg::Node * > NodeSet
Definition Optimizer:474
osgUtil::Optimizer::StateVisitor::_statesets
StateSetMap _statesets
Definition Optimizer:480
osgUtil::Optimizer::StateVisitor::apply
virtual void apply(osg::Node &node)
osgUtil::Optimizer::StateVisitor::reset
virtual void reset()
osgUtil::Optimizer::StaticObjectDetectionVisitor::applyStateSet
void applyStateSet(osg::StateSet &stateset)
osgUtil::Optimizer::StaticObjectDetectionVisitor::apply
virtual void apply(osg::Drawable &drawable)
osgUtil::Optimizer::StaticObjectDetectionVisitor::apply
virtual void apply(osg::Node &node)
osgUtil::Optimizer::StaticObjectDetectionVisitor::StaticObjectDetectionVisitor
StaticObjectDetectionVisitor(Optimizer *optimizer=0)
default to traversing all children.
Definition Optimizer:828
osgUtil::Optimizer::TessellateVisitor::TessellateVisitor
TessellateVisitor(Optimizer *optimizer=0)
Definition Optimizer:414
osgUtil::Optimizer::TessellateVisitor::_groupList
GroupList _groupList
Definition Optimizer:412
osgUtil::Optimizer::TessellateVisitor::apply
virtual void apply(osg::Geometry &geom)
osgUtil::Optimizer::TessellateVisitor::GroupList
std::set< osg::Group * > GroupList
Definition Optimizer:411
osgUtil::Optimizer::TextureAtlasBuilder::Atlas
Definition Optimizer:721
osgUtil::Optimizer::TextureAtlasBuilder::Atlas::addSource
bool addSource(Source *source)
osgUtil::Optimizer::TextureAtlasBuilder::Atlas::_height
int _height
Definition Optimizer:745
osgUtil::Optimizer::TextureAtlasBuilder::Atlas::_maximumAtlasHeight
int _maximumAtlasHeight
Definition Optimizer:734
osgUtil::Optimizer::TextureAtlasBuilder::Atlas::clampToNearestPowerOfTwoSize
void clampToNearestPowerOfTwoSize()
osgUtil::Optimizer::TextureAtlasBuilder::Atlas::_width
int _width
Definition Optimizer:744
osgUtil::Optimizer::TextureAtlasBuilder::Atlas::_margin
int _margin
Definition Optimizer:735
osgUtil::Optimizer::TextureAtlasBuilder::Atlas::Atlas
Atlas(int width, int height, int margin)
Definition Optimizer:723
osgUtil::Optimizer::TextureAtlasBuilder::Atlas::_indexFirstOfRow
unsigned int _indexFirstOfRow
Contain the index of the first element of the last row.
Definition Optimizer:746
osgUtil::Optimizer::TextureAtlasBuilder::Atlas::_y
int _y
Definition Optimizer:743
osgUtil::Optimizer::TextureAtlasBuilder::Atlas::_texture
osg::ref_ptr< osg::Texture2D > _texture
Definition Optimizer:737
osgUtil::Optimizer::TextureAtlasBuilder::Atlas::~Atlas
virtual ~Atlas()
Definition Optimizer:759
osgUtil::Optimizer::TextureAtlasBuilder::Atlas::_maximumAtlasWidth
int _maximumAtlasWidth
Definition Optimizer:733
osgUtil::Optimizer::TextureAtlasBuilder::Atlas::doesSourceFit
FitsIn doesSourceFit(Source *source)
osgUtil::Optimizer::TextureAtlasBuilder::Atlas::_sourceList
SourceList _sourceList
Definition Optimizer:740
osgUtil::Optimizer::TextureAtlasBuilder::Atlas::_image
osg::ref_ptr< osg::Image > _image
Definition Optimizer:738
osgUtil::Optimizer::TextureAtlasBuilder::Atlas::FitsIn
FitsIn
Definition Optimizer:748
osgUtil::Optimizer::TextureAtlasBuilder::Atlas::DOES_NOT_FIT_IN_ANY_ROW
@ DOES_NOT_FIT_IN_ANY_ROW
Definition Optimizer:749
osgUtil::Optimizer::TextureAtlasBuilder::Atlas::IN_NEXT_ROW
@ IN_NEXT_ROW
Definition Optimizer:751
osgUtil::Optimizer::TextureAtlasBuilder::Atlas::FITS_IN_CURRENT_ROW
@ FITS_IN_CURRENT_ROW
Definition Optimizer:750
osgUtil::Optimizer::TextureAtlasBuilder::Atlas::copySources
void copySources()
osgUtil::Optimizer::TextureAtlasBuilder::Atlas::_x
int _x
Definition Optimizer:742
osgUtil::Optimizer::TextureAtlasBuilder::Source
Definition Optimizer:691
osgUtil::Optimizer::TextureAtlasBuilder::Source::computeTextureMatrix
osg::Matrix computeTextureMatrix() const
osgUtil::Optimizer::TextureAtlasBuilder::Source::Source
Source(const osg::Texture2D *texture)
Definition Optimizer:699
osgUtil::Optimizer::TextureAtlasBuilder::Source::_atlas
Atlas * _atlas
Definition Optimizer:704
osgUtil::Optimizer::TextureAtlasBuilder::Source::_image
osg::ref_ptr< const osg::Image > _image
Definition Optimizer:706
osgUtil::Optimizer::TextureAtlasBuilder::Source::_y
int _y
Definition Optimizer:703
osgUtil::Optimizer::TextureAtlasBuilder::Source::Source
Source()
Definition Optimizer:693
osgUtil::Optimizer::TextureAtlasBuilder::Source::suitableForAtlas
bool suitableForAtlas(int maximumAtlasWidth, int maximumAtlasHeight, int margin)
osgUtil::Optimizer::TextureAtlasBuilder::Source::_x
int _x
Definition Optimizer:702
osgUtil::Optimizer::TextureAtlasBuilder::Source::_texture
osg::ref_ptr< const osg::Texture2D > _texture
Definition Optimizer:707
osgUtil::Optimizer::TextureAtlasBuilder::Source::Source
Source(const osg::Image *image)
Definition Optimizer:696
osgUtil::Optimizer::TextureAtlasBuilder::Source::~Source
virtual ~Source()
Definition Optimizer:715
osgUtil::Optimizer::TextureAtlasBuilder
Definition Optimizer:646
osgUtil::Optimizer::TextureAtlasBuilder::addSource
void addSource(const osg::Texture2D *texture)
osgUtil::Optimizer::TextureAtlasBuilder::addSource
void addSource(const osg::Image *image)
osgUtil::Optimizer::TextureAtlasBuilder::getTextureMatrix
osg::Matrix getTextureMatrix(const osg::Texture2D *texture)
osgUtil::Optimizer::TextureAtlasBuilder::getMargin
int getMargin() const
Definition Optimizer:658
osgUtil::Optimizer::TextureAtlasBuilder::getMaximumAtlasWidth
int getMaximumAtlasWidth() const
Definition Optimizer:654
osgUtil::Optimizer::TextureAtlasBuilder::_margin
int _margin
Definition Optimizer:684
osgUtil::Optimizer::TextureAtlasBuilder::getTextureAtlas
osg::Texture2D * getTextureAtlas(const osg::Image *image)
osgUtil::Optimizer::TextureAtlasBuilder::getImageAtlas
osg::Image * getImageAtlas(const osg::Image *image)
osgUtil::Optimizer::TextureAtlasBuilder::getSourceTexture
const osg::Texture2D * getSourceTexture(unsigned int i)
Definition Optimizer:665
osgUtil::Optimizer::TextureAtlasBuilder::reset
void reset()
osgUtil::Optimizer::TextureAtlasBuilder::_maximumAtlasHeight
int _maximumAtlasHeight
Definition Optimizer:683
osgUtil::Optimizer::TextureAtlasBuilder::setMaximumAtlasSize
void setMaximumAtlasSize(int width, int height)
osgUtil::Optimizer::TextureAtlasBuilder::AtlasList
std::vector< osg::ref_ptr< Atlas > > AtlasList
Definition Optimizer:762
osgUtil::Optimizer::TextureAtlasBuilder::_atlasList
AtlasList _atlasList
Definition Optimizer:768
osgUtil::Optimizer::TextureAtlasBuilder::getTextureMatrix
osg::Matrix getTextureMatrix(unsigned int i)
osgUtil::Optimizer::TextureAtlasBuilder::getSourceImage
const osg::Image * getSourceImage(unsigned int i)
Definition Optimizer:664
osgUtil::Optimizer::TextureAtlasBuilder::getMaximumAtlasHeight
int getMaximumAtlasHeight() const
Definition Optimizer:655
osgUtil::Optimizer::TextureAtlasBuilder::SourceList
std::vector< osg::ref_ptr< Source > > SourceList
Definition Optimizer:718
osgUtil::Optimizer::TextureAtlasBuilder::_maximumAtlasWidth
int _maximumAtlasWidth
Definition Optimizer:682
osgUtil::Optimizer::TextureAtlasBuilder::getImageAtlas
osg::Image * getImageAtlas(unsigned int i)
osgUtil::Optimizer::TextureAtlasBuilder::getNumSources
unsigned int getNumSources() const
Definition Optimizer:663
osgUtil::Optimizer::TextureAtlasBuilder::getSource
Source * getSource(const osg::Image *image)
osgUtil::Optimizer::TextureAtlasBuilder::TextureAtlasBuilder
TextureAtlasBuilder()
osgUtil::Optimizer::TextureAtlasBuilder::getSource
Source * getSource(const osg::Texture2D *texture)
osgUtil::Optimizer::TextureAtlasBuilder::getTextureMatrix
osg::Matrix getTextureMatrix(const osg::Image *image)
osgUtil::Optimizer::TextureAtlasBuilder::getTextureAtlas
osg::Texture2D * getTextureAtlas(const osg::Texture2D *texture)
osgUtil::Optimizer::TextureAtlasBuilder::getImageAtlas
osg::Image * getImageAtlas(const osg::Texture2D *textue)
osgUtil::Optimizer::TextureAtlasBuilder::_sourceList
SourceList _sourceList
Definition Optimizer:767
osgUtil::Optimizer::TextureAtlasBuilder::setMargin
void setMargin(int margin)
osgUtil::Optimizer::TextureAtlasBuilder::buildAtlas
void buildAtlas()
osgUtil::Optimizer::TextureAtlasBuilder::getTextureAtlas
osg::Texture2D * getTextureAtlas(unsigned int i)
osgUtil::Optimizer::TextureAtlasVisitor::apply
virtual void apply(osg::Node &node)
osgUtil::Optimizer::TextureAtlasVisitor::StateSetMap
std::map< osg::StateSet *, Drawables > StateSetMap
Definition Optimizer:809
osgUtil::Optimizer::TextureAtlasVisitor::_builder
TextureAtlasBuilder _builder
Definition Optimizer:813
osgUtil::Optimizer::TextureAtlasVisitor::Drawables
std::set< osg::Drawable * > Drawables
Definition Optimizer:808
osgUtil::Optimizer::TextureAtlasVisitor::_statesetMap
StateSetMap _statesetMap
Definition Optimizer:815
osgUtil::Optimizer::TextureAtlasVisitor::getTextureAtlasBuilder
TextureAtlasBuilder & getTextureAtlasBuilder()
Definition Optimizer:793
osgUtil::Optimizer::TextureAtlasVisitor::reset
virtual void reset()
osgUtil::Optimizer::TextureAtlasVisitor::_textures
Textures _textures
Definition Optimizer:817
osgUtil::Optimizer::TextureAtlasVisitor::StateSetStack
std::vector< osg::StateSet * > StateSetStack
Definition Optimizer:811
osgUtil::Optimizer::TextureAtlasVisitor::optimize
void optimize()
osgUtil::Optimizer::TextureAtlasVisitor::popStateSet
void popStateSet()
osgUtil::Optimizer::TextureAtlasVisitor::_statesetStack
StateSetStack _statesetStack
Definition Optimizer:816
osgUtil::Optimizer::TextureAtlasVisitor::Textures
std::set< osg::Texture2D * > Textures
Definition Optimizer:810
osgUtil::Optimizer::TextureAtlasVisitor::pushStateSet
bool pushStateSet(osg::StateSet *stateset)
osgUtil::Optimizer::TextureAtlasVisitor::TextureAtlasVisitor
TextureAtlasVisitor(Optimizer *optimizer=0)
default to traversing all children.
Definition Optimizer:789
osgUtil::Optimizer::TextureAtlasVisitor::apply
virtual void apply(osg::Drawable &node)
osgUtil::Optimizer::TextureVisitor::_valueClientImageStorage
bool _valueClientImageStorage
Definition Optimizer:617
osgUtil::Optimizer::TextureVisitor::_valueAnisotropy
float _valueAnisotropy
Definition Optimizer:619
osgUtil::Optimizer::TextureVisitor::apply
virtual void apply(osg::Node &node)
osgUtil::Optimizer::TextureVisitor::apply
void apply(osg::StateSet &stateset)
osgUtil::Optimizer::TextureVisitor::_changeAnisotropy
bool _changeAnisotropy
Definition Optimizer:618
osgUtil::Optimizer::TextureVisitor::_changeClientImageStorage
bool _changeClientImageStorage
Definition Optimizer:617
osgUtil::Optimizer::TextureVisitor::_valueAutoUnRef
bool _valueAutoUnRef
Definition Optimizer:616
osgUtil::Optimizer::TextureVisitor::_changeAutoUnRef
bool _changeAutoUnRef
Definition Optimizer:616
osgUtil::Optimizer::TextureVisitor::apply
void apply(osg::Texture &texture)
osgUtil::Optimizer::TextureVisitor::TextureVisitor
TextureVisitor(bool changeAutoUnRef, bool valueAutoUnRef, bool changeClientImageStorage, bool valueClientImageStorage, bool changeAnisotropy, float valueAnisotropy, Optimizer *optimizer=0)
Definition Optimizer:602
osgUtil::Optimizer
Definition Optimizer:61
osgUtil::Optimizer::isOperationPermissibleForObject
bool isOperationPermissibleForObject(const osg::Node *object, unsigned int option) const
Definition Optimizer:208
osgUtil::Optimizer::isOperationPermissibleForObject
bool isOperationPermissibleForObject(const osg::StateSet *object, unsigned int option) const
Definition Optimizer:184
osgUtil::Optimizer::getIsOperationPermissibleForObjectCallback
const IsOperationPermissibleForObjectCallback * getIsOperationPermissibleForObjectCallback() const
Definition Optimizer:168
osgUtil::Optimizer::setIsOperationPermissibleForObjectCallback
void setIsOperationPermissibleForObjectCallback(IsOperationPermissibleForObjectCallback *callback)
Definition Optimizer:162
osgUtil::Optimizer::~Optimizer
virtual ~Optimizer()
Definition Optimizer:66
osgUtil::Optimizer::optimize
virtual void optimize(osg::Node *node, unsigned int options)
osgUtil::Optimizer::optimize
void optimize(osg::Node *node)
osgUtil::Optimizer::PermissibleOptimizationsMap
std::map< const osg::Object *, unsigned int > PermissibleOptimizationsMap
Definition Optimizer:259
osgUtil::Optimizer::isOperationPermissibleForObjectImplementation
bool isOperationPermissibleForObjectImplementation(const osg::Node *node, unsigned int option) const
Definition Optimizer:238
osgUtil::Optimizer::Optimizer
Optimizer()
Definition Optimizer:65
osgUtil::Optimizer::_isOperationPermissibleForObjectCallback
osg::ref_ptr< IsOperationPermissibleForObjectCallback > _isOperationPermissibleForObjectCallback
Definition Optimizer:257
osgUtil::Optimizer::getIsOperationPermissibleForObjectCallback
IsOperationPermissibleForObjectCallback * getIsOperationPermissibleForObjectCallback()
Definition Optimizer:165
osgUtil::Optimizer::getPermissibleOptimizationsForObject
unsigned int getPermissibleOptimizationsForObject(const osg::Object *object) const
Definition Optimizer:176
osgUtil::Optimizer::isOperationPermissibleForObjectImplementation
bool isOperationPermissibleForObjectImplementation(const osg::StateAttribute *attribute, unsigned int option) const
Definition Optimizer:221
osgUtil::Optimizer::optimize
void optimize(const osg::ref_ptr< T > &node, unsigned int options)
Definition Optimizer:133
osgUtil::Optimizer::OptimizationOptions
OptimizationOptions
Definition Optimizer:69
osgUtil::Optimizer::VERTEX_POSTTRANSFORM
@ VERTEX_POSTTRANSFORM
Definition Optimizer:89
osgUtil::Optimizer::INDEX_MESH
@ INDEX_MESH
Definition Optimizer:88
osgUtil::Optimizer::MAKE_FAST_GEOMETRY
@ MAKE_FAST_GEOMETRY
Definition Optimizer:77
osgUtil::Optimizer::STATIC_OBJECT_DETECTION
@ STATIC_OBJECT_DETECTION
Definition Optimizer:86
osgUtil::Optimizer::TESSELLATE_GEOMETRY
@ TESSELLATE_GEOMETRY
Definition Optimizer:81
osgUtil::Optimizer::FLATTEN_STATIC_TRANSFORMS
@ FLATTEN_STATIC_TRANSFORMS
Definition Optimizer:70
osgUtil::Optimizer::MERGE_GEODES
@ MERGE_GEODES
Definition Optimizer:83
osgUtil::Optimizer::FLATTEN_STATIC_TRANSFORMS_DUPLICATING_SHARED_SUBGRAPHS
@ FLATTEN_STATIC_TRANSFORMS_DUPLICATING_SHARED_SUBGRAPHS
Definition Optimizer:87
osgUtil::Optimizer::CHECK_GEOMETRY
@ CHECK_GEOMETRY
Definition Optimizer:76
osgUtil::Optimizer::TEXTURE_ATLAS_BUILDER
@ TEXTURE_ATLAS_BUILDER
Definition Optimizer:85
osgUtil::Optimizer::BUFFER_OBJECT_SETTINGS
@ BUFFER_OBJECT_SETTINGS
Definition Optimizer:91
osgUtil::Optimizer::ALL_OPTIMIZATIONS
@ ALL_OPTIMIZATIONS
Definition Optimizer:102
osgUtil::Optimizer::DEFAULT_OPTIMIZATIONS
@ DEFAULT_OPTIMIZATIONS
Definition Optimizer:92
osgUtil::Optimizer::MERGE_GEOMETRY
@ MERGE_GEOMETRY
Definition Optimizer:75
osgUtil::Optimizer::OPTIMIZE_TEXTURE_SETTINGS
@ OPTIMIZE_TEXTURE_SETTINGS
Definition Optimizer:82
osgUtil::Optimizer::VERTEX_PRETRANSFORM
@ VERTEX_PRETRANSFORM
Definition Optimizer:90
osgUtil::Optimizer::TRISTRIP_GEOMETRY
@ TRISTRIP_GEOMETRY
Definition Optimizer:80
osgUtil::Optimizer::REMOVE_REDUNDANT_NODES
@ REMOVE_REDUNDANT_NODES
Definition Optimizer:71
osgUtil::Optimizer::SPATIALIZE_GROUPS
@ SPATIALIZE_GROUPS
Definition Optimizer:78
osgUtil::Optimizer::COPY_SHARED_NODES
@ COPY_SHARED_NODES
Definition Optimizer:79
osgUtil::Optimizer::REMOVE_LOADED_PROXY_NODES
@ REMOVE_LOADED_PROXY_NODES
Definition Optimizer:72
osgUtil::Optimizer::COMBINE_ADJACENT_LODS
@ COMBINE_ADJACENT_LODS
Definition Optimizer:73
osgUtil::Optimizer::FLATTEN_BILLBOARDS
@ FLATTEN_BILLBOARDS
Definition Optimizer:84
osgUtil::Optimizer::SHARE_DUPLICATE_STATE
@ SHARE_DUPLICATE_STATE
Definition Optimizer:74
osgUtil::Optimizer::reset
void reset()
osgUtil::Optimizer::optimize
void optimize(const osg::ref_ptr< T > &node)
Definition Optimizer:127
osgUtil::Optimizer::isOperationPermissibleForObject
bool isOperationPermissibleForObject(const osg::StateAttribute *object, unsigned int option) const
Definition Optimizer:192
osgUtil::Optimizer::isOperationPermissibleForObjectImplementation
bool isOperationPermissibleForObjectImplementation(const osg::Drawable *drawable, unsigned int option) const
Definition Optimizer:226
osgUtil::Optimizer::isOperationPermissibleForObjectImplementation
bool isOperationPermissibleForObjectImplementation(const osg::StateSet *stateset, unsigned int option) const
Definition Optimizer:216
osgUtil::Optimizer::setPermissibleOptimizationsForObject
void setPermissibleOptimizationsForObject(const osg::Object *object, unsigned int options)
Definition Optimizer:171
osgUtil::Optimizer::isOperationPermissibleForObject
bool isOperationPermissibleForObject(const osg::Drawable *object, unsigned int option) const
Definition Optimizer:200
osgUtil::Optimizer::_permissibleOptimizationsMap
PermissibleOptimizationsMap _permissibleOptimizationsMap
Definition Optimizer:260
osg::Billboard
Definition Billboard:27
osg::DrawArrayLengths
Definition PrimitiveSet:278
osg::DrawArrays
Definition PrimitiveSet:222
osg::DrawElementsUByte
Definition PrimitiveSet:372
osg::DrawElementsUInt
Definition PrimitiveSet:502
osg::DrawElementsUShort
Definition PrimitiveSet:435
osg::Drawable
Definition Drawable:89
osg::Geode
Definition Geode:29
osg::Geometry
Definition Geometry:31
osg::Group
Definition Group:29
osg::Image
Definition Image:179
osg::LOD
Definition LOD:36
osg::MatrixTransform
Definition MatrixTransform:26
osg::NodeVisitor
Definition NodeVisitor:82
osg::NodeVisitor::TRAVERSE_ALL_CHILDREN
@ TRAVERSE_ALL_CHILDREN
Definition NodeVisitor:89
osg::NodeVisitor::traverse
void traverse(Node &node)
Definition NodeVisitor:274
osg::NodeVisitor::NodeVisitor
NodeVisitor(TraversalMode tm=TRAVERSE_NONE)
osg::NodeVisitor::setNodeMaskOverride
void setNodeMaskOverride(Node::NodeMask mask)
Definition NodeVisitor:210
osg::Node
Definition Node:72
osg::Node::getNumDescriptions
unsigned int getNumDescriptions() const
osg::Node::getNodeMask
NodeMask getNodeMask() const
Definition Node:367
osg::Node::getStateSet
osg::StateSet * getStateSet()
Definition Node:382
osg::Node::getUpdateCallback
Callback * getUpdateCallback()
Definition Node:211
osg::Node::getCullCallback
Callback * getCullCallback()
Definition Node:293
osg::Node::getEventCallback
Callback * getEventCallback()
Definition Node:252
osg::Object
Definition Object:61
osg::Object::DataVariance
DataVariance
Definition Object:217
osg::Object::DYNAMIC
@ DYNAMIC
Definition Object:218
osg::Object::STATIC
@ STATIC
Definition Object:219
osg::Object::UNSPECIFIED
@ UNSPECIFIED
Definition Object:220
osg::Object::getUserData
virtual Referenced * getUserData()
osg::PagedLOD
Definition PagedLOD:24
osg::ProxyNode
Definition ProxyNode:24
osg::Referenced
Definition Referenced:44
osg::StateAttribute
Definition StateAttribute:77
osg::StateSet
Definition StateSet:46
osg::Texture2D
Definition Texture2D:25
osg::Texture2D::getImage
Image * getImage()
Definition Texture2D:58
osg::Texture
Definition Texture:422
osg::Transform
Definition Transform:75
osg::ref_ptr
Definition ref_ptr:32
osg::ref_ptr::get
T * get() const
Definition ref_ptr:117
osgUtil
Definition NodeVisitor:25
osg
Definition AlphaFunc:19
osg::Matrix
Matrixd Matrix
Definition Matrix:27
Export
OSGUTIL_EXPORT
#define OSGUTIL_EXPORT
Definition osgUtil/Export:40
osgUtil::Optimizer::IsOperationPermissibleForObjectCallback
Definition Optimizer:138
osgUtil::Optimizer::IsOperationPermissibleForObjectCallback::isOperationPermissibleForObjectImplementation
virtual bool isOperationPermissibleForObjectImplementation(const Optimizer *optimizer, const osg::StateSet *stateset, unsigned int option) const
Definition Optimizer:139
osgUtil::Optimizer::IsOperationPermissibleForObjectCallback::isOperationPermissibleForObjectImplementation
virtual bool isOperationPermissibleForObjectImplementation(const Optimizer *optimizer, const osg::Drawable *drawable, unsigned int option) const
Definition Optimizer:149
osgUtil::Optimizer::IsOperationPermissibleForObjectCallback::isOperationPermissibleForObjectImplementation
virtual bool isOperationPermissibleForObjectImplementation(const Optimizer *optimizer, const osg::Node *node, unsigned int option) const
Definition Optimizer:154
osgUtil::Optimizer::IsOperationPermissibleForObjectCallback::isOperationPermissibleForObjectImplementation
virtual bool isOperationPermissibleForObjectImplementation(const Optimizer *optimizer, const osg::StateAttribute *attribute, unsigned int option) const
Definition Optimizer:144