Cleaned up handling of Drawables so it utilizes the Node inheritance properly.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14822 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
parent
814693ffc1
commit
6cff8650f2
@ -461,15 +461,15 @@ class OSGUTIL_EXPORT Optimizer
|
||||
|
||||
protected:
|
||||
|
||||
void addStateSet(osg::StateSet* stateset,osg::Object* obj);
|
||||
void addStateSet(osg::StateSet* stateset, osg::Node* node);
|
||||
|
||||
inline bool optimize(osg::Object::DataVariance variance)
|
||||
{
|
||||
return _optimize[variance];
|
||||
}
|
||||
|
||||
typedef std::set<osg::Object*> ObjectSet;
|
||||
typedef std::map<osg::StateSet*,ObjectSet> StateSetMap;
|
||||
typedef std::set<osg::Node*> NodeSet;
|
||||
typedef std::map<osg::StateSet*, NodeSet> StateSetMap;
|
||||
|
||||
// note, one element for DYNAMIC, STATIC and UNSPECIFIED
|
||||
bool _optimize[3];
|
||||
|
@ -162,19 +162,8 @@ osg::StateAttribute *SharedStateManager::find(osg::StateAttribute *sa)
|
||||
//----------------------------------------------------------------
|
||||
void SharedStateManager::setStateSet(osg::StateSet* ss, osg::Object* object)
|
||||
{
|
||||
osg::Drawable* drawable = dynamic_cast<osg::Drawable*>(object);
|
||||
if (drawable)
|
||||
{
|
||||
drawable->setStateSet(ss);
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::Node* node = dynamic_cast<osg::Node*>(object);
|
||||
if (node)
|
||||
{
|
||||
node->setStateSet(ss);
|
||||
}
|
||||
}
|
||||
osg::Node* node = dynamic_cast<osg::Node*>(object);
|
||||
if (node) node->setStateSet(ss);
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,14 +72,8 @@ void StateSetManipulator::clone()
|
||||
itr != parents.end();
|
||||
++itr)
|
||||
{
|
||||
osg::Object* object = *itr;
|
||||
osg::Node* node = dynamic_cast<osg::Node*>(object);
|
||||
if (node) node->setStateSet(newStateSet.get());
|
||||
else
|
||||
{
|
||||
osg::Drawable* drawable = dynamic_cast<osg::Drawable*>(object);
|
||||
if (drawable) drawable->setStateSet(newStateSet.get());
|
||||
}
|
||||
osg::Node* node = *itr;
|
||||
node->setStateSet(newStateSet.get());
|
||||
}
|
||||
|
||||
_stateset = newStateSet;
|
||||
|
@ -438,9 +438,9 @@ void Optimizer::StateVisitor::reset()
|
||||
_statesets.clear();
|
||||
}
|
||||
|
||||
void Optimizer::StateVisitor::addStateSet(osg::StateSet* stateset,osg::Object* obj)
|
||||
void Optimizer::StateVisitor::addStateSet(osg::StateSet* stateset, osg::Node* node)
|
||||
{
|
||||
_statesets[stateset].insert(obj);
|
||||
_statesets[stateset].insert(node);
|
||||
}
|
||||
|
||||
void Optimizer::StateVisitor::apply(osg::Node& node)
|
||||
@ -688,26 +688,13 @@ void Optimizer::StateVisitor::optimize()
|
||||
if (**current==**first_unique)
|
||||
{
|
||||
OSG_INFO << " found duplicate "<<(*current)->className()<<" first="<<*first_unique<<" current="<<*current<< std::endl;
|
||||
ObjectSet& objSet = _statesets[*current];
|
||||
for(ObjectSet::iterator sitr=objSet.begin();
|
||||
sitr!=objSet.end();
|
||||
NodeSet& nodeSet = _statesets[*current];
|
||||
for(NodeSet::iterator sitr=nodeSet.begin();
|
||||
sitr!=nodeSet.end();
|
||||
++sitr)
|
||||
{
|
||||
OSG_INFO << " replace duplicate "<<*current<<" with "<<*first_unique<< std::endl;
|
||||
osg::Object* obj = *sitr;
|
||||
osg::Drawable* drawable = dynamic_cast<osg::Drawable*>(obj);
|
||||
if (drawable)
|
||||
{
|
||||
drawable->setStateSet(*first_unique);
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::Node* node = dynamic_cast<osg::Node*>(obj);
|
||||
if (node)
|
||||
{
|
||||
node->setStateSet(*first_unique);
|
||||
}
|
||||
}
|
||||
(*sitr)->setStateSet(*first_unique);
|
||||
}
|
||||
}
|
||||
else first_unique = current;
|
||||
|
Loading…
Reference in New Issue
Block a user