X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FEntity.hpp;h=a3811427332628250761bad32210bc64103ea9de;hb=2ea26d9ca5eaeae65daa0edbbaeada8c1f23670e;hp=ae14297bb0baf282a3ddef142285a262a95c11b6;hpb=d02daa5a4805dc3184884f3a7cd7620e5787adcb;p=blank.git diff --git a/src/world/Entity.hpp b/src/world/Entity.hpp index ae14297..a381142 100644 --- a/src/world/Entity.hpp +++ b/src/world/Entity.hpp @@ -2,7 +2,7 @@ #define BLANK_WORLD_ENTITY_HPP_ #include "Chunk.hpp" -#include "../model/CompositeModel.hpp" +#include "../model/CompositeInstance.hpp" #include "../model/geometry.hpp" #include @@ -20,8 +20,8 @@ class Entity { public: Entity() noexcept; - CompositeModel &GetModel() noexcept { return model; } - const CompositeModel &GetModel() const noexcept { return model; } + CompositeInstance &GetModel() noexcept { return model; } + const CompositeInstance &GetModel() const noexcept { return model; } const std::string &Name() const noexcept { return name; } void Name(const std::string &n) { name = n; } @@ -61,17 +61,21 @@ public: glm::mat4 Transform(const Chunk::Pos &chunk_offset) const noexcept; Ray Aim(const Chunk::Pos &chunk_offset) const noexcept; - void Remove() noexcept { remove = true; } - bool CanRemove() const noexcept { return remove; } + void Ref() noexcept { ++ref_count; } + void UnRef() noexcept { --ref_count; } + void Kill() noexcept { dead = true; } + bool Referenced() const noexcept { return ref_count > 0; } + bool Dead() const noexcept { return dead; } + bool CanRemove() const noexcept { return dead && ref_count <= 0; } void Update(int dt) noexcept; void Render(const glm::mat4 &M, DirectionalLighting &prog) noexcept { - model.Render(M, prog); + if (model) model.Render(M, prog); } private: - CompositeModel model; + CompositeInstance model; std::string name; @@ -82,8 +86,10 @@ private: glm::vec3 angular_velocity; + int ref_count; + bool world_collision; - bool remove; + bool dead; };