mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 02:45:32 +00:00
use std::optional instead of boost::optional
This commit is contained in:
parent
37ac5323f1
commit
62b0781f7d
18 changed files with 50 additions and 50 deletions
|
@ -18,7 +18,7 @@ namespace MWSound
|
|||
}
|
||||
}
|
||||
|
||||
boost::optional<std::string> RegionSoundSelector::getNextRandom(float duration, const std::string& regionName,
|
||||
std::optional<std::string> RegionSoundSelector::getNextRandom(float duration, const std::string& regionName,
|
||||
const MWBase::World& world)
|
||||
{
|
||||
mTimePassed += duration;
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace MWSound
|
|||
class RegionSoundSelector
|
||||
{
|
||||
public:
|
||||
boost::optional<std::string> getNextRandom(float duration, const std::string& regionName,
|
||||
std::optional<std::string> getNextRandom(float duration, const std::string& regionName,
|
||||
const MWBase::World& world);
|
||||
|
||||
private:
|
||||
|
|
|
@ -198,7 +198,7 @@ namespace DetourNavigator
|
|||
return isSuccess(status);
|
||||
}
|
||||
|
||||
boost::optional<AsyncNavMeshUpdater::Job> AsyncNavMeshUpdater::getNextJob()
|
||||
std::optional<AsyncNavMeshUpdater::Job> AsyncNavMeshUpdater::getNextJob()
|
||||
{
|
||||
std::unique_lock<std::mutex> 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::Job> AsyncNavMeshUpdater::getJob(Jobs& jobs, Pushed& pushed, bool changeLastUpdate)
|
||||
std::optional<AsyncNavMeshUpdater::Job> AsyncNavMeshUpdater::getJob(Jobs& jobs, Pushed& pushed, bool changeLastUpdate)
|
||||
{
|
||||
const auto now = std::chrono::steady_clock::now();
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ namespace DetourNavigator
|
|||
Jobs mJobs;
|
||||
std::map<osg::Vec3f, std::set<TilePosition>> mPushed;
|
||||
Misc::ScopeGuarded<TilePosition> mPlayerTile;
|
||||
Misc::ScopeGuarded<boost::optional<std::chrono::steady_clock::time_point>> mFirstStart;
|
||||
Misc::ScopeGuarded<std::optional<std::chrono::steady_clock::time_point>> mFirstStart;
|
||||
NavMeshTilesCache mNavMeshTilesCache;
|
||||
Misc::ScopeGuarded<std::map<osg::Vec3f, std::map<TilePosition, std::thread::id>>> mProcessingTiles;
|
||||
std::map<osg::Vec3f, std::map<TilePosition, std::chrono::steady_clock::time_point>> mLastUpdates;
|
||||
|
@ -117,9 +117,9 @@ namespace DetourNavigator
|
|||
|
||||
bool processJob(const Job& job);
|
||||
|
||||
boost::optional<Job> getNextJob();
|
||||
std::optional<Job> getNextJob();
|
||||
|
||||
boost::optional<Job> getJob(Jobs& jobs, Pushed& pushed, bool changeLastUpdate);
|
||||
std::optional<Job> getJob(Jobs& jobs, Pushed& pushed, bool changeLastUpdate);
|
||||
|
||||
void postThreadJob(Job&& job, Queue& queue);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace DetourNavigator
|
|||
return true;
|
||||
}
|
||||
|
||||
boost::optional<RemovedRecastMeshObject> CachedRecastMeshManager::removeObject(const ObjectId id)
|
||||
std::optional<RemovedRecastMeshObject> CachedRecastMeshManager::removeObject(const ObjectId id)
|
||||
{
|
||||
const auto object = mImpl.removeObject(id);
|
||||
if (object)
|
||||
|
@ -42,7 +42,7 @@ namespace DetourNavigator
|
|||
return true;
|
||||
}
|
||||
|
||||
boost::optional<RecastMeshManager::Water> CachedRecastMeshManager::removeWater(const osg::Vec2i& cellPosition)
|
||||
std::optional<RecastMeshManager::Water> CachedRecastMeshManager::removeWater(const osg::Vec2i& cellPosition)
|
||||
{
|
||||
const auto water = mImpl.removeWater(cellPosition);
|
||||
if (water)
|
||||
|
|
|
@ -19,9 +19,9 @@ namespace DetourNavigator
|
|||
|
||||
bool addWater(const osg::Vec2i& cellPosition, const int cellSize, const btTransform& transform);
|
||||
|
||||
boost::optional<RecastMeshManager::Water> removeWater(const osg::Vec2i& cellPosition);
|
||||
std::optional<RecastMeshManager::Water> removeWater(const osg::Vec2i& cellPosition);
|
||||
|
||||
boost::optional<RemovedRecastMeshObject> removeObject(const ObjectId id);
|
||||
std::optional<RemovedRecastMeshObject> removeObject(const ObjectId id);
|
||||
|
||||
std::shared_ptr<RecastMesh> getMesh();
|
||||
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
|
||||
namespace DetourNavigator
|
||||
{
|
||||
boost::optional<osg::Vec3f> findRandomPointAroundCircle(const dtNavMesh& navMesh, const osg::Vec3f& halfExtents,
|
||||
std::optional<osg::Vec3f> 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<osg::Vec3f>();
|
||||
return std::optional<osg::Vec3f>();
|
||||
|
||||
dtQueryFilter queryFilter;
|
||||
queryFilter.setIncludeFlags(includeFlags);
|
||||
|
@ -31,7 +31,7 @@ namespace DetourNavigator
|
|||
}
|
||||
|
||||
if (startRef == 0)
|
||||
return boost::optional<osg::Vec3f>();
|
||||
return std::optional<osg::Vec3f>();
|
||||
|
||||
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<osg::Vec3f>();
|
||||
return std::optional<osg::Vec3f>();
|
||||
|
||||
return boost::optional<osg::Vec3f>(resultPosition);
|
||||
return std::optional<osg::Vec3f>(resultPosition);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace DetourNavigator
|
|||
{
|
||||
struct Settings;
|
||||
|
||||
boost::optional<osg::Vec3f> findRandomPointAroundCircle(const dtNavMesh& navMesh, const osg::Vec3f& halfExtents,
|
||||
std::optional<osg::Vec3f> findRandomPointAroundCircle(const dtNavMesh& navMesh, const osg::Vec3f& halfExtents,
|
||||
const osg::Vec3f& start, const float maxRadius, const Flags includeFlags, const Settings& settings);
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ namespace DetourNavigator
|
|||
return result;
|
||||
}
|
||||
|
||||
boost::optional<SteerTarget> getSteerTarget(const dtNavMeshQuery& navQuery, const osg::Vec3f& startPos,
|
||||
std::optional<SteerTarget> getSteerTarget(const dtNavMeshQuery& navQuery, const osg::Vec3f& startPos,
|
||||
const osg::Vec3f& endPos, const float minTargetDist, const std::vector<dtPolyRef>& 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<std::size_t>(nsteerPath))
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
|
||||
dtVcopy(result.steerPos.ptr(), &steerPath[ns * 3]);
|
||||
result.steerPos.y() = startPos[1];
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace DetourNavigator
|
|||
dtPolyRef steerPosRef;
|
||||
};
|
||||
|
||||
boost::optional<SteerTarget> getSteerTarget(const dtNavMeshQuery& navQuery, const osg::Vec3f& startPos,
|
||||
std::optional<SteerTarget> getSteerTarget(const dtNavMeshQuery& navQuery, const osg::Vec3f& startPos,
|
||||
const osg::Vec3f& endPos, const float minTargetDist, const std::vector<dtPolyRef>& path);
|
||||
|
||||
template <class OutputIterator>
|
||||
|
@ -111,7 +111,7 @@ namespace DetourNavigator
|
|||
std::vector<dtPolyRef> mVisited;
|
||||
};
|
||||
|
||||
inline boost::optional<MoveAlongSurfaceResult> moveAlongSurface(const dtNavMeshQuery& navMeshQuery,
|
||||
inline std::optional<MoveAlongSurfaceResult> 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<std::vector<dtPolyRef>> findPath(const dtNavMeshQuery& navMeshQuery, const dtPolyRef startRef,
|
||||
inline std::optional<std::vector<dtPolyRef>> 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<float> getPolyHeight(const dtNavMeshQuery& navMeshQuery, const dtPolyRef ref, const osg::Vec3f& pos)
|
||||
inline std::optional<float> getPolyHeight(const dtNavMeshQuery& navMeshQuery, const dtPolyRef ref, const osg::Vec3f& pos)
|
||||
{
|
||||
float result = 0.0f;
|
||||
const auto status = navMeshQuery.getPolyHeight(ref, pos.ptr(), &result);
|
||||
|
|
|
@ -3,18 +3,18 @@
|
|||
|
||||
namespace DetourNavigator
|
||||
{
|
||||
boost::optional<osg::Vec3f> Navigator::findRandomPointAroundCircle(const osg::Vec3f& agentHalfExtents,
|
||||
std::optional<osg::Vec3f> 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<osg::Vec3f>();
|
||||
return std::optional<osg::Vec3f>();
|
||||
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<osg::Vec3f>();
|
||||
return boost::optional<osg::Vec3f>(fromNavMeshCoordinates(settings, *result));
|
||||
return std::optional<osg::Vec3f>();
|
||||
return std::optional<osg::Vec3f>(fromNavMeshCoordinates(settings, *result));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<osg::Vec3f> findRandomPointAroundCircle(const osg::Vec3f& agentHalfExtents,
|
||||
std::optional<osg::Vec3f> findRandomPointAroundCircle(const osg::Vec3f& agentHalfExtents,
|
||||
const osg::Vec3f& start, const float maxRadius, const Flags includeFlags) const;
|
||||
|
||||
virtual RecastMeshTiles getRecastMeshTiles() = 0;
|
||||
|
|
|
@ -34,11 +34,11 @@ namespace DetourNavigator
|
|||
return true;
|
||||
}
|
||||
|
||||
boost::optional<RemovedRecastMeshObject> RecastMeshManager::removeObject(const ObjectId id)
|
||||
std::optional<RemovedRecastMeshObject> 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::Water> RecastMeshManager::removeWater(const osg::Vec2i& cellPosition)
|
||||
std::optional<RecastMeshManager::Water> 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);
|
||||
|
|
|
@ -43,9 +43,9 @@ namespace DetourNavigator
|
|||
|
||||
bool addWater(const osg::Vec2i& cellPosition, const int cellSize, const btTransform& transform);
|
||||
|
||||
boost::optional<Water> removeWater(const osg::Vec2i& cellPosition);
|
||||
std::optional<Water> removeWater(const osg::Vec2i& cellPosition);
|
||||
|
||||
boost::optional<RemovedRecastMeshObject> removeObject(const ObjectId id);
|
||||
std::optional<RemovedRecastMeshObject> removeObject(const ObjectId id);
|
||||
|
||||
std::shared_ptr<RecastMesh> getMesh();
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
namespace DetourNavigator
|
||||
{
|
||||
boost::optional<Settings> makeSettingsFromSettingsManager()
|
||||
std::optional<Settings> makeSettingsFromSettingsManager()
|
||||
{
|
||||
if (!::Settings::Manager::getBool("enable", "Navigator"))
|
||||
return boost::optional<Settings>();
|
||||
return std::optional<Settings>();
|
||||
|
||||
Settings navigatorSettings;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace DetourNavigator
|
|||
std::chrono::milliseconds mMinUpdateInterval;
|
||||
};
|
||||
|
||||
boost::optional<Settings> makeSettingsFromSettingsManager();
|
||||
std::optional<Settings> makeSettingsFromSettingsManager();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -31,12 +31,12 @@ namespace DetourNavigator
|
|||
return result;
|
||||
}
|
||||
|
||||
boost::optional<RemovedRecastMeshObject> TileCachedRecastMeshManager::removeObject(const ObjectId id)
|
||||
std::optional<RemovedRecastMeshObject> TileCachedRecastMeshManager::removeObject(const ObjectId id)
|
||||
{
|
||||
const auto object = mObjectsTilesPositions.find(id);
|
||||
if (object == mObjectsTilesPositions.end())
|
||||
return boost::none;
|
||||
boost::optional<RemovedRecastMeshObject> result;
|
||||
return std::nullopt;
|
||||
std::optional<RemovedRecastMeshObject> result;
|
||||
{
|
||||
auto tiles = mTiles.lock();
|
||||
for (const auto& tilePosition : object->second)
|
||||
|
@ -100,12 +100,12 @@ namespace DetourNavigator
|
|||
return result;
|
||||
}
|
||||
|
||||
boost::optional<RecastMeshManager::Water> TileCachedRecastMeshManager::removeWater(const osg::Vec2i& cellPosition)
|
||||
std::optional<RecastMeshManager::Water> TileCachedRecastMeshManager::removeWater(const osg::Vec2i& cellPosition)
|
||||
{
|
||||
const auto object = mWaterTilesPositions.find(cellPosition);
|
||||
if (object == mWaterTilesPositions.end())
|
||||
return boost::none;
|
||||
boost::optional<RecastMeshManager::Water> result;
|
||||
return std::nullopt;
|
||||
std::optional<RecastMeshManager::Water> 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<RemovedRecastMeshObject> TileCachedRecastMeshManager::removeTile(const ObjectId id,
|
||||
std::optional<RemovedRecastMeshObject> TileCachedRecastMeshManager::removeTile(const ObjectId id,
|
||||
const TilePosition& tilePosition, std::map<TilePosition, CachedRecastMeshManager>& tiles)
|
||||
{
|
||||
const auto tile = tiles.find(tilePosition);
|
||||
if (tile == tiles.end())
|
||||
return boost::optional<RemovedRecastMeshObject>();
|
||||
return std::optional<RemovedRecastMeshObject>();
|
||||
const auto tileResult = tile->second.removeObject(id);
|
||||
if (tile->second.isEmpty())
|
||||
{
|
||||
|
|
|
@ -69,11 +69,11 @@ namespace DetourNavigator
|
|||
return changed;
|
||||
}
|
||||
|
||||
boost::optional<RemovedRecastMeshObject> removeObject(const ObjectId id);
|
||||
std::optional<RemovedRecastMeshObject> removeObject(const ObjectId id);
|
||||
|
||||
bool addWater(const osg::Vec2i& cellPosition, const int cellSize, const btTransform& transform);
|
||||
|
||||
boost::optional<RecastMeshManager::Water> removeWater(const osg::Vec2i& cellPosition);
|
||||
std::optional<RecastMeshManager::Water> removeWater(const osg::Vec2i& cellPosition);
|
||||
|
||||
std::shared_ptr<RecastMesh> 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<TilePosition, CachedRecastMeshManager>& tiles);
|
||||
|
||||
boost::optional<RemovedRecastMeshObject> removeTile(const ObjectId id, const TilePosition& tilePosition,
|
||||
std::optional<RemovedRecastMeshObject> removeTile(const ObjectId id, const TilePosition& tilePosition,
|
||||
std::map<TilePosition, CachedRecastMeshManager>& tiles);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue