From 9aae773e912df035aa2c13e889abd0dfd90aad6a Mon Sep 17 00:00:00 2001 From: Benau Date: Mon, 22 Jan 2018 01:09:58 +0800 Subject: [PATCH] Use absolute path when caching --- src/graphics/shader_files_manager.cpp | 3 ++- src/graphics/sp/sp_shader_manager.cpp | 15 +++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/graphics/shader_files_manager.cpp b/src/graphics/shader_files_manager.cpp index 2c5bc9792..ecf037ec3 100644 --- a/src/graphics/shader_files_manager.cpp +++ b/src/graphics/shader_files_manager.cpp @@ -264,7 +264,8 @@ ShaderFilesManager::SharedShader ShaderFilesManager::getShaderFile { const std::string full_path = (file.find('/') != std::string::npos || file.find('\\') != std::string::npos) ? - file : file_manager->getShader(file); + file : std::string(file_manager->getFileSystem()->getAbsolutePath + (file_manager->getShadersDir().c_str()).c_str()) + file; // found in cache auto it = m_shader_files_loaded.find(full_path); if (it != m_shader_files_loaded.end()) diff --git a/src/graphics/sp/sp_shader_manager.cpp b/src/graphics/sp/sp_shader_manager.cpp index 39fef09f5..81c3d0065 100644 --- a/src/graphics/sp/sp_shader_manager.cpp +++ b/src/graphics/sp/sp_shader_manager.cpp @@ -389,7 +389,13 @@ std::string SPShaderManager::getShaderFullPath(const std::string& name) { return cur_location; } - return file_manager->getAssetChecked(FileManager::SHADER, name); + cur_location = file_manager->getAssetChecked(FileManager::SHADER, name); + if (cur_location.empty()) + { + return ""; + } + return file_manager->getFileSystem()->getAbsolutePath(cur_location.c_str()) + .c_str(); } // getShaderFullPath // ---------------------------------------------------------------------------- @@ -533,7 +539,7 @@ void SPShaderManager::addPrefilledTexturesToShader(SPShader* s, void SPShaderManager::loadSPShaders(const std::string& directory_name) { std::set shaders; - file_manager->listFiles(shaders, directory_name, true/*make_full_path*/); + file_manager->listFiles(shaders, directory_name); for (auto it = shaders.begin(); it != shaders.end();) { if ((*it).find("sps") == std::string::npos || @@ -551,10 +557,11 @@ void SPShaderManager::loadSPShaders(const std::string& directory_name) return; } - m_shader_directory = directory_name; + m_shader_directory = file_manager->getFileSystem()->getAbsolutePath + (directory_name.c_str()).c_str(); for (const std::string& file_name : shaders) { - loadEachShader(file_name); + loadEachShader(m_shader_directory + file_name); } m_shader_directory = ""; } // loadSPShaders