diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-01-23 14:51:57 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-01-23 14:51:57 +0000 |
commit | d7388ee954d9ea7acea346aad4af57764e20dd04 (patch) | |
tree | 64bad9cdd4572bd2434c2c23c05c759e27d414c0 /game/physical.cpp | |
parent | Add a basic cache template (diff) | |
download | ilt-d7388ee954d9ea7acea346aad4af57764e20dd04.tar.bz2 ilt-d7388ee954d9ea7acea346aad4af57764e20dd04.tar.xz ilt-d7388ee954d9ea7acea346aad4af57764e20dd04.zip |
Allow physical objects to share meshes and textures
Diffstat (limited to 'game/physical.cpp')
-rw-r--r-- | game/physical.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/game/physical.cpp b/game/physical.cpp index f4c17d4..5263268 100644 --- a/game/physical.cpp +++ b/game/physical.cpp @@ -1,8 +1,14 @@ #include "physical.h" +#include "gfx/models/mesh.h" +#include "gfx/models/texture.h" +#include <cache.h> #include <gfx/gl/shader.h> +Cache<Mesh> Physical::cachedMesh; +Cache<Texture> Physical::cachedTexture; + Physical::Physical(glm::vec3 where, const std::string & m, const std::string & t) : - location {where}, mesh {m}, texture {t} + location {where}, mesh {cachedMesh.get(m)}, texture {cachedTexture.get(t)} { } @@ -10,6 +16,6 @@ void Physical::render(const Shader & shader, const Camera & camera) const { shader.Update(location, camera); - texture.Bind(); - mesh.Draw(); + texture->Bind(); + mesh->Draw(); } |