diff options
author | x2048 <codeforsmile@gmail.com> | 2023-03-30 00:10:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-30 00:10:23 +0200 |
commit | 93898957b6c5862c6db0fa2555eaa5d3a0070e12 (patch) | |
tree | 76383f2376f5f5665ba62d1d9a15edd24fa30713 /src | |
parent | bd88d299b9159acbbf7d9d1df6d4f5487653a863 (diff) | |
download | minetest-93898957b6c5862c6db0fa2555eaa5d3a0070e12.tar.xz |
Return 'loops' occlusion culler under a setting (#13352)
* Add occlusion_culler setting to minetest.conf.example
* Add raytraced occlusion culling to 'loops' algorithm
---------
Co-authored-by: sfan5 <sfan5@live.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/client/clientmap.cpp | 18 | ||||
-rw-r--r-- | src/client/clientmap.h | 2 | ||||
-rw-r--r-- | src/defaultsettings.cpp | 1 |
3 files changed, 19 insertions, 2 deletions
diff --git a/src/client/clientmap.cpp b/src/client/clientmap.cpp index e19ef0f53..e876c9efc 100644 --- a/src/client/clientmap.cpp +++ b/src/client/clientmap.cpp @@ -103,18 +103,23 @@ ClientMap::ClientMap( m_cache_bilinear_filter = g_settings->getBool("bilinear_filter"); m_cache_anistropic_filter = g_settings->getBool("anisotropic_filter"); m_cache_transparency_sorting_distance = g_settings->getU16("transparency_sorting_distance"); + m_loops_occlusion_culler = g_settings->get("occlusion_culler") == "loops"; + g_settings->registerChangedCallback("occlusion_culler", on_settings_changed, this); m_enable_raytraced_culling = g_settings->getBool("enable_raytraced_culling"); g_settings->registerChangedCallback("enable_raytraced_culling", on_settings_changed, this); } void ClientMap::onSettingChanged(const std::string &name) { + if (name == "occlusion_culler") + m_loops_occlusion_culler = g_settings->get("occlusion_culler") == "loops"; if (name == "enable_raytraced_culling") m_enable_raytraced_culling = g_settings->getBool("enable_raytraced_culling"); } ClientMap::~ClientMap() { + g_settings->deregisterChangedCallback("occlusion_culler", on_settings_changed, this); g_settings->deregisterChangedCallback("enable_raytraced_culling", on_settings_changed, this); } @@ -298,7 +303,7 @@ void ClientMap::updateDrawList() When range_all is enabled, enumerate all blocks visible in the frustum and display them. */ - if (m_control.range_all) { + if (m_control.range_all || m_loops_occlusion_culler) { MapBlockVect sectorblocks; for (auto §or_it : m_sectors) { @@ -339,6 +344,14 @@ void ClientMap::updateDrawList() continue; } + // Raytraced occlusion culling - send rays from the camera to the block's corners + if (occlusion_culling_enabled && m_enable_raytraced_culling && + mesh && + isMeshOccluded(block, mesh_grid.cell_size, cam_pos_nodes)) { + blocks_occlusion_culled++; + continue; + } + if (mesh_grid.cell_size > 1) { // Block meshes are stored in the corner block of a chunk // (where all coordinate are divisible by the chunk size) @@ -582,6 +595,9 @@ void ClientMap::updateDrawList() void ClientMap::touchMapBlocks() { + if (!m_loops_occlusion_culler) + return; + v3s16 cam_pos_nodes = floatToInt(m_camera_position, BS); v3s16 p_blocks_min; diff --git a/src/client/clientmap.h b/src/client/clientmap.h index b9f7b4dfa..4d565ec9f 100644 --- a/src/client/clientmap.h +++ b/src/client/clientmap.h @@ -215,6 +215,6 @@ private: bool m_cache_anistropic_filter; u16 m_cache_transparency_sorting_distance; - bool m_new_occlusion_culler; + bool m_loops_occlusion_culler; bool m_enable_raytraced_culling; }; diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index e2457ce78..01ee1a8a1 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -65,6 +65,7 @@ void set_default_settings() settings->setDefault("max_out_chat_queue_size", "20"); settings->setDefault("pause_on_lost_focus", "false"); settings->setDefault("enable_split_login_register", "true"); + settings->setDefault("occlusion_culler", "bfs"); settings->setDefault("enable_raytraced_culling", "true"); settings->setDefault("chat_weblink_color", "#8888FF"); |