2018-03-13 22:49:08 +00:00
|
|
|
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESHMANAGER_H
|
|
|
|
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESHMANAGER_H
|
|
|
|
|
|
|
|
#include "recastmeshbuilder.hpp"
|
2018-05-26 14:44:25 +00:00
|
|
|
#include "recastmeshobject.hpp"
|
2018-09-22 15:36:57 +00:00
|
|
|
#include "objectid.hpp"
|
2018-03-13 22:49:08 +00:00
|
|
|
|
|
|
|
#include <LinearMath/btTransform.h>
|
|
|
|
|
2018-07-20 19:11:34 +00:00
|
|
|
#include <osg/Vec2i>
|
|
|
|
|
2018-04-01 00:44:16 +00:00
|
|
|
#include <boost/optional.hpp>
|
|
|
|
|
2018-07-20 19:11:34 +00:00
|
|
|
#include <map>
|
2018-03-13 22:49:08 +00:00
|
|
|
#include <unordered_map>
|
2018-09-30 22:33:25 +00:00
|
|
|
#include <list>
|
2018-03-13 22:49:08 +00:00
|
|
|
|
|
|
|
class btCollisionShape;
|
|
|
|
|
|
|
|
namespace DetourNavigator
|
|
|
|
{
|
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
|
|
|
|
{
|
2019-12-22 06:44:14 +00:00
|
|
|
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
|
|
|
|
2018-09-22 15:36:57 +00:00
|
|
|
bool addObject(const ObjectId id, const btCollisionShape& 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);
|
|
|
|
|
2020-10-24 22:33:41 +00:00
|
|
|
std::optional<Water> removeWater(const osg::Vec2i& cellPosition);
|
2018-07-20 19:11:34 +00:00
|
|
|
|
2020-10-24 22:33:41 +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;
|
|
|
|
|
2018-03-13 22:49:08 +00:00
|
|
|
private:
|
2019-11-27 22:45:01 +00:00
|
|
|
std::size_t mRevision = 0;
|
|
|
|
std::size_t mLastBuildRevision = 0;
|
|
|
|
std::size_t mGeneration;
|
2018-03-13 22:49:08 +00:00
|
|
|
RecastMeshBuilder mMeshBuilder;
|
2018-09-30 22:33:25 +00:00
|
|
|
std::list<RecastMeshObject> mObjectsOrder;
|
|
|
|
std::unordered_map<ObjectId, std::list<RecastMeshObject>::iterator> mObjects;
|
|
|
|
std::list<Water> mWaterOrder;
|
|
|
|
std::map<osg::Vec2i, std::list<Water>::iterator> mWater;
|
2018-03-13 22:49:08 +00:00
|
|
|
|
|
|
|
void rebuild();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|