|
发表于 2009-11-16 15:45:07
|
显示全部楼层
本帖最后由 qele 于 2009-11-17 10:54 编辑
-
- /////////////////////////////////////////////////////////////////////////////
- // class CAddRemoveCallBack implement
- CAddRemoveCallBack::CAddRemoveCallBack(OpenThreads::Mutex* mutex) : _mutex(mutex), _paused(FALSE)
- {}
- CAddRemoveCallBack::~CAddRemoveCallBack(void)
- {}
- void CAddRemoveCallBack:perator()(osg::Node* node, osg::NodeVisitor* nv)
- {
- if ( _paused )
- {
- OpenThreads::ScopedLock<OpenThreads::Mutex> lock( *_mutex);
- osg::Group* root = dynamic_cast<osg::Group*>(node);
- if ( root != NULL )
- {
- // remove first
- for ( size_t i = 0; i < _vtRemoving.size(); ++i )
- {
- root->removeChild( _vtRemoving[i] );
- }
- _vtRemoving.clear();
- // add node
- for ( size_t i = 0; i < _vtAdding.size(); ++i )
- {
- root->addChild( _vtAdding[i] );
- }
- vtAdding.clear();
- }
- _paused = FALSE;
- }
- }
- void CAddRemoveCallBack::AddChild( osg::Node* node )
- {
- OpenThreads::ScopedLock<OpenThreads::Mutex> lock( *_mutex);
- _vtAdding.push_back( node );
- _paused = TRUE;
- }
- void CAddRemoveCallBack::RemoveChild( osg::Node* node )
- {
- OpenThreads::ScopedLock<OpenThreads::Mutex> lock( *_mutex);
- _vtRemoving.push_back( node );
- _paused = TRUE;
- }
复制代码 |
|