From 813b8ee0d18e66bb5e029ff5aa687bdab1c6cf95 Mon Sep 17 00:00:00 2001 From: CedricMocquillon Date: Wed, 5 May 2021 23:19:08 +0200 Subject: [PATCH 1/2] Search only in the niffilemanager for nif files --- components/resource/scenemanager.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index a3c751f7a..64128ae30 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -378,7 +378,7 @@ namespace Resource Resource::ImageManager* mImageManager; }; - osg::ref_ptr load (Files::IStreamPtr file, const std::string& normalizedFilename, Resource::ImageManager* imageManager, Resource::NifFileManager* nifFileManager) + osg::ref_ptr load (const std::string& normalizedFilename, const VFS::Manager* vfs, Resource::ImageManager* imageManager, Resource::NifFileManager* nifFileManager) { std::string ext = Resource::getFileExtension(normalizedFilename); if (ext == "nif") @@ -400,7 +400,7 @@ namespace Resource options->setReadFileCallback(new ImageReadCallback(imageManager)); if (ext == "dae") options->setOptionString("daeUseSequencedTextureUnits"); - osgDB::ReaderWriter::ReadResult result = reader->readNode(*file, options); + osgDB::ReaderWriter::ReadResult result = reader->readNode(*vfs->get(normalizedFilename), options); if (!result.success()) { std::stringstream errormsg; @@ -527,9 +527,7 @@ namespace Resource osg::ref_ptr loaded; try { - Files::IStreamPtr file = mVFS->get(normalized); - - loaded = load(file, normalized, mImageManager, mNifFileManager); + loaded = load(normalized, mVFS, mImageManager, mNifFileManager); } catch (std::exception& e) { @@ -542,7 +540,7 @@ namespace Resource { Log(Debug::Error) << "Failed to load '" << name << "': " << e.what() << ", using marker_error." << sMeshTypes[i] << " instead"; Files::IStreamPtr file = mVFS->get(normalized); - loaded = load(file, normalized, mImageManager, mNifFileManager); + loaded = load(normalized, mVFS, mImageManager, mNifFileManager); break; } } From a88513486844fddf14f116e0c95668de2e39f9b3 Mon Sep 17 00:00:00 2001 From: CedricMocquillon Date: Thu, 6 May 2021 13:28:06 +0200 Subject: [PATCH 2/2] Do not search if it is not used --- components/resource/scenemanager.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index 64128ae30..8ca6c8214 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -539,7 +539,6 @@ namespace Resource if (mVFS->exists(normalized)) { Log(Debug::Error) << "Failed to load '" << name << "': " << e.what() << ", using marker_error." << sMeshTypes[i] << " instead"; - Files::IStreamPtr file = mVFS->get(normalized); loaded = load(normalized, mVFS, mImageManager, mNifFileManager); break; }