mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 19:45:40 +00:00
Use ranged for loops in GenericObjectCache
This commit is contained in:
parent
2f0613c8d4
commit
7b1ee2780b
1 changed files with 7 additions and 15 deletions
|
@ -139,35 +139,27 @@ namespace Resource
|
|||
void releaseGLObjects(osg::State* state)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_objectCacheMutex);
|
||||
for (typename ObjectCacheMap::iterator itr = _objectCache.begin(); itr != _objectCache.end(); ++itr)
|
||||
{
|
||||
osg::Object* object = itr->second.mValue.get();
|
||||
object->releaseGLObjects(state);
|
||||
}
|
||||
for (const auto& [k, v] : _objectCache)
|
||||
v.mValue->releaseGLObjects(state);
|
||||
}
|
||||
|
||||
/** call node->accept(nv); for all nodes in the objectCache. */
|
||||
void accept(osg::NodeVisitor& nv)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_objectCacheMutex);
|
||||
for (typename ObjectCacheMap::iterator itr = _objectCache.begin(); itr != _objectCache.end(); ++itr)
|
||||
{
|
||||
if (osg::Object* object = itr->second.mValue.get())
|
||||
{
|
||||
osg::Node* node = dynamic_cast<osg::Node*>(object);
|
||||
if (node)
|
||||
for (const auto& [k, v] : _objectCache)
|
||||
if (osg::Object* const object = v.mValue.get())
|
||||
if (osg::Node* const node = dynamic_cast<osg::Node*>(object))
|
||||
node->accept(nv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** call operator()(KeyType, osg::Object*) for each object in the cache. */
|
||||
template <class Functor>
|
||||
void call(Functor&& f)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_objectCacheMutex);
|
||||
for (typename ObjectCacheMap::iterator it = _objectCache.begin(); it != _objectCache.end(); ++it)
|
||||
f(it->first, it->second.mValue.get());
|
||||
for (const auto& [k, v] : _objectCache)
|
||||
f(k, v.mValue.get());
|
||||
}
|
||||
|
||||
/** Get the number of objects in the cache. */
|
||||
|
|
Loading…
Reference in a new issue