forked from Mirrorlandia_minetest/minetest
refacto: RenderingEngine::get_scene_manager() is now not callable from singleton
This permits to make evidence that we have some bad object passing on various code parts. I fixed majority of them to reduce the scope of passed objects Unfortunately, for some edge cases i should have to expose ISceneManager from client, this should be fixed in the future when our POO will be cleaner client side (we have a mix of rendering and processing in majority of the client objects, it works but it's not clean)
This commit is contained in:
parent
ccdd886e27
commit
5a02c376ea
@ -1475,6 +1475,11 @@ bool Client::updateWieldedItem()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
irr::scene::ISceneManager* Client::getSceneManager()
|
||||||
|
{
|
||||||
|
return m_rendering_engine->get_scene_manager();
|
||||||
|
}
|
||||||
|
|
||||||
Inventory* Client::getInventory(const InventoryLocation &loc)
|
Inventory* Client::getInventory(const InventoryLocation &loc)
|
||||||
{
|
{
|
||||||
switch(loc.type){
|
switch(loc.type){
|
||||||
|
@ -355,6 +355,7 @@ public:
|
|||||||
void setCamera(Camera* camera) { m_camera = camera; }
|
void setCamera(Camera* camera) { m_camera = camera; }
|
||||||
|
|
||||||
Camera* getCamera () { return m_camera; }
|
Camera* getCamera () { return m_camera; }
|
||||||
|
irr::scene::ISceneManager *getSceneManager();
|
||||||
|
|
||||||
bool shouldShowMinimap() const;
|
bool shouldShowMinimap() const;
|
||||||
|
|
||||||
|
@ -352,7 +352,7 @@ u16 ClientEnvironment::addActiveObject(ClientActiveObject *object)
|
|||||||
if (!m_ao_manager.registerObject(object))
|
if (!m_ao_manager.registerObject(object))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
object->addToScene(m_texturesource, RenderingEngine::get_scene_manager());
|
object->addToScene(m_texturesource, m_client->getSceneManager());
|
||||||
|
|
||||||
// Update lighting immediately
|
// Update lighting immediately
|
||||||
object->updateLight(getDayNightRatio());
|
object->updateLight(getDayNightRatio());
|
||||||
|
@ -60,18 +60,16 @@ static constexpr u16 quad_indices[] = {0, 1, 2, 2, 3, 0};
|
|||||||
|
|
||||||
const std::string MapblockMeshGenerator::raillike_groupname = "connect_to_raillike";
|
const std::string MapblockMeshGenerator::raillike_groupname = "connect_to_raillike";
|
||||||
|
|
||||||
MapblockMeshGenerator::MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output)
|
MapblockMeshGenerator::MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output,
|
||||||
|
irr::scene::IMeshManipulator *mm):
|
||||||
|
data(input),
|
||||||
|
collector(output),
|
||||||
|
nodedef(data->m_client->ndef()),
|
||||||
|
meshmanip(mm),
|
||||||
|
blockpos_nodes(data->m_blockpos * MAP_BLOCKSIZE)
|
||||||
{
|
{
|
||||||
data = input;
|
|
||||||
collector = output;
|
|
||||||
|
|
||||||
nodedef = data->m_client->ndef();
|
|
||||||
meshmanip = RenderingEngine::get_scene_manager()->getMeshManipulator();
|
|
||||||
|
|
||||||
enable_mesh_cache = g_settings->getBool("enable_mesh_cache") &&
|
enable_mesh_cache = g_settings->getBool("enable_mesh_cache") &&
|
||||||
!data->m_smooth_lighting; // Mesh cache is not supported with smooth lighting
|
!data->m_smooth_lighting; // Mesh cache is not supported with smooth lighting
|
||||||
|
|
||||||
blockpos_nodes = data->m_blockpos * MAP_BLOCKSIZE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapblockMeshGenerator::useTile(int index, u8 set_flags, u8 reset_flags, bool special)
|
void MapblockMeshGenerator::useTile(int index, u8 set_flags, u8 reset_flags, bool special)
|
||||||
|
@ -172,7 +172,8 @@ public:
|
|||||||
void drawNode();
|
void drawNode();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output);
|
MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output,
|
||||||
|
irr::scene::IMeshManipulator *mm);
|
||||||
void generate();
|
void generate();
|
||||||
void renderSingle(content_t node, u8 param2 = 0x00);
|
void renderSingle(content_t node, u8 param2 = 0x00);
|
||||||
};
|
};
|
||||||
|
@ -1072,8 +1072,8 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
MapblockMeshGenerator generator(data, &collector);
|
MapblockMeshGenerator(data, &collector,
|
||||||
generator.generate();
|
data->m_client->getSceneManager()->getMeshManipulator()).generate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -64,8 +64,8 @@ Particle::Particle(
|
|||||||
v2f texsize,
|
v2f texsize,
|
||||||
video::SColor color
|
video::SColor color
|
||||||
):
|
):
|
||||||
scene::ISceneNode(RenderingEngine::get_scene_manager()->getRootSceneNode(),
|
scene::ISceneNode(((Client *)gamedef)->getSceneManager()->getRootSceneNode(),
|
||||||
RenderingEngine::get_scene_manager())
|
((Client *)gamedef)->getSceneManager())
|
||||||
{
|
{
|
||||||
// Misc
|
// Misc
|
||||||
m_gamedef = gamedef;
|
m_gamedef = gamedef;
|
||||||
|
@ -79,10 +79,9 @@ public:
|
|||||||
return s_singleton->m_device->getVideoDriver();
|
return s_singleton->m_device->getVideoDriver();
|
||||||
}
|
}
|
||||||
|
|
||||||
static scene::ISceneManager *get_scene_manager()
|
scene::ISceneManager *get_scene_manager()
|
||||||
{
|
{
|
||||||
sanity_check(s_singleton && s_singleton->m_device);
|
return m_device->getSceneManager();
|
||||||
return s_singleton->m_device->getSceneManager();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static irr::IrrlichtDevice *get_raw_device()
|
static irr::IrrlichtDevice *get_raw_device()
|
||||||
|
@ -307,7 +307,8 @@ static scene::SMesh *createSpecialNodeMesh(Client *client, MapNode n,
|
|||||||
MeshMakeData mesh_make_data(client, false);
|
MeshMakeData mesh_make_data(client, false);
|
||||||
MeshCollector collector;
|
MeshCollector collector;
|
||||||
mesh_make_data.setSmoothLighting(false);
|
mesh_make_data.setSmoothLighting(false);
|
||||||
MapblockMeshGenerator gen(&mesh_make_data, &collector);
|
MapblockMeshGenerator gen(&mesh_make_data, &collector,
|
||||||
|
client->getSceneManager()->getMeshManipulator());
|
||||||
|
|
||||||
if (n.getParam2()) {
|
if (n.getParam2()) {
|
||||||
// keep it
|
// keep it
|
||||||
|
@ -2794,7 +2794,7 @@ void GUIFormSpecMenu::parseModel(parserData *data, const std::string &element)
|
|||||||
|
|
||||||
core::rect<s32> rect(pos, pos + geom);
|
core::rect<s32> rect(pos, pos + geom);
|
||||||
|
|
||||||
GUIScene *e = new GUIScene(Environment, RenderingEngine::get_scene_manager(),
|
GUIScene *e = new GUIScene(Environment, m_client->getSceneManager(),
|
||||||
data->current_parent, rect, spec.fid);
|
data->current_parent, rect, spec.fid);
|
||||||
|
|
||||||
auto meshnode = e->setMesh(mesh);
|
auto meshnode = e->setMesh(mesh);
|
||||||
|
@ -1446,8 +1446,8 @@ void NodeDefManager::updateTextures(IGameDef *gamedef,
|
|||||||
Client *client = (Client *)gamedef;
|
Client *client = (Client *)gamedef;
|
||||||
ITextureSource *tsrc = client->tsrc();
|
ITextureSource *tsrc = client->tsrc();
|
||||||
IShaderSource *shdsrc = client->getShaderSource();
|
IShaderSource *shdsrc = client->getShaderSource();
|
||||||
scene::IMeshManipulator *meshmanip =
|
auto smgr = client->getSceneManager();
|
||||||
RenderingEngine::get_scene_manager()->getMeshManipulator();
|
scene::IMeshManipulator *meshmanip = smgr->getMeshManipulator();
|
||||||
TextureSettings tsettings;
|
TextureSettings tsettings;
|
||||||
tsettings.readSettings();
|
tsettings.readSettings();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user