1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 19:19:55 +00:00
openmw-tes3mp/components/detournavigator/recastmeshmanager.hpp

83 lines
2.2 KiB
C++
Raw Normal View History

2018-03-13 22:49:08 +00:00
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESHMANAGER_H
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESHMANAGER_H
#include "oscillatingrecastmeshobject.hpp"
2018-09-22 15:36:57 +00:00
#include "objectid.hpp"
#include "version.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 <list>
2018-07-20 19:11:34 +00:00
#include <map>
#include <optional>
#include <memory>
#include <mutex>
2018-03-13 22:49:08 +00:00
class btCollisionShape;
namespace DetourNavigator
{
struct Settings;
class RecastMesh;
2018-05-26 14:44:25 +00:00
struct RemovedRecastMeshObject
{
std::reference_wrapper<const btCollisionShape> mShape;
btTransform mTransform;
};
2018-03-13 22:49:08 +00:00
class RecastMeshManager
{
public:
2018-07-20 19:11:34 +00:00
struct Water
{
int mCellSize = 0;
2018-07-20 19:11:34 +00:00
btTransform mTransform;
};
2019-11-27 22:45:01 +00:00
RecastMeshManager(const Settings& settings, const TileBounds& bounds, std::size_t generation);
2018-03-13 22:49:08 +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
2018-07-20 19:11:34 +00:00
bool addWater(const osg::Vec2i& cellPosition, const int cellSize, const btTransform& transform);
std::optional<Water> removeWater(const osg::Vec2i& cellPosition);
2018-07-20 19:11:34 +00:00
std::optional<RemovedRecastMeshObject> removeObject(const ObjectId id);
2018-03-13 22:49:08 +00:00
std::shared_ptr<RecastMesh> getMesh();
2018-04-15 22:07:18 +00:00
bool isEmpty() const;
void reportNavMeshChange(Version recastMeshVersion, Version navMeshVersion);
Version getVersion() const;
2018-03-13 22:49:08 +00:00
private:
struct Report
{
std::size_t mRevision;
Version mNavMeshVersion;
};
const Settings& mSettings;
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;
std::list<OscillatingRecastMeshObject> mObjectsOrder;
std::map<ObjectId, std::list<OscillatingRecastMeshObject>::iterator> mObjects;
std::list<Water> mWaterOrder;
std::map<osg::Vec2i, std::list<Water>::iterator> mWater;
std::optional<Report> mLastNavMeshReportedChange;
std::optional<Report> mLastNavMeshReport;
2018-03-13 22:49:08 +00:00
};
}
#endif