mirror of
https://github.com/minetest/minetest.git
synced 2024-11-10 01:33:46 +01:00
refacto: hide mesh_cache inside the rendering engine
This permit cleaner access to meshCache and ensure we don't access to it from all the code
This commit is contained in:
parent
e0716384d6
commit
74125a74d3
@ -1983,7 +1983,7 @@ scene::IAnimatedMesh* Client::getMesh(const std::string &filename, bool cache)
|
||||
return nullptr;
|
||||
mesh->grab();
|
||||
if (!cache)
|
||||
m_rendering_engine->get_mesh_cache()->removeMesh(mesh);
|
||||
m_rendering_engine->removeMesh(mesh);
|
||||
return mesh;
|
||||
}
|
||||
|
||||
|
@ -652,8 +652,6 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
void extendedResourceCleanup();
|
||||
|
||||
// Basic initialisation
|
||||
bool init(const std::string &map_dir, const std::string &address,
|
||||
u16 port, const SubgameSpec &gamespec);
|
||||
@ -968,7 +966,7 @@ Game::~Game()
|
||||
delete itemdef_manager;
|
||||
delete draw_control;
|
||||
|
||||
extendedResourceCleanup();
|
||||
clearTextureNameCache();
|
||||
|
||||
g_settings->deregisterChangedCallback("doubletap_jump",
|
||||
&settingChangedCallback, this);
|
||||
@ -4063,27 +4061,6 @@ void Game::readSettings()
|
||||
****************************************************************************/
|
||||
/****************************************************************************/
|
||||
|
||||
void Game::extendedResourceCleanup()
|
||||
{
|
||||
// Extended resource accounting
|
||||
infostream << "Irrlicht resources after cleanup:" << std::endl;
|
||||
infostream << "\tRemaining meshes : "
|
||||
<< RenderingEngine::get_mesh_cache()->getMeshCount() << std::endl;
|
||||
infostream << "\tRemaining textures : "
|
||||
<< driver->getTextureCount() << std::endl;
|
||||
|
||||
for (unsigned int i = 0; i < driver->getTextureCount(); i++) {
|
||||
irr::video::ITexture *texture = driver->getTextureByIndex(i);
|
||||
infostream << "\t\t" << i << ":" << texture->getName().getPath().c_str()
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
clearTextureNameCache();
|
||||
infostream << "\tRemaining materials: "
|
||||
<< driver-> getMaterialRendererCount()
|
||||
<< " (note: irrlicht doesn't support removing renderers)" << std::endl;
|
||||
}
|
||||
|
||||
void Game::showDeathFormspec()
|
||||
{
|
||||
static std::string formspec_str =
|
||||
|
@ -225,12 +225,17 @@ bool RenderingEngine::print_video_modes()
|
||||
return videomode_list != NULL;
|
||||
}
|
||||
|
||||
void RenderingEngine::removeMesh(const irr::scene::IMesh* mesh)
|
||||
{
|
||||
m_device->getSceneManager()->getMeshCache()->removeMesh(mesh);
|
||||
}
|
||||
|
||||
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);
|
||||
mesh_cache->removeMesh(mesh);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "irrlichttypes_extrabloated.h"
|
||||
#include "debug.h"
|
||||
|
||||
namespace irr { namespace scene {
|
||||
class IMesh;
|
||||
}}
|
||||
class ITextureSource;
|
||||
class Camera;
|
||||
class Client;
|
||||
@ -58,6 +61,8 @@ public:
|
||||
static bool print_video_modes();
|
||||
void cleanupMeshCache();
|
||||
|
||||
void removeMesh(const irr::scene::IMesh* mesh);
|
||||
|
||||
static RenderingEngine *get_instance() { return s_singleton; }
|
||||
|
||||
io::IFileSystem *get_filesystem()
|
||||
@ -71,12 +76,6 @@ public:
|
||||
return s_singleton->m_device->getVideoDriver();
|
||||
}
|
||||
|
||||
static scene::IMeshCache *get_mesh_cache()
|
||||
{
|
||||
sanity_check(s_singleton && s_singleton->m_device);
|
||||
return s_singleton->m_device->getSceneManager()->getMeshCache();
|
||||
}
|
||||
|
||||
static scene::ISceneManager *get_scene_manager()
|
||||
{
|
||||
sanity_check(s_singleton && s_singleton->m_device);
|
||||
|
Loading…
Reference in New Issue
Block a user