Added a osgViewer::setSceneData(ref_ptr<Node>) method.

This commit is contained in:
Robert Osfield
2007-12-12 17:59:06 +00:00
parent 213a370c25
commit 6cca3b8f49
3 changed files with 16 additions and 9 deletions

View File

@@ -60,7 +60,10 @@ 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.*/
virtual void setSceneData(osg::Node* node);
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);
/** Get the View's scene graph.*/
osg::Node* getSceneData() { return _scene.valid() ? _scene->getSceneData() : 0; }

View File

@@ -241,16 +241,15 @@ void View::setStartTick(osg::Timer_t tick)
_startTick = tick;
}
void View::setSceneData(osg::Node* node)
void View::setSceneData(osg::ref_ptr<osg::Node> node)
{
if (_scene->getSceneData()==node) return;
if (node==_scene->getSceneData()) return;
Scene* scene = Scene::getScene(node);
osg::ref_ptr<Scene> scene = Scene::getScene(node.get());
if (scene)
if (scene.valid())
{
osg::notify(osg::INFO)<<"View::setSceneData() Sharing scene "<<scene<<std::endl;
osg::notify(osg::INFO)<<"View::setSceneData() Sharing scene "<<scene.get()<<std::endl;
_scene = scene;
}
else
@@ -266,7 +265,7 @@ void View::setSceneData(osg::Node* node)
osg::notify(osg::INFO)<<"View::setSceneData() Reusing exisitng scene"<<_scene.get()<<std::endl;
}
_scene->setSceneData(node);
_scene->setSceneData(node.get());
}
if (getSceneData())

View File

@@ -110,10 +110,15 @@ BEGIN_OBJECT_REFLECTOR(osgViewer::View)
"",
"");
I_Method1(void, setSceneData, IN, osg::Node *, node,
Properties::VIRTUAL,
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_,
"Set the scene graph that the View will use. ",
"");
I_Method0(osg::Node *, getSceneData,
Properties::NON_VIRTUAL,
__osg_Node_P1__getSceneData,