mirror of
https://github.com/minetest/minetest.git
synced 2024-12-28 08:57:30 +01:00
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;
|
||||
}
|
||||
|
||||
irr::scene::ISceneManager* Client::getSceneManager()
|
||||
{
|
||||
return m_rendering_engine->get_scene_manager();
|
||||
}
|
||||
|
||||
Inventory* Client::getInventory(const InventoryLocation &loc)
|
||||
{
|
||||
switch(loc.type){
|
||||
|
@ -355,6 +355,7 @@ public:
|
||||
void setCamera(Camera* camera) { m_camera = camera; }
|
||||
|
||||
Camera* getCamera () { return m_camera; }
|
||||
irr::scene::ISceneManager *getSceneManager();
|
||||
|
||||
bool shouldShowMinimap() const;
|
||||
|
||||
|
@ -352,7 +352,7 @@ u16 ClientEnvironment::addActiveObject(ClientActiveObject *object)
|
||||
if (!m_ao_manager.registerObject(object))
|
||||
return 0;
|
||||
|
||||
object->addToScene(m_texturesource, RenderingEngine::get_scene_manager());
|
||||
object->addToScene(m_texturesource, m_client->getSceneManager());
|
||||
|
||||
// Update lighting immediately
|
||||
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";
|
||||
|
||||
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") &&
|
||||
!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)
|
||||
|
@ -172,7 +172,8 @@ public:
|
||||
void drawNode();
|
||||
|
||||
public:
|
||||
MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output);
|
||||
MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output,
|
||||
irr::scene::IMeshManipulator *mm);
|
||||
void generate();
|
||||
void renderSingle(content_t node, u8 param2 = 0x00);
|
||||
};
|
||||
|
@ -1072,8 +1072,8 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
|
||||
*/
|
||||
|
||||
{
|
||||
MapblockMeshGenerator generator(data, &collector);
|
||||
generator.generate();
|
||||
MapblockMeshGenerator(data, &collector,
|
||||
data->m_client->getSceneManager()->getMeshManipulator()).generate();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -64,8 +64,8 @@ Particle::Particle(
|
||||
v2f texsize,
|
||||
video::SColor color
|
||||
):
|
||||
scene::ISceneNode(RenderingEngine::get_scene_manager()->getRootSceneNode(),
|
||||
RenderingEngine::get_scene_manager())
|
||||
scene::ISceneNode(((Client *)gamedef)->getSceneManager()->getRootSceneNode(),
|
||||
((Client *)gamedef)->getSceneManager())
|
||||
{
|
||||
// Misc
|
||||
m_gamedef = gamedef;
|
||||
|
@ -79,10 +79,9 @@ public:
|
||||
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 s_singleton->m_device->getSceneManager();
|
||||
return m_device->getSceneManager();
|
||||
}
|
||||
|
||||
static irr::IrrlichtDevice *get_raw_device()
|
||||
|
@ -307,7 +307,8 @@ static scene::SMesh *createSpecialNodeMesh(Client *client, MapNode n,
|
||||
MeshMakeData mesh_make_data(client, false);
|
||||
MeshCollector collector;
|
||||
mesh_make_data.setSmoothLighting(false);
|
||||
MapblockMeshGenerator gen(&mesh_make_data, &collector);
|
||||
MapblockMeshGenerator gen(&mesh_make_data, &collector,
|
||||
client->getSceneManager()->getMeshManipulator());
|
||||
|
||||
if (n.getParam2()) {
|
||||
// keep it
|
||||
@ -538,7 +539,7 @@ void getItemMesh(Client *client, const ItemStack &item, ItemMesh *result)
|
||||
content_t id = ndef->getId(def.name);
|
||||
|
||||
FATAL_ERROR_IF(!g_extrusion_mesh_cache, "Extrusion mesh cache is not yet initialized");
|
||||
|
||||
|
||||
scene::SMesh *mesh = nullptr;
|
||||
|
||||
// Shading is on by default
|
||||
|
@ -2794,7 +2794,7 @@ void GUIFormSpecMenu::parseModel(parserData *data, const std::string &element)
|
||||
|
||||
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);
|
||||
|
||||
auto meshnode = e->setMesh(mesh);
|
||||
|
@ -1446,8 +1446,8 @@ void NodeDefManager::updateTextures(IGameDef *gamedef,
|
||||
Client *client = (Client *)gamedef;
|
||||
ITextureSource *tsrc = client->tsrc();
|
||||
IShaderSource *shdsrc = client->getShaderSource();
|
||||
scene::IMeshManipulator *meshmanip =
|
||||
RenderingEngine::get_scene_manager()->getMeshManipulator();
|
||||
auto smgr = client->getSceneManager();
|
||||
scene::IMeshManipulator *meshmanip = smgr->getMeshManipulator();
|
||||
TextureSettings tsettings;
|
||||
tsettings.readSettings();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user