Skip to content

Commit

Permalink
refacto: add RenderingEngine::cleanupMeshCache
Browse files Browse the repository at this point in the history
This permits to prevent client to own the mesh cache cleanup logic. It's better in RenderingEngine
  • Loading branch information
nerzhul committed May 3, 2021
1 parent e34d28a commit e071638
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 1 addition & 6 deletions src/client/client.cpp
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions src/client/renderingengine.cpp
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/client/renderingengine.h
Expand Up @@ -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; }

Expand Down

0 comments on commit e071638

Please sign in to comment.