1/**************************************************************************/
2/* navigation_obstacle_3d.h */
3/**************************************************************************/
4/* This file is part of: */
5/* GODOT ENGINE */
6/* https://godotengine.org */
7/**************************************************************************/
8/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10/* */
11/* Permission is hereby granted, free of charge, to any person obtaining */
12/* a copy of this software and associated documentation files (the */
13/* "Software"), to deal in the Software without restriction, including */
14/* without limitation the rights to use, copy, modify, merge, publish, */
15/* distribute, sublicense, and/or sell copies of the Software, and to */
16/* permit persons to whom the Software is furnished to do so, subject to */
17/* the following conditions: */
18/* */
19/* The above copyright notice and this permission notice shall be */
20/* included in all copies or substantial portions of the Software. */
21/* */
22/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29/**************************************************************************/
30
31#ifndef NAVIGATION_OBSTACLE_3D_H
32#define NAVIGATION_OBSTACLE_3D_H
33
34#include "scene/3d/node_3d.h"
35
36class NavigationObstacle3D : public Node3D {
37 GDCLASS(NavigationObstacle3D, Node3D);
38
39 RID obstacle;
40 RID map_before_pause;
41 RID map_override;
42 RID map_current;
43
44 real_t height = 1.0;
45 real_t radius = 0.0;
46
47 Vector<Vector3> vertices;
48
49 bool avoidance_enabled = true;
50 uint32_t avoidance_layers = 1;
51
52 bool use_3d_avoidance = false;
53
54 Transform3D previous_transform;
55
56 Vector3 velocity;
57 Vector3 previous_velocity;
58 bool velocity_submitted = false;
59
60#ifdef DEBUG_ENABLED
61 RID fake_agent_radius_debug_instance;
62 Ref<ArrayMesh> fake_agent_radius_debug_mesh;
63
64 RID static_obstacle_debug_instance;
65 Ref<ArrayMesh> static_obstacle_debug_mesh;
66
67private:
68 void _update_fake_agent_radius_debug();
69 void _update_static_obstacle_debug();
70#endif // DEBUG_ENABLED
71
72protected:
73 static void _bind_methods();
74 void _notification(int p_what);
75
76public:
77 NavigationObstacle3D();
78 virtual ~NavigationObstacle3D();
79
80 RID get_rid() const { return obstacle; }
81
82 void set_avoidance_enabled(bool p_enabled);
83 bool get_avoidance_enabled() const;
84
85 void set_navigation_map(RID p_navigation_map);
86 RID get_navigation_map() const;
87
88 void set_radius(real_t p_radius);
89 real_t get_radius() const { return radius; }
90
91 void set_height(real_t p_height);
92 real_t get_height() const { return height; }
93
94 void set_vertices(const Vector<Vector3> &p_vertices);
95 const Vector<Vector3> &get_vertices() const { return vertices; };
96
97 void set_avoidance_layers(uint32_t p_layers);
98 uint32_t get_avoidance_layers() const;
99
100 void set_avoidance_layer_value(int p_layer_number, bool p_value);
101 bool get_avoidance_layer_value(int p_layer_number) const;
102
103 void set_use_3d_avoidance(bool p_use_3d_avoidance);
104 bool get_use_3d_avoidance() const { return use_3d_avoidance; }
105
106 void set_velocity(const Vector3 p_velocity);
107 Vector3 get_velocity() const { return velocity; };
108
109 void _avoidance_done(Vector3 p_new_velocity); // Dummy
110
111private:
112 void _update_map(RID p_map);
113 void _update_position(const Vector3 p_position);
114 void _update_use_3d_avoidance(bool p_use_3d_avoidance);
115};
116
117#endif // NAVIGATION_OBSTACLE_3D_H
118