2022-12-19 19:21:05 +01:00
|
|
|
#include "recastcontext.hpp"
|
|
|
|
#include "debug.hpp"
|
|
|
|
|
2025-03-21 14:32:33 +01:00
|
|
|
#include <components/debug/debuglog.hpp>
|
2022-12-19 19:21:05 +01:00
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
namespace DetourNavigator
|
|
|
|
{
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
Debug::Level getLogLevel(rcLogCategory category)
|
|
|
|
{
|
|
|
|
switch (category)
|
|
|
|
{
|
|
|
|
case RC_LOG_PROGRESS:
|
|
|
|
return Debug::Verbose;
|
|
|
|
case RC_LOG_WARNING:
|
|
|
|
return Debug::Warning;
|
|
|
|
case RC_LOG_ERROR:
|
|
|
|
return Debug::Error;
|
|
|
|
}
|
|
|
|
return Debug::Debug;
|
|
|
|
}
|
|
|
|
|
2025-03-22 02:49:48 +01:00
|
|
|
std::string formatPrefix(ESM::RefId worldspace, const TilePosition& tilePosition,
|
|
|
|
const AgentBounds& agentBounds, const Version& version)
|
2022-12-19 19:21:05 +01:00
|
|
|
{
|
|
|
|
std::ostringstream stream;
|
2023-06-10 13:23:47 +02:00
|
|
|
stream << "Worldspace: " << worldspace << "; tile position: " << tilePosition.x() << ", "
|
2025-03-22 02:49:48 +01:00
|
|
|
<< tilePosition.y() << "; agent bounds: " << agentBounds << "; version: " << version << "; ";
|
2022-12-19 19:21:05 +01:00
|
|
|
return stream.str();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-03-21 14:32:33 +01:00
|
|
|
RecastContext::RecastContext(ESM::RefId worldspace, const TilePosition& tilePosition,
|
2025-03-22 02:49:48 +01:00
|
|
|
const AgentBounds& agentBounds, const Version& version, Debug::Level maxLogLevel)
|
2025-03-21 14:32:33 +01:00
|
|
|
: mMaxLogLevel(maxLogLevel)
|
2025-03-22 02:49:48 +01:00
|
|
|
, mPrefix(formatPrefix(worldspace, tilePosition, agentBounds, version))
|
2022-12-19 19:21:05 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void RecastContext::doLog(const rcLogCategory category, const char* msg, const int len)
|
|
|
|
{
|
2025-03-21 14:32:33 +01:00
|
|
|
if (msg == nullptr || len <= 0)
|
|
|
|
return;
|
|
|
|
const Debug::Level level = getLogLevel(category);
|
|
|
|
if (level > mMaxLogLevel)
|
|
|
|
return;
|
|
|
|
Log(level) << mPrefix << std::string_view(msg, static_cast<std::size_t>(len));
|
2022-12-19 19:21:05 +01:00
|
|
|
}
|
|
|
|
}
|