]> git.mxchange.org Git - simgear.git/blob - simgear/scene/model/SGPagedLOD.cxx
Improved tile cache priority scheme.
[simgear.git] / simgear / scene / model / SGPagedLOD.cxx
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 #ifdef HAVE_CONFIG_H
18 #  include <simgear_config.h>
19 #endif
20
21 #include <osgDB/ReadFile>
22 #include <osgDB/Input>
23 #include <osgDB/ParameterOutput>
24
25 #include <simgear/debug/logstream.hxx>
26 #include <simgear/structure/OSGVersion.hxx>
27
28 #include "modellib.hxx"
29 #include "SGReaderWriterXMLOptions.hxx"
30 #include "SGPagedLOD.hxx"
31
32 #include <simgear/math/SGMath.hxx>
33
34 using namespace osg;
35 using namespace simgear;
36
37 SGPagedLOD::SGPagedLOD()
38         : PagedLOD()
39 {
40 }
41
42 SGPagedLOD::~SGPagedLOD()
43 {
44     //SG_LOG(SG_GENERAL, SG_ALERT, "SGPagedLOD::~SGPagedLOD(" << getFileName(0) << ")");
45 }
46
47 SGPagedLOD::SGPagedLOD(const SGPagedLOD& plod,const CopyOp& copyop)
48         : osg::PagedLOD(plod, copyop),
49         _readerWriterOptions(plod._readerWriterOptions)
50 {
51 }
52
53 bool SGPagedLOD::addChild(osg::Node *child)
54 {
55     if (!PagedLOD::addChild(child))
56         return false;
57
58     setRadius(getBound().radius());
59     setCenter(getBound().center());
60     return true;
61 }
62
63 void SGPagedLOD::forceLoad(osgDB::DatabasePager *dbp)
64 {
65     //SG_LOG(SG_GENERAL, SG_ALERT, "SGPagedLOD::forceLoad(" <<
66     //getFileName(getNumChildren()) << ")");
67     unsigned childNum = getNumChildren();
68     setTimeStamp(childNum, 0);
69     double priority=1.0;
70     dbp->requestNodeFile(getFileName(childNum),this,priority,0,
71                          getDatabaseRequest(childNum),
72                          _readerWriterOptions.get());
73 }
74
75 bool SGPagedLOD_writeLocalData(const Object& obj, osgDB::Output& fw)
76 {
77     return true;
78 }
79
80 namespace
81 {
82 osgDB::RegisterDotOsgWrapperProxy sgPagedLODProxy
83 (
84     new SGPagedLOD,
85     "simgear::SGPagedLOD",
86     "Object Node LOD PagedLOD SGPagedLOD Group",
87     0,
88     &SGPagedLOD_writeLocalData
89     );
90 }