]> git.lizzy.rs Git - minetest.git/commitdiff
Add debug priv, and allow player to display the scene as wire-frame. (#4709)
authorlhofhansl <lhofhansl@yahoo.com>
Fri, 4 Nov 2016 02:14:32 +0000 (19:14 -0700)
committerest31 <est31@users.noreply.github.com>
Fri, 4 Nov 2016 02:14:32 +0000 (03:14 +0100)
builtin/game/privileges.lua
src/clientmap.cpp
src/clientmap.h
src/game.cpp

index 05c79440c75bde7c1fe9277f74da73fd9b8d78e4..f895141347b2bc117b3c46a9e49373044fe109c5 100644 (file)
@@ -58,4 +58,7 @@ core.register_privilege("zoom", {
        description = "Can zoom the camera",
        give_to_singleplayer = false,
 })
-
+core.register_privilege("debug", {
+       description = "Allows enabling various debug options that may affect gameplay",
+       give_to_singleplayer = false,
+})
index a0a7802507653fdab778b07f4cbff08d2abb0ad8..60170ab704c4f21b8aa908482cbed30f1d5c7732 100644 (file)
@@ -521,6 +521,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
                                buf->getMaterial().setFlag(video::EMF_TRILINEAR_FILTER, m_cache_trilinear_filter);
                                buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, m_cache_bilinear_filter);
                                buf->getMaterial().setFlag(video::EMF_ANISOTROPIC_FILTER, m_cache_anistropic_filter);
+                               buf->getMaterial().setFlag(video::EMF_WIREFRAME, m_control.show_wireframe);
 
                                const video::SMaterial& material = buf->getMaterial();
                                video::IMaterialRenderer* rnd =
index 396e68f64fdb854b550715fd9956ae1df913a72d..8855eecf692660e63e5e1920e2107f298cabed83 100644 (file)
@@ -32,6 +32,7 @@ struct MapDrawControl
                range_all(false),
                wanted_range(0),
                wanted_max_blocks(0),
+               show_wireframe(false),
                blocks_drawn(0),
                blocks_would_have_drawn(0),
                farthest_drawn(0)
@@ -43,6 +44,8 @@ struct MapDrawControl
        float wanted_range;
        // Maximum number of blocks to draw
        u32 wanted_max_blocks;
+       // show a wire frame for debugging
+       bool show_wireframe;
        // Number of blocks rendered is written here by the renderer
        u32 blocks_drawn;
        // Number of blocks that would have been drawn in wanted_range
index 9a03071dd45c820c1da99af394498dfce0f0a896..af0476a0b74dd8f79749a505a5936f80e41f8529 100644 (file)
@@ -1573,7 +1573,7 @@ class Game {
                        bool shift_pressed);
        void toggleFog(float *statustext_time, bool *flag);
        void toggleDebug(float *statustext_time, bool *show_debug,
-                       bool *show_profiler_graph);
+                       bool *show_profiler_graph, bool *show_wireframe);
        void toggleUpdateCamera(float *statustext_time, bool *flag);
        void toggleProfiler(float *statustext_time, u32 *profiler_current_page,
                        u32 profiler_max_page);
@@ -2812,7 +2812,8 @@ void Game::processKeyInput(VolatileRunFlags *flags,
        } else if (wasKeyDown(KeyType::TOGGLE_UPDATE_CAMERA)) {
                toggleUpdateCamera(statustext_time, &flags->disable_camera_update);
        } else if (wasKeyDown(KeyType::TOGGLE_DEBUG)) {
-               toggleDebug(statustext_time, &flags->show_debug, &flags->show_profiler_graph);
+               toggleDebug(statustext_time, &flags->show_debug, &flags->show_profiler_graph,
+                       &draw_control->show_wireframe);
        } else if (wasKeyDown(KeyType::TOGGLE_PROFILER)) {
                toggleProfiler(statustext_time, profiler_current_page, profiler_max_page);
        } else if (wasKeyDown(KeyType::INCREASE_VIEWING_RANGE)) {
@@ -3119,22 +3120,33 @@ void Game::toggleFog(float *statustext_time, bool *flag)
 
 
 void Game::toggleDebug(float *statustext_time, bool *show_debug,
-               bool *show_profiler_graph)
+               bool *show_profiler_graph, bool *show_wireframe)
 {
-       // Initial / 3x toggle: Chat only
+       // Initial / 4x toggle: Chat only
        // 1x toggle: Debug text with chat
        // 2x toggle: Debug text with profiler graph
+       // 3x toggle: Debug text and wireframe
        if (!*show_debug) {
                *show_debug = true;
                *show_profiler_graph = false;
+               *show_wireframe = false;
                statustext = L"Debug info shown";
-       } else if (*show_profiler_graph) {
-               *show_debug = false;
-               *show_profiler_graph = false;
-               statustext = L"Debug info and profiler graph hidden";
-       } else {
+       } else if (!*show_profiler_graph) {
                *show_profiler_graph = true;
                statustext = L"Profiler graph shown";
+       } else if (!*show_wireframe && client->checkPrivilege("debug")) {
+               *show_profiler_graph = false;
+               *show_wireframe = true;
+               statustext = L"Wireframe shown";
+       } else {
+               *show_debug = false;
+               *show_profiler_graph = false;
+               *show_wireframe = false;
+               if (client->checkPrivilege("debug")) {
+                       statustext = L"Debug info, profiler graph, and wireframe hidden";
+               } else {
+                       statustext = L"Debug info and profiler graph hidden";
+               }
        }
        *statustext_time = 0;
 }