-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtriangle_lib_navmesh.h
More file actions
65 lines (53 loc) · 2.71 KB
/
triangle_lib_navmesh.h
File metadata and controls
65 lines (53 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef PATHFINDER_NAVMESH_TRIANGLE_LIB_NAVMESH_H_
#define PATHFINDER_NAVMESH_TRIANGLE_LIB_NAVMESH_H_
#include "navmesh_astar_state.h"
#include "navmesh_types.h"
#include "vector.h"
#include "triangle/triangle_api.h"
#include <optional>
#include <utility>
#include <vector>
namespace pathfinder {
namespace navmesh {
class TriangleLibNavmesh : public NavmeshTypes<uint16_t> {
public:
using State = NavmeshAStarState<IndexType>;
using MarkerType = int;
TriangleLibNavmesh(const triangle::triangleio &triangleData, const triangle::triangleio &triangleVoronoiData);
std::size_t getVertexCount() const;
Vector getVertex(const IndexType vertexIndex) const;
MarkerType getVertexMarker(const IndexType vertexIndex) const;
std::size_t getEdgeCount() const;
EdgeType getEdge(const IndexType edgeIndex) const;
EdgeVertexIndicesType getEdgeVertexIndices(const IndexType edgeIndex) const;
MarkerType getEdgeMarker(const IndexType edgeIndex) const;
std::size_t getTriangleCount() const;
TriangleVertexIndicesType getTriangleVertexIndices(const IndexType triangleIndex) const;
TriangleVerticesType getTriangleVertices(const IndexType triangleIndex) const;
TriangleEdgeIndicesType getTriangleEdgeIndices(const IndexType triangleIndex) const;
TriangleNeighborsAcrossEdgesIndicesType getTriangleNeighborsWithSharedEdges(const IndexType triangleIndex) const;
EdgeType getSharedEdge(const IndexType triangle1Index, const IndexType triangle2Index) const;
bool pointIsOnTriangle(const Vector &point, const IndexType triangleIndex) const;
std::optional<IndexType> findTriangleForPoint(const Vector &point) const;
std::vector<State> getSuccessors(const State ¤tState, const std::optional<State> goalState, const double agentRadius) const;
// Debug help
std::optional<IndexType> getVertexIndex(const Vector &vertex) const;
// Checks
void checkForDuplicateVertices() const;
static Vector to2dPoint(const Vector &point);
static State createStartState(const Vector &startPoint, const IndexType startTriangle);
static State createGoalState(const Vector &goalPoint, const IndexType goalTriangle);
protected:
std::vector<Vector> vertices_;
std::vector<EdgeVertexIndicesType> edgeVertexIndices_;
std::vector<MarkerType> vertexMarkers_;
std::vector<MarkerType> edgeMarkers_;
std::vector<TriangleEdgeIndicesType> triangleEdgeIndices_;
std::vector<TriangleVertexIndicesType> triangleVertexIndices_;
// Sorted so that valid references are always first
std::vector<TriangleNeighborIndicesType> triangleNeighborIndices_;
std::vector<TriangleNeighborsAcrossEdgesIndicesType> triangleNeighborsAcrossEdgesIndices_;
};
} // namespace navmesh
} // namespace pathfinder
#endif // PATHFINDER_NAVMESH_TRIANGLE_LIB_NAVMESH_H_