[osg-users] update slave camera with frame scheme ON_DEMAND

Gianni Ambrosio g.ambrosio+osg at gmail.com
Wed Aug 5 08:58:31 PDT 2015

Hi Robert, I didn't understand your answer.

I use OSG 3.0.1 but I tried with 3.4.0.-rc8 and the behavior is the same. Moreover updateTraversal() of CompositeViewer is basically the same for these versions.
Anyway we are probably talking of a slightly different scenario: I have a slave camera which update callback needs an up to date viewer master camera's view matrix. In this case, as you told me, since the master camera matrix is updated (with the inverse matrix of the manipulator) after the slave camera update callback, then the value is that of the previous frame. I can understand and the reason is in CompositeViewer::updateTraversal() because the for loop "// Do UpdateTraversal for slaves with their own subgraph" is done before "view->getCameraManipulator()->updateCamera(*(view->getCamera()));".
So, to make scenarios like mine working, my suggestion is to move:


            // Do UpdateTraversal for slaves with their own subgraph
            for(unsigned int i=0; i<view->getNumSlaves(); ++i)
                osg::View::Slave& slave = view->getSlave(i);
                osg::Camera* camera = slave._camera.get();
                if(camera && !slave._useMastersSceneData)



        if (view->getCameraManipulator())
            view->setFusionDistance( view->getCameraManipulator()->getFusionDistanceMode(),
                                    view->getCameraManipulator()->getFusionDistanceValue() );



I tried this solution and it works fine.
With this modification the scene remains updated before the main camera, so nothing you already told me should be broken.
Moreover the for loop to move down is related to slave cameras with thier own subgraph.


Read this topic online here:

More information about the osg-users mailing list