2020-01-20 22:06:47 +00:00
|
|
|
#include "navigator.hpp"
|
2021-11-05 23:14:41 +00:00
|
|
|
#include "navigatorimpl.hpp"
|
|
|
|
#include "navigatorstub.hpp"
|
|
|
|
#include "recastglobalallocator.hpp"
|
2020-01-20 22:06:47 +00:00
|
|
|
|
2022-01-27 20:18:01 +00:00
|
|
|
#include <components/debug/debuglog.hpp>
|
2022-07-02 22:02:29 +00:00
|
|
|
#include <components/files/conversion.hpp>
|
2022-01-27 20:18:01 +00:00
|
|
|
|
2020-01-20 22:06:47 +00:00
|
|
|
namespace DetourNavigator
|
|
|
|
{
|
2022-06-19 11:28:33 +00:00
|
|
|
std::unique_ptr<Navigator> makeNavigator(const Settings& settings, const std::filesystem::path& userDataPath)
|
2021-11-05 23:14:41 +00:00
|
|
|
{
|
|
|
|
DetourNavigator::RecastGlobalAllocator::init();
|
2021-07-09 20:51:42 +00:00
|
|
|
|
|
|
|
std::unique_ptr<NavMeshDb> db;
|
|
|
|
if (settings.mEnableNavMeshDiskCache)
|
2022-01-27 20:18:01 +00:00
|
|
|
{
|
2023-07-21 21:54:27 +00:00
|
|
|
const std::string path = Files::pathToUnicodeString(userDataPath / "navmesh.db");
|
|
|
|
Log(Debug::Info) << "Using " << path << " to store navigation mesh cache";
|
2022-01-27 20:18:01 +00:00
|
|
|
try
|
|
|
|
{
|
2023-07-21 21:54:27 +00:00
|
|
|
db = std::make_unique<NavMeshDb>(path, settings.mMaxDbFileSize);
|
2022-01-27 20:18:01 +00:00
|
|
|
}
|
|
|
|
catch (const std::exception& e)
|
|
|
|
{
|
|
|
|
Log(Debug::Error) << e.what() << ", navigation mesh disk cache will be disabled";
|
|
|
|
}
|
|
|
|
}
|
2021-07-09 20:51:42 +00:00
|
|
|
|
|
|
|
return std::make_unique<NavigatorImpl>(settings, std::move(db));
|
2021-11-05 23:14:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<Navigator> makeNavigatorStub()
|
|
|
|
{
|
|
|
|
return std::make_unique<NavigatorStub>();
|
|
|
|
}
|
2020-01-20 22:06:47 +00:00
|
|
|
}
|