mirror of https://github.com/OpenMW/openmw.git
Support rendering for navmesh update frequency as a heatmap
Useful when need to find tiles with high number of updates. Add debug Lua package with new functions to toggle render mode and set navmesh render mode.pull/3227/head
parent
c88d3e712d
commit
215b46503c
@ -0,0 +1,51 @@
|
||||
#include "debugbindings.hpp"
|
||||
#include "context.hpp"
|
||||
#include "luamanagerimp.hpp"
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwrender/renderingmanager.hpp"
|
||||
|
||||
#include <components/lua/luastate.hpp>
|
||||
|
||||
namespace MWLua
|
||||
{
|
||||
sol::table initDebugPackage(const Context& context)
|
||||
{
|
||||
sol::table api = context.mLua->newTable();
|
||||
|
||||
api["RENDER_MODE"] = LuaUtil::makeStrictReadOnly(context.mLua->tableFromPairs<std::string_view, MWRender::RenderMode>({
|
||||
{"CollisionDebug", MWRender::Render_CollisionDebug},
|
||||
{"Wireframe", MWRender::Render_Wireframe},
|
||||
{"Pathgrid", MWRender::Render_Pathgrid},
|
||||
{"Water", MWRender::Render_Water},
|
||||
{"Scene", MWRender::Render_Scene},
|
||||
{"NavMesh", MWRender::Render_NavMesh},
|
||||
{"ActorsPaths", MWRender::Render_ActorsPaths},
|
||||
{"RecastMesh", MWRender::Render_RecastMesh},
|
||||
}));
|
||||
|
||||
api["toggleRenderMode"] = [context] (MWRender::RenderMode value)
|
||||
{
|
||||
context.mLuaManager->addAction([value]
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->toggleRenderMode(value);
|
||||
});
|
||||
};
|
||||
|
||||
api["NAV_MESH_RENDER_MODE"] = LuaUtil::makeStrictReadOnly(context.mLua->tableFromPairs<std::string_view, MWRender::NavMeshMode>({
|
||||
{"AreaType", MWRender::NavMeshMode::AreaType},
|
||||
{"UpdateFrequency", MWRender::NavMeshMode::UpdateFrequency},
|
||||
}));
|
||||
|
||||
api["setNavMeshRenderMode"] = [context] (MWRender::NavMeshMode value)
|
||||
{
|
||||
context.mLuaManager->addAction([value]
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->getRenderingManager()->setNavMeshMode(value);
|
||||
});
|
||||
};
|
||||
|
||||
return LuaUtil::makeReadOnly(api);
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
#ifndef OPENMW_MWLUA_DEBUGBINDINGS_H
|
||||
#define OPENMW_MWLUA_DEBUGBINDINGS_H
|
||||
|
||||
#include <sol/sol.hpp>
|
||||
|
||||
namespace MWLua
|
||||
{
|
||||
struct Context;
|
||||
|
||||
sol::table initDebugPackage(const Context& context);
|
||||
}
|
||||
|
||||
#endif // OPENMW_MWLUA_DEBUGBINDINGS_H
|
@ -0,0 +1,16 @@
|
||||
#include "navmeshmode.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
NavMeshMode parseNavMeshMode(std::string_view value)
|
||||
{
|
||||
if (value == "area type")
|
||||
return NavMeshMode::AreaType;
|
||||
if (value == "update frequency")
|
||||
return NavMeshMode::UpdateFrequency;
|
||||
throw std::logic_error("Unsupported navigation mesh rendering mode: " + std::string(value));
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
#ifndef OPENMW_MWRENDER_NAVMESHMODE_H
|
||||
#define OPENMW_MWRENDER_NAVMESHMODE_H
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
enum class NavMeshMode
|
||||
{
|
||||
AreaType,
|
||||
UpdateFrequency,
|
||||
};
|
||||
|
||||
NavMeshMode parseNavMeshMode(std::string_view value);
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,5 @@
|
||||
Package openmw.debug
|
||||
====================
|
||||
|
||||
.. raw:: html
|
||||
:file: generated_html/openmw_debug.html
|
@ -0,0 +1,11 @@
|
||||
+---------------------------------------------------------+--------------------+---------------------------------------------------------------+
|
||||
| Built-in library | Can be used | Description |
|
||||
+=========================================================+====================+===============================================================+
|
||||
|:ref:`openmw_aux.calendar <Package openmw_aux.calendar>` | everywhere | | Game time calendar |
|
||||
+---------------------------------------------------------+--------------------+---------------------------------------------------------------+
|
||||
|:ref:`openmw_aux.util <Package openmw_aux.util>` | everywhere | | Miscellaneous utils |
|
||||
+---------------------------------------------------------+--------------------+---------------------------------------------------------------+
|
||||
|:ref:`openmw_aux.time <Package openmw_aux.time>` | everywhere | | Timers and game time utils |
|
||||
+---------------------------------------------------------+--------------------+---------------------------------------------------------------+
|
||||
|:ref:`openmw_aux.ui <Package openmw_aux.ui>` | by player scripts | | User interface utils |
|
||||
+---------------------------------------------------------+--------------------+---------------------------------------------------------------+
|
@ -0,0 +1,33 @@
|
||||
+------------------------------------------------------------+--------------------+---------------------------------------------------------------+
|
||||
| Package | Can be used | Description |
|
||||
+============================================================+====================+===============================================================+
|
||||
|:ref:`openmw.interfaces <Script interfaces>` | everywhere | | Public interfaces of other scripts. |
|
||||
+------------------------------------------------------------+--------------------+---------------------------------------------------------------+
|
||||
|:ref:`openmw.util <Package openmw.util>` | everywhere | | Defines utility functions and classes like 3D vectors, |
|
||||
| | | | that don't depend on the game world. |
|
||||
+------------------------------------------------------------+--------------------+---------------------------------------------------------------+
|
||||
|:ref:`openmw.storage <Package openmw.storage>` | everywhere | | Storage API. In particular can be used to store data |
|
||||
| | | | between game sessions. |
|
||||
+------------------------------------------------------------+--------------------+---------------------------------------------------------------+
|
||||
|:ref:`openmw.core <Package openmw.core>` | everywhere | | Functions that are common for both global and local scripts |
|
||||
+------------------------------------------------------------+--------------------+---------------------------------------------------------------+
|
||||
|:ref:`openmw.types <Package openmw.types>` | everywhere | | Functions for specific types of game objects. |
|
||||
+------------------------------------------------------------+--------------------+---------------------------------------------------------------+
|
||||
|:ref:`openmw.async <Package openmw.async>` | everywhere | | Timers (implemented) and coroutine utils (not implemented) |
|
||||
+------------------------------------------------------------+--------------------+---------------------------------------------------------------+
|
||||
|:ref:`openmw.world <Package openmw.world>` | by global scripts | | Read-write access to the game world. |
|
||||
+------------------------------------------------------------+--------------------+---------------------------------------------------------------+
|
||||
|:ref:`openmw.self <Package openmw.self>` | by local scripts | | Full access to the object the script is attached to. |
|
||||
+------------------------------------------------------------+--------------------+---------------------------------------------------------------+
|
||||
|:ref:`openmw.nearby <Package openmw.nearby>` | by local scripts | | Read-only access to the nearest area of the game world. |
|
||||
+------------------------------------------------------------+--------------------+---------------------------------------------------------------+
|
||||
|:ref:`openmw.input <Package openmw.input>` | by player scripts | | User input. |
|
||||
+------------------------------------------------------------+--------------------+---------------------------------------------------------------+
|
||||
|:ref:`openmw.ui <Package openmw.ui>` | by player scripts | | Controls :ref:`user interface <User interface reference>`. |
|
||||
+------------------------------------------------------------+--------------------+---------------------------------------------------------------+
|
||||
|:ref:`openmw.camera <Package openmw.camera>` | by player scripts | | Controls camera. |
|
||||
+------------------------------------------------------------+--------------------+---------------------------------------------------------------+
|
||||
|:ref:`openmw.postprocessing <Package openmw.postprocessing>`| by player scripts | | Controls post-process shaders. |
|
||||
+------------------------------------------------------------+--------------------+---------------------------------------------------------------+
|
||||
|:ref:`openmw.debug <Package openmw.debug>` | by player scripts | | Collection of debug utils. |
|
||||
+------------------------------------------------------------+--------------------+---------------------------------------------------------------+
|
@ -0,0 +1,44 @@
|
||||
---
|
||||
-- `openmw.debug` is an interface to the engine debug utils.
|
||||
-- Can be used only by local scripts, that are attached to a player.
|
||||
-- @module debug
|
||||
-- @usage local debug = require('openmw.debug')
|
||||
|
||||
|
||||
---
|
||||
-- Rendering modes
|
||||
-- @type RENDER_MODE
|
||||
-- @field [parent=#RENDER_MODE] #number CollisionDebug
|
||||
-- @field [parent=#RENDER_MODE] #number Wireframe
|
||||
-- @field [parent=#RENDER_MODE] #number Pathgrid
|
||||
-- @field [parent=#RENDER_MODE] #number Water
|
||||
-- @field [parent=#RENDER_MODE] #number Scene
|
||||
-- @field [parent=#RENDER_MODE] #number NavMesh
|
||||
-- @field [parent=#RENDER_MODE] #number ActorsPaths
|
||||
-- @field [parent=#RENDER_MODE] #number RecastMesh
|
||||
|
||||
---
|
||||
-- Rendering mode values
|
||||
-- @field [parent=#debug] #RENDER_MODE RENDER_MODE
|
||||
|
||||
---
|
||||
-- Toggles rendering mode
|
||||
-- @function [parent=#debug] toggleRenderMode
|
||||
-- @param #RENDER_MODE value
|
||||
|
||||
---
|
||||
-- Navigation mesh rendering modes
|
||||
-- @type NAV_MESH_RENDER_MODE
|
||||
-- @field [parent=#NAV_MESH_RENDER_MODE] #number AreaType
|
||||
-- @field [parent=#NAV_MESH_RENDER_MODE] #number UpdateFrequency
|
||||
|
||||
---
|
||||
-- Navigation mesh rendering mode values
|
||||
-- @field [parent=#debug] #NAV_MESH_RENDER_MODE NAV_MESH_RENDER_MODE
|
||||
|
||||
---
|
||||
-- Sets navigation mesh rendering mode
|
||||
-- @function [parent=#debug] setNavMeshRenderMode
|
||||
-- @param #NAV_MESH_RENDER_MODE value
|
||||
|
||||
return nil
|
Loading…
Reference in New Issue