Added detection and disabling of flattening of static transforms which a
LightPointNode exists in the scene graph.
This commit is contained in:
parent
3d61e25cce
commit
9b9cb9cdb0
@ -125,6 +125,7 @@ class OSGUTIL_EXPORT Optimizer
|
|||||||
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
|
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
|
||||||
_optimizer(optimizer) {}
|
_optimizer(optimizer) {}
|
||||||
|
|
||||||
|
virtual void apply(osg::Node& geode);
|
||||||
virtual void apply(osg::Geode& geode);
|
virtual void apply(osg::Geode& geode);
|
||||||
virtual void apply(osg::Billboard& geode);
|
virtual void apply(osg::Billboard& geode);
|
||||||
virtual void apply(osg::Transform& transform);
|
virtual void apply(osg::Transform& transform);
|
||||||
@ -142,10 +143,12 @@ class OSGUTIL_EXPORT Optimizer
|
|||||||
typedef std::vector<osg::Transform*> TransformStack;
|
typedef std::vector<osg::Transform*> TransformStack;
|
||||||
typedef std::set<osg::Drawable*> DrawableSet;
|
typedef std::set<osg::Drawable*> DrawableSet;
|
||||||
typedef std::set<osg::Billboard*> BillboardSet;
|
typedef std::set<osg::Billboard*> BillboardSet;
|
||||||
|
typedef std::set<osg::Node* > NodeSet;
|
||||||
typedef std::set<osg::Transform*> TransformSet;
|
typedef std::set<osg::Transform*> TransformSet;
|
||||||
|
|
||||||
Optimizer* _optimizer;
|
Optimizer* _optimizer;
|
||||||
TransformStack _transformStack;
|
TransformStack _transformStack;
|
||||||
|
NodeSet _excludedNodeSet;
|
||||||
DrawableSet _drawableSet;
|
DrawableSet _drawableSet;
|
||||||
BillboardSet _billboardSet;
|
BillboardSet _billboardSet;
|
||||||
TransformSet _transformSet;
|
TransformSet _transformSet;
|
||||||
|
@ -548,6 +548,15 @@ class CollectLowestTransformsVisitor : public osg::NodeVisitor
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void collectDataFor(osg::Node* node)
|
||||||
|
{
|
||||||
|
_currentObjectList.push_back(node);
|
||||||
|
|
||||||
|
node->accept(*this);
|
||||||
|
|
||||||
|
_currentObjectList.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
void collectDataFor(osg::Billboard* billboard)
|
void collectDataFor(osg::Billboard* billboard)
|
||||||
{
|
{
|
||||||
_currentObjectList.push_back(billboard);
|
_currentObjectList.push_back(billboard);
|
||||||
@ -578,9 +587,13 @@ class CollectLowestTransformsVisitor : public osg::NodeVisitor
|
|||||||
|
|
||||||
inline bool isOperationPermissableForObject(const osg::Object* object)
|
inline bool isOperationPermissableForObject(const osg::Object* object)
|
||||||
{
|
{
|
||||||
|
// disable if cannot apply transform functor.
|
||||||
const osg::Drawable* drawable = dynamic_cast<const osg::Drawable*>(object);
|
const osg::Drawable* drawable = dynamic_cast<const osg::Drawable*>(object);
|
||||||
if (drawable && !drawable->supports(_transformFunctor)) return false;
|
if (drawable && !drawable->supports(_transformFunctor)) return false;
|
||||||
|
|
||||||
|
// disable if object is a light point node.
|
||||||
|
if (strcmp(object->className(),"LightPointNode")==0) return false;
|
||||||
|
|
||||||
return _optimizer ? _optimizer->isOperationPermissableForObject(object,Optimizer::FLATTEN_STATIC_TRANSFORMS) : true;
|
return _optimizer ? _optimizer->isOperationPermissableForObject(object,Optimizer::FLATTEN_STATIC_TRANSFORMS) : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -903,9 +916,17 @@ bool CollectLowestTransformsVisitor::removeTransforms(osg::Node* nodeWeCannotRem
|
|||||||
return transformRemoved;
|
return transformRemoved;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Optimizer::FlattenStaticTransformsVisitor::apply(osg::Node& node)
|
||||||
|
{
|
||||||
|
if (strcmp(node.className(),"LightPointNode")==0)
|
||||||
|
{
|
||||||
|
_excludedNodeSet.insert(&node);
|
||||||
|
}
|
||||||
|
traverse(node);
|
||||||
|
}
|
||||||
|
|
||||||
void Optimizer::FlattenStaticTransformsVisitor::apply(osg::Geode& geode)
|
void Optimizer::FlattenStaticTransformsVisitor::apply(osg::Geode& geode)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!_transformStack.empty())
|
if (!_transformStack.empty())
|
||||||
{
|
{
|
||||||
for(unsigned int i=0;i<geode.getNumDrawables();++i)
|
for(unsigned int i=0;i<geode.getNumDrawables();++i)
|
||||||
@ -945,6 +966,13 @@ bool Optimizer::FlattenStaticTransformsVisitor::removeTransforms(osg::Node* node
|
|||||||
{
|
{
|
||||||
CollectLowestTransformsVisitor cltv(_optimizer);
|
CollectLowestTransformsVisitor cltv(_optimizer);
|
||||||
|
|
||||||
|
for(NodeSet::iterator nitr=_excludedNodeSet.begin();
|
||||||
|
nitr!=_excludedNodeSet.end();
|
||||||
|
++nitr)
|
||||||
|
{
|
||||||
|
cltv.collectDataFor(*nitr);
|
||||||
|
}
|
||||||
|
|
||||||
for(DrawableSet::iterator ditr=_drawableSet.begin();
|
for(DrawableSet::iterator ditr=_drawableSet.begin();
|
||||||
ditr!=_drawableSet.end();
|
ditr!=_drawableSet.end();
|
||||||
++ditr)
|
++ditr)
|
||||||
|
Loading…
Reference in New Issue
Block a user