fix: some code tidy about includes & irr namespaces

This commit is contained in:
Loic Blot 2021-05-03 10:27:00 +02:00 committed by Loïc Blot
parent 48d5abd5be
commit de85bc9227
14 changed files with 59 additions and 65 deletions

View File

@ -1475,7 +1475,7 @@ bool Client::updateWieldedItem()
return true; return true;
} }
irr::scene::ISceneManager* Client::getSceneManager() scene::ISceneManager* Client::getSceneManager()
{ {
return m_rendering_engine->get_scene_manager(); return m_rendering_engine->get_scene_manager();
} }

View File

@ -356,7 +356,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(); scene::ISceneManager *getSceneManager();
bool shouldShowMinimap() const; bool shouldShowMinimap() const;

View File

@ -33,17 +33,13 @@ class LocalPlayer;
struct ItemStack; struct ItemStack;
class WieldMeshSceneNode; class WieldMeshSceneNode;
namespace irr { namespace scene {
class ISceneManager;
}}
class ClientActiveObject : public ActiveObject class ClientActiveObject : public ActiveObject
{ {
public: public:
ClientActiveObject(u16 id, Client *client, ClientEnvironment *env); ClientActiveObject(u16 id, Client *client, ClientEnvironment *env);
virtual ~ClientActiveObject(); virtual ~ClientActiveObject();
virtual void addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr) = 0; virtual void addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr) = 0;
virtual void removeFromScene(bool permanent) {} virtual void removeFromScene(bool permanent) {}
virtual void updateLight(u32 day_night_ratio) {} virtual void updateLight(u32 day_night_ratio) {}

View File

@ -30,7 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
// Menu clouds are created later // Menu clouds are created later
class Clouds; class Clouds;
Clouds *g_menuclouds = NULL; Clouds *g_menuclouds = NULL;
irr::scene::ISceneManager *g_menucloudsmgr = NULL; scene::ISceneManager *g_menucloudsmgr = NULL;
// Constant for now // Constant for now
static constexpr const float cloud_size = BS * 64.0f; static constexpr const float cloud_size = BS * 64.0f;

View File

@ -29,8 +29,7 @@ class Clouds;
extern Clouds *g_menuclouds; extern Clouds *g_menuclouds;
// Scene manager used for menu clouds // Scene manager used for menu clouds
namespace irr{namespace scene{class ISceneManager;}} extern scene::ISceneManager *g_menucloudsmgr;
extern irr::scene::ISceneManager *g_menucloudsmgr;
class Clouds : public scene::ISceneNode class Clouds : public scene::ISceneNode
{ {

View File

@ -188,7 +188,7 @@ public:
static ClientActiveObject* create(Client *client, ClientEnvironment *env); static ClientActiveObject* create(Client *client, ClientEnvironment *env);
void addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr); void addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr);
void removeFromScene(bool permanent); void removeFromScene(bool permanent);
void updateLight(u32 day_night_ratio); void updateLight(u32 day_night_ratio);
void updateNodePos(); void updateNodePos();
@ -219,7 +219,7 @@ ClientActiveObject* TestCAO::create(Client *client, ClientEnvironment *env)
return new TestCAO(client, env); return new TestCAO(client, env);
} }
void TestCAO::addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr) void TestCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
{ {
if(m_node != NULL) if(m_node != NULL)
return; return;
@ -590,7 +590,7 @@ void GenericCAO::removeFromScene(bool permanent)
m_client->getMinimap()->removeMarker(&m_marker); m_client->getMinimap()->removeMarker(&m_marker);
} }
void GenericCAO::addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr) void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
{ {
m_smgr = smgr; m_smgr = smgr;
@ -1484,10 +1484,10 @@ void GenericCAO::updateBonePosition()
if (m_bone_position.empty() || !m_animated_meshnode) if (m_bone_position.empty() || !m_animated_meshnode)
return; return;
m_animated_meshnode->setJointMode(irr::scene::EJUOR_CONTROL); // To write positions to the mesh on render m_animated_meshnode->setJointMode(scene::EJUOR_CONTROL); // To write positions to the mesh on render
for (auto &it : m_bone_position) { for (auto &it : m_bone_position) {
std::string bone_name = it.first; std::string bone_name = it.first;
irr::scene::IBoneSceneNode* bone = m_animated_meshnode->getJointNode(bone_name.c_str()); scene::IBoneSceneNode* bone = m_animated_meshnode->getJointNode(bone_name.c_str());
if (bone) { if (bone) {
bone->setPosition(it.second.X); bone->setPosition(it.second.X);
bone->setRotation(it.second.Y); bone->setRotation(it.second.Y);
@ -1496,7 +1496,7 @@ void GenericCAO::updateBonePosition()
// search through bones to find mistakenly rotated bones due to bug in Irrlicht // search through bones to find mistakenly rotated bones due to bug in Irrlicht
for (u32 i = 0; i < m_animated_meshnode->getJointCount(); ++i) { for (u32 i = 0; i < m_animated_meshnode->getJointCount(); ++i) {
irr::scene::IBoneSceneNode *bone = m_animated_meshnode->getJointNode(i); scene::IBoneSceneNode *bone = m_animated_meshnode->getJointNode(i);
if (!bone) if (!bone)
continue; continue;
@ -1924,7 +1924,7 @@ void GenericCAO::updateMeshCulling()
return; return;
} }
irr::scene::ISceneNode *node = getSceneNode(); scene::ISceneNode *node = getSceneNode();
if (!node) if (!node)
return; return;

View File

@ -236,7 +236,7 @@ public:
void removeFromScene(bool permanent); void removeFromScene(bool permanent);
void addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr); void addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr);
inline void expireVisuals() inline void expireVisuals()
{ {

View File

@ -61,7 +61,7 @@ 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): scene::IMeshManipulator *mm):
data(input), data(input),
collector(output), collector(output),
nodedef(data->m_client->ndef()), nodedef(data->m_client->ndef()),

View File

@ -173,7 +173,7 @@ public:
public: public:
MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output, MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output,
irr::scene::IMeshManipulator *mm); scene::IMeshManipulator *mm);
void generate(); void generate();
void renderSingle(content_t node, u8 param2 = 0x00); void renderSingle(content_t node, u8 param2 = 0x00);
}; };

View File

@ -839,7 +839,7 @@ private:
MapDrawControl *draw_control = nullptr; MapDrawControl *draw_control = nullptr;
Camera *camera = nullptr; Camera *camera = nullptr;
Clouds *clouds = nullptr; // Free using ->Drop() Clouds *clouds = nullptr; // Free using ->Drop()
Sky *m_sky = nullptr; // Free using ->Drop() Sky *sky = nullptr; // Free using ->Drop()
Hud *hud = nullptr; Hud *hud = nullptr;
Minimap *mapper = nullptr; Minimap *mapper = nullptr;
@ -1159,8 +1159,8 @@ void Game::shutdown()
if (gui_chat_console) if (gui_chat_console)
gui_chat_console->drop(); gui_chat_console->drop();
if (m_sky) if (sky)
m_sky->drop(); sky->drop();
/* cleanup menus */ /* cleanup menus */
while (g_menumgr.menuCount() > 0) { while (g_menumgr.menuCount() > 0) {
@ -1346,8 +1346,8 @@ bool Game::createClient(const GameStartData &start_data)
/* Skybox /* Skybox
*/ */
m_sky = new Sky(-1, m_rendering_engine, texture_src, shader_src); sky = new Sky(-1, m_rendering_engine, texture_src, shader_src);
scsf->setSky(m_sky); scsf->setSky(sky);
skybox = NULL; // This is used/set later on in the main run loop skybox = NULL; // This is used/set later on in the main run loop
/* Pre-calculated values /* Pre-calculated values
@ -2754,23 +2754,23 @@ void Game::handleClientEvent_HudChange(ClientEvent *event, CameraOrientation *ca
void Game::handleClientEvent_SetSky(ClientEvent *event, CameraOrientation *cam) void Game::handleClientEvent_SetSky(ClientEvent *event, CameraOrientation *cam)
{ {
m_sky->setVisible(false); sky->setVisible(false);
// Whether clouds are visible in front of a custom skybox. // Whether clouds are visible in front of a custom skybox.
m_sky->setCloudsEnabled(event->set_sky->clouds); sky->setCloudsEnabled(event->set_sky->clouds);
if (skybox) { if (skybox) {
skybox->remove(); skybox->remove();
skybox = NULL; skybox = NULL;
} }
// Clear the old textures out in case we switch rendering type. // Clear the old textures out in case we switch rendering type.
m_sky->clearSkyboxTextures(); sky->clearSkyboxTextures();
// Handle according to type // Handle according to type
if (event->set_sky->type == "regular") { if (event->set_sky->type == "regular") {
// Shows the mesh skybox // Shows the mesh skybox
m_sky->setVisible(true); sky->setVisible(true);
// Update mesh based skybox colours if applicable. // Update mesh based skybox colours if applicable.
m_sky->setSkyColors(event->set_sky->sky_color); sky->setSkyColors(event->set_sky->sky_color);
m_sky->setHorizonTint( sky->setHorizonTint(
event->set_sky->fog_sun_tint, event->set_sky->fog_sun_tint,
event->set_sky->fog_moon_tint, event->set_sky->fog_moon_tint,
event->set_sky->fog_tint_type event->set_sky->fog_tint_type
@ -2778,27 +2778,27 @@ void Game::handleClientEvent_SetSky(ClientEvent *event, CameraOrientation *cam)
} else if (event->set_sky->type == "skybox" && } else if (event->set_sky->type == "skybox" &&
event->set_sky->textures.size() == 6) { event->set_sky->textures.size() == 6) {
// Disable the dyanmic mesh skybox: // Disable the dyanmic mesh skybox:
m_sky->setVisible(false); sky->setVisible(false);
// Set fog colors: // Set fog colors:
m_sky->setFallbackBgColor(event->set_sky->bgcolor); sky->setFallbackBgColor(event->set_sky->bgcolor);
// Set sunrise and sunset fog tinting: // Set sunrise and sunset fog tinting:
m_sky->setHorizonTint( sky->setHorizonTint(
event->set_sky->fog_sun_tint, event->set_sky->fog_sun_tint,
event->set_sky->fog_moon_tint, event->set_sky->fog_moon_tint,
event->set_sky->fog_tint_type event->set_sky->fog_tint_type
); );
// Add textures to skybox. // Add textures to skybox.
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
m_sky->addTextureToSkybox(event->set_sky->textures[i], i, texture_src); sky->addTextureToSkybox(event->set_sky->textures[i], i, texture_src);
} else { } else {
// Handle everything else as plain color. // Handle everything else as plain color.
if (event->set_sky->type != "plain") if (event->set_sky->type != "plain")
infostream << "Unknown sky type: " infostream << "Unknown sky type: "
<< (event->set_sky->type) << std::endl; << (event->set_sky->type) << std::endl;
m_sky->setVisible(false); sky->setVisible(false);
m_sky->setFallbackBgColor(event->set_sky->bgcolor); sky->setFallbackBgColor(event->set_sky->bgcolor);
// Disable directional sun/moon tinting on plain or invalid skyboxes. // Disable directional sun/moon tinting on plain or invalid skyboxes.
m_sky->setHorizonTint( sky->setHorizonTint(
event->set_sky->bgcolor, event->set_sky->bgcolor,
event->set_sky->bgcolor, event->set_sky->bgcolor,
"custom" "custom"
@ -2810,30 +2810,30 @@ void Game::handleClientEvent_SetSky(ClientEvent *event, CameraOrientation *cam)
void Game::handleClientEvent_SetSun(ClientEvent *event, CameraOrientation *cam) void Game::handleClientEvent_SetSun(ClientEvent *event, CameraOrientation *cam)
{ {
m_sky->setSunVisible(event->sun_params->visible); sky->setSunVisible(event->sun_params->visible);
m_sky->setSunTexture(event->sun_params->texture, sky->setSunTexture(event->sun_params->texture,
event->sun_params->tonemap, texture_src); event->sun_params->tonemap, texture_src);
m_sky->setSunScale(event->sun_params->scale); sky->setSunScale(event->sun_params->scale);
m_sky->setSunriseVisible(event->sun_params->sunrise_visible); sky->setSunriseVisible(event->sun_params->sunrise_visible);
m_sky->setSunriseTexture(event->sun_params->sunrise, texture_src); sky->setSunriseTexture(event->sun_params->sunrise, texture_src);
delete event->sun_params; delete event->sun_params;
} }
void Game::handleClientEvent_SetMoon(ClientEvent *event, CameraOrientation *cam) void Game::handleClientEvent_SetMoon(ClientEvent *event, CameraOrientation *cam)
{ {
m_sky->setMoonVisible(event->moon_params->visible); sky->setMoonVisible(event->moon_params->visible);
m_sky->setMoonTexture(event->moon_params->texture, sky->setMoonTexture(event->moon_params->texture,
event->moon_params->tonemap, texture_src); event->moon_params->tonemap, texture_src);
m_sky->setMoonScale(event->moon_params->scale); sky->setMoonScale(event->moon_params->scale);
delete event->moon_params; delete event->moon_params;
} }
void Game::handleClientEvent_SetStars(ClientEvent *event, CameraOrientation *cam) void Game::handleClientEvent_SetStars(ClientEvent *event, CameraOrientation *cam)
{ {
m_sky->setStarsVisible(event->star_params->visible); sky->setStarsVisible(event->star_params->visible);
m_sky->setStarCount(event->star_params->count, false); sky->setStarCount(event->star_params->count, false);
m_sky->setStarColor(event->star_params->starcolor); sky->setStarColor(event->star_params->starcolor);
m_sky->setStarScale(event->star_params->scale); sky->setStarScale(event->star_params->scale);
delete event->star_params; delete event->star_params;
} }
@ -3710,7 +3710,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
direct_brightness = time_brightness; direct_brightness = time_brightness;
sunlight_seen = true; sunlight_seen = true;
} else { } else {
float old_brightness = m_sky->getBrightness(); float old_brightness = sky->getBrightness();
direct_brightness = client->getEnv().getClientMap() direct_brightness = client->getEnv().getClientMap()
.getBackgroundBrightness(MYMIN(runData.fog_range * 1.2, 60 * BS), .getBackgroundBrightness(MYMIN(runData.fog_range * 1.2, 60 * BS),
daynight_ratio, (int)(old_brightness * 255.5), &sunlight_seen) daynight_ratio, (int)(old_brightness * 255.5), &sunlight_seen)
@ -3737,7 +3737,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
runData.time_of_day_smooth = time_of_day_smooth; runData.time_of_day_smooth = time_of_day_smooth;
m_sky->update(time_of_day_smooth, time_brightness, direct_brightness, sky->update(time_of_day_smooth, time_brightness, direct_brightness,
sunlight_seen, camera->getCameraMode(), player->getYaw(), sunlight_seen, camera->getCameraMode(), player->getYaw(),
player->getPitch()); player->getPitch());
@ -3745,7 +3745,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
Update clouds Update clouds
*/ */
if (clouds) { if (clouds) {
if (m_sky->getCloudsVisible()) { if (sky->getCloudsVisible()) {
clouds->setVisible(true); clouds->setVisible(true);
clouds->step(dtime); clouds->step(dtime);
// camera->getPosition is not enough for 3rd person views // camera->getPosition is not enough for 3rd person views
@ -3755,14 +3755,14 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
camera_node_position.Y = camera_node_position.Y + camera_offset.Y * BS; camera_node_position.Y = camera_node_position.Y + camera_offset.Y * BS;
camera_node_position.Z = camera_node_position.Z + camera_offset.Z * BS; camera_node_position.Z = camera_node_position.Z + camera_offset.Z * BS;
clouds->update(camera_node_position, clouds->update(camera_node_position,
m_sky->getCloudColor()); sky->getCloudColor());
if (clouds->isCameraInsideCloud() && m_cache_enable_fog) { if (clouds->isCameraInsideCloud() && m_cache_enable_fog) {
// if inside clouds, and fog enabled, use that as sky // if inside clouds, and fog enabled, use that as sky
// color(s) // color(s)
video::SColor clouds_dark = clouds->getColor() video::SColor clouds_dark = clouds->getColor()
.getInterpolated(video::SColor(255, 0, 0, 0), 0.9); .getInterpolated(video::SColor(255, 0, 0, 0), 0.9);
m_sky->overrideColors(clouds_dark, clouds->getColor()); sky->overrideColors(clouds_dark, clouds->getColor());
m_sky->setInClouds(true); sky->setInClouds(true);
runData.fog_range = std::fmin(runData.fog_range * 0.5f, 32.0f * BS); runData.fog_range = std::fmin(runData.fog_range * 0.5f, 32.0f * BS);
// do not draw clouds after all // do not draw clouds after all
clouds->setVisible(false); clouds->setVisible(false);
@ -3783,7 +3783,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
if (m_cache_enable_fog) { if (m_cache_enable_fog) {
driver->setFog( driver->setFog(
m_sky->getBgColor(), sky->getBgColor(),
video::EFT_FOG_LINEAR, video::EFT_FOG_LINEAR,
runData.fog_range * m_cache_fog_start, runData.fog_range * m_cache_fog_start,
runData.fog_range * 1.0, runData.fog_range * 1.0,
@ -3793,7 +3793,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
); );
} else { } else {
driver->setFog( driver->setFog(
m_sky->getBgColor(), sky->getBgColor(),
video::EFT_FOG_LINEAR, video::EFT_FOG_LINEAR,
100000 * BS, 100000 * BS,
110000 * BS, 110000 * BS,
@ -3873,7 +3873,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
/* /*
Drawing begins Drawing begins
*/ */
const video::SColor &skycolor = m_sky->getSkyColor(); const video::SColor &skycolor = sky->getSkyColor();
TimeTaker tt_draw("Draw scene"); TimeTaker tt_draw("Draw scene");
driver->beginScene(true, true, skycolor); driver->beginScene(true, true, skycolor);

View File

@ -225,7 +225,7 @@ bool RenderingEngine::print_video_modes()
return videomode_list != NULL; return videomode_list != NULL;
} }
void RenderingEngine::removeMesh(const irr::scene::IMesh* mesh) void RenderingEngine::removeMesh(const scene::IMesh* mesh)
{ {
m_device->getSceneManager()->getMeshCache()->removeMesh(mesh); m_device->getSceneManager()->getMeshCache()->removeMesh(mesh);
} }

View File

@ -26,9 +26,6 @@ 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;
@ -60,7 +57,7 @@ public:
static bool print_video_modes(); static bool print_video_modes();
void cleanupMeshCache(); void cleanupMeshCache();
void removeMesh(const irr::scene::IMesh* mesh); void removeMesh(const scene::IMesh* mesh);
static v2u32 getWindowSize() static v2u32 getWindowSize()
{ {

View File

@ -39,6 +39,8 @@ extern "C" {
#include "itemgroup.h" #include "itemgroup.h"
#include "itemdef.h" #include "itemdef.h"
#include "c_types.h" #include "c_types.h"
// We do a explicit path include because by default c_content.h include src/client/hud.h
// prior to the src/hud.h, which is not good on server only build
#include "../../hud.h" #include "../../hud.h"
namespace Json { class Value; } namespace Json { class Value; }

View File

@ -29,7 +29,7 @@ public:
TestClientActiveObject() : ClientActiveObject(0, nullptr, nullptr) {} TestClientActiveObject() : ClientActiveObject(0, nullptr, nullptr) {}
~TestClientActiveObject() = default; ~TestClientActiveObject() = default;
ActiveObjectType getType() const { return ACTIVEOBJECT_TYPE_TEST; } ActiveObjectType getType() const { return ACTIVEOBJECT_TYPE_TEST; }
virtual void addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr) {} virtual void addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr) {}
}; };
class TestClientActiveObjectMgr : public TestBase class TestClientActiveObjectMgr : public TestBase