using namespace osg;
using namespace simgear;
+bool SGPagedLOD::_cache = true;
+
SGPagedLOD::SGPagedLOD()
: PagedLOD()
{
{
}
+void
+SGPagedLOD::setReaderWriterOptions(osgDB::ReaderWriter::Options *options)
+{
+ if (_cache)
+ options->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_ALL);
+ else
+ options->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_NONE);
+#if SG_PAGEDLOD_HAS_OPTIONS
+ setDatabaseOptions(options);
+#else
+ _readerWriterOptions = options;
+#endif
+}
+
bool SGPagedLOD::addChild(osg::Node *child)
{
if (!PagedLOD::addChild(child))
// reimplemented to notify the loading through ModelData
bool addChild(osg::Node *child);
- void setReaderWriterOptions(osgDB::ReaderWriter::Options *options) {
- options->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_NONE);
-#if SG_PAGEDLOD_HAS_OPTIONS
- setDatabaseOptions(options);
-#else
- _readerWriterOptions = options;
-#endif
- }
+ void setReaderWriterOptions(osgDB::ReaderWriter::Options *options);
osgDB::ReaderWriter::Options* getReaderWriterOptions() {
#if SG_PAGEDLOD_HAS_OPTIONS
#endif
}
+ static void setRenderingCache(bool cache) {_cache = cache;}
protected:
virtual ~SGPagedLOD();
#if !SG_PAGEDLOD_HAS_OPTIONS
osg::ref_ptr<osgDB::ReaderWriter::Options> _readerWriterOptions;
#endif
+private:
+ static bool _cache;
};
}
#endif
////////////////////////////////////////////////////////////////////////
// Implementation of SGModelLib.
////////////////////////////////////////////////////////////////////////
-void SGModelLib::init(const string &root_dir)
+void SGModelLib::init(const string &root_dir, SGPropertyNode* root)
{
osgDB::Registry::instance()->getDataFilePathList().push_front(root_dir);
+ static_propRoot = root;
+ SGPagedLOD::setRenderingCache(root->getBoolValue("/sim/rendering/cache",true));
}
-void SGModelLib::setPropRoot(SGPropertyNode* root)
-{
- static_propRoot = root;
-}
-
void SGModelLib::setPanelFunc(panel_func pf)
{
static_panelFunc = pf;
public:
typedef osg::Node *(*panel_func)(SGPropertyNode *);
- static void init(const std::string &root_dir);
+ static void init(const std::string &root_dir, SGPropertyNode* root);
- static void setPropRoot(SGPropertyNode* root);
-
static void setPanelFunc(panel_func pf);
// Load a 3D model (any format)