From adf82193471758426ccfd881340c8ffcc2a15526 Mon Sep 17 00:00:00 2001 From: Joseph Walton-Rivers <joseph@walton-rivers.uk> Date: Sun, 23 Oct 2022 00:54:24 +0100 Subject: [PATCH] if a mesh is uploaded, don't reupload it --- fggl/gfx/ogl4/meshes.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fggl/gfx/ogl4/meshes.cpp b/fggl/gfx/ogl4/meshes.cpp index 0a3d6b1..6e59761 100644 --- a/fggl/gfx/ogl4/meshes.cpp +++ b/fggl/gfx/ogl4/meshes.cpp @@ -221,19 +221,20 @@ namespace fggl::gfx::ogl4 { return {}; } - debug::info("requested: {}", name ); - for ( auto& name : manager->known() ) { - debug::info("known type: {}", name); + auto* material = manager->get<Material>("ogl_"+name); + if ( material != nullptr ) { + return material; } - Material* material = new Material(); + material = new Material(); if ( !meshMaterial->diffuseTextures.empty() ) { material->m_diffuse = upload_texture(meshMaterial->getPrimaryDiffuse(), manager); } if ( !meshMaterial->normalTextures.empty() ) { material->m_normals = upload_texture(meshMaterial->getPrimaryNormals(), manager); } - return material; + + return manager->set("ogl_"+name, material); } MeshData upload_mesh(const mesh::Mesh3D& rawMesh, assets::AssetManager* manager) { -- GitLab