]> git.mxchange.org Git - simgear.git/blob - simgear/scene/model/SGPagedLOD.hxx
fix SGPagedLOD change for 2.8.3
[simgear.git] / simgear / scene / model / SGPagedLOD.hxx
1 // Copyright (C) 2008 Till Busch buti@bux.at
2 //
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License as
5 // published by the Free Software Foundation; either version 2 of the
6 // License, or (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful, but
9 // WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
16
17 #ifndef SGPAGEDLOD_HXX
18 #define SGPAGEDLOD_HXX 1
19
20 #include <simgear/structure/OSGVersion.hxx>
21
22 #define SG_PAGEDLOD_HAS_OPTIONS \
23     (SG_OSG_VERSION >= 29005)
24
25 #include <osg/PagedLOD>
26 #include <osgDB/Registry>
27 #include <osgDB/ReaderWriter>
28 #include <simgear/props/props.hxx>
29
30 namespace osgDB {
31 class DatabasePager;
32 }
33
34
35 namespace simgear
36 {
37
38 class SGPagedLOD : public osg::PagedLOD
39 {
40 public:
41     SGPagedLOD();
42
43     SGPagedLOD(const SGPagedLOD&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
44
45     META_Node(simgear, SGPagedLOD);
46
47     // virtual void traverse(osg::NodeVisitor& nv);
48     virtual void forceLoad(osgDB::DatabasePager* dbp,
49                            osg::FrameStamp* framestamp,
50                            osg::NodePath& path);
51
52     // reimplemented to notify the loading through ModelData
53     bool addChild(osg::Node *child);
54
55     void setReaderWriterOptions(osgDB::ReaderWriter::Options *options) {
56         options->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_NONE);
57 #if SG_PAGEDLOD_HAS_OPTIONS
58         setDatabaseOptions(options);
59 #else
60         _readerWriterOptions = options;
61 #endif
62     }
63
64     osgDB::ReaderWriter::Options* getReaderWriterOptions() {
65 #if SG_PAGEDLOD_HAS_OPTIONS
66         return static_cast<osgDB::ReaderWriter::Options*>(getDatabaseOptions());
67 #else
68         return _readerWriterOptions.get();
69 #endif
70     }
71
72 protected:
73     virtual ~SGPagedLOD();
74 #if !SG_PAGEDLOD_HAS_OPTIONS
75     osg::ref_ptr<osgDB::ReaderWriter::Options> _readerWriterOptions;
76 #endif
77 };
78 }
79 #endif