diff --git a/apps/openmw/mwsound/regionsoundselector.cpp b/apps/openmw/mwsound/regionsoundselector.cpp index ac5f66721..c95ed9c72 100644 --- a/apps/openmw/mwsound/regionsoundselector.cpp +++ b/apps/openmw/mwsound/regionsoundselector.cpp @@ -18,7 +18,7 @@ namespace MWSound } } - boost::optional RegionSoundSelector::getNextRandom(float duration, const std::string& regionName, + std::optional RegionSoundSelector::getNextRandom(float duration, const std::string& regionName, const MWBase::World& world) { mTimePassed += duration; diff --git a/apps/openmw/mwsound/regionsoundselector.hpp b/apps/openmw/mwsound/regionsoundselector.hpp index 00a2d5ca8..0dce5a7aa 100644 --- a/apps/openmw/mwsound/regionsoundselector.hpp +++ b/apps/openmw/mwsound/regionsoundselector.hpp @@ -15,7 +15,7 @@ namespace MWSound class RegionSoundSelector { public: - boost::optional getNextRandom(float duration, const std::string& regionName, + std::optional getNextRandom(float duration, const std::string& regionName, const MWBase::World& world); private: diff --git a/components/detournavigator/asyncnavmeshupdater.cpp b/components/detournavigator/asyncnavmeshupdater.cpp index 878b8130a..1ac928f07 100644 --- a/components/detournavigator/asyncnavmeshupdater.cpp +++ b/components/detournavigator/asyncnavmeshupdater.cpp @@ -198,7 +198,7 @@ namespace DetourNavigator return isSuccess(status); } - boost::optional AsyncNavMeshUpdater::getNextJob() + std::optional AsyncNavMeshUpdater::getNextJob() { std::unique_lock lock(mMutex); @@ -217,7 +217,7 @@ namespace DetourNavigator mFirstStart.lock()->reset(); if (mJobs.empty() && getTotalThreadJobsUnsafe() == 0) mDone.notify_all(); - return boost::none; + return std::nullopt; } Log(Debug::Debug) << "Got " << mJobs.size() << " navigator jobs and " @@ -239,7 +239,7 @@ namespace DetourNavigator } } - boost::optional AsyncNavMeshUpdater::getJob(Jobs& jobs, Pushed& pushed, bool changeLastUpdate) + std::optional AsyncNavMeshUpdater::getJob(Jobs& jobs, Pushed& pushed, bool changeLastUpdate) { const auto now = std::chrono::steady_clock::now(); diff --git a/components/detournavigator/asyncnavmeshupdater.hpp b/components/detournavigator/asyncnavmeshupdater.hpp index 26f886512..fcdc0f21a 100644 --- a/components/detournavigator/asyncnavmeshupdater.hpp +++ b/components/detournavigator/asyncnavmeshupdater.hpp @@ -106,7 +106,7 @@ namespace DetourNavigator Jobs mJobs; std::map> mPushed; Misc::ScopeGuarded mPlayerTile; - Misc::ScopeGuarded> mFirstStart; + Misc::ScopeGuarded> mFirstStart; NavMeshTilesCache mNavMeshTilesCache; Misc::ScopeGuarded>> mProcessingTiles; std::map> mLastUpdates; @@ -117,9 +117,9 @@ namespace DetourNavigator bool processJob(const Job& job); - boost::optional getNextJob(); + std::optional getNextJob(); - boost::optional getJob(Jobs& jobs, Pushed& pushed, bool changeLastUpdate); + std::optional getJob(Jobs& jobs, Pushed& pushed, bool changeLastUpdate); void postThreadJob(Job&& job, Queue& queue); diff --git a/components/detournavigator/cachedrecastmeshmanager.cpp b/components/detournavigator/cachedrecastmeshmanager.cpp index da0f6c874..90b426610 100644 --- a/components/detournavigator/cachedrecastmeshmanager.cpp +++ b/components/detournavigator/cachedrecastmeshmanager.cpp @@ -25,7 +25,7 @@ namespace DetourNavigator return true; } - boost::optional CachedRecastMeshManager::removeObject(const ObjectId id) + std::optional CachedRecastMeshManager::removeObject(const ObjectId id) { const auto object = mImpl.removeObject(id); if (object) @@ -42,7 +42,7 @@ namespace DetourNavigator return true; } - boost::optional CachedRecastMeshManager::removeWater(const osg::Vec2i& cellPosition) + std::optional CachedRecastMeshManager::removeWater(const osg::Vec2i& cellPosition) { const auto water = mImpl.removeWater(cellPosition); if (water) diff --git a/components/detournavigator/cachedrecastmeshmanager.hpp b/components/detournavigator/cachedrecastmeshmanager.hpp index 5efb315e8..8ce2e48c2 100644 --- a/components/detournavigator/cachedrecastmeshmanager.hpp +++ b/components/detournavigator/cachedrecastmeshmanager.hpp @@ -19,9 +19,9 @@ namespace DetourNavigator bool addWater(const osg::Vec2i& cellPosition, const int cellSize, const btTransform& transform); - boost::optional removeWater(const osg::Vec2i& cellPosition); + std::optional removeWater(const osg::Vec2i& cellPosition); - boost::optional removeObject(const ObjectId id); + std::optional removeObject(const ObjectId id); std::shared_ptr getMesh(); diff --git a/components/detournavigator/findrandompointaroundcircle.cpp b/components/detournavigator/findrandompointaroundcircle.cpp index 263dba68e..f2e815c91 100644 --- a/components/detournavigator/findrandompointaroundcircle.cpp +++ b/components/detournavigator/findrandompointaroundcircle.cpp @@ -10,12 +10,12 @@ namespace DetourNavigator { - boost::optional findRandomPointAroundCircle(const dtNavMesh& navMesh, const osg::Vec3f& halfExtents, + std::optional findRandomPointAroundCircle(const dtNavMesh& navMesh, const osg::Vec3f& halfExtents, const osg::Vec3f& start, const float maxRadius, const Flags includeFlags, const Settings& settings) { dtNavMeshQuery navMeshQuery; if (!initNavMeshQuery(navMeshQuery, navMesh, settings.mMaxNavMeshQueryNodes)) - return boost::optional(); + return std::optional(); dtQueryFilter queryFilter; queryFilter.setIncludeFlags(includeFlags); @@ -31,7 +31,7 @@ namespace DetourNavigator } if (startRef == 0) - return boost::optional(); + return std::optional(); dtPolyRef resultRef = 0; osg::Vec3f resultPosition; @@ -39,8 +39,8 @@ namespace DetourNavigator []() { return Misc::Rng::rollProbability(); }, &resultRef, resultPosition.ptr()); if (resultRef == 0) - return boost::optional(); + return std::optional(); - return boost::optional(resultPosition); + return std::optional(resultPosition); } } diff --git a/components/detournavigator/findrandompointaroundcircle.hpp b/components/detournavigator/findrandompointaroundcircle.hpp index 841508f67..fb0b5c5ba 100644 --- a/components/detournavigator/findrandompointaroundcircle.hpp +++ b/components/detournavigator/findrandompointaroundcircle.hpp @@ -13,7 +13,7 @@ namespace DetourNavigator { struct Settings; - boost::optional findRandomPointAroundCircle(const dtNavMesh& navMesh, const osg::Vec3f& halfExtents, + std::optional findRandomPointAroundCircle(const dtNavMesh& navMesh, const osg::Vec3f& halfExtents, const osg::Vec3f& start, const float maxRadius, const Flags includeFlags, const Settings& settings); } diff --git a/components/detournavigator/findsmoothpath.cpp b/components/detournavigator/findsmoothpath.cpp index ef0341d72..8e443def9 100644 --- a/components/detournavigator/findsmoothpath.cpp +++ b/components/detournavigator/findsmoothpath.cpp @@ -103,7 +103,7 @@ namespace DetourNavigator return result; } - boost::optional getSteerTarget(const dtNavMeshQuery& navQuery, const osg::Vec3f& startPos, + std::optional getSteerTarget(const dtNavMeshQuery& navQuery, const osg::Vec3f& startPos, const osg::Vec3f& endPos, const float minTargetDist, const std::vector& path) { // Find steer target. @@ -117,7 +117,7 @@ namespace DetourNavigator steerPathFlags.data(), steerPathPolys.data(), &nsteerPath, MAX_STEER_POINTS); assert(nsteerPath >= 0); if (!nsteerPath) - return boost::none; + return std::nullopt; // Find vertex far enough to steer to. std::size_t ns = 0; @@ -131,7 +131,7 @@ namespace DetourNavigator } // Failed to find good point to steer to. if (ns >= static_cast(nsteerPath)) - return boost::none; + return std::nullopt; dtVcopy(result.steerPos.ptr(), &steerPath[ns * 3]); result.steerPos.y() = startPos[1]; diff --git a/components/detournavigator/findsmoothpath.hpp b/components/detournavigator/findsmoothpath.hpp index f1de71207..23609ab09 100644 --- a/components/detournavigator/findsmoothpath.hpp +++ b/components/detournavigator/findsmoothpath.hpp @@ -58,7 +58,7 @@ namespace DetourNavigator dtPolyRef steerPosRef; }; - boost::optional getSteerTarget(const dtNavMeshQuery& navQuery, const osg::Vec3f& startPos, + std::optional getSteerTarget(const dtNavMeshQuery& navQuery, const osg::Vec3f& startPos, const osg::Vec3f& endPos, const float minTargetDist, const std::vector& path); template @@ -111,7 +111,7 @@ namespace DetourNavigator std::vector mVisited; }; - inline boost::optional moveAlongSurface(const dtNavMeshQuery& navMeshQuery, + inline std::optional moveAlongSurface(const dtNavMeshQuery& navMeshQuery, const dtPolyRef startRef, const osg::Vec3f& startPos, const osg::Vec3f& endPos, const dtQueryFilter& filter, const std::size_t maxVisitedSize) { @@ -128,7 +128,7 @@ namespace DetourNavigator return {std::move(result)}; } - inline boost::optional> findPath(const dtNavMeshQuery& navMeshQuery, const dtPolyRef startRef, + inline std::optional> findPath(const dtNavMeshQuery& navMeshQuery, const dtPolyRef startRef, const dtPolyRef endRef, const osg::Vec3f& startPos, const osg::Vec3f& endPos, const dtQueryFilter& queryFilter, const std::size_t maxSize) { @@ -144,7 +144,7 @@ namespace DetourNavigator return {std::move(result)}; } - inline boost::optional getPolyHeight(const dtNavMeshQuery& navMeshQuery, const dtPolyRef ref, const osg::Vec3f& pos) + inline std::optional getPolyHeight(const dtNavMeshQuery& navMeshQuery, const dtPolyRef ref, const osg::Vec3f& pos) { float result = 0.0f; const auto status = navMeshQuery.getPolyHeight(ref, pos.ptr(), &result); diff --git a/components/detournavigator/navigator.cpp b/components/detournavigator/navigator.cpp index a58a4f876..658e539ad 100644 --- a/components/detournavigator/navigator.cpp +++ b/components/detournavigator/navigator.cpp @@ -3,18 +3,18 @@ namespace DetourNavigator { - boost::optional Navigator::findRandomPointAroundCircle(const osg::Vec3f& agentHalfExtents, + std::optional Navigator::findRandomPointAroundCircle(const osg::Vec3f& agentHalfExtents, const osg::Vec3f& start, const float maxRadius, const Flags includeFlags) const { const auto navMesh = getNavMesh(agentHalfExtents); if (!navMesh) - return boost::optional(); + return std::optional(); const auto settings = getSettings(); const auto result = DetourNavigator::findRandomPointAroundCircle(navMesh->lockConst()->getImpl(), toNavMeshCoordinates(settings, agentHalfExtents), toNavMeshCoordinates(settings, start), toNavMeshCoordinates(settings, maxRadius), includeFlags, settings); if (!result) - return boost::optional(); - return boost::optional(fromNavMeshCoordinates(settings, *result)); + return std::optional(); + return std::optional(fromNavMeshCoordinates(settings, *result)); } } diff --git a/components/detournavigator/navigator.hpp b/components/detournavigator/navigator.hpp index 3e7f54178..a79aa59d4 100644 --- a/components/detournavigator/navigator.hpp +++ b/components/detournavigator/navigator.hpp @@ -220,7 +220,7 @@ namespace DetourNavigator * @param includeFlags setup allowed surfaces for actor to walk. * @return not empty optional with position if point is found and empty optional if point is not found. */ - boost::optional findRandomPointAroundCircle(const osg::Vec3f& agentHalfExtents, + std::optional findRandomPointAroundCircle(const osg::Vec3f& agentHalfExtents, const osg::Vec3f& start, const float maxRadius, const Flags includeFlags) const; virtual RecastMeshTiles getRecastMeshTiles() = 0; diff --git a/components/detournavigator/recastmeshmanager.cpp b/components/detournavigator/recastmeshmanager.cpp index 05f250596..3796c9816 100644 --- a/components/detournavigator/recastmeshmanager.cpp +++ b/components/detournavigator/recastmeshmanager.cpp @@ -34,11 +34,11 @@ namespace DetourNavigator return true; } - boost::optional RecastMeshManager::removeObject(const ObjectId id) + std::optional RecastMeshManager::removeObject(const ObjectId id) { const auto object = mObjects.find(id); if (object == mObjects.end()) - return boost::none; + return std::nullopt; const RemovedRecastMeshObject result {object->second->getShape(), object->second->getTransform()}; mObjectsOrder.erase(object->second); mObjects.erase(object); @@ -59,11 +59,11 @@ namespace DetourNavigator return true; } - boost::optional RecastMeshManager::removeWater(const osg::Vec2i& cellPosition) + std::optional RecastMeshManager::removeWater(const osg::Vec2i& cellPosition) { const auto water = mWater.find(cellPosition); if (water == mWater.end()) - return boost::none; + return std::nullopt; ++mRevision; const auto result = *water->second; mWaterOrder.erase(water->second); diff --git a/components/detournavigator/recastmeshmanager.hpp b/components/detournavigator/recastmeshmanager.hpp index f1870ec6b..47f5f5190 100644 --- a/components/detournavigator/recastmeshmanager.hpp +++ b/components/detournavigator/recastmeshmanager.hpp @@ -43,9 +43,9 @@ namespace DetourNavigator bool addWater(const osg::Vec2i& cellPosition, const int cellSize, const btTransform& transform); - boost::optional removeWater(const osg::Vec2i& cellPosition); + std::optional removeWater(const osg::Vec2i& cellPosition); - boost::optional removeObject(const ObjectId id); + std::optional removeObject(const ObjectId id); std::shared_ptr getMesh(); diff --git a/components/detournavigator/settings.cpp b/components/detournavigator/settings.cpp index 49aec41ff..977b80cf5 100644 --- a/components/detournavigator/settings.cpp +++ b/components/detournavigator/settings.cpp @@ -4,10 +4,10 @@ namespace DetourNavigator { - boost::optional makeSettingsFromSettingsManager() + std::optional makeSettingsFromSettingsManager() { if (!::Settings::Manager::getBool("enable", "Navigator")) - return boost::optional(); + return std::optional(); Settings navigatorSettings; diff --git a/components/detournavigator/settings.hpp b/components/detournavigator/settings.hpp index 939d825a5..290e763a9 100644 --- a/components/detournavigator/settings.hpp +++ b/components/detournavigator/settings.hpp @@ -42,7 +42,7 @@ namespace DetourNavigator std::chrono::milliseconds mMinUpdateInterval; }; - boost::optional makeSettingsFromSettingsManager(); + std::optional makeSettingsFromSettingsManager(); } #endif diff --git a/components/detournavigator/tilecachedrecastmeshmanager.cpp b/components/detournavigator/tilecachedrecastmeshmanager.cpp index 9debe5dea..fddaa88f1 100644 --- a/components/detournavigator/tilecachedrecastmeshmanager.cpp +++ b/components/detournavigator/tilecachedrecastmeshmanager.cpp @@ -31,12 +31,12 @@ namespace DetourNavigator return result; } - boost::optional TileCachedRecastMeshManager::removeObject(const ObjectId id) + std::optional TileCachedRecastMeshManager::removeObject(const ObjectId id) { const auto object = mObjectsTilesPositions.find(id); if (object == mObjectsTilesPositions.end()) - return boost::none; - boost::optional result; + return std::nullopt; + std::optional result; { auto tiles = mTiles.lock(); for (const auto& tilePosition : object->second) @@ -100,12 +100,12 @@ namespace DetourNavigator return result; } - boost::optional TileCachedRecastMeshManager::removeWater(const osg::Vec2i& cellPosition) + std::optional TileCachedRecastMeshManager::removeWater(const osg::Vec2i& cellPosition) { const auto object = mWaterTilesPositions.find(cellPosition); if (object == mWaterTilesPositions.end()) - return boost::none; - boost::optional result; + return std::nullopt; + std::optional result; for (const auto& tilePosition : object->second) { const auto tiles = mTiles.lock(); @@ -168,12 +168,12 @@ namespace DetourNavigator return tile != tiles.end() && tile->second.updateObject(id, transform, areaType); } - boost::optional TileCachedRecastMeshManager::removeTile(const ObjectId id, + std::optional TileCachedRecastMeshManager::removeTile(const ObjectId id, const TilePosition& tilePosition, std::map& tiles) { const auto tile = tiles.find(tilePosition); if (tile == tiles.end()) - return boost::optional(); + return std::optional(); const auto tileResult = tile->second.removeObject(id); if (tile->second.isEmpty()) { diff --git a/components/detournavigator/tilecachedrecastmeshmanager.hpp b/components/detournavigator/tilecachedrecastmeshmanager.hpp index 557cde1be..fa192bd73 100644 --- a/components/detournavigator/tilecachedrecastmeshmanager.hpp +++ b/components/detournavigator/tilecachedrecastmeshmanager.hpp @@ -69,11 +69,11 @@ namespace DetourNavigator return changed; } - boost::optional removeObject(const ObjectId id); + std::optional removeObject(const ObjectId id); bool addWater(const osg::Vec2i& cellPosition, const int cellSize, const btTransform& transform); - boost::optional removeWater(const osg::Vec2i& cellPosition); + std::optional removeWater(const osg::Vec2i& cellPosition); std::shared_ptr getMesh(const TilePosition& tilePosition); @@ -103,7 +103,7 @@ namespace DetourNavigator bool updateTile(const ObjectId id, const btTransform& transform, const AreaType areaType, const TilePosition& tilePosition, std::map& tiles); - boost::optional removeTile(const ObjectId id, const TilePosition& tilePosition, + std::optional removeTile(const ObjectId id, const TilePosition& tilePosition, std::map& tiles); }; }