mirror of
https://github.com/minetest/minetest.git
synced 2024-07-04 15:05:27 +02:00
Reload graphics & dynamic shadows
You can force reload graphics by showing the verbose debug page (press F5 a few times). It might be better to bind it to a specific keybind, but this was easier to implement and didn't require taking up another keybind.
This commit is contained in:
parent
b8959a0bac
commit
b2792e59f7
@ -218,6 +218,7 @@ core.register_on_formspec_input(function(formname, fields)
|
|||||||
dialogdata.components = nil
|
dialogdata.components = nil
|
||||||
dialogdata.rightscroll = 0
|
dialogdata.rightscroll = 0
|
||||||
core.show_settings()
|
core.show_settings()
|
||||||
|
core.reload_graphics()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -274,6 +274,9 @@ void ClientEnvironment::step(float dtime)
|
|||||||
// Step object
|
// Step object
|
||||||
cao->step(dtime, this);
|
cao->step(dtime, this);
|
||||||
|
|
||||||
|
if (m_update_shadows)
|
||||||
|
cao->updateSceneShadows();
|
||||||
|
|
||||||
if (update_lighting)
|
if (update_lighting)
|
||||||
cao->updateLight(day_night_ratio);
|
cao->updateLight(day_night_ratio);
|
||||||
};
|
};
|
||||||
@ -296,6 +299,9 @@ void ClientEnvironment::step(float dtime)
|
|||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_update_shadows)
|
||||||
|
m_update_shadows = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientEnvironment::addSimpleObject(ClientSimpleObject *simple)
|
void ClientEnvironment::addSimpleObject(ClientSimpleObject *simple)
|
||||||
|
@ -142,14 +142,15 @@ class ClientEnvironment : public Environment
|
|||||||
const std::set<std::string> &getPlayerNames() { return m_player_names; }
|
const std::set<std::string> &getPlayerNames() { return m_player_names; }
|
||||||
void addPlayerName(const std::string &name) { m_player_names.insert(name); }
|
void addPlayerName(const std::string &name) { m_player_names.insert(name); }
|
||||||
void removePlayerName(const std::string &name) { m_player_names.erase(name); }
|
void removePlayerName(const std::string &name) { m_player_names.erase(name); }
|
||||||
void updateCameraOffset(const v3s16 &camera_offset)
|
void updateCameraOffset(const v3s16 &camera_offset) { m_camera_offset = camera_offset; }
|
||||||
{ m_camera_offset = camera_offset; }
|
void requestUpdateShadows() { m_update_shadows = true; }
|
||||||
v3s16 getCameraOffset() const { return m_camera_offset; }
|
v3s16 getCameraOffset() const { return m_camera_offset; }
|
||||||
|
|
||||||
void updateFrameTime(bool is_paused);
|
void updateFrameTime(bool is_paused);
|
||||||
u64 getFrameTime() const { return m_frame_time; }
|
u64 getFrameTime() const { return m_frame_time; }
|
||||||
u64 getFrameTimeDelta() const { return m_frame_dtime; }
|
u64 getFrameTimeDelta() const { return m_frame_dtime; }
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ClientMap *m_map;
|
ClientMap *m_map;
|
||||||
LocalPlayer *m_local_player = nullptr;
|
LocalPlayer *m_local_player = nullptr;
|
||||||
@ -162,6 +163,7 @@ class ClientEnvironment : public Environment
|
|||||||
IntervalLimiter m_active_object_light_update_interval;
|
IntervalLimiter m_active_object_light_update_interval;
|
||||||
std::set<std::string> m_player_names;
|
std::set<std::string> m_player_names;
|
||||||
v3s16 m_camera_offset;
|
v3s16 m_camera_offset;
|
||||||
|
bool m_update_shadows = false;
|
||||||
u64 m_frame_time = 0;
|
u64 m_frame_time = 0;
|
||||||
u64 m_frame_dtime = 0;
|
u64 m_frame_dtime = 0;
|
||||||
u64 m_frame_time_pause_accumulator = 0;
|
u64 m_frame_time_pause_accumulator = 0;
|
||||||
|
@ -62,6 +62,7 @@ class ClientActiveObject : public ActiveObject
|
|||||||
virtual void updateAttachments() {};
|
virtual void updateAttachments() {};
|
||||||
|
|
||||||
virtual bool doShowSelectionBox() { return true; }
|
virtual bool doShowSelectionBox() { return true; }
|
||||||
|
virtual void updateSceneShadows() {}
|
||||||
|
|
||||||
// Step object in time
|
// Step object in time
|
||||||
virtual void step(float dtime, ClientEnvironment *env) {}
|
virtual void step(float dtime, ClientEnvironment *env) {}
|
||||||
|
@ -604,6 +604,17 @@ void GenericCAO::removeFromScene(bool permanent)
|
|||||||
m_client->getMinimap()->removeMarker(&m_marker);
|
m_client->getMinimap()->removeMarker(&m_marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GenericCAO::updateSceneShadows()
|
||||||
|
{
|
||||||
|
if (scene::ISceneNode *node = getSceneNode()) {
|
||||||
|
if (m_matrixnode)
|
||||||
|
node->setParent(m_matrixnode);
|
||||||
|
|
||||||
|
if (auto shadow = RenderingEngine::get_shadow_renderer())
|
||||||
|
shadow->addNodeToShadowList(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
|
void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
|
||||||
{
|
{
|
||||||
m_smgr = smgr;
|
m_smgr = smgr;
|
||||||
@ -833,6 +844,8 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
|
|||||||
if (m_reset_textures_timer < 0)
|
if (m_reset_textures_timer < 0)
|
||||||
updateTextures(m_current_texture_modifier);
|
updateTextures(m_current_texture_modifier);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (scene::ISceneNode *node = getSceneNode()) {
|
if (scene::ISceneNode *node = getSceneNode()) {
|
||||||
if (m_matrixnode)
|
if (m_matrixnode)
|
||||||
node->setParent(m_matrixnode);
|
node->setParent(m_matrixnode);
|
||||||
|
@ -249,6 +249,7 @@ class GenericCAO : public ClientActiveObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateLight(u32 day_night_ratio) override;
|
void updateLight(u32 day_night_ratio) override;
|
||||||
|
void updateSceneShadows() override;
|
||||||
|
|
||||||
void setNodeLight(const video::SColor &light);
|
void setNodeLight(const video::SColor &light);
|
||||||
|
|
||||||
|
@ -739,6 +739,7 @@ class Game {
|
|||||||
void updateCameraOrientation(CameraOrientation *cam, float dtime);
|
void updateCameraOrientation(CameraOrientation *cam, float dtime);
|
||||||
void updatePlayerControl(const CameraOrientation &cam);
|
void updatePlayerControl(const CameraOrientation &cam);
|
||||||
void updatePauseState();
|
void updatePauseState();
|
||||||
|
void reloadGraphics();
|
||||||
void step(f32 dtime);
|
void step(f32 dtime);
|
||||||
void processClientEvents(CameraOrientation *cam);
|
void processClientEvents(CameraOrientation *cam);
|
||||||
void updateCamera(f32 dtime);
|
void updateCamera(f32 dtime);
|
||||||
@ -1126,6 +1127,12 @@ bool Game::startup(bool *kill,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void Game::reloadGraphics()
|
||||||
|
{
|
||||||
|
m_rendering_engine->initialize(client, hud);
|
||||||
|
client->getEnv().requestUpdateShadows();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void Game::run()
|
void Game::run()
|
||||||
{
|
{
|
||||||
@ -1802,6 +1809,8 @@ bool Game::getServerContent(bool *aborted)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
Run
|
Run
|
||||||
@ -1865,9 +1874,15 @@ inline bool Game::handleCallbacks()
|
|||||||
|
|
||||||
if (g_gamecallback->unpause_requested) {
|
if (g_gamecallback->unpause_requested) {
|
||||||
m_is_paused = false;
|
m_is_paused = false;
|
||||||
|
m_rendering_engine->initialize(client, hud);
|
||||||
g_gamecallback->unpause_requested = false;
|
g_gamecallback->unpause_requested = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_gamecallback->reload_graphics_requested) {
|
||||||
|
reloadGraphics();
|
||||||
|
g_gamecallback->reload_graphics_requested = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (g_gamecallback->show_settings_requested) {
|
if (g_gamecallback->show_settings_requested) {
|
||||||
if (client->modsLoaded())
|
if (client->modsLoaded())
|
||||||
{
|
{
|
||||||
@ -1911,7 +1926,9 @@ void Game::updateDebugState()
|
|||||||
m_game_ui->m_flags.show_basic_debug = false;
|
m_game_ui->m_flags.show_basic_debug = false;
|
||||||
} else if (m_game_ui->m_flags.show_minimal_debug) {
|
} else if (m_game_ui->m_flags.show_minimal_debug) {
|
||||||
if (has_basic_debug)
|
if (has_basic_debug)
|
||||||
|
{
|
||||||
m_game_ui->m_flags.show_basic_debug = true;
|
m_game_ui->m_flags.show_basic_debug = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!has_basic_debug)
|
if (!has_basic_debug)
|
||||||
hud->disableBlockBounds();
|
hud->disableBlockBounds();
|
||||||
@ -2523,6 +2540,7 @@ void Game::toggleDebug()
|
|||||||
} else if (!m_game_ui->m_flags.show_profiler_graph && !draw_control->show_wireframe) {
|
} else if (!m_game_ui->m_flags.show_profiler_graph && !draw_control->show_wireframe) {
|
||||||
if (has_basic_debug)
|
if (has_basic_debug)
|
||||||
m_game_ui->m_flags.show_basic_debug = true;
|
m_game_ui->m_flags.show_basic_debug = true;
|
||||||
|
reloadGraphics();
|
||||||
m_game_ui->m_flags.show_profiler_graph = true;
|
m_game_ui->m_flags.show_profiler_graph = true;
|
||||||
m_game_ui->showTranslatedStatusText("Profiler graph shown");
|
m_game_ui->showTranslatedStatusText("Profiler graph shown");
|
||||||
} else if (!draw_control->show_wireframe && client->checkPrivilege("debug")) {
|
} else if (!draw_control->show_wireframe && client->checkPrivilege("debug")) {
|
||||||
|
@ -35,6 +35,7 @@ class IGameCallback
|
|||||||
virtual void changePassword() = 0;
|
virtual void changePassword() = 0;
|
||||||
virtual void changeVolume() = 0;
|
virtual void changeVolume() = 0;
|
||||||
virtual void unpause() = 0;
|
virtual void unpause() = 0;
|
||||||
|
virtual void reloadGraphics() = 0;
|
||||||
virtual void showSettings() = 0;
|
virtual void showSettings() = 0;
|
||||||
virtual void showOpenURLDialog(const std::string &url) = 0;
|
virtual void showOpenURLDialog(const std::string &url) = 0;
|
||||||
virtual void signalKeyConfigChange() = 0;
|
virtual void signalKeyConfigChange() = 0;
|
||||||
@ -154,6 +155,11 @@ class MainGameCallback : public IGameCallback
|
|||||||
unpause_requested = true;
|
unpause_requested = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reloadGraphics() override
|
||||||
|
{
|
||||||
|
reload_graphics_requested = true;
|
||||||
|
}
|
||||||
|
|
||||||
void showSettings() override
|
void showSettings() override
|
||||||
{
|
{
|
||||||
show_settings_requested = true;
|
show_settings_requested = true;
|
||||||
@ -165,6 +171,7 @@ class MainGameCallback : public IGameCallback
|
|||||||
bool keyconfig_requested = false;
|
bool keyconfig_requested = false;
|
||||||
bool shutdown_requested = false;
|
bool shutdown_requested = false;
|
||||||
bool unpause_requested = false;
|
bool unpause_requested = false;
|
||||||
|
bool reload_graphics_requested = false;
|
||||||
bool show_settings_requested = false;
|
bool show_settings_requested = false;
|
||||||
bool keyconfig_changed = false;
|
bool keyconfig_changed = false;
|
||||||
std::string show_open_url_dialog = "";
|
std::string show_open_url_dialog = "";
|
||||||
|
@ -196,6 +196,12 @@ int ModApiClient::l_exit_to_os(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ModApiClient::l_reload_graphics(lua_State *L)
|
||||||
|
{
|
||||||
|
g_gamecallback->reloadGraphics();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int ModApiClient::l_key_config(lua_State *L)
|
int ModApiClient::l_key_config(lua_State *L)
|
||||||
{
|
{
|
||||||
g_gamecallback->keyConfig();
|
g_gamecallback->keyConfig();
|
||||||
@ -392,6 +398,7 @@ void ModApiClient::Initialize(lua_State *L, int top)
|
|||||||
API_FCT(disconnect);
|
API_FCT(disconnect);
|
||||||
API_FCT(unpause);
|
API_FCT(unpause);
|
||||||
API_FCT(exit_to_os);
|
API_FCT(exit_to_os);
|
||||||
|
API_FCT(reload_graphics);
|
||||||
API_FCT(key_config);
|
API_FCT(key_config);
|
||||||
API_FCT(get_meta);
|
API_FCT(get_meta);
|
||||||
API_FCT(get_server_info);
|
API_FCT(get_server_info);
|
||||||
|
@ -57,6 +57,9 @@ class ModApiClient : public ModApiBase
|
|||||||
// exit_to_os()
|
// exit_to_os()
|
||||||
static int l_exit_to_os(lua_State *L);
|
static int l_exit_to_os(lua_State *L);
|
||||||
|
|
||||||
|
// reload_graphics()
|
||||||
|
static int l_reload_graphics(lua_State *L);
|
||||||
|
|
||||||
// key_config()
|
// key_config()
|
||||||
static int l_key_config(lua_State *L);
|
static int l_key_config(lua_State *L);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user