From Alberto Farre, fix to nested OpenFlight file problem.

This commit is contained in:
Robert Osfield 2005-02-14 15:17:20 +00:00
parent 1b805f7bdb
commit 1223e4c8ca

View File

@ -240,20 +240,14 @@ bool FltFile::readFile(const std::string& fileName)
#endif
pExternalFltFile = registerFLT ? Registry::instance()->getFltFile(filename) : NULL;
if (pExternalFltFile == NULL)
{
osg::ref_ptr<osgDB::ReaderWriter::Options> options = new osgDB::ReaderWriter::Options;
if (_pFltFile->getOptions())
{
options = _pFltFile->getOptions();
}
else
{
options = new osgDB::ReaderWriter::Options;
osg::ref_ptr<osgDB::ReaderWriter::Options> options =
_pFltFile->getOptions() ? _pFltFile->getOptions() :
new osgDB::ReaderWriter::Options;
//Path for Nested external references
osgDB::FilePathList& fpl = options->getDatabasePathList();
std::string filePath = osgDB::getFilePath(filename);
std::string pushAndPopPath;
//If absolute path
@ -264,19 +258,17 @@ bool FltFile::readFile(const std::string& fileName)
}
else
{
osgDB::FilePathList fpl = osgDB::getDataFilePathList();
pushAndPopPath = fpl.empty() ? "." : fpl.front();
pushAndPopPath += "/" + filePath;
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"<<pushAndPopPath<<std::endl;
//osg::notify(osg::NOTICE)<<"Create local path"<<pushAndPopPath<<std::endl;
fpl.push_back(pushAndPopPath);
options->getDatabasePathList().push_back(pushAndPopPath);
}
pExternalFltFile = new FltFile( pColorPool, pTexturePool, pMaterialPool,
pLtPtAppearancePool, pLtPtAnimationPool, options.get() );