mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-20 15:40:32 +00:00
Option in settings to enable/disable detour navigator debug log
This commit is contained in:
parent
0c8db84962
commit
6d233ae868
@ -20,6 +20,7 @@
|
||||
#include <components/sceneutil/positionattitudetransform.hpp>
|
||||
|
||||
#include <components/detournavigator/navigator.hpp>
|
||||
#include <components/detournavigator/debug.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
@ -183,6 +184,7 @@ namespace MWWorld
|
||||
navigatorSettings.mMaxPolygonPathSize = static_cast<std::size_t>(Settings::Manager::getInt("max polygon path size", "Navigator"));
|
||||
navigatorSettings.mMaxSmoothPathSize = static_cast<std::size_t>(Settings::Manager::getInt("max smooth path size", "Navigator"));
|
||||
navigatorSettings.mTrianglesPerChunk = static_cast<std::size_t>(Settings::Manager::getInt("triangles per chunk", "Navigator"));
|
||||
DetourNavigator::Log::instance().setEnabled(Settings::Manager::getBool("enable log", "Navigator"));
|
||||
mNavigator.reset(new DetourNavigator::Navigator(navigatorSettings));
|
||||
|
||||
mRendering->preloadCommonAssets();
|
||||
|
@ -39,6 +39,37 @@ namespace DetourNavigator
|
||||
void writeToFile(const dtNavMesh& navMesh, const std::string& revision);
|
||||
#endif
|
||||
|
||||
class Log
|
||||
{
|
||||
public:
|
||||
Log() : mEnabled(false) {}
|
||||
|
||||
void setEnabled(bool value)
|
||||
{
|
||||
mEnabled = value;
|
||||
}
|
||||
|
||||
bool isEnabled() const
|
||||
{
|
||||
return mEnabled;
|
||||
}
|
||||
|
||||
void write(const std::string& text)
|
||||
{
|
||||
if (mEnabled)
|
||||
std::cout << text;
|
||||
}
|
||||
|
||||
static Log& instance()
|
||||
{
|
||||
static Log value;
|
||||
return value;
|
||||
}
|
||||
|
||||
private:
|
||||
bool mEnabled;
|
||||
};
|
||||
|
||||
inline void write(std::ostream& stream)
|
||||
{
|
||||
stream << '\n';
|
||||
@ -54,9 +85,12 @@ namespace DetourNavigator
|
||||
template <class ... Ts>
|
||||
void log(Ts&& ... values)
|
||||
{
|
||||
auto& log = Log::instance();
|
||||
if (!log.isEnabled())
|
||||
return;
|
||||
std::ostringstream stream;
|
||||
write(stream, std::forward<Ts>(values) ...);
|
||||
std::cout << stream.str();
|
||||
log.write(stream.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "makenavmesh.hpp"
|
||||
#include "chunkytrimesh.hpp"
|
||||
#include "debug.hpp"
|
||||
#include "dtstatus.hpp"
|
||||
#include "exceptions.hpp"
|
||||
#include "recastmesh.hpp"
|
||||
@ -12,10 +13,6 @@
|
||||
#include <Recast.h>
|
||||
#include <RecastAlloc.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
|
||||
namespace
|
||||
{
|
||||
using namespace DetourNavigator;
|
||||
|
@ -590,3 +590,6 @@ max smooth path size = 1024
|
||||
|
||||
# Maximum number of triangles in each node of mesh AABB tree (value > 0)
|
||||
triangles per chunk = 256
|
||||
|
||||
# Enable debug log (true, false)
|
||||
enable log = false
|
||||
|
Loading…
x
Reference in New Issue
Block a user