OsgEarth RenderTravel代码跟踪

OSGEarth RenderTravel代码跟踪
contexts 获取contex,每一个context中包含一个traits

 traits->x = 0;
 traits->y = 50;
 traits->width = rect.right - rect.left - 0;
 traits->height = rect.bottom - rect.top - 0;
 traits->windowDecoration = false;
 traits->doubleBuffer = true;
 traits->sharedContext = 0;
 traits->setInheritedWindowPixelFormat = true;
 traits->inheritedWindowData = windata;
 osg::ref_ptr<osg::GraphicsContext> pGC = osg::GraphicsContext::createGraphicsContext(traits);

2.Scenes 获取 scene,每个scene中包含一个根节点 osg::ref_ptr root

   scene->getSceneData()->getBound();
  m_Viewer->setSceneData(m_root.get());

3.cameras 获取所有的camera,包括slave

if (_endDynamicDrawBlock.valid())
{
    _endDynamicDrawBlock->reset();
}

4.针对每个camera,获取其 Renderer,执行

        if (!renderer->getGraphicsThreadDoesCull() && !(camera->getCameraThread()))
        {
            renderer->cull();//精选; 挑选,剔除
        }

在cull中,每个render的成员变量增加

     osgUtil::SceneView* sceneView = _availableQueue.takeFront();
     _drawQueue.add(sceneView);

eventTraversal
获取所有事件,并封装成osg::Event
根据事件类型获取事件相关数据,如鼠标坐标等

5.1对所有事件从root开始访问者进行

void Group::traverse(NodeVisitor& nv)
{
for(NodeList::iterator itr=_children.begin();
itr!=_children.end();
++itr)
{
(*itr)->accept(nv);
}
}

virtual void apply(osg::Group& node)        { handle_callbacks_and_traverse(node); }
    inline void handle_callbacks(osg::StateSet* stateset)
    {
        if (stateset && stateset->requiresEventTraversal())
        {
            stateset->runEventCallbacks(this);
        }
    }
    inline void handle_callbacks_and_traverse(osg::Node& node)
    {
        handle_callbacks(node.getStateSet());
        osg::Callback* callback = node.getEventCallback();
        if (callback) 
            callback->run(&node,this);
        else if (node.getNumChildrenRequiringEventTraversal()>0)
            traverse(node);
    }

对于每个事件针对各个相机进行处理,无论是否是用_useMastersSceneData
camera->accept(*_eventVisitor);

对每个事件对osgViewer::_eventHandlers进行处理

对_cameraManipulator进行处理