Hi, > A custom "cull visitor" wouldn't be related to the osgViewer, rather > it's something you'd instantiate and call yourself on demand. The > custom "cull visitor" needn't even subclass from CullVisitor. The > subclass from IntersectionVisitor with a Polytope representing the > view frustum way actually be the best place to start.
Before I read Roberts response I tried to follow a different route to solve the speed problem. The basic strategy was to sub-class osgViewer::Renderer and implement the "operator()" so that only cull (not draw) was done during osgViewer::ViewerBase::renderTraversals() while PagedLOD were being loaded:
[...snip...]
class CustomRenderer : public osgViewer::Renderer
{
public:
CustomRenderer(osg::Camera* camera)
: osgViewer::Renderer(camera),
_cullOnly(true)
{
setTargetFrameRate(1);
setMinimumTimeAvailableForGLCompileAndDeletePerFrame(1);
}
void setCullOnly(bool on) { _cullOnly = on; }
void operator () (osg::GraphicsContext* /*context*/)
{
if (_graphicsThreadDoesCull)
{
if (_cullOnly)
cull();
else
cull_draw();
}
}
void cull()
{
osgUtil::SceneView* sceneView = _sceneView[0].get();
if (!sceneView || _done ) return;
updateSceneView(sceneView);
osgViewer::View* view =
dynamic_cast<osgViewer::View*>(_camera->getView());
if (view)
sceneView->setFusionDistance(view->getFusionDistanceMode(),
view->getFusionDistanceValue());
sceneView->inheritCullSettings(*(sceneView->getCamera()));
sceneView->cull();
}
bool _cullOnly;
};
[...snip...]
The CustomRenderer was installed and used as shown below:
[...snip...]
// Install custom renderer
osg::ref_ptr<CustomRenderer> customRenderer = new
CustomRenderer(getCamera());
getCamera()->setRenderer(customRenderer);
// Initiate the first PagedLOD request
frame();
osgDB::DatabasePager* pager = getDatabasePager();
osg::Timer_t beforeLoadTick = osg::Timer::instance()->tick();
// Keep updating and culling until full level of detail is reached
while(!done() && pager->getRequestsInProgress())
{
updateTraversal();
renderingTraversals();
}
osg::Timer_t afterLoadTick = osg::Timer::instance()->tick();
std::cout<<"Time used to load all PageLODs =
"<<osg::Timer::instance()->delta_s(beforeLoadTick, afterLoadTick)<<"
seconds"<<std::endl;
// Do cull _and_ draw to render the scene correctly
customRenderer->setCullOnly(false);
// Add the WindowCaptureCallback now that we have full resolution
getCamera()->setFinalDrawCallback(new
WindowCaptureCallback(GL_BACK, _fileName));
// Do rendering with capture callback
renderingTraversals();
// Automatically close after capture
close();
[...snip...]
The image rendered just fine, but the time saved was minimal /
insignificant. On average the above approach yields a load time of
approx. 47.2 seconds, while the original load time without the
CustomRenderer was about 48.8 seconds. An improvement of only 0.04% is
quite disappointing, and could just as well be ascribed to other factors.
At the time of implementation the approach seemed like a clever idea, but the timing results shows that it has a big flaw. Is it the approach or the implementation that is flawed? (The complete example is attached to this email.)
PS: The database pager was configured as follows; osgDB::DatabasePager* pager = viewerWindow->getDatabasePager(); pager->setTargetFrameRate(1); pager->setMinimumTimeAvailableForGLCompileAndDeletePerFrame(1); pager->setMaximumNumOfObjectsToCompilePerFrame(100); pager->setDoPreCompile(false);I guess I'll try the "IntersectionVisitor" approach now, but I'm not totally convinced that this will be any faster if it is the colling that makes things go slow.
Best regards, John Robert Osfield wrote:
Hi John, A custom "cull visitor" wouldn't be related to the osgViewer, rather it's something you'd instantiate and call yourself on demand. The custom "cull visitor" needn't even subclass from CullVisitor. The subclass from IntersectionVisitor with a Polytope representing the view frustum way actually be the best place to start. Robert.
-- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.
osgautocapture.tgz
Description: GNU Zip compressed data
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

