#ifndef _SG_MODELREGISTRY_HXX
#define _SG_MODELREGISTRY_HXX 1
-#include <OpenThreads/ReentrantMutex>
-
#include <osg/ref_ptr>
#include <osg/Node>
#include <osgDB/FileUtils>
#include <osgDB/Registry>
#include <simgear/compiler.h>
-#include <simgear/structure/Singleton.hxx>
+#include <simgear/scene/util/OsgSingleton.hxx>
#include <string>
#include <map>
}
virtual osgDB::ReaderWriter::ReadResult
readNode(const std::string& fileName,
- const osgDB::ReaderWriter::Options* opt)
+ const osgDB::Options* opt)
{
using namespace osg;
using namespace osgDB;
optimizedNode = _optimizePolicy.optimize(processedNode.get(),
fileName, opt);
}
- _bvhPolicy.buildBVH(fileName, optimizedNode.get());
+ if (opt->getPluginStringData("SimGear::BOUNDINGVOLUMES") != "OFF")
+ _bvhPolicy.buildBVH(fileName, optimizedNode.get());
_cachePolicy.addToCache(fileName, optimizedNode.get());
}
- return ReaderWriter::ReadResult(optimizedNode);
+ return ReaderWriter::ReadResult(optimizedNode.get());
}
protected:
static osgDB::ReaderWriter::ReadResult
loadUsingReaderWriter(const std::string& fileName,
- const osgDB::ReaderWriter::Options* opt)
+ const osgDB::Options* opt)
{
using namespace osgDB;
ReaderWriter* rw = Registry::instance()
struct DefaultProcessPolicy {
DefaultProcessPolicy(const std::string& extension) {}
osg::Node* process(osg::Node* node, const std::string& filename,
- const osgDB::ReaderWriter::Options* opt);
+ const osgDB::Options* opt);
};
struct DefaultCachePolicy {
DefaultCachePolicy(const std::string& extension) {}
osg::Node* find(const std::string& fileName,
- const osgDB::ReaderWriter::Options* opt);
+ const osgDB::Options* opt);
void addToCache(const std::string& filename, osg::Node* node);
};
struct NoCachePolicy {
NoCachePolicy(const std::string& extension) {}
osg::Node* find(const std::string& fileName,
- const osgDB::ReaderWriter::Options* opt)
+ const osgDB::Options* opt)
{
return 0;
}
public:
OptimizeModelPolicy(const std::string& extension);
osg::Node* optimize(osg::Node* node, const std::string& fileName,
- const osgDB::ReaderWriter::Options* opt);
+ const osgDB::Options* opt);
protected:
unsigned _osgOptions;
};
struct NoOptimizePolicy {
NoOptimizePolicy(const std::string& extension) {}
osg::Node* optimize(osg::Node* node, const std::string& fileName,
- const osgDB::ReaderWriter::Options* opt)
+ const osgDB::Options* opt)
{
return node;
}
struct OSGSubstitutePolicy {
OSGSubstitutePolicy(const std::string& extension) {}
std::string substitute(const std::string& name,
- const osgDB::ReaderWriter::Options* opt);
+ const osgDB::Options* opt);
};
struct NoSubstitutePolicy {
NoSubstitutePolicy(const std::string& extension) {}
std::string substitute(const std::string& name,
- const osgDB::ReaderWriter::Options* opt)
+ const osgDB::Options* opt)
{
return std::string();
}
ModelRegistry();
virtual osgDB::ReaderWriter::ReadResult
readImage(const std::string& fileName,
- const osgDB::ReaderWriter::Options* opt);
+ const osgDB::Options* opt);
virtual osgDB::ReaderWriter::ReadResult
readNode(const std::string& fileName,
- const osgDB::ReaderWriter::Options* opt);
+ const osgDB::Options* opt);
void addImageCallbackForExtension(const std::string& extension,
osgDB::Registry::ReadFileCallback*
callback);
CallbackMap imageCallbackMap;
CallbackMap nodeCallbackMap;
osg::ref_ptr<DefaultCallback> _defaultCallback;
- // Protect against simultaneous calls from main thread (MP models)
- // and pager thread.
- OpenThreads::ReentrantMutex readerMutex;
};
// Callback that only loads the file without any caching or