2018-03-14 01:49:08 +03:00
|
|
|
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_CACHEDRECASTMESHMANAGER_H
|
|
|
|
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_CACHEDRECASTMESHMANAGER_H
|
|
|
|
|
|
|
|
#include "recastmeshmanager.hpp"
|
2021-04-18 16:51:52 +02:00
|
|
|
#include "version.hpp"
|
2021-07-14 20:57:52 +02:00
|
|
|
#include "heightfieldshape.hpp"
|
2018-03-14 01:49:08 +03:00
|
|
|
|
2021-08-01 02:43:36 +02:00
|
|
|
#include <components/misc/guarded.hpp>
|
|
|
|
|
2021-10-09 18:36:37 +02:00
|
|
|
#include <atomic>
|
|
|
|
|
2018-03-14 01:49:08 +03:00
|
|
|
namespace DetourNavigator
|
|
|
|
{
|
|
|
|
class CachedRecastMeshManager
|
|
|
|
{
|
|
|
|
public:
|
2021-11-05 20:47:11 +01:00
|
|
|
explicit CachedRecastMeshManager(const TileBounds& bounds, std::size_t generation);
|
2018-03-14 01:49:08 +03:00
|
|
|
|
2021-08-01 02:13:55 +02:00
|
|
|
bool addObject(const ObjectId id, const CollisionShape& shape, const btTransform& transform,
|
2018-07-18 22:09:50 +03:00
|
|
|
const AreaType areaType);
|
2018-03-14 01:49:08 +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
|
|
|
|
2021-07-14 20:57:52 +02:00
|
|
|
std::optional<RemovedRecastMeshObject> removeObject(const ObjectId id);
|
|
|
|
|
2021-11-04 02:48:32 +01:00
|
|
|
bool addWater(const osg::Vec2i& cellPosition, int cellSize, float level);
|
2018-07-20 22:11:34 +03:00
|
|
|
|
2021-11-04 02:48:32 +01:00
|
|
|
std::optional<Water> removeWater(const osg::Vec2i& cellPosition);
|
2018-07-20 22:11:34 +03:00
|
|
|
|
2021-11-04 03:19:41 +01:00
|
|
|
bool addHeightfield(const osg::Vec2i& cellPosition, int cellSize, const HeightfieldShape& shape);
|
2021-07-14 20:57:52 +02:00
|
|
|
|
2021-11-04 03:19:41 +01:00
|
|
|
std::optional<SizedHeightfieldShape> removeHeightfield(const osg::Vec2i& cellPosition);
|
2018-03-14 01:49:08 +03:00
|
|
|
|
|
|
|
std::shared_ptr<RecastMesh> getMesh();
|
|
|
|
|
2021-10-09 18:36:37 +02:00
|
|
|
std::shared_ptr<RecastMesh> getCachedMesh() const;
|
|
|
|
|
2021-06-29 03:49:21 +02:00
|
|
|
std::shared_ptr<RecastMesh> getNewMesh() const;
|
|
|
|
|
2018-04-16 01:07:18 +03:00
|
|
|
bool isEmpty() const;
|
|
|
|
|
2021-06-25 21:52:02 +02:00
|
|
|
void reportNavMeshChange(const Version& recastMeshVersion, const Version& navMeshVersion);
|
2021-04-18 16:51:52 +02:00
|
|
|
|
2021-05-27 01:09:58 +02:00
|
|
|
Version getVersion() const;
|
|
|
|
|
2018-03-14 01:49:08 +03:00
|
|
|
private:
|
|
|
|
RecastMeshManager mImpl;
|
2021-08-01 02:43:36 +02:00
|
|
|
Misc::ScopeGuarded<std::shared_ptr<RecastMesh>> mCached;
|
2021-10-09 18:36:37 +02:00
|
|
|
std::atomic_bool mOutdatedCache {true};
|
2018-03-14 01:49:08 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|