mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-05-08 03:28:15 +03:00
Preload magic effect visuals of the player's selected weapon/spell
This commit is contained in:
parent
e46fb1770c
commit
57b585570a
13 changed files with 158 additions and 2 deletions
|
@ -49,6 +49,18 @@ osg::ref_ptr<osg::Object> ObjectCache::getRefFromObjectCache(const std::string&
|
|||
else return 0;
|
||||
}
|
||||
|
||||
bool ObjectCache::checkInObjectCache(const std::string &fileName, double timeStamp)
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_objectCacheMutex);
|
||||
ObjectCacheMap::iterator itr = _objectCache.find(fileName);
|
||||
if (itr!=_objectCache.end())
|
||||
{
|
||||
itr->second.second = timeStamp;
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
void ObjectCache::updateTimeStampOfObjectsInCacheWithExternalReferences(double referenceTime)
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_objectCacheMutex);
|
||||
|
|
|
@ -64,6 +64,9 @@ class ObjectCache : public osg::Referenced
|
|||
/** Get an ref_ptr<Object> from the object cache*/
|
||||
osg::ref_ptr<osg::Object> getRefFromObjectCache(const std::string& fileName);
|
||||
|
||||
/** Check if an object is in the cache, and if it is, update its usage time stamp. */
|
||||
bool checkInObjectCache(const std::string& fileName, double timeStamp);
|
||||
|
||||
/** call releaseGLObjects on all objects attached to the object cache.*/
|
||||
void releaseGLObjects(osg::State* state);
|
||||
|
||||
|
|
|
@ -272,6 +272,14 @@ namespace Resource
|
|||
mShaderManager->setShaderPath(path);
|
||||
}
|
||||
|
||||
bool SceneManager::checkLoaded(const std::string &name, double timeStamp)
|
||||
{
|
||||
std::string normalized = name;
|
||||
mVFS->normalizeFilename(normalized);
|
||||
|
||||
return mCache->checkInObjectCache(normalized, timeStamp);
|
||||
}
|
||||
|
||||
/// @brief Callback to read image files from the VFS.
|
||||
class ImageReadCallback : public osgDB::ReadFileCallback
|
||||
{
|
||||
|
|
|
@ -77,6 +77,9 @@ namespace Resource
|
|||
|
||||
void setShaderPath(const std::string& 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);
|
||||
|
||||
/// 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.
|
||||
/// If even the error marker mesh can not be found, an exception is thrown.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue