#include <simgear/props/condition.hxx>
#include "BoundingVolumeBuildVisitor.hxx"
+#include "model.hxx"
+#include "SGReaderWriterXMLOptions.hxx"
using namespace std;
using namespace osg;
using namespace osgDB;
using namespace simgear;
-using OpenThreads::ReentrantMutex;
-using OpenThreads::ScopedLock;
-
// Little helper class that holds an extra reference to a
// loaded 3d model.
// Since we clone all structural nodes from our 3d models,
ModelRegistry::readImage(const string& fileName,
const ReaderWriter::Options* opt)
{
- ScopedLock<ReentrantMutex> lock(readerMutex);
CallbackMap::iterator iter
= imageCallbackMap.find(getFileExtension(fileName));
{
if (iter != imageCallbackMap.end() && iter->second.valid())
return iter->second->readImage(fileName, opt);
- string absFileName = findDataFile(fileName, opt);
+ string absFileName = SGModelLib::findDataFile(fileName, opt);
if (!fileExists(absFileName)) {
SG_LOG(SG_IO, SG_ALERT, "Cannot find image file \""
<< fileName << "\"");
{
string fileSansExtension = getNameLessExtension(name);
string osgFileName = fileSansExtension + ".osg";
- string absFileName = findDataFile(osgFileName, opt);
+ string absFileName = SGModelLib::findDataFile(osgFileName, opt);
return absFileName;
}
ModelRegistry::readNode(const string& fileName,
const ReaderWriter::Options* opt)
{
- ScopedLock<ReentrantMutex> lock(readerMutex);
-
ReaderWriter::ReadResult res;
CallbackMap::iterator iter
= nodeCallbackMap.find(getFileExtension(fileName));
static SGReadCallbackInstaller readCallbackInstaller;
-// we get optimal geometry from the loader.
+// we get optimal geometry from the loader (Hah!).
struct ACOptimizePolicy : public OptimizeModelPolicy {
ACOptimizePolicy(const string& extension) :
OptimizeModelPolicy(extension)
&& group->getNumChildren() == 1)
optimized = static_cast<Node*>(group->getChild(0));
}
+ const SGReaderWriterXMLOptions* sgopt
+ = dynamic_cast<const SGReaderWriterXMLOptions*>(opt);
+ if (sgopt && sgopt->getInstantiateEffects())
+ optimized = instantiateEffects(optimized.get(), sgopt);
return optimized.release();
}
};