Added support for an update OperationQueue to Viewer and CompositeViewer to allow asyncrnous adding of operations to be added
to the view to be done during syncronous updateTraversal(). This feature can be used for doing things like merging subgraphs that have been loaded in a background thread.
This commit is contained in:
@@ -181,6 +181,40 @@ void OperationQueue::removeAllOperations()
|
||||
}
|
||||
}
|
||||
|
||||
void OperationQueue::runOperations(Object* callingObject)
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_operationsMutex);
|
||||
|
||||
// reset current operation iterator to begining if at end.
|
||||
if (_currentOperationIterator==_operations.end()) _currentOperationIterator = _operations.begin();
|
||||
|
||||
for(;
|
||||
_currentOperationIterator != _operations.end();
|
||||
)
|
||||
{
|
||||
ref_ptr<Operation> operation = *_currentOperationIterator;
|
||||
|
||||
if (!operation->getKeep())
|
||||
{
|
||||
_currentOperationIterator = _operations.erase(_currentOperationIterator);
|
||||
}
|
||||
else
|
||||
{
|
||||
++_currentOperationIterator;
|
||||
}
|
||||
|
||||
// osg::notify(osg::INFO)<<"Doing op "<<_currentOperation->getName()<<" "<<this<<std::endl;
|
||||
|
||||
// call the graphics operation.
|
||||
(*operation)(callingObject);
|
||||
}
|
||||
|
||||
if (_operations.empty())
|
||||
{
|
||||
_operationsBlock->set(false);
|
||||
}
|
||||
}
|
||||
|
||||
void OperationQueue::releaseOperationsBlock()
|
||||
{
|
||||
_operationsBlock->release();
|
||||
|
||||
Reference in New Issue
Block a user