Moved main setSceneData methods in osgViewer::View::setSceneData()

This commit is contained in:
Robert Osfield 2008-12-19 17:50:58 +00:00
parent de53ed75f4
commit 2cc53e2256
4 changed files with 17 additions and 24 deletions

View File

@ -60,10 +60,7 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter
const Scene* getScene() const { return _scene.get(); }
/** Set the scene graph that the View will use.*/
inline void setSceneData(osg::Node* node) { setSceneData(osg::ref_ptr<osg::Node>(node)); }
/** Set the scene graph that the View will use.*/
virtual void setSceneData(osg::ref_ptr<osg::Node> node);
virtual void setSceneData(osg::Node* node);
/** Get the View's scene graph.*/
osg::Node* getSceneData() { return _scene.valid() ? _scene->getSceneData() : 0; }

View File

@ -243,13 +243,13 @@ void View::setStartTick(osg::Timer_t tick)
_startTick = tick;
}
void View::setSceneData(osg::ref_ptr<osg::Node> node)
void View::setSceneData(osg::Node* node)
{
if (node==_scene->getSceneData()) return;
osg::ref_ptr<Scene> scene = Scene::getScene(node.get());
osg::ref_ptr<Scene> scene = Scene::getScene(node);
if (scene.valid())
if (scene)
{
osg::notify(osg::INFO)<<"View::setSceneData() Sharing scene "<<scene.get()<<std::endl;
_scene = scene;
@ -267,7 +267,7 @@ void View::setSceneData(osg::ref_ptr<osg::Node> node)
osg::notify(osg::INFO)<<"View::setSceneData() Reusing exisitng scene"<<_scene.get()<<std::endl;
}
_scene->setSceneData(node.get());
_scene->setSceneData(node);
}
if (getSceneData())
@ -276,6 +276,17 @@ void View::setSceneData(osg::ref_ptr<osg::Node> node)
// the scene graph from being run in parallel.
osgUtil::Optimizer::StaticObjectDetectionVisitor sodv;
getSceneData()->accept(sodv);
// make sure that existing scene graph objects are allocated with thread safe ref/unref
if (getViewerBase()->getThreadingModel()!=ViewerBase::SingleThreaded)
{
osg::notify(osg::NOTICE)<<"Making sure we have set the thread safe ref/unref"<<std::endl;
getSceneData()->setThreadSafeRefUnref(true);
}
// update the scene graph so that it has enough GL object buffer memory for the graphics contexts that will be using it.
getSceneData()->resizeGLObjectBuffers(osg::DisplaySettings::instance()->getMaxNumberOfGraphicsContexts());
}
computeActiveCoordinateSystemNodePath();

View File

@ -360,16 +360,6 @@ void Viewer::setSceneData(osg::Node* node)
setReferenceTime(0.0);
View::setSceneData(node);
if (_threadingModel!=SingleThreaded && getSceneData())
{
// make sure that existing scene graph objects are allocated with thread safe ref/unref
getSceneData()->setThreadSafeRefUnref(true);
// update the scene graph so that it has enough GL object buffer memory for the graphics contexts that will be using it.
getSceneData()->resizeGLObjectBuffers(osg::DisplaySettings::instance()->getMaxNumberOfGraphicsContexts());
}
}
GraphicsWindowEmbedded* Viewer::setUpViewerAsEmbeddedInWindow(int x, int y, int width, int height)

View File

@ -112,13 +112,8 @@ BEGIN_OBJECT_REFLECTOR(osgViewer::View)
"",
"");
I_Method1(void, setSceneData, IN, osg::Node *, node,
Properties::NON_VIRTUAL,
__void__setSceneData__osg_Node_P1,
"Set the scene graph that the View will use. ",
"");
I_Method1(void, setSceneData, IN, osg::ref_ptr< osg::Node >, node,
Properties::VIRTUAL,
__void__setSceneData__osg_ref_ptrT1_osg_Node_,
__void__setSceneData__osg_Node_P1,
"Set the scene graph that the View will use. ",
"");
I_Method0(osg::Node *, getSceneData,