Add factory functions to create navigator implementations

pull/3223/head
elsid 3 years ago
parent b6d2c57de2
commit 5e99454cc4
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

@ -27,10 +27,7 @@
#include <components/sceneutil/positionattitudetransform.hpp> #include <components/sceneutil/positionattitudetransform.hpp>
#include <components/detournavigator/debug.hpp> #include <components/detournavigator/navigator.hpp>
#include <components/detournavigator/navigatorimpl.hpp>
#include <components/detournavigator/navigatorstub.hpp>
#include <components/detournavigator/recastglobalallocator.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
@ -197,12 +194,11 @@ namespace MWWorld
{ {
auto navigatorSettings = DetourNavigator::makeSettingsFromSettingsManager(); auto navigatorSettings = DetourNavigator::makeSettingsFromSettingsManager();
navigatorSettings.mSwimHeightScale = mSwimHeightScale; navigatorSettings.mSwimHeightScale = mSwimHeightScale;
DetourNavigator::RecastGlobalAllocator::init(); mNavigator = DetourNavigator::makeNavigator(navigatorSettings);
mNavigator.reset(new DetourNavigator::NavigatorImpl(navigatorSettings));
} }
else else
{ {
mNavigator.reset(new DetourNavigator::NavigatorStub()); mNavigator = DetourNavigator::makeNavigatorStub();
} }
mRendering.reset(new MWRender::RenderingManager(viewer, rootNode, resourceSystem, workQueue, resourcePath, *mNavigator)); mRendering.reset(new MWRender::RenderingManager(viewer, rootNode, resourceSystem, workQueue, resourcePath, *mNavigator));

@ -1,6 +1,9 @@
#include "findrandompointaroundcircle.hpp" #include "findrandompointaroundcircle.hpp"
#include "navigator.hpp" #include "navigator.hpp"
#include "raycast.hpp" #include "raycast.hpp"
#include "navigatorimpl.hpp"
#include "navigatorstub.hpp"
#include "recastglobalallocator.hpp"
namespace DetourNavigator namespace DetourNavigator
{ {
@ -33,4 +36,15 @@ namespace DetourNavigator
return {}; return {};
return fromNavMeshCoordinates(settings, *result); return fromNavMeshCoordinates(settings, *result);
} }
std::unique_ptr<Navigator> makeNavigator(const Settings& settings)
{
DetourNavigator::RecastGlobalAllocator::init();
return std::make_unique<NavigatorImpl>(settings);
}
std::unique_ptr<Navigator> makeNavigatorStub()
{
return std::make_unique<NavigatorStub>();
}
} }

@ -240,6 +240,10 @@ namespace DetourNavigator
virtual float getMaxNavmeshAreaRealRadius() const = 0; virtual float getMaxNavmeshAreaRealRadius() const = 0;
}; };
std::unique_ptr<Navigator> makeNavigator(const Settings& settings);
std::unique_ptr<Navigator> makeNavigatorStub();
} }
#endif #endif

Loading…
Cancel
Save