mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-07-21 03:44:05 +00:00
Option in settings to enable/disable detour navigator debug log
This commit is contained in:
parent
0c8db84962
commit
6d233ae868
4 changed files with 41 additions and 5 deletions
|
@ -20,6 +20,7 @@
|
||||||
#include <components/sceneutil/positionattitudetransform.hpp>
|
#include <components/sceneutil/positionattitudetransform.hpp>
|
||||||
|
|
||||||
#include <components/detournavigator/navigator.hpp>
|
#include <components/detournavigator/navigator.hpp>
|
||||||
|
#include <components/detournavigator/debug.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/soundmanager.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.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.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"));
|
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));
|
mNavigator.reset(new DetourNavigator::Navigator(navigatorSettings));
|
||||||
|
|
||||||
mRendering->preloadCommonAssets();
|
mRendering->preloadCommonAssets();
|
||||||
|
|
|
@ -39,6 +39,37 @@ namespace DetourNavigator
|
||||||
void writeToFile(const dtNavMesh& navMesh, const std::string& revision);
|
void writeToFile(const dtNavMesh& navMesh, const std::string& revision);
|
||||||
#endif
|
#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)
|
inline void write(std::ostream& stream)
|
||||||
{
|
{
|
||||||
stream << '\n';
|
stream << '\n';
|
||||||
|
@ -54,9 +85,12 @@ namespace DetourNavigator
|
||||||
template <class ... Ts>
|
template <class ... Ts>
|
||||||
void log(Ts&& ... values)
|
void log(Ts&& ... values)
|
||||||
{
|
{
|
||||||
|
auto& log = Log::instance();
|
||||||
|
if (!log.isEnabled())
|
||||||
|
return;
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
write(stream, std::forward<Ts>(values) ...);
|
write(stream, std::forward<Ts>(values) ...);
|
||||||
std::cout << stream.str();
|
log.write(stream.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "makenavmesh.hpp"
|
#include "makenavmesh.hpp"
|
||||||
#include "chunkytrimesh.hpp"
|
#include "chunkytrimesh.hpp"
|
||||||
|
#include "debug.hpp"
|
||||||
#include "dtstatus.hpp"
|
#include "dtstatus.hpp"
|
||||||
#include "exceptions.hpp"
|
#include "exceptions.hpp"
|
||||||
#include "recastmesh.hpp"
|
#include "recastmesh.hpp"
|
||||||
|
@ -12,10 +13,6 @@
|
||||||
#include <Recast.h>
|
#include <Recast.h>
|
||||||
#include <RecastAlloc.h>
|
#include <RecastAlloc.h>
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <limits>
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
using namespace DetourNavigator;
|
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)
|
# Maximum number of triangles in each node of mesh AABB tree (value > 0)
|
||||||
triangles per chunk = 256
|
triangles per chunk = 256
|
||||||
|
|
||||||
|
# Enable debug log (true, false)
|
||||||
|
enable log = false
|
||||||
|
|
Loading…
Reference in a new issue