Add cached flag to update navmesh status

pull/3011/head
elsid 4 years ago
parent eb140ed15f
commit f637dc38bd
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

@ -38,6 +38,12 @@ namespace DetourNavigator
return stream << "failed";
case UpdateNavMeshStatus::lost:
return stream << "lost";
case UpdateNavMeshStatus::cached:
return stream << "cached";
case UpdateNavMeshStatus::unchanged:
return stream << "unchanged";
case UpdateNavMeshStatus::restored:
return stream << "restored";
}
return stream << "unknown(" << static_cast<unsigned>(value) << ")";
}

@ -559,6 +559,7 @@ namespace DetourNavigator
}
auto cachedNavMeshData = navMeshTilesCache.get(agentHalfExtents, changedTile, *recastMesh, offMeshConnections);
bool cached = static_cast<bool>(cachedNavMeshData);
if (!cachedNavMeshData)
{
@ -584,6 +585,7 @@ namespace DetourNavigator
{
cachedNavMeshData = navMeshTilesCache.get(agentHalfExtents, changedTile, *recastMesh,
offMeshConnections);
cached = static_cast<bool>(cachedNavMeshData);
}
if (!cachedNavMeshData)
@ -593,6 +595,8 @@ namespace DetourNavigator
}
}
return navMeshCacheItem->lock()->updateTile(changedTile, std::move(cachedNavMeshData));
const auto updateStatus = navMeshCacheItem->lock()->updateTile(changedTile, std::move(cachedNavMeshData));
return UpdateNavMeshStatusBuilder(updateStatus).cached(cached).getResult();
}
}

@ -22,6 +22,9 @@ namespace DetourNavigator
replaced = removed | added,
failed = 1 << 2,
lost = removed | failed,
cached = 1 << 3,
unchanged = replaced | cached,
restored = added | cached,
};
inline bool isSuccess(UpdateNavMeshStatus value)
@ -34,6 +37,9 @@ namespace DetourNavigator
public:
UpdateNavMeshStatusBuilder() = default;
explicit UpdateNavMeshStatusBuilder(UpdateNavMeshStatus value)
: mResult(value) {}
UpdateNavMeshStatusBuilder removed(bool value)
{
if (value)
@ -61,6 +67,15 @@ namespace DetourNavigator
return *this;
}
UpdateNavMeshStatusBuilder cached(bool value)
{
if (value)
set(UpdateNavMeshStatus::cached);
else
unset(UpdateNavMeshStatus::cached);
return *this;
}
UpdateNavMeshStatus getResult() const
{
return mResult;

Loading…
Cancel
Save