From d7388ee954d9ea7acea346aad4af57764e20dd04 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 23 Jan 2021 14:51:57 +0000 Subject: Allow physical objects to share meshes and textures --- game/physical.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'game/physical.cpp') 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 #include +Cache Physical::cachedMesh; +Cache 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(); } -- cgit v1.2.3