Option in settings to enable/disable detour navigator debug log

pull/541/head
elsid 7 years ago
parent 0c8db84962
commit 6d233ae868
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

@ -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…
Cancel
Save