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;
|
return nullptr;
|
||||||
mesh->grab();
|
mesh->grab();
|
||||||
if (!cache)
|
if (!cache)
|
||||||
m_rendering_engine->get_mesh_cache()->removeMesh(mesh);
|
m_rendering_engine->removeMesh(mesh);
|
||||||
return mesh;
|
return mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -652,8 +652,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void extendedResourceCleanup();
|
|
||||||
|
|
||||||
// Basic initialisation
|
// Basic initialisation
|
||||||
bool init(const std::string &map_dir, const std::string &address,
|
bool init(const std::string &map_dir, const std::string &address,
|
||||||
u16 port, const SubgameSpec &gamespec);
|
u16 port, const SubgameSpec &gamespec);
|
||||||
@ -968,7 +966,7 @@ Game::~Game()
|
|||||||
delete itemdef_manager;
|
delete itemdef_manager;
|
||||||
delete draw_control;
|
delete draw_control;
|
||||||
|
|
||||||
extendedResourceCleanup();
|
clearTextureNameCache();
|
||||||
|
|
||||||
g_settings->deregisterChangedCallback("doubletap_jump",
|
g_settings->deregisterChangedCallback("doubletap_jump",
|
||||||
&settingChangedCallback, this);
|
&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()
|
void Game::showDeathFormspec()
|
||||||
{
|
{
|
||||||
static std::string formspec_str =
|
static std::string formspec_str =
|
||||||
|
@ -225,12 +225,17 @@ bool RenderingEngine::print_video_modes()
|
|||||||
return videomode_list != NULL;
|
return videomode_list != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderingEngine::removeMesh(const irr::scene::IMesh* mesh)
|
||||||
|
{
|
||||||
|
m_device->getSceneManager()->getMeshCache()->removeMesh(mesh);
|
||||||
|
}
|
||||||
|
|
||||||
void RenderingEngine::cleanupMeshCache()
|
void RenderingEngine::cleanupMeshCache()
|
||||||
{
|
{
|
||||||
auto mesh_cache = m_device->getSceneManager()->getMeshCache();
|
auto mesh_cache = m_device->getSceneManager()->getMeshCache();
|
||||||
while (mesh_cache->getMeshCount() != 0) {
|
while (mesh_cache->getMeshCount() != 0) {
|
||||||
if (scene::IAnimatedMesh *mesh = mesh_cache->getMeshByIndex(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 "irrlichttypes_extrabloated.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
namespace irr { namespace scene {
|
||||||
|
class IMesh;
|
||||||
|
}}
|
||||||
class ITextureSource;
|
class ITextureSource;
|
||||||
class Camera;
|
class Camera;
|
||||||
class Client;
|
class Client;
|
||||||
@ -58,6 +61,8 @@ public:
|
|||||||
static bool print_video_modes();
|
static bool print_video_modes();
|
||||||
void cleanupMeshCache();
|
void cleanupMeshCache();
|
||||||
|
|
||||||
|
void removeMesh(const irr::scene::IMesh* mesh);
|
||||||
|
|
||||||
static RenderingEngine *get_instance() { return s_singleton; }
|
static RenderingEngine *get_instance() { return s_singleton; }
|
||||||
|
|
||||||
io::IFileSystem *get_filesystem()
|
io::IFileSystem *get_filesystem()
|
||||||
@ -71,12 +76,6 @@ public:
|
|||||||
return s_singleton->m_device->getVideoDriver();
|
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()
|
static scene::ISceneManager *get_scene_manager()
|
||||||
{
|
{
|
||||||
sanity_check(s_singleton && s_singleton->m_device);
|
sanity_check(s_singleton && s_singleton->m_device);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user