探索未知种族之osg类生物---呼吸分解之更新循环三
程序员文章站
2022-04-20 09:03:18
...
补充
当然细心的你会发现,_scene->updateSceneGraph(*_updateVisitor)中还有一个imagePager::UpdateSceneGraph()还没有进行讲解,这是因为imagePager和DatabasePager是可以对比这理解的,这里imagePager的主要功能就是加载纹理图片文件。但是imagePager只是负责在另一个线程中加载图片,而没有databasePager的分页功能以及去掉过期数据。这样我们就真的可以重新回到Viewer::updateTraversal()中,继续向下进行了。
Viewer::updateTraversal()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// if we have a shared state manager prune any unused entries if (osgDB::Registry::instance()->getSharedStateManager())
osgDB::Registry::instance()->getSharedStateManager()->prune();
// update the Registry object cache.
osgDB::Registry::instance()->updateTimeStampOfObjectsInCacheWithExternalReferences(*getFrameStamp());
osgDB::Registry::instance()->removeExpiredObjectsInCache(*getFrameStamp());
if (_updateOperations.valid())
{
_updateOperations->runOperations( this );
}
if (_incrementalCompileOperation.valid())
{
// merge subgraphs that have been compiled by the incremental compiler operation.
_incrementalCompileOperation->mergeCompiledSubgraphs(getFrameStamp());
}
{
// Do UpdateTraversal for slaves with their own subgraph
for (unsigned int i=0; i<getNumSlaves(); ++i)
{
osg::View::Slave& slave = getSlave(i);
osg::Camera* camera = slave._camera.get();
if (camera && !slave._useMastersSceneData)
{
camera->accept(*_updateVisitor);
}
}
}
{
// call any camera update callbacks, but only traverse that callback, don't traverse its subgraph
// leave that to the scene update traversal.
osg::NodeVisitor::TraversalMode tm = _updateVisitor->getTraversalMode();
_updateVisitor->setTraversalMode(osg::NodeVisitor::TRAVERSE_NONE);
if (_camera.valid() && _camera->getUpdateCallback()) _camera->accept(*_updateVisitor);
for (unsigned int i=0; i<getNumSlaves(); ++i)
{
osg::View::Slave& slave = getSlave(i);
osg::Camera* camera = slave._camera.get();
if (camera && slave._useMastersSceneData && camera->getUpdateCallback())
{
camera->accept(*_updateVisitor);
}
}
_updateVisitor->setTraversalMode( tm );
}
if (_cameraManipulator.valid())
{
setFusionDistance( getCameraManipulator()->getFusionDistanceMode(),
getCameraManipulator()->getFusionDistanceValue() );
_cameraManipulator->updateCamera(*_camera);
}
updateSlaves();
if (getViewerStats() && getViewerStats()->collectStats( "update" ))
{
double endUpdateTraversal = osg::Timer::instance()->delta_s(_startTick, osg::Timer::instance()->tick());
// update current frames stats
getViewerStats()->setAttribute(_frameStamp->getFrameNumber(), "Update traversal begin time" , beginUpdateTraversal);
getViewerStats()->setAttribute(_frameStamp->getFrameNumber(), "Update traversal end time" , endUpdateTraversal);
getViewerStats()->setAttribute(_frameStamp->getFrameNumber(), "Update traversal time taken" , endUpdateTraversal-beginUpdateTraversal);
}
|
现在我们总有算是完成了漫长的 updateTraversal 函数之旅。我们明天开始更艰巨的任务osgViewer:: ViewerBase::renderingTraversals()。
上一篇: 软键盘遮挡住输入 解决方案