]> git.lizzy.rs Git - minetest.git/commitdiff
refacto: add RenderingEngine::cleanupMeshCache
authorLoic Blot <loic.blot@unix-experience.fr>
Wed, 28 Apr 2021 08:53:36 +0000 (10:53 +0200)
committerLoïc Blot <nerzhul@users.noreply.github.com>
Mon, 3 May 2021 17:49:19 +0000 (19:49 +0200)
This permits to prevent client to own the mesh cache cleanup logic. It's better in RenderingEngine

src/client/client.cpp
src/client/renderingengine.cpp
src/client/renderingengine.h

index d7e69f3493ae8b9a6ab75b136051219021e82fcb..48097be2e10fac5361f5ac66cd6d667a085ee7fa 100644 (file)
@@ -300,12 +300,7 @@ Client::~Client()
        }
 
        // cleanup 3d model meshes on client shutdown
-       while (RenderingEngine::get_mesh_cache()->getMeshCount() != 0) {
-               scene::IAnimatedMesh *mesh = RenderingEngine::get_mesh_cache()->getMeshByIndex(0);
-
-               if (mesh)
-                       RenderingEngine::get_mesh_cache()->removeMesh(mesh);
-       }
+       m_rendering_engine->cleanupMeshCache();
 
        delete m_minimap;
        m_minimap = nullptr;
index d2d136a61f5e688f4c9b1eabdc42dc0882fae7a1..970bcf95b4dcbd2b63fd8cece033853a7d7ab187 100644 (file)
@@ -225,6 +225,15 @@ bool RenderingEngine::print_video_modes()
        return videomode_list != NULL;
 }
 
+void RenderingEngine::cleanupMeshCache()
+{
+       auto mesh_cache = m_device->getSceneManager()->getMeshCache();
+       while (mesh_cache->getMeshCount() != 0) {
+               if (scene::IAnimatedMesh *mesh = mesh_cache->getMeshByIndex(0))
+                       m_rendering_engine->get_mesh_cache()->removeMesh(mesh);
+       }
+}
+
 bool RenderingEngine::setupTopLevelWindow(const std::string &name)
 {
        // FIXME: It would make more sense for there to be a switch of some
index 5807421ef7c8eaeb2c9a66a97bf05ebd233703c0..fae431f1fca070b89734e894c74b40a414b060d0 100644 (file)
@@ -56,6 +56,7 @@ class RenderingEngine
        bool setWindowIcon();
        bool setXorgWindowIconFromPath(const std::string &icon_file);
        static bool print_video_modes();
+       void cleanupMeshCache();
 
        static RenderingEngine *get_instance() { return s_singleton; }