From David Callu, added getOrCreateScene method, made contractors protected.
From Robert Osfield, made getOrCreateScene protected and made View a friend of Scene to all it to construct Scene objects itself.
This commit is contained in:
parent
82b0f004e9
commit
da70320707
@ -29,9 +29,6 @@ class OSGVIEWER_EXPORT Scene : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
|
||||
Scene();
|
||||
virtual ~Scene();
|
||||
|
||||
void setSceneData(osg::Node* node);
|
||||
osg::Node* getSceneData();
|
||||
const osg::Node* getSceneData() const;
|
||||
@ -44,9 +41,17 @@ class OSGVIEWER_EXPORT Scene : public osg::Referenced
|
||||
* return 0 if no Scene has yet been assigned the specified node.*/
|
||||
static Scene* getScene(osg::Node* node);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
Scene();
|
||||
virtual ~Scene();
|
||||
|
||||
/** Get the Scene object that has the specified node assigned to it.
|
||||
* or return a new Scene if no Scene has yet been assigned the specified node.*/
|
||||
static Scene* getOrCreateScene(osg::Node* node);
|
||||
|
||||
friend class View;
|
||||
|
||||
osg::ref_ptr<osg::Node> _sceneData;
|
||||
|
||||
osg::ref_ptr<osgDB::DatabasePager> _databasePager;
|
||||
|
@ -52,7 +52,7 @@ void Scene::setSceneData(osg::Node* node)
|
||||
if (_databasePager.valid())
|
||||
{
|
||||
// register any PagedLOD that need to be tracked in the scene graph
|
||||
_databasePager->registerPagedLODs(node);
|
||||
if (node) _databasePager->registerPagedLODs(node);
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,3 +85,16 @@ Scene* Scene::getScene(osg::Node* node)
|
||||
return 0;
|
||||
}
|
||||
|
||||
Scene* Scene::getOrCreateScene(osg::Node* node)
|
||||
{
|
||||
if (!node) return 0;
|
||||
|
||||
osgViewer::Scene* scene = getScene(node);
|
||||
if (!scene)
|
||||
{
|
||||
scene = new Scene;
|
||||
scene->setSceneData(node);
|
||||
}
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user