mirror of
https://github.com/zoriya/Bomberman.git
synced 2025-12-20 21:35:12 +00:00
model now use shared ptr + cache system to spare memmory
This commit is contained in:
@@ -14,7 +14,8 @@
|
||||
#include <raylib.h>
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
|
||||
namespace RAY::Drawables::Drawables3D {
|
||||
//! @brief Basic 3D Model type
|
||||
@@ -42,8 +43,8 @@ namespace RAY::Drawables::Drawables3D {
|
||||
//! @brief A model is assignable
|
||||
Model& operator=(const Model &model) = default;
|
||||
|
||||
//! @brief Model destructor, unloads all related data
|
||||
~Model();
|
||||
//! @brief Model destructor, model's data will be deleted if it's the last entity alive
|
||||
~Model() = default;
|
||||
|
||||
//! @brief Unload model (excluding meshes) from memory (RAM and/or VRAM)
|
||||
bool unloadKeepMeshes();
|
||||
@@ -81,15 +82,19 @@ namespace RAY::Drawables::Drawables3D {
|
||||
|
||||
private:
|
||||
//! @brief Raw data from raylib
|
||||
::Model _model;
|
||||
std::shared_ptr<::Model> _model;
|
||||
//! @brief The list of textures that can be applied to this model.
|
||||
std::map<MaterialType, Texture> _textureList;
|
||||
std::unordered_map<MaterialType, Texture> _textureList;
|
||||
//! @brief Rotation property
|
||||
RAY::Vector3 _rotationAxis;
|
||||
//! @brief Rotation property
|
||||
float _rotationAngle;
|
||||
//! @brief Scale of the shape
|
||||
RAY::Vector3 _scale;
|
||||
//! @brief, look through cache to see if a model using same file
|
||||
std::shared_ptr<::Model>fetchModelInCache(const std::string &path);
|
||||
|
||||
static std::unordered_map<std::string, std::shared_ptr<::Model>> _modelsCache;
|
||||
|
||||
INTERNAL:
|
||||
//! @brief A RAY Model is cast-able in libray's model
|
||||
|
||||
Reference in New Issue
Block a user