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