Удалил старый ModelManager. Доработал режим сборки "Engine" теперь копирование инициируется не bat файлом а проектом. Теперь UwURenderEngine копирует свои заголовки

This commit is contained in:
Jiga228
2026-05-22 14:47:44 +07:00
parent 5b6974aa8b
commit 9db3d9b0e2
7 changed files with 60 additions and 113 deletions
-64
View File
@@ -1,64 +0,0 @@
#include "ModelManager.hpp"
#include "Log/Log.hpp"
ModelManager::owner_counter::owner_counter(const owner_counter& other) : counter(other.counter.load()), model(other.model)
{
}
unsigned int ModelManager::FNV1aHash(const char* buf)
{
unsigned int h_val = 0x811c9dc5;
while (*buf)
{
h_val ^= static_cast<unsigned int>(*buf++);
h_val *= 0x01000193;
}
return h_val;
}
ModelManager::~ModelManager()
{
models.clear();
}
ModelManager::StaticModel* ModelManager::LoadModel(const std::string& name)
{
if (name.empty())
return nullptr;
unsigned int hash = FNV1aHash(name.c_str());
auto counter = models.find(hash);
if (counter != models.cend())
{
++counter->second.counter;
return counter->second.model;
}
Loging::Log("Load new model: " + name);
// Load model_data
owner_counter new_counter;
new_counter.counter.store(1);
new_counter.model = new StaticModel();
models.try_emplace(hash, new_counter);
return new_counter.model;
}
void ModelManager::FreeModel(const std::string& name)
{
if (name.empty())
return;
unsigned int hash = FNV1aHash(name.c_str());
auto counter = models.find(hash);
--counter->second.counter;
StaticModel* model = counter->second.model;
if (counter->second.counter.load() == 0)
{
models.erase(hash);
delete model;
}
}
-35
View File
@@ -1,35 +0,0 @@
#pragma once
#include <unordered_map>
#include <string>
#include <atomic>
class ModelManager
{
public:
class StaticModel
{
//DATA
};
struct owner_counter
{
std::atomic_ullong counter;
StaticModel* model;
owner_counter() = default;
owner_counter(const owner_counter& other);
};
private:
std::unordered_map<unsigned int, owner_counter> models;
static unsigned int FNV1aHash (const char *buf);
public:
~ModelManager();
StaticModel* LoadModel(const std::string& name);
void FreeModel(const std::string& name);
};