#pragma once #include #include #include #include #include class ModelManager { public: struct Voxel { glm::vec3 loc, color; int mass; }; class StaticModel { std::string name_; std::vector voxels_; glm::vec3 mass_center_; public: Delegate OnDestroy; StaticModel(const std::vector& voxels, std::string name); ~StaticModel(); const std::vector& GetVoxels() const { return voxels_; } glm::vec3 GetMassCenter() const { return mass_center_; } const std::string& GetName() const { return name_; } }; struct owner_counter { std::atomic_ullong counter; StaticModel* model; owner_counter() = default; owner_counter(const owner_counter& other); }; private: std::unordered_map models; static unsigned int FNV1aHash (const char *buf); void OnDestroySometimeModelCaller(const std::string& name); public: Delegate OnDestroySometimeModel; Delegate OnLoadSometimeModel; ~ModelManager(); StaticModel* LoadModel(const std::string& name); void FreeModel(const std::string& name); };