2018-03-14 01:49:08 +03:00
|
|
|
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESHBUILDER_H
|
|
|
|
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESHBUILDER_H
|
|
|
|
|
|
|
|
#include "recastmesh.hpp"
|
2018-04-16 01:07:18 +03:00
|
|
|
#include "tilebounds.hpp"
|
2018-03-14 01:49:08 +03:00
|
|
|
|
2021-07-11 21:43:19 +02:00
|
|
|
#include <osg/Vec3f>
|
|
|
|
|
2018-07-20 22:11:34 +03:00
|
|
|
#include <LinearMath/btTransform.h>
|
|
|
|
|
2021-07-11 21:43:19 +02:00
|
|
|
#include <array>
|
|
|
|
#include <functional>
|
|
|
|
#include <memory>
|
|
|
|
#include <tuple>
|
|
|
|
#include <vector>
|
|
|
|
|
2018-04-07 23:09:42 +03:00
|
|
|
class btBoxShape;
|
2018-04-03 00:04:19 +03:00
|
|
|
class btCollisionShape;
|
|
|
|
class btCompoundShape;
|
2018-03-14 01:49:08 +03:00
|
|
|
class btConcaveShape;
|
|
|
|
class btHeightfieldTerrainShape;
|
|
|
|
class btTriangleCallback;
|
|
|
|
|
|
|
|
namespace DetourNavigator
|
|
|
|
{
|
2021-07-11 21:43:19 +02:00
|
|
|
struct RecastMeshTriangle
|
|
|
|
{
|
|
|
|
AreaType mAreaType;
|
|
|
|
std::array<osg::Vec3f, 3> mVertices;
|
|
|
|
|
|
|
|
friend inline bool operator<(const RecastMeshTriangle& lhs, const RecastMeshTriangle& rhs)
|
|
|
|
{
|
|
|
|
return std::tie(lhs.mAreaType, lhs.mVertices) < std::tie(rhs.mAreaType, rhs.mVertices);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-03-14 01:49:08 +03:00
|
|
|
class RecastMeshBuilder
|
|
|
|
{
|
|
|
|
public:
|
2021-07-16 20:19:11 +02:00
|
|
|
explicit RecastMeshBuilder(const TileBounds& bounds) noexcept;
|
2018-03-14 01:49:08 +03:00
|
|
|
|
2018-07-18 22:09:50 +03:00
|
|
|
void addObject(const btCollisionShape& shape, const btTransform& transform, const AreaType areaType);
|
2018-04-03 00:04:19 +03:00
|
|
|
|
2018-07-18 22:09:50 +03:00
|
|
|
void addObject(const btCompoundShape& shape, const btTransform& transform, const AreaType areaType);
|
2018-04-03 00:04:19 +03:00
|
|
|
|
2018-07-18 22:09:50 +03:00
|
|
|
void addObject(const btConcaveShape& shape, const btTransform& transform, const AreaType areaType);
|
2018-03-14 01:49:08 +03:00
|
|
|
|
2018-07-18 22:09:50 +03:00
|
|
|
void addObject(const btHeightfieldTerrainShape& shape, const btTransform& transform, const AreaType areaType);
|
2018-03-14 01:49:08 +03:00
|
|
|
|
2018-07-18 22:09:50 +03:00
|
|
|
void addObject(const btBoxShape& shape, const btTransform& transform, const AreaType areaType);
|
2018-04-07 23:09:42 +03:00
|
|
|
|
2021-07-14 21:54:41 +02:00
|
|
|
void addWater(const int mCellSize, const osg::Vec3f& shift);
|
2018-07-20 22:11:34 +03:00
|
|
|
|
2021-07-03 02:59:07 +02:00
|
|
|
std::shared_ptr<RecastMesh> create(std::size_t generation, std::size_t revision) &&;
|
2018-03-14 01:49:08 +03:00
|
|
|
|
|
|
|
private:
|
2021-07-16 20:19:11 +02:00
|
|
|
const TileBounds mBounds;
|
2021-07-11 21:43:19 +02:00
|
|
|
std::vector<RecastMeshTriangle> mTriangles;
|
2021-07-14 22:00:16 +02:00
|
|
|
std::vector<Cell> mWater;
|
2018-03-14 01:49:08 +03:00
|
|
|
|
2018-04-16 01:07:18 +03:00
|
|
|
void addObject(const btConcaveShape& shape, const btTransform& transform, btTriangleCallback&& callback);
|
2018-03-14 01:49:08 +03:00
|
|
|
|
2019-11-29 21:17:52 +01:00
|
|
|
void addObject(const btHeightfieldTerrainShape& shape, const btTransform& transform, btTriangleCallback&& callback);
|
2018-03-14 01:49:08 +03:00
|
|
|
};
|
2021-07-11 21:43:19 +02:00
|
|
|
|
|
|
|
Mesh makeMesh(std::vector<RecastMeshTriangle>&& triangles);
|
2018-03-14 01:49:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|