1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-27 12:35:46 +00:00
OpenMW/apps/openmw/mwlua/debugbindings.cpp
elsid 215b46503c
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.
2022-05-17 01:54:20 +02:00

52 lines
1.8 KiB
C++

#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);
}
}