Added support notification of Drawable parents of StateSet that event/update callbacks have been called.
This commit is contained in:
@@ -271,6 +271,9 @@ Drawable::Drawable()
|
||||
|
||||
_supportsVertexBufferObjects = false;
|
||||
_useVertexBufferObjects = false;
|
||||
|
||||
_numChildrenRequiringUpdateTraversal = 0;
|
||||
_numChildrenRequiringEventTraversal = 0;
|
||||
}
|
||||
|
||||
Drawable::Drawable(const Drawable& drawable,const CopyOp& copyop):
|
||||
@@ -285,6 +288,9 @@ Drawable::Drawable(const Drawable& drawable,const CopyOp& copyop):
|
||||
_supportsVertexBufferObjects(drawable._supportsVertexBufferObjects),
|
||||
_useVertexBufferObjects(drawable._useVertexBufferObjects),
|
||||
_updateCallback(drawable._updateCallback),
|
||||
_numChildrenRequiringUpdateTraversal(drawable._numChildrenRequiringUpdateTraversal),
|
||||
_eventCallback(drawable._eventCallback),
|
||||
_numChildrenRequiringEventTraversal(drawable._numChildrenRequiringEventTraversal),
|
||||
_cullCallback(drawable._cullCallback),
|
||||
_drawCallback(drawable._drawCallback)
|
||||
{
|
||||
@@ -343,7 +349,7 @@ void Drawable::setStateSet(osg::StateSet* stateset)
|
||||
itr!=_parents.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->setNumChildrenRequiringUpdateTraversal((*itr)->getNumChildrenRequiringUpdateTraversal()+delta_update);
|
||||
(*itr)->setNumChildrenRequiringUpdateTraversal( (*itr)->getNumChildrenRequiringUpdateTraversal()+delta_update );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,13 +360,82 @@ void Drawable::setStateSet(osg::StateSet* stateset)
|
||||
itr!=_parents.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->setNumChildrenRequiringEventTraversal((*itr)->getNumChildrenRequiringEventTraversal()+delta_event);
|
||||
(*itr)->setNumChildrenRequiringEventTraversal( (*itr)->getNumChildrenRequiringEventTraversal()+delta_event );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Drawable::setNumChildrenRequiringUpdateTraversal(unsigned int num)
|
||||
{
|
||||
// if no changes just return.
|
||||
if (_numChildrenRequiringUpdateTraversal==num) return;
|
||||
|
||||
// note, if _updateCallback is set then the
|
||||
// parents won't be affected by any changes to
|
||||
// _numChildrenRequiringUpdateTraversal so no need to inform them.
|
||||
if (!_updateCallback && !_parents.empty())
|
||||
{
|
||||
// need to pass on changes to parents.
|
||||
int delta = 0;
|
||||
if (_numChildrenRequiringUpdateTraversal>0) --delta;
|
||||
if (num>0) ++delta;
|
||||
if (delta!=0)
|
||||
{
|
||||
// the number of callbacks has changed, need to pass this
|
||||
// on to parents so they know whether app traversal is
|
||||
// reqired on this subgraph.
|
||||
for(ParentList::iterator itr =_parents.begin();
|
||||
itr != _parents.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->setNumChildrenRequiringUpdateTraversal( (*itr)->getNumChildrenRequiringUpdateTraversal()+delta );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// finally update this objects value.
|
||||
_numChildrenRequiringUpdateTraversal=num;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Drawable::setNumChildrenRequiringEventTraversal(unsigned int num)
|
||||
{
|
||||
// if no changes just return.
|
||||
if (_numChildrenRequiringEventTraversal==num) return;
|
||||
|
||||
// note, if _eventCallback is set then the
|
||||
// parents won't be affected by any changes to
|
||||
// _numChildrenRequiringEventTraversal so no need to inform them.
|
||||
if (!_eventCallback && !_parents.empty())
|
||||
{
|
||||
// need to pass on changes to parents.
|
||||
int delta = 0;
|
||||
if (_numChildrenRequiringEventTraversal>0) --delta;
|
||||
if (num>0) ++delta;
|
||||
if (delta!=0)
|
||||
{
|
||||
// the number of callbacks has changed, need to pass this
|
||||
// on to parents so they know whether app traversal is
|
||||
// reqired on this subgraph.
|
||||
for(ParentList::iterator itr =_parents.begin();
|
||||
itr != _parents.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->setNumChildrenRequiringEventTraversal( (*itr)->getNumChildrenRequiringEventTraversal()+delta );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// finally Event this objects value.
|
||||
_numChildrenRequiringEventTraversal=num;
|
||||
|
||||
}
|
||||
|
||||
osg::StateSet* Drawable::getOrCreateStateSet()
|
||||
{
|
||||
if (!_stateset) setStateSet(new StateSet);
|
||||
@@ -568,7 +643,7 @@ void Drawable::setEventCallback(EventCallback* ac)
|
||||
itr!=_parents.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->setNumChildrenRequiringEventTraversal((*itr)->getNumChildrenRequiringEventTraversal()+delta);
|
||||
(*itr)->setNumChildrenRequiringEventTraversal( (*itr)->getNumChildrenRequiringEventTraversal()+delta );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user