2018-03-14 01:49:08 +03:00
|
|
|
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESHMANAGER_H
|
|
|
|
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESHMANAGER_H
|
|
|
|
|
|
|
|
#include "recastmeshbuilder.hpp"
|
2018-05-26 17:44:25 +03:00
|
|
|
#include "recastmeshobject.hpp"
|
2018-09-22 18:36:57 +03:00
|
|
|
#include "objectid.hpp"
|
2018-03-14 01:49:08 +03:00
|
|
|
|
|
|
|
#include <LinearMath/btTransform.h>
|
|
|
|
|
2018-07-20 22:11:34 +03:00
|
|
|
#include <osg/Vec2i>
|
|
|
|
|
2018-04-01 03:44:16 +03:00
|
|
|
#include <boost/optional.hpp>
|
|
|
|
|
2018-07-20 22:11:34 +03:00
|
|
|
#include <map>
|
2018-03-14 01:49:08 +03:00
|
|
|
#include <unordered_map>
|
2018-10-01 01:33:25 +03:00
|
|
|
#include <list>
|
2018-03-14 01:49:08 +03:00
|
|
|
|
|
|
|
class btCollisionShape;
|
|
|
|
|
|
|
|
namespace DetourNavigator
|
|
|
|
{
|
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:
|
2018-07-20 22:11:34 +03:00
|
|
|
struct Water
|
|
|
|
{
|
|
|
|
int mCellSize;
|
|
|
|
btTransform mTransform;
|
|
|
|
};
|
|
|
|
|
2018-04-16 01:07:18 +03:00
|
|
|
RecastMeshManager(const Settings& settings, const TileBounds& bounds);
|
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
|
|
|
|
2018-07-20 22:11:34 +03:00
|
|
|
bool addWater(const osg::Vec2i& cellPosition, const int cellSize, const btTransform& transform);
|
|
|
|
|
|
|
|
boost::optional<Water> removeWater(const osg::Vec2i& cellPosition);
|
|
|
|
|
2018-09-22 18:36:57 +03:00
|
|
|
boost::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;
|
|
|
|
|
2018-03-14 01:49:08 +03:00
|
|
|
private:
|
|
|
|
bool mShouldRebuild;
|
|
|
|
RecastMeshBuilder mMeshBuilder;
|
2018-10-01 01:33:25 +03: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-14 01:49:08 +03:00
|
|
|
|
|
|
|
void rebuild();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|