mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
Restore UnrefQueue to destruct animation asynchronously
This commit is contained in:
parent
1e7989c5e5
commit
0614b82452
12 changed files with 109 additions and 14 deletions
28
components/sceneutil/unrefqueue.cpp
Normal file
28
components/sceneutil/unrefqueue.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include "unrefqueue.hpp"
|
||||
|
||||
namespace SceneUtil
|
||||
{
|
||||
namespace
|
||||
{
|
||||
struct ClearVector final : SceneUtil::WorkItem
|
||||
{
|
||||
std::vector<osg::ref_ptr<osg::Referenced>> mObjects;
|
||||
|
||||
explicit ClearVector(std::vector<osg::ref_ptr<osg::Referenced>>&& objects)
|
||||
: mObjects(std::move(objects)) {}
|
||||
|
||||
void doWork() override { mObjects.clear(); }
|
||||
};
|
||||
}
|
||||
|
||||
void UnrefQueue::flush(SceneUtil::WorkQueue& workQueue)
|
||||
{
|
||||
if (mObjects.empty())
|
||||
return;
|
||||
|
||||
// Move only objects to keep allocated storage in mObjects
|
||||
workQueue.addWorkItem(new ClearVector(std::vector<osg::ref_ptr<osg::Referenced>>(
|
||||
std::move_iterator(mObjects.begin()), std::move_iterator(mObjects.end()))));
|
||||
mObjects.clear();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue