1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 06:35:30 +00:00
OpenMW/components/detournavigator/tilecachedrecastmeshmanager.hpp

53 lines
1.7 KiB
C++
Raw Normal View History

2018-04-16 01:07:18 +03:00
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_TILECACHEDRECASTMESHMANAGER_H
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_TILECACHEDRECASTMESHMANAGER_H
#include "cachedrecastmeshmanager.hpp"
#include "tileposition.hpp"
2018-09-29 22:57:41 +03:00
#include <components/misc/guarded.hpp>
2018-04-16 01:07:18 +03:00
#include <map>
#include <mutex>
namespace DetourNavigator
{
class TileCachedRecastMeshManager
{
public:
TileCachedRecastMeshManager(const Settings& settings);
2018-09-22 18:36:57 +03:00
bool addObject(const ObjectId id, const btCollisionShape& shape, const btTransform& transform,
2018-07-18 22:09:50 +03:00
const AreaType areaType);
2018-04-16 01:07:18 +03:00
2018-09-22 18:36:57 +03:00
bool updateObject(const ObjectId id, const btTransform& transform, const AreaType areaType);
2018-05-26 17:44:25 +03:00
2018-09-22 18:36:57 +03:00
boost::optional<RemovedRecastMeshObject> removeObject(const ObjectId id);
2018-04-16 01:07:18 +03:00
2018-07-20 22:11:34 +03:00
bool addWater(const osg::Vec2i& cellPosition, const int cellSize, const btTransform& transform);
boost::optional<RecastMeshManager::Water> removeWater(const osg::Vec2i& cellPosition);
2018-04-16 01:07:18 +03:00
std::shared_ptr<RecastMesh> getMesh(const TilePosition& tilePosition);
bool hasTile(const TilePosition& tilePosition);
template <class Function>
void forEachTilePosition(Function&& function)
{
2018-09-29 22:57:41 +03:00
for (const auto& tile : *mTiles.lock())
function(tile.first);
}
std::size_t getRevision() const;
2018-04-16 01:07:18 +03:00
private:
const Settings& mSettings;
2018-09-29 22:57:41 +03:00
Misc::ScopeGuarded<std::map<TilePosition, CachedRecastMeshManager>> mTiles;
2018-09-22 18:36:57 +03:00
std::unordered_map<ObjectId, std::vector<TilePosition>> mObjectsTilesPositions;
2018-07-20 22:11:34 +03:00
std::map<osg::Vec2i, std::vector<TilePosition>> mWaterTilesPositions;
std::size_t mRevision = 0;
2018-04-16 01:07:18 +03:00
};
}
#endif