You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openmw/components/detournavigator/tilecachedrecastmeshmanager...

48 lines
1.4 KiB
C++

#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_TILECACHEDRECASTMESHMANAGER_H
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_TILECACHEDRECASTMESHMANAGER_H
#include "cachedrecastmeshmanager.hpp"
#include "tileposition.hpp"
#include <map>
#include <mutex>
namespace DetourNavigator
{
class TileCachedRecastMeshManager
{
public:
TileCachedRecastMeshManager(const Settings& settings);
bool addObject(std::size_t id, const btCollisionShape& shape, const btTransform& transform,
const AreaType areaType);
bool updateObject(std::size_t id, const btTransform& transform, const AreaType areaType);
boost::optional<RemovedRecastMeshObject> removeObject(std::size_t id);
std::shared_ptr<RecastMesh> getMesh(const TilePosition& tilePosition);
bool hasTile(const TilePosition& tilePosition);
template <class Function>
void forEachTilePosition(Function&& function)
{
const std::lock_guard<std::mutex> lock(mTilesMutex);
for (const auto& tile : mTiles)
function(tile.first);
}
std::size_t getRevision() const;
private:
const Settings& mSettings;
std::mutex mTilesMutex;
std::map<TilePosition, CachedRecastMeshManager> mTiles;
std::unordered_map<std::size_t, std::vector<TilePosition>> mObjectsTilesPositions;
std::size_t mRevision = 0;
};
}
#endif