| 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 |
#pragma once |
| 32 |
|
| 33 |
#include "core/io/resource.h" |
| 34 |
#include "core/os/rw_lock.h" |
| 35 |
|
| 36 |
class NavigationMeshSourceGeometryData2D : public Resource { |
| 37 |
friend class NavMeshGenerator2D; |
| 38 |
|
| 39 |
GDCLASS(NavigationMeshSourceGeometryData2D, Resource); |
| 40 |
RWLock geometry_rwlock; |
| 41 |
|
| 42 |
Vector<Vector<Vector2>> traversable_outlines; |
| 43 |
Vector<Vector<Vector2>> obstruction_outlines; |
| 44 |
|
| 45 |
Rect2 bounds; |
| 46 |
bool bounds_dirty = true; |
| 47 |
|
| 48 |
public: |
| 49 |
struct ProjectedObstruction; |
| 50 |
|
| 51 |
private: |
| 52 |
Vector<ProjectedObstruction> _projected_obstructions; |
| 53 |
|
| 54 |
protected: |
| 55 |
bool _set(const StringName &p_name, const Variant &p_value); |
| 56 |
bool _get(const StringName &p_name, Variant &r_ret) const; |
| 57 |
static void _bind_methods(); |
| 58 |
|
| 59 |
public: |
| 60 |
struct ProjectedObstruction { |
| 61 |
static inline uint32_t VERSION = 1; |
| 62 |
|
| 63 |
Vector<float> vertices; |
| 64 |
bool carve = false; |
| 65 |
}; |
| 66 |
|
| 67 |
void _set_traversable_outlines(const Vector<Vector<Vector2>> &p_traversable_outlines); |
| 68 |
const Vector<Vector<Vector2>> &_get_traversable_outlines() const; |
| 69 |
|
| 70 |
void _set_obstruction_outlines(const Vector<Vector<Vector2>> &p_obstruction_outlines); |
| 71 |
const Vector<Vector<Vector2>> &_get_obstruction_outlines() const; |
| 72 |
|
| 73 |
void _add_traversable_outline(const Vector<Vector2> &p_shape_outline); |
| 74 |
void _add_obstruction_outline(const Vector<Vector2> &p_shape_outline); |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
Transform2D root_node_transform; |
| 81 |
|
| 82 |
void set_traversable_outlines(const TypedArray<Vector<Vector2>> &p_traversable_outlines); |
| 83 |
TypedArray<Vector<Vector2>> get_traversable_outlines() const; |
| 84 |
|
| 85 |
void set_obstruction_outlines(const TypedArray<Vector<Vector2>> &p_obstruction_outlines); |
| 86 |
TypedArray<Vector<Vector2>> get_obstruction_outlines() const; |
| 87 |
|
| 88 |
void append_traversable_outlines(const TypedArray<Vector<Vector2>> &p_traversable_outlines); |
| 89 |
void append_obstruction_outlines(const TypedArray<Vector<Vector2>> &p_obstruction_outlines); |
| 90 |
|
| 91 |
void add_traversable_outline(const PackedVector2Array &p_shape_outline); |
| 92 |
void add_obstruction_outline(const PackedVector2Array &p_shape_outline); |
| 93 |
|
| 94 |
bool has_data(); |
| 95 |
void clear(); |
| 96 |
void clear_projected_obstructions(); |
| 97 |
|
| 98 |
void add_projected_obstruction(const Vector<Vector2> &p_vertices, bool p_carve); |
| 99 |
Vector<ProjectedObstruction> _get_projected_obstructions() const; |
| 100 |
|
| 101 |
void set_projected_obstructions(const Array &p_array); |
| 102 |
Array get_projected_obstructions() const; |
| 103 |
|
| 104 |
void merge(const Ref<NavigationMeshSourceGeometryData2D> &p_other_geometry); |
| 105 |
|
| 106 |
void set_data(const Vector<Vector<Vector2>> &p_traversable_outlines, const Vector<Vector<Vector2>> &p_obstruction_outlines, Vector<ProjectedObstruction> &p_projected_obstructions); |
| 107 |
void get_data(Vector<Vector<Vector2>> &r_traversable_outlines, Vector<Vector<Vector2>> &r_obstruction_outlines, Vector<ProjectedObstruction> &r_projected_obstructions); |
| 108 |
|
| 109 |
Rect2 get_bounds(); |
| 110 |
|
| 111 |
~NavigationMeshSourceGeometryData2D() { clear(); } |
| 112 |
}; |