diff --git a/components/detournavigator/navigator.hpp b/components/detournavigator/navigator.hpp index cc62d61640..baf56145bb 100644 --- a/components/detournavigator/navigator.hpp +++ b/components/detournavigator/navigator.hpp @@ -191,7 +191,7 @@ namespace DetourNavigator */ virtual std::map getNavMeshes() const = 0; - virtual Settings getSettings() const = 0; + virtual const Settings& getSettings() const = 0; }; } diff --git a/components/detournavigator/navigatorimpl.cpp b/components/detournavigator/navigatorimpl.cpp index 2e16b6d04d..a62220e555 100644 --- a/components/detournavigator/navigatorimpl.cpp +++ b/components/detournavigator/navigatorimpl.cpp @@ -133,7 +133,7 @@ namespace DetourNavigator return mNavMeshManager.getNavMeshes(); } - Settings NavigatorImpl::getSettings() const + const Settings& NavigatorImpl::getSettings() const { return mSettings; } diff --git a/components/detournavigator/navigatorimpl.hpp b/components/detournavigator/navigatorimpl.hpp index 8156f6655e..d2ff8a57bd 100644 --- a/components/detournavigator/navigatorimpl.hpp +++ b/components/detournavigator/navigatorimpl.hpp @@ -46,7 +46,7 @@ namespace DetourNavigator std::map getNavMeshes() const override; - Settings getSettings() const override; + const Settings& getSettings() const override; private: Settings mSettings; diff --git a/components/detournavigator/navigatorstub.hpp b/components/detournavigator/navigatorstub.hpp index 5d82d2f59f..cab93b1052 100644 --- a/components/detournavigator/navigatorstub.hpp +++ b/components/detournavigator/navigatorstub.hpp @@ -5,8 +5,9 @@ namespace DetourNavigator { - struct NavigatorStub final : public Navigator + class NavigatorStub final : public Navigator { + public: NavigatorStub() = default; void addAgent(const osg::Vec3f& /*agentHalfExtents*/) override {} @@ -65,7 +66,7 @@ namespace DetourNavigator SharedNavMeshCacheItem getNavMesh(const osg::Vec3f& /*agentHalfExtents*/) const override { - return SharedNavMeshCacheItem(); + return mEmptyNavMeshCacheItem; } std::map getNavMeshes() const override @@ -73,10 +74,14 @@ namespace DetourNavigator return std::map(); } - Settings getSettings() const override + const Settings& getSettings() const override { - return Settings {}; + return mDefaultSettings; } + + private: + Settings mDefaultSettings {}; + SharedNavMeshCacheItem mEmptyNavMeshCacheItem; }; }