1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 17:49:55 +00:00
openmw-tes3mp/components/detournavigator/cachedrecastmeshmanager.cpp

78 lines
2.3 KiB
C++
Raw Normal View History

2018-03-13 22:49:08 +00:00
#include "cachedrecastmeshmanager.hpp"
#include "debug.hpp"
namespace DetourNavigator
{
2019-11-27 22:45:01 +00:00
CachedRecastMeshManager::CachedRecastMeshManager(const Settings& settings, const TileBounds& bounds,
std::size_t generation)
: mImpl(settings, bounds, generation)
2018-07-12 08:44:11 +00:00
{}
2018-04-02 21:04:19 +00:00
bool CachedRecastMeshManager::addObject(const ObjectId id, const CollisionShape& shape,
2018-07-18 19:09:50 +00:00
const btTransform& transform, const AreaType areaType)
2018-03-13 22:49:08 +00:00
{
2018-07-18 19:09:50 +00:00
if (!mImpl.addObject(id, shape, transform, areaType))
2018-04-02 21:04:19 +00:00
return false;
mCached.lock()->reset();
2018-04-02 21:04:19 +00:00
return true;
2018-03-13 22:49:08 +00:00
}
2018-09-22 15:36:57 +00:00
bool CachedRecastMeshManager::updateObject(const ObjectId id, const btTransform& transform, const AreaType areaType)
2018-05-26 14:44:25 +00:00
{
2018-07-18 19:09:50 +00:00
if (!mImpl.updateObject(id, transform, areaType))
2018-05-26 14:44:25 +00:00
return false;
mCached.lock()->reset();
2018-05-26 14:44:25 +00:00
return true;
}
std::optional<RemovedRecastMeshObject> CachedRecastMeshManager::removeObject(const ObjectId id)
2018-03-13 22:49:08 +00:00
{
const auto object = mImpl.removeObject(id);
if (object)
mCached.lock()->reset();
return object;
2018-03-13 22:49:08 +00:00
}
2018-07-20 19:11:34 +00:00
bool CachedRecastMeshManager::addWater(const osg::Vec2i& cellPosition, const int cellSize,
const btTransform& transform)
{
if (!mImpl.addWater(cellPosition, cellSize, transform))
return false;
mCached.lock()->reset();
2018-07-20 19:11:34 +00:00
return true;
}
std::optional<RecastMeshManager::Water> CachedRecastMeshManager::removeWater(const osg::Vec2i& cellPosition)
2018-07-20 19:11:34 +00:00
{
const auto water = mImpl.removeWater(cellPosition);
if (water)
mCached.lock()->reset();
2018-07-20 19:11:34 +00:00
return water;
}
2018-03-13 22:49:08 +00:00
std::shared_ptr<RecastMesh> CachedRecastMeshManager::getMesh()
{
std::shared_ptr<RecastMesh> cached = *mCached.lock();
if (cached != nullptr)
return cached;
cached = mImpl.getMesh();
*mCached.lock() = cached;
return cached;
2018-04-02 21:04:19 +00:00
}
2018-04-15 22:07:18 +00:00
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();
}
2018-03-13 22:49:08 +00:00
}