mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-15 17:49:55 +00:00
d122e184cc
Corresponding recast mesh tiles can be updated but navmesh tiles may never appear for them. Report back zero navmesh version to allow oscillating recast objects detection to work. This version is always less than any generated navmesh tile version so any report for generated navmesh will override it. If zero navmesh version is reported after recast mesh tile got report about generated navmesh tile it is a no-op since generated version is always greater than zero.
74 lines
2.2 KiB
C++
74 lines
2.2 KiB
C++
#include "cachedrecastmeshmanager.hpp"
|
|
#include "debug.hpp"
|
|
|
|
namespace DetourNavigator
|
|
{
|
|
CachedRecastMeshManager::CachedRecastMeshManager(const Settings& settings, const TileBounds& bounds,
|
|
std::size_t generation)
|
|
: mImpl(settings, bounds, generation)
|
|
{}
|
|
|
|
bool CachedRecastMeshManager::addObject(const ObjectId id, const btCollisionShape& shape,
|
|
const btTransform& transform, const AreaType areaType)
|
|
{
|
|
if (!mImpl.addObject(id, shape, transform, areaType))
|
|
return false;
|
|
mCached.reset();
|
|
return true;
|
|
}
|
|
|
|
bool CachedRecastMeshManager::updateObject(const ObjectId id, const btTransform& transform, const AreaType areaType)
|
|
{
|
|
if (!mImpl.updateObject(id, transform, areaType))
|
|
return false;
|
|
mCached.reset();
|
|
return true;
|
|
}
|
|
|
|
std::optional<RemovedRecastMeshObject> CachedRecastMeshManager::removeObject(const ObjectId id)
|
|
{
|
|
const auto object = mImpl.removeObject(id);
|
|
if (object)
|
|
mCached.reset();
|
|
return object;
|
|
}
|
|
|
|
bool CachedRecastMeshManager::addWater(const osg::Vec2i& cellPosition, const int cellSize,
|
|
const btTransform& transform)
|
|
{
|
|
if (!mImpl.addWater(cellPosition, cellSize, transform))
|
|
return false;
|
|
mCached.reset();
|
|
return true;
|
|
}
|
|
|
|
std::optional<RecastMeshManager::Water> CachedRecastMeshManager::removeWater(const osg::Vec2i& cellPosition)
|
|
{
|
|
const auto water = mImpl.removeWater(cellPosition);
|
|
if (water)
|
|
mCached.reset();
|
|
return water;
|
|
}
|
|
|
|
std::shared_ptr<RecastMesh> CachedRecastMeshManager::getMesh()
|
|
{
|
|
if (!mCached)
|
|
mCached = mImpl.getMesh();
|
|
return mCached;
|
|
}
|
|
|
|
bool CachedRecastMeshManager::isEmpty() const
|
|
{
|
|
return mImpl.isEmpty();
|
|
}
|
|
|
|
void CachedRecastMeshManager::reportNavMeshChange(Version recastMeshVersion, Version navMeshVersion)
|
|
{
|
|
mImpl.reportNavMeshChange(recastMeshVersion, navMeshVersion);
|
|
}
|
|
|
|
Version CachedRecastMeshManager::getVersion() const
|
|
{
|
|
return mImpl.getVersion();
|
|
}
|
|
}
|