| 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 "scene/2d/node_2d.h" |
| 34 |
|
| 35 |
class NavigationPolygon; |
| 36 |
class NavigationMeshSourceGeometryData2D; |
| 37 |
|
| 38 |
class NavigationObstacle2D : public Node2D { |
| 39 |
GDCLASS(NavigationObstacle2D, Node2D); |
| 40 |
|
| 41 |
RID obstacle; |
| 42 |
RID map_before_pause; |
| 43 |
RID map_override; |
| 44 |
RID map_current; |
| 45 |
|
| 46 |
real_t radius = 0.0; |
| 47 |
|
| 48 |
Vector<Vector2> vertices; |
| 49 |
bool vertices_are_clockwise = true; |
| 50 |
bool vertices_are_valid = true; |
| 51 |
|
| 52 |
bool avoidance_enabled = true; |
| 53 |
uint32_t avoidance_layers = 1; |
| 54 |
|
| 55 |
Transform2D previous_transform; |
| 56 |
|
| 57 |
Vector2 velocity; |
| 58 |
Vector2 previous_velocity; |
| 59 |
bool velocity_submitted = false; |
| 60 |
|
| 61 |
bool affect_navigation_mesh = false; |
| 62 |
bool carve_navigation_mesh = false; |
| 63 |
|
| 64 |
#ifdef DEBUG_ENABLED |
| 65 |
private: |
| 66 |
RID debug_canvas_item; |
| 67 |
RID debug_mesh_rid; |
| 68 |
|
| 69 |
void _update_fake_agent_radius_debug(); |
| 70 |
void _update_static_obstacle_debug(); |
| 71 |
#endif |
| 72 |
|
| 73 |
protected: |
| 74 |
static void _bind_methods(); |
| 75 |
void _notification(int p_what); |
| 76 |
|
| 77 |
public: |
| 78 |
NavigationObstacle2D(); |
| 79 |
virtual ~NavigationObstacle2D(); |
| 80 |
|
| 81 |
RID get_rid() const { return obstacle; } |
| 82 |
|
| 83 |
void set_avoidance_enabled(bool p_enabled); |
| 84 |
bool get_avoidance_enabled() const; |
| 85 |
|
| 86 |
void set_navigation_map(RID p_navigation_map); |
| 87 |
RID get_navigation_map() const; |
| 88 |
|
| 89 |
void set_radius(real_t p_radius); |
| 90 |
real_t get_radius() const { return radius; } |
| 91 |
|
| 92 |
void set_vertices(const Vector<Vector2> &p_vertices); |
| 93 |
const Vector<Vector2> &get_vertices() const { return vertices; } |
| 94 |
|
| 95 |
bool are_vertices_clockwise() const { return vertices_are_clockwise; } |
| 96 |
bool are_vertices_valid() const { return vertices_are_valid; } |
| 97 |
|
| 98 |
void set_avoidance_layers(uint32_t p_layers); |
| 99 |
uint32_t get_avoidance_layers() const; |
| 100 |
|
| 101 |
void set_avoidance_mask(uint32_t p_mask); |
| 102 |
uint32_t get_avoidance_mask() const; |
| 103 |
|
| 104 |
void set_avoidance_layer_value(int p_layer_number, bool p_value); |
| 105 |
bool get_avoidance_layer_value(int p_layer_number) const; |
| 106 |
|
| 107 |
void set_velocity(const Vector2 p_velocity); |
| 108 |
Vector2 get_velocity() const { return velocity; } |
| 109 |
|
| 110 |
void _avoidance_done(Vector3 p_new_velocity); |
| 111 |
|
| 112 |
void set_affect_navigation_mesh(bool p_enabled); |
| 113 |
bool get_affect_navigation_mesh() const; |
| 114 |
|
| 115 |
void set_carve_navigation_mesh(bool p_enabled); |
| 116 |
bool get_carve_navigation_mesh() const; |
| 117 |
|
| 118 |
PackedStringArray get_configuration_warnings() const override; |
| 119 |
|
| 120 |
private: |
| 121 |
static Callable _navmesh_source_geometry_parsing_callback; |
| 122 |
static RID _navmesh_source_geometry_parser; |
| 123 |
|
| 124 |
public: |
| 125 |
static void navmesh_parse_init(); |
| 126 |
static void navmesh_parse_source_geometry(const Ref<NavigationPolygon> &p_navigation_mesh, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry_data, Node *p_node); |
| 127 |
|
| 128 |
private: |
| 129 |
void _update_map(RID p_map); |
| 130 |
void _update_position(const Vector2 p_position); |
| 131 |
void _update_transform(); |
| 132 |
}; |