From 1223e4c8ca0c146461a2341f9220214ba15c9f0a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 14 Feb 2005 15:17:20 +0000 Subject: [PATCH] From Alberto Farre, fix to nested OpenFlight file problem. --- src/osgPlugins/flt/FltFile.cpp | 50 ++++++++++++++-------------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/src/osgPlugins/flt/FltFile.cpp b/src/osgPlugins/flt/FltFile.cpp index 74471e86c..1ba5c0f37 100644 --- a/src/osgPlugins/flt/FltFile.cpp +++ b/src/osgPlugins/flt/FltFile.cpp @@ -240,44 +240,36 @@ bool FltFile::readFile(const std::string& fileName) #endif pExternalFltFile = registerFLT ? Registry::instance()->getFltFile(filename) : NULL; - if (pExternalFltFile == NULL) { - osg::ref_ptr options = new osgDB::ReaderWriter::Options; + osg::ref_ptr options = + _pFltFile->getOptions() ? _pFltFile->getOptions() : + new osgDB::ReaderWriter::Options; - if (_pFltFile->getOptions()) + //Path for Nested external references + osgDB::FilePathList& fpl = options->getDatabasePathList(); + std::string filePath = osgDB::getFilePath(filename); + std::string pushAndPopPath; + //If absolute path + if( (filePath.length()>0 && filePath.find_first_of("/\\")==0) || + (filePath.length()>2 && filePath.substr(1,1)==":" && filePath.find_first_of("/\\")==2) ) { - options = _pFltFile->getOptions(); + pushAndPopPath = filePath; } else { - options = new osgDB::ReaderWriter::Options; - - //Path for Nested external references - std::string filePath = osgDB::getFilePath(filename); - std::string pushAndPopPath; - //If absolute path - if( (filePath.length()>0 && filePath.find_first_of("/\\")==0) || - (filePath.length()>2 && filePath.substr(1,1)==":" && filePath.find_first_of("/\\")==2) ) - { - pushAndPopPath = filePath; - } - else - { - osgDB::FilePathList fpl = osgDB::getDataFilePathList(); - pushAndPopPath = fpl.empty() ? "." : fpl.front(); - pushAndPopPath += "/" + filePath; - } - - char optionsString[256]; - sprintf(optionsString,"FLT_VER %d",rec.getFlightVersion()); - options->setOptionString(optionsString); - - osg::notify(osg::NOTICE)<<"Create local path"<getDatabasePathList().push_back(pushAndPopPath); + pushAndPopPath = (fpl.empty() ? "." : fpl.back()) + "/" + filePath; } + char optionsString[256]; + sprintf(optionsString,"FLT_VER %d",rec.getFlightVersion()); + options->setOptionString(optionsString); + + //osg::notify(osg::NOTICE)<<"Create local path"<