aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2021-04-28 10:53:36 +0200
committerLoïc Blot <nerzhul@users.noreply.github.com>2021-05-03 19:49:19 +0200
commite0716384d6c7abfa228b039056f1e872ca7bb8cf (patch)
tree78a6393bdbd7f5ea7e6b67d3b62c10595235949d /src/client
parente34d28af9f4b779b7a137f0e4017e499266e1931 (diff)
downloadminetest-e0716384d6c7abfa228b039056f1e872ca7bb8cf.tar.gz
minetest-e0716384d6c7abfa228b039056f1e872ca7bb8cf.tar.bz2
minetest-e0716384d6c7abfa228b039056f1e872ca7bb8cf.zip
refacto: add RenderingEngine::cleanupMeshCache
This permits to prevent client to own the mesh cache cleanup logic. It's better in RenderingEngine
Diffstat (limited to 'src/client')
-rw-r--r--src/client/client.cpp7
-rw-r--r--src/client/renderingengine.cpp9
-rw-r--r--src/client/renderingengine.h1
3 files changed, 11 insertions, 6 deletions
diff --git a/src/client/client.cpp b/src/client/client.cpp
index d7e69f349..48097be2e 100644
--- a/src/client/client.cpp
+++ b/src/client/client.cpp
@@ -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;
diff --git a/src/client/renderingengine.cpp b/src/client/renderingengine.cpp
index d2d136a61..970bcf95b 100644
--- a/src/client/renderingengine.cpp
+++ b/src/client/renderingengine.cpp
@@ -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
diff --git a/src/client/renderingengine.h b/src/client/renderingengine.h
index 5807421ef..fae431f1f 100644
--- a/src/client/renderingengine.h
+++ b/src/client/renderingengine.h
@@ -56,6 +56,7 @@ public:
bool setWindowIcon();
bool setXorgWindowIconFromPath(const std::string &icon_file);
static bool print_video_modes();
+ void cleanupMeshCache();
static RenderingEngine *get_instance() { return s_singleton; }