mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-22 04:49:12 -06:00
Switch to std::list for adding & removing assets in deterministic order (#2543)
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <list>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -164,10 +164,10 @@ private:
|
||||
|
||||
/// This list contains all of the assets that are queued to be loading in the next
|
||||
/// update call
|
||||
std::unordered_set<std::string> _assetAddQueue;
|
||||
std::list<std::string> _assetAddQueue;
|
||||
|
||||
/// The list contains all of the assets that should be removed in the next update call
|
||||
std::unordered_set<std::string> _assetRemoveQueue;
|
||||
std::list<std::string> _assetRemoveQueue;
|
||||
|
||||
/// This list contains all assets that need to be initialized in the next update call
|
||||
std::vector<Asset*> _toBeInitialized;
|
||||
|
||||
@@ -300,24 +300,15 @@ void AssetManager::update() {
|
||||
void AssetManager::add(const std::string& path) {
|
||||
ghoul_precondition(!path.empty(), "Path must not be empty");
|
||||
// First check if the path is already in the remove queue. If so, remove it from there
|
||||
const auto it = _assetRemoveQueue.find(path);
|
||||
if (it != _assetRemoveQueue.end()) {
|
||||
_assetRemoveQueue.erase(it);
|
||||
}
|
||||
|
||||
_assetAddQueue.insert(path);
|
||||
_assetRemoveQueue.remove(path);
|
||||
_assetAddQueue.push_back(path);
|
||||
}
|
||||
|
||||
void AssetManager::remove(const std::string& path) {
|
||||
ghoul_precondition(!path.empty(), "Path must not be empty");
|
||||
|
||||
// First check if the path is already in the add queue. If so, remove it from there
|
||||
const auto it = _assetAddQueue.find(path);
|
||||
if (it != _assetAddQueue.end()) {
|
||||
_assetAddQueue.erase(it);
|
||||
}
|
||||
|
||||
_assetRemoveQueue.insert(path);
|
||||
_assetAddQueue.remove(path);
|
||||
_assetRemoveQueue.push_back(path);
|
||||
}
|
||||
|
||||
std::vector<const Asset*> AssetManager::allAssets() const {
|
||||
|
||||
Reference in New Issue
Block a user