1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-06 06:15:32 +00:00

Use normalized path in SceneManager::checkLoaded

This commit is contained in:
elsid 2024-09-19 00:47:51 +02:00
parent 28faae69b0
commit 5f2582fe68
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625
3 changed files with 15 additions and 15 deletions

View file

@ -1126,19 +1126,19 @@ namespace MWWorld
void Scene::preload(const std::string& mesh, bool useAnim)
{
std::string meshPath = mesh;
if (useAnim)
meshPath = Misc::ResourceHelpers::correctActorModelPath(meshPath, mRendering.getResourceSystem()->getVFS());
const VFS::Path::Normalized meshPath = useAnim
? Misc::ResourceHelpers::correctActorModelPath(mesh, mRendering.getResourceSystem()->getVFS())
: mesh;
if (!mRendering.getResourceSystem()->getSceneManager()->checkLoaded(meshPath, mRendering.getReferenceTime()))
{
osg::ref_ptr<PreloadMeshItem> item(new PreloadMeshItem(
VFS::Path::toNormalized(meshPath), mRendering.getResourceSystem()->getSceneManager()));
mRendering.getWorkQueue()->addWorkItem(item);
const auto isDone = [](const osg::ref_ptr<SceneUtil::WorkItem>& v) { return v->isDone(); };
mWorkItems.erase(std::remove_if(mWorkItems.begin(), mWorkItems.end(), isDone), mWorkItems.end());
mWorkItems.emplace_back(std::move(item));
}
if (mRendering.getResourceSystem()->getSceneManager()->checkLoaded(meshPath, mRendering.getReferenceTime()))
return;
osg::ref_ptr<PreloadMeshItem> item(
new PreloadMeshItem(meshPath, mRendering.getResourceSystem()->getSceneManager()));
mRendering.getWorkQueue()->addWorkItem(item);
const auto isDone = [](const osg::ref_ptr<SceneUtil::WorkItem>& v) { return v->isDone(); };
mWorkItems.erase(std::remove_if(mWorkItems.begin(), mWorkItems.end(), isDone), mWorkItems.end());
mWorkItems.emplace_back(std::move(item));
}
void Scene::preloadCells(float dt)

View file

@ -597,9 +597,9 @@ namespace Resource
mShaderManager->setShaderPath(path);
}
bool SceneManager::checkLoaded(const std::string& name, double timeStamp)
bool SceneManager::checkLoaded(VFS::Path::NormalizedView name, double timeStamp)
{
return mCache->checkInObjectCache(VFS::Path::normalizeFilename(name), timeStamp);
return mCache->checkInObjectCache(name, timeStamp);
}
void SceneManager::setUpNormalsRTForStateSet(osg::StateSet* stateset, bool enabled)

View file

@ -152,7 +152,7 @@ namespace Resource
void setShaderPath(const std::filesystem::path& path);
/// Check if a given scene is loaded and if so, update its usage timestamp to prevent it from being unloaded
bool checkLoaded(const std::string& name, double referenceTime);
bool checkLoaded(VFS::Path::NormalizedView name, double referenceTime);
/// Get a read-only copy of this scene "template"
/// @note If the given filename does not exist or fails to load, an error marker mesh will be used instead.