mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-15 15:49:56 +00:00
3e67f5ffa5
To avoid triggering NavMesh update when RecastMesh change should not change NavMesh. Based on the following assumption: Given a set of transformations and a bounding shape for all these tranformations, a new object transformation that does not change this bounding shape also should not change navmesh if for all of this object transformations resulting navmesh tiles are equivalent The idea is to report back to RecastMeshManager all changes of NavMesh if there are any assiciated with RecastMesh version. So we know the last time when RecastMesh change resulted into the NavMesh change. When later report shows that there was no NavMesh change for a new RecastMesh version we can assume that any object transformation within the same bounding box should not change NavMesh.
69 lines
2.1 KiB
C++
69 lines
2.1 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);
|
|
}
|
|
}
|