2018-03-13 22:49:08 +00:00
|
|
|
#include "cachedrecastmeshmanager.hpp"
|
|
|
|
#include "debug.hpp"
|
|
|
|
|
|
|
|
namespace DetourNavigator
|
|
|
|
{
|
|
|
|
CachedRecastMeshManager::CachedRecastMeshManager(const Settings& settings)
|
|
|
|
: mImpl(settings)
|
2018-04-02 21:04:19 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
bool CachedRecastMeshManager::addObject(std::size_t id, const btCollisionShape& shape, const btTransform& transform)
|
2018-03-13 22:49:08 +00:00
|
|
|
{
|
2018-04-02 21:04:19 +00:00
|
|
|
if (!mImpl.addObject(id, shape, transform))
|
|
|
|
return false;
|
|
|
|
mCached.reset();
|
|
|
|
return true;
|
2018-03-13 22:49:08 +00:00
|
|
|
}
|
|
|
|
|
2018-04-01 00:44:16 +00:00
|
|
|
boost::optional<RecastMeshManager::Object> CachedRecastMeshManager::removeObject(std::size_t id)
|
2018-03-13 22:49:08 +00:00
|
|
|
{
|
2018-04-01 00:44:16 +00:00
|
|
|
const auto object = mImpl.removeObject(id);
|
|
|
|
if (object)
|
|
|
|
mCached.reset();
|
|
|
|
return object;
|
2018-03-13 22:49:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<RecastMesh> CachedRecastMeshManager::getMesh()
|
|
|
|
{
|
|
|
|
if (!mCached)
|
|
|
|
mCached = mImpl.getMesh();
|
|
|
|
return mCached;
|
2018-04-02 21:04:19 +00:00
|
|
|
}
|
2018-03-13 22:49:08 +00:00
|
|
|
}
|