2018-03-14 01:49:08 +03:00
|
|
|
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESHMANAGER_H
|
|
|
|
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESHMANAGER_H
|
|
|
|
|
2021-04-18 16:51:52 +02:00
|
|
|
#include "oscillatingrecastmeshobject.hpp"
|
2018-09-22 18:36:57 +03:00
|
|
|
#include "objectid.hpp"
|
2021-04-18 16:51:52 +02:00
|
|
|
#include "version.hpp"
|
2021-07-14 21:39:39 +02:00
|
|
|
#include "recastmesh.hpp"
|
2018-03-14 01:49:08 +03:00
|
|
|
|
|
|
|
#include <LinearMath/btTransform.h>
|
|
|
|
|
2018-07-20 22:11:34 +03:00
|
|
|
#include <osg/Vec2i>
|
|
|
|
|
|
|
|
#include <map>
|
2020-10-25 01:34:04 +02:00
|
|
|
#include <optional>
|
2021-07-03 02:59:07 +02:00
|
|
|
#include <memory>
|
2018-03-14 01:49:08 +03:00
|
|
|
|
|
|
|
class btCollisionShape;
|
|
|
|
|
|
|
|
namespace DetourNavigator
|
|
|
|
{
|
2021-07-03 02:59:07 +02:00
|
|
|
struct Settings;
|
|
|
|
class RecastMesh;
|
|
|
|
|
2018-05-26 17:44:25 +03:00
|
|
|
struct RemovedRecastMeshObject
|
|
|
|
{
|
|
|
|
std::reference_wrapper<const btCollisionShape> mShape;
|
|
|
|
btTransform mTransform;
|
|
|
|
};
|
|
|
|
|
2018-03-14 01:49:08 +03:00
|
|
|
class RecastMeshManager
|
|
|
|
{
|
|
|
|
public:
|
2019-11-27 23:45:01 +01:00
|
|
|
RecastMeshManager(const Settings& settings, const TileBounds& bounds, std::size_t generation);
|
2018-03-14 01:49:08 +03:00
|
|
|
|
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-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 21:54:41 +02:00
|
|
|
bool addWater(const osg::Vec2i& cellPosition, const int cellSize, const osg::Vec3f& shift);
|
2018-07-20 22:11:34 +03:00
|
|
|
|
2021-07-14 22:00:16 +02:00
|
|
|
std::optional<Cell> removeWater(const osg::Vec2i& cellPosition);
|
2018-07-20 22:11:34 +03:00
|
|
|
|
2020-10-25 00:33:41 +02:00
|
|
|
std::optional<RemovedRecastMeshObject> removeObject(const ObjectId id);
|
2018-03-14 01:49:08 +03:00
|
|
|
|
|
|
|
std::shared_ptr<RecastMesh> getMesh();
|
|
|
|
|
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:
|
2021-04-18 16:51:52 +02:00
|
|
|
struct Report
|
|
|
|
{
|
|
|
|
std::size_t mRevision;
|
|
|
|
Version mNavMeshVersion;
|
|
|
|
};
|
|
|
|
|
2021-07-03 02:59:07 +02:00
|
|
|
const Settings& mSettings;
|
2019-11-27 23:45:01 +01:00
|
|
|
std::size_t mRevision = 0;
|
|
|
|
std::size_t mGeneration;
|
2021-05-27 01:59:07 +02:00
|
|
|
TileBounds mTileBounds;
|
2021-07-11 21:43:19 +02:00
|
|
|
std::map<ObjectId, OscillatingRecastMeshObject> mObjects;
|
2021-07-14 22:00:16 +02:00
|
|
|
std::map<osg::Vec2i, Cell> mWater;
|
2021-04-18 16:51:52 +02:00
|
|
|
std::optional<Report> mLastNavMeshReportedChange;
|
|
|
|
std::optional<Report> mLastNavMeshReport;
|
2018-03-14 01:49:08 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|