Debian Codegraph @

scene/resources/navigation_mesh.h

raw symbols SCIP
1 /**************************************************************************/
2 /* navigation_mesh.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 #pragma once
32
33 #include "core/os/rw_lock.h"
34 #include "scene/resources/mesh.h"
35 #include "servers/navigation_3d/navigation_constants_3d.h"
36
37 class NavigationMesh : public Resource {
38 GDCLASS(NavigationMesh, Resource);
39 RWLock rwlock;
40
41 Vector<Vector3> vertices;
42 Vector<Vector<int>> polygons;
43 Ref<ArrayMesh> debug_mesh;
44
45 protected:
46 static void _bind_methods();
47 void _validate_property(PropertyInfo &p_property) const;
48
49 #ifndef DISABLE_DEPRECATED
50 bool _set(const StringName &p_name, const Variant &p_value);
51 bool _get(const StringName &p_name, Variant &r_ret) const;
52 #endif // DISABLE_DEPRECATED
53
54 void _set_polygons(const Array &p_array);
55 Array _get_polygons() const;
56
57 public:
58 enum SamplePartitionType {
59 SAMPLE_PARTITION_WATERSHED = 0,
60 SAMPLE_PARTITION_MONOTONE,
61 SAMPLE_PARTITION_LAYERS,
62 SAMPLE_PARTITION_MAX
63 };
64
65 enum ParsedGeometryType {
66 PARSED_GEOMETRY_MESH_INSTANCES = 0,
67 PARSED_GEOMETRY_STATIC_COLLIDERS,
68 PARSED_GEOMETRY_BOTH,
69 PARSED_GEOMETRY_MAX
70 };
71
72 enum SourceGeometryMode {
73 SOURCE_GEOMETRY_ROOT_NODE_CHILDREN = 0,
74 SOURCE_GEOMETRY_GROUPS_WITH_CHILDREN,
75 SOURCE_GEOMETRY_GROUPS_EXPLICIT,
76 SOURCE_GEOMETRY_MAX
77 };
78
79 protected:
80 float cell_size = NavigationDefaults3D::NAV_MESH_CELL_SIZE;
81 float cell_height = NavigationDefaults3D::NAV_MESH_CELL_HEIGHT;
82 float border_size = 0.0f;
83 float agent_height = 1.5f;
84 float agent_radius = 0.5f;
85 float agent_max_climb = 0.25f;
86 float agent_max_slope = 45.0f;
87 float region_min_size = 2.0f;
88 float region_merge_size = 20.0f;
89 float edge_max_length = 0.0f;
90 float edge_max_error = 1.3f;
91 float vertices_per_polygon = 6.0f;
92 float detail_sample_distance = 6.0f;
93 float detail_sample_max_error = 1.0f;
94
95 SamplePartitionType partition_type = SAMPLE_PARTITION_WATERSHED;
96 ParsedGeometryType parsed_geometry_type = PARSED_GEOMETRY_BOTH;
97 uint32_t collision_mask = 0xFFFFFFFF;
98
99 SourceGeometryMode source_geometry_mode = SOURCE_GEOMETRY_ROOT_NODE_CHILDREN;
100 StringName source_group_name = "navigation_mesh_source_group";
101
102 bool filter_low_hanging_obstacles = false;
103 bool filter_ledge_spans = false;
104 bool filter_walkable_low_height_spans = false;
105 AABB filter_baking_aabb;
106 Vector3 filter_baking_aabb_offset;
107
108 public:
109 // Recast settings
110 void set_sample_partition_type(SamplePartitionType p_value);
111 SamplePartitionType get_sample_partition_type() const;
112
113 void set_parsed_geometry_type(ParsedGeometryType p_value);
114 ParsedGeometryType get_parsed_geometry_type() const;
115
116 void set_collision_mask(uint32_t p_mask);
117 uint32_t get_collision_mask() const;
118
119 void set_collision_mask_value(int p_layer_number, bool p_value);
120 bool get_collision_mask_value(int p_layer_number) const;
121
122 void set_source_geometry_mode(SourceGeometryMode p_geometry_mode);
123 SourceGeometryMode get_source_geometry_mode() const;
124
125 void set_source_group_name(const StringName &p_group_name);
126 StringName get_source_group_name() const;
127
128 void set_cell_size(float p_value);
129 float get_cell_size() const;
130
131 void set_cell_height(float p_value);
132 float get_cell_height() const;
133
134 void set_border_size(float p_value);
135 float get_border_size() const;
136
137 void set_agent_height(float p_value);
138 float get_agent_height() const;
139
140 void set_agent_radius(float p_value);
141 float get_agent_radius();
142
143 void set_agent_max_climb(float p_value);
144 float get_agent_max_climb() const;
145
146 void set_agent_max_slope(float p_value);
147 float get_agent_max_slope() const;
148
149 void set_region_min_size(float p_value);
150 float get_region_min_size() const;
151
152 void set_region_merge_size(float p_value);
153 float get_region_merge_size() const;
154
155 void set_edge_max_length(float p_value);
156 float get_edge_max_length() const;
157
158 void set_edge_max_error(float p_value);
159 float get_edge_max_error() const;
160
161 void set_vertices_per_polygon(float p_value);
162 float get_vertices_per_polygon() const;
163
164 void set_detail_sample_distance(float p_value);
165 float get_detail_sample_distance() const;
166
167 void set_detail_sample_max_error(float p_value);
168 float get_detail_sample_max_error() const;
169
170 void set_filter_low_hanging_obstacles(bool p_value);
171 bool get_filter_low_hanging_obstacles() const;
172
173 void set_filter_ledge_spans(bool p_value);
174 bool get_filter_ledge_spans() const;
175
176 void set_filter_walkable_low_height_spans(bool p_value);
177 bool get_filter_walkable_low_height_spans() const;
178
179 void set_filter_baking_aabb(const AABB &p_aabb);
180 AABB get_filter_baking_aabb() const;
181
182 void set_filter_baking_aabb_offset(const Vector3 &p_aabb_offset);
183 Vector3 get_filter_baking_aabb_offset() const;
184
185 void create_from_mesh(const Ref<Mesh> &p_mesh);
186
187 void set_vertices(const Vector<Vector3> &p_vertices);
188 Vector<Vector3> get_vertices() const;
189
190 void add_polygon(const Vector<int> &p_polygon);
191 int get_polygon_count() const;
192 Vector<int> get_polygon(int p_idx);
193 void clear_polygons();
194 void set_polygons(const Vector<Vector<int>> &p_polygons);
195 Vector<Vector<int>> get_polygons() const;
196
197 void clear();
198
199 void set_data(const Vector<Vector3> &p_vertices, const Vector<Vector<int>> &p_polygons);
200 void get_data(Vector<Vector3> &r_vertices, Vector<Vector<int>> &r_polygons);
201
202 #ifdef DEBUG_ENABLED
203 Ref<ArrayMesh> get_debug_mesh();
204 #endif // DEBUG_ENABLED
205 };
206
207 VARIANT_ENUM_CAST(NavigationMesh::SamplePartitionType);
208 VARIANT_ENUM_CAST(NavigationMesh::ParsedGeometryType);
209 VARIANT_ENUM_CAST(NavigationMesh::SourceGeometryMode);