2018-03-13 22:49:08 +00:00
|
|
|
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESHMANAGER_H
|
|
|
|
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESHMANAGER_H
|
|
|
|
|
2021-04-18 14:51:52 +00:00
|
|
|
#include "oscillatingrecastmeshobject.hpp"
|
2018-09-22 15:36:57 +00:00
|
|
|
#include "objectid.hpp"
|
2021-04-18 14:51:52 +00:00
|
|
|
#include "version.hpp"
|
2021-07-14 19:39:39 +00:00
|
|
|
#include "recastmesh.hpp"
|
2021-07-14 18:57:52 +00:00
|
|
|
#include "heightfieldshape.hpp"
|
2018-03-13 22:49:08 +00:00
|
|
|
|
|
|
|
#include <LinearMath/btTransform.h>
|
|
|
|
|
2018-07-20 19:11:34 +00:00
|
|
|
#include <osg/Vec2i>
|
|
|
|
|
|
|
|
#include <map>
|
2020-10-24 23:34:04 +00:00
|
|
|
#include <optional>
|
2021-07-03 00:59:07 +00:00
|
|
|
#include <memory>
|
2021-08-01 00:43:36 +00:00
|
|
|
#include <mutex>
|
2018-03-13 22:49:08 +00:00
|
|
|
|
|
|
|
class btCollisionShape;
|
|
|
|
|
|
|
|
namespace DetourNavigator
|
|
|
|
{
|
2021-07-03 00:59:07 +00:00
|
|
|
struct Settings;
|
|
|
|
class RecastMesh;
|
|
|
|
|
2018-05-26 14:44:25 +00:00
|
|
|
struct RemovedRecastMeshObject
|
|
|
|
{
|
|
|
|
std::reference_wrapper<const btCollisionShape> mShape;
|
|
|
|
btTransform mTransform;
|
|
|
|
};
|
|
|
|
|
2021-11-04 02:19:41 +00:00
|
|
|
struct SizedHeightfieldShape
|
|
|
|
{
|
|
|
|
int mCellSize;
|
|
|
|
HeightfieldShape mShape;
|
|
|
|
};
|
|
|
|
|
2018-03-13 22:49:08 +00:00
|
|
|
class RecastMeshManager
|
|
|
|
{
|
|
|
|
public:
|
2021-11-05 19:47:11 +00:00
|
|
|
explicit RecastMeshManager(const TileBounds& bounds, std::size_t generation);
|
2018-03-13 22:49:08 +00:00
|
|
|
|
2021-08-01 00:13:55 +00:00
|
|
|
bool addObject(const ObjectId id, const CollisionShape& shape, const btTransform& transform,
|
2018-07-18 19:09:50 +00:00
|
|
|
const AreaType areaType);
|
2018-03-13 22:49:08 +00:00
|
|
|
|
2018-09-22 15:36:57 +00:00
|
|
|
bool updateObject(const ObjectId id, const btTransform& transform, const AreaType areaType);
|
2018-05-26 14:44:25 +00:00
|
|
|
|
2021-07-14 18:57:52 +00:00
|
|
|
std::optional<RemovedRecastMeshObject> removeObject(const ObjectId id);
|
|
|
|
|
2021-11-04 01:48:32 +00:00
|
|
|
bool addWater(const osg::Vec2i& cellPosition, int cellSize, float level);
|
2018-07-20 19:11:34 +00:00
|
|
|
|
2021-11-04 01:48:32 +00:00
|
|
|
std::optional<Water> removeWater(const osg::Vec2i& cellPosition);
|
2018-07-20 19:11:34 +00:00
|
|
|
|
2021-11-04 02:19:41 +00:00
|
|
|
bool addHeightfield(const osg::Vec2i& cellPosition, int cellSize, const HeightfieldShape& shape);
|
2021-07-14 18:57:52 +00:00
|
|
|
|
2021-11-04 02:19:41 +00:00
|
|
|
std::optional<SizedHeightfieldShape> removeHeightfield(const osg::Vec2i& cellPosition);
|
2018-03-13 22:49:08 +00:00
|
|
|
|
2021-08-08 14:58:47 +00:00
|
|
|
std::shared_ptr<RecastMesh> getMesh() const;
|
2018-03-13 22:49:08 +00:00
|
|
|
|
2018-04-15 22:07:18 +00:00
|
|
|
bool isEmpty() const;
|
|
|
|
|
2021-06-25 19:52:02 +00:00
|
|
|
void reportNavMeshChange(const Version& recastMeshVersion, const Version& navMeshVersion);
|
2021-04-18 14:51:52 +00:00
|
|
|
|
2021-05-26 23:09:58 +00:00
|
|
|
Version getVersion() const;
|
|
|
|
|
2018-03-13 22:49:08 +00:00
|
|
|
private:
|
2021-04-18 14:51:52 +00:00
|
|
|
struct Report
|
|
|
|
{
|
|
|
|
std::size_t mRevision;
|
|
|
|
Version mNavMeshVersion;
|
|
|
|
};
|
|
|
|
|
2021-08-01 00:43:36 +00:00
|
|
|
const std::size_t mGeneration;
|
|
|
|
const TileBounds mTileBounds;
|
|
|
|
mutable std::mutex mMutex;
|
2019-11-27 22:45:01 +00:00
|
|
|
std::size_t mRevision = 0;
|
2021-07-11 19:43:19 +00:00
|
|
|
std::map<ObjectId, OscillatingRecastMeshObject> mObjects;
|
2021-11-04 01:48:32 +00:00
|
|
|
std::map<osg::Vec2i, Water> mWater;
|
2021-11-04 02:19:41 +00:00
|
|
|
std::map<osg::Vec2i, SizedHeightfieldShape> mHeightfields;
|
2021-04-18 14:51:52 +00:00
|
|
|
std::optional<Report> mLastNavMeshReportedChange;
|
|
|
|
std::optional<Report> mLastNavMeshReport;
|
2018-03-13 22:49:08 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|