diff options
author | sfan5 <sfan5@live.de> | 2022-05-21 20:29:44 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2022-06-03 21:48:52 +0200 |
commit | 575caa8015fe420ce5e709d6c137036dfc0262ef (patch) | |
tree | e3ea30432afdcf9adaeb6868da03afdc12ad4c9a /src | |
parent | 5f3af7d18b528e502e2cf09e0f46cc892df98dd4 (diff) | |
download | minetest-575caa8015fe420ce5e709d6c137036dfc0262ef.tar.gz minetest-575caa8015fe420ce5e709d6c137036dfc0262ef.tar.bz2 minetest-575caa8015fe420ce5e709d6c137036dfc0262ef.zip |
Properly keep noclip state in Game and ClientMap
Diffstat (limited to 'src')
-rw-r--r-- | src/client/clientmap.cpp | 24 | ||||
-rw-r--r-- | src/client/clientmap.h | 6 | ||||
-rw-r--r-- | src/client/game.cpp | 10 |
3 files changed, 23 insertions, 17 deletions
diff --git a/src/client/clientmap.cpp b/src/client/clientmap.cpp index 98e3f40d3..38ba1daad 100644 --- a/src/client/clientmap.cpp +++ b/src/client/clientmap.cpp @@ -219,13 +219,11 @@ void ClientMap::updateDrawList() // Number of blocks occlusion culled u32 blocks_occlusion_culled = 0; - // No occlusion culling when free_move is on and camera is - // inside ground + // No occlusion culling when free_move is on and camera is inside ground bool occlusion_culling_enabled = true; - if (g_settings->getBool("free_move") && g_settings->getBool("noclip")) { + if (m_control.allow_noclip) { MapNode n = getNode(cam_pos_nodes); - if (n.getContent() == CONTENT_IGNORE || - m_nodedef->get(n).solidness == 2) + if (n.getContent() == CONTENT_IGNORE || m_nodedef->get(n).solidness == 2) occlusion_culling_enabled = false; } @@ -678,19 +676,17 @@ void ClientMap::renderPostFx(CameraMode cam_mode) MapNode n = getNode(floatToInt(m_camera_position, BS)); - // - If the player is in a solid node, make everything black. - // - If the player is in liquid, draw a semi-transparent overlay. - // - Do not if player is in third person mode const ContentFeatures& features = m_nodedef->get(n); video::SColor post_effect_color = features.post_effect_color; - if(features.solidness == 2 && !(g_settings->getBool("noclip") && - m_client->checkLocalPrivilege("noclip")) && - cam_mode == CAMERA_MODE_FIRST) - { + + // If the camera is in a solid node, make everything black. + // (first person mode only) + if (features.solidness == 2 && cam_mode == CAMERA_MODE_FIRST && + !m_control.allow_noclip) { post_effect_color = video::SColor(255, 0, 0, 0); } - if (post_effect_color.getAlpha() != 0) - { + + if (post_effect_color.getAlpha() != 0) { // Draw a full-screen rectangle video::IVideoDriver* driver = SceneManager->getVideoDriver(); v2u32 ss = driver->getScreenSize(); diff --git a/src/client/clientmap.h b/src/client/clientmap.h index 823870c68..8c45b5382 100644 --- a/src/client/clientmap.h +++ b/src/client/clientmap.h @@ -27,10 +27,12 @@ with this program; if not, write to the Free Software Foundation, Inc., struct MapDrawControl { - // Overrides limits by drawing everything - bool range_all = false; // Wanted drawing range float wanted_range = 0.0f; + // Overrides limits by drawing everything + bool range_all = false; + // Allow rendering out of bounds + bool allow_noclip = false; // show a wire frame for debugging bool show_wireframe = false; }; diff --git a/src/client/game.cpp b/src/client/game.cpp index f93bd34a3..d6e0cc8b8 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -1743,6 +1743,8 @@ void Game::processQueues() void Game::updateDebugState() { LocalPlayer *player = client->getEnv().getLocalPlayer(); + + // debug UI and wireframe bool has_debug = client->checkPrivilege("debug"); bool has_basic_debug = has_debug || (player->hud_flags & HUD_FLAG_BASIC_DEBUG); @@ -1757,6 +1759,9 @@ void Game::updateDebugState() hud->disableBlockBounds(); if (!has_debug) draw_control->show_wireframe = false; + + // noclip + draw_control->allow_noclip = m_cache_enable_noclip && client->checkPrivilege("noclip"); } void Game::updateProfilers(const RunStats &stats, const FpsControl &draw_times, @@ -3762,7 +3767,10 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime, float direct_brightness; bool sunlight_seen; - if (m_cache_enable_noclip && m_cache_enable_free_move) { + // When in noclip mode force same sky brightness as above ground so you + // can see properly + if (draw_control->allow_noclip && m_cache_enable_free_move && + client->checkPrivilege("fly")) { direct_brightness = time_brightness; sunlight_seen = true; } else { |