Added checks against Options to osga plugin to ensure archives are only cached
when requested, cleaned up the Registry::openArchiveImplementation function.
This commit is contained in:
@@ -1537,25 +1537,19 @@ ReaderWriter::ReadResult Registry::readImplementation(const ReadFunctor& readFun
|
||||
|
||||
ReaderWriter::ReadResult Registry::openArchiveImplementation(const std::string& fileName, ReaderWriter::ArchiveStatus status, unsigned int indexBlockSizeHint, const ReaderWriter::Options* options)
|
||||
{
|
||||
osgDB::Archive* archive = getFromArchiveCache(fileName);
|
||||
if (archive) return archive;
|
||||
|
||||
ReaderWriter::ReadResult result = readImplementation(ReadArchiveFunctor(fileName, status, indexBlockSizeHint, options),false);
|
||||
|
||||
// default to using chaching archive if no options structure provided, but if options are provided use archives
|
||||
// only if supplied.
|
||||
if (!options || (options && (options->getObjectCacheHint() & ReaderWriter::Options::CACHE_ARCHIVES)))
|
||||
if (result.validArchive() &&
|
||||
(!options || (options->getObjectCacheHint() & ReaderWriter::Options::CACHE_ARCHIVES)) )
|
||||
{
|
||||
osgDB::Archive* archive = getFromArchiveCache(fileName);
|
||||
if (archive) return archive;
|
||||
|
||||
ReaderWriter::ReadResult result = readImplementation(ReadArchiveFunctor(fileName, status, indexBlockSizeHint, options),false);
|
||||
if (result.validArchive())
|
||||
{
|
||||
addToArchiveCache(fileName,result.getArchive());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return readImplementation(ReadArchiveFunctor(fileName, status, indexBlockSizeHint, _options.get()),false);
|
||||
addToArchiveCache(fileName,result.getArchive());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
return archive.get();
|
||||
}
|
||||
|
||||
virtual ReadResult readImage(const std::string& file,const Options*) const
|
||||
virtual ReadResult readImage(const std::string& file,const Options* options) const
|
||||
{
|
||||
ReadResult result = openArchive(file,osgDB::Archive::READ);
|
||||
|
||||
@@ -64,14 +64,16 @@ public:
|
||||
ReadResult result_2 = result.getArchive()->readImage(result.getArchive()->getMasterFileName(),local_options.get());
|
||||
|
||||
|
||||
// register the archive so that it is cached for future use.
|
||||
osgDB::Registry::instance()->addToArchiveCache(file, result.getArchive());
|
||||
|
||||
if (!options || (options->getObjectCacheHint() & osgDB::ReaderWriter::Options::CACHE_ARCHIVES))
|
||||
{
|
||||
// register the archive so that it is cached for future use.
|
||||
osgDB::Registry::instance()->addToArchiveCache(file, result.getArchive());
|
||||
}
|
||||
|
||||
return result_2;
|
||||
}
|
||||
|
||||
virtual ReadResult readNode(const std::string& file,const Options*) const
|
||||
virtual ReadResult readNode(const std::string& file,const Options* options) const
|
||||
{
|
||||
ReadResult result = openArchive(file,osgDB::Archive::READ);
|
||||
|
||||
@@ -84,9 +86,11 @@ public:
|
||||
ReadResult result_2 = result.getArchive()->readNode(result.getArchive()->getMasterFileName(),local_options.get());
|
||||
|
||||
|
||||
// register the archive so that it is cached for future use.
|
||||
osgDB::Registry::instance()->addToArchiveCache(file, result.getArchive());
|
||||
|
||||
if (!options || (options->getObjectCacheHint() & osgDB::ReaderWriter::Options::CACHE_ARCHIVES))
|
||||
{
|
||||
// register the archive so that it is cached for future use.
|
||||
osgDB::Registry::instance()->addToArchiveCache(file, result.getArchive());
|
||||
}
|
||||
|
||||
return result_2;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user