Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/servers/navigation/navigation_path_query_parameters_3d.cpp
10277 views
1
/**************************************************************************/
2
/* navigation_path_query_parameters_3d.cpp */
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
#include "navigation_path_query_parameters_3d.h"
32
33
void NavigationPathQueryParameters3D::set_pathfinding_algorithm(const NavigationPathQueryParameters3D::PathfindingAlgorithm p_pathfinding_algorithm) {
34
pathfinding_algorithm = p_pathfinding_algorithm;
35
}
36
37
NavigationPathQueryParameters3D::PathfindingAlgorithm NavigationPathQueryParameters3D::get_pathfinding_algorithm() const {
38
return pathfinding_algorithm;
39
}
40
41
void NavigationPathQueryParameters3D::set_path_postprocessing(const NavigationPathQueryParameters3D::PathPostProcessing p_path_postprocessing) {
42
path_postprocessing = p_path_postprocessing;
43
}
44
45
NavigationPathQueryParameters3D::PathPostProcessing NavigationPathQueryParameters3D::get_path_postprocessing() const {
46
return path_postprocessing;
47
}
48
49
void NavigationPathQueryParameters3D::set_map(RID p_map) {
50
map = p_map;
51
}
52
53
RID NavigationPathQueryParameters3D::get_map() const {
54
return map;
55
}
56
57
void NavigationPathQueryParameters3D::set_start_position(Vector3 p_start_position) {
58
start_position = p_start_position;
59
}
60
61
Vector3 NavigationPathQueryParameters3D::get_start_position() const {
62
return start_position;
63
}
64
65
void NavigationPathQueryParameters3D::set_target_position(Vector3 p_target_position) {
66
target_position = p_target_position;
67
}
68
69
Vector3 NavigationPathQueryParameters3D::get_target_position() const {
70
return target_position;
71
}
72
73
void NavigationPathQueryParameters3D::set_navigation_layers(uint32_t p_navigation_layers) {
74
navigation_layers = p_navigation_layers;
75
}
76
77
uint32_t NavigationPathQueryParameters3D::get_navigation_layers() const {
78
return navigation_layers;
79
}
80
81
void NavigationPathQueryParameters3D::set_metadata_flags(BitField<NavigationPathQueryParameters3D::PathMetadataFlags> p_flags) {
82
metadata_flags = (int64_t)p_flags;
83
}
84
85
BitField<NavigationPathQueryParameters3D::PathMetadataFlags> NavigationPathQueryParameters3D::get_metadata_flags() const {
86
return (int64_t)metadata_flags;
87
}
88
89
void NavigationPathQueryParameters3D::set_simplify_path(bool p_enabled) {
90
simplify_path = p_enabled;
91
}
92
93
bool NavigationPathQueryParameters3D::get_simplify_path() const {
94
return simplify_path;
95
}
96
97
void NavigationPathQueryParameters3D::set_simplify_epsilon(real_t p_epsilon) {
98
simplify_epsilon = MAX(0.0, p_epsilon);
99
}
100
101
real_t NavigationPathQueryParameters3D::get_simplify_epsilon() const {
102
return simplify_epsilon;
103
}
104
105
void NavigationPathQueryParameters3D::set_included_regions(const TypedArray<RID> &p_regions) {
106
_included_regions.resize(p_regions.size());
107
for (uint32_t i = 0; i < _included_regions.size(); i++) {
108
_included_regions[i] = p_regions[i];
109
}
110
}
111
112
TypedArray<RID> NavigationPathQueryParameters3D::get_included_regions() const {
113
TypedArray<RID> r_regions;
114
r_regions.resize(_included_regions.size());
115
for (uint32_t i = 0; i < _included_regions.size(); i++) {
116
r_regions[i] = _included_regions[i];
117
}
118
return r_regions;
119
}
120
121
void NavigationPathQueryParameters3D::set_excluded_regions(const TypedArray<RID> &p_regions) {
122
_excluded_regions.resize(p_regions.size());
123
for (uint32_t i = 0; i < _excluded_regions.size(); i++) {
124
_excluded_regions[i] = p_regions[i];
125
}
126
}
127
128
TypedArray<RID> NavigationPathQueryParameters3D::get_excluded_regions() const {
129
TypedArray<RID> r_regions;
130
r_regions.resize(_excluded_regions.size());
131
for (uint32_t i = 0; i < _excluded_regions.size(); i++) {
132
r_regions[i] = _excluded_regions[i];
133
}
134
return r_regions;
135
}
136
137
void NavigationPathQueryParameters3D::set_path_return_max_length(float p_length) {
138
path_return_max_length = MAX(0.0, p_length);
139
}
140
141
float NavigationPathQueryParameters3D::get_path_return_max_length() const {
142
return path_return_max_length;
143
}
144
145
void NavigationPathQueryParameters3D::set_path_return_max_radius(float p_radius) {
146
path_return_max_radius = MAX(0.0, p_radius);
147
}
148
149
float NavigationPathQueryParameters3D::get_path_return_max_radius() const {
150
return path_return_max_radius;
151
}
152
153
void NavigationPathQueryParameters3D::set_path_search_max_polygons(int p_max_polygons) {
154
path_search_max_polygons = p_max_polygons;
155
}
156
157
int NavigationPathQueryParameters3D::get_path_search_max_polygons() const {
158
return path_search_max_polygons;
159
}
160
161
void NavigationPathQueryParameters3D::set_path_search_max_distance(float p_distance) {
162
path_search_max_distance = MAX(0.0, p_distance);
163
}
164
165
float NavigationPathQueryParameters3D::get_path_search_max_distance() const {
166
return path_search_max_distance;
167
}
168
169
void NavigationPathQueryParameters3D::_bind_methods() {
170
ClassDB::bind_method(D_METHOD("set_pathfinding_algorithm", "pathfinding_algorithm"), &NavigationPathQueryParameters3D::set_pathfinding_algorithm);
171
ClassDB::bind_method(D_METHOD("get_pathfinding_algorithm"), &NavigationPathQueryParameters3D::get_pathfinding_algorithm);
172
173
ClassDB::bind_method(D_METHOD("set_path_postprocessing", "path_postprocessing"), &NavigationPathQueryParameters3D::set_path_postprocessing);
174
ClassDB::bind_method(D_METHOD("get_path_postprocessing"), &NavigationPathQueryParameters3D::get_path_postprocessing);
175
176
ClassDB::bind_method(D_METHOD("set_map", "map"), &NavigationPathQueryParameters3D::set_map);
177
ClassDB::bind_method(D_METHOD("get_map"), &NavigationPathQueryParameters3D::get_map);
178
179
ClassDB::bind_method(D_METHOD("set_start_position", "start_position"), &NavigationPathQueryParameters3D::set_start_position);
180
ClassDB::bind_method(D_METHOD("get_start_position"), &NavigationPathQueryParameters3D::get_start_position);
181
182
ClassDB::bind_method(D_METHOD("set_target_position", "target_position"), &NavigationPathQueryParameters3D::set_target_position);
183
ClassDB::bind_method(D_METHOD("get_target_position"), &NavigationPathQueryParameters3D::get_target_position);
184
185
ClassDB::bind_method(D_METHOD("set_navigation_layers", "navigation_layers"), &NavigationPathQueryParameters3D::set_navigation_layers);
186
ClassDB::bind_method(D_METHOD("get_navigation_layers"), &NavigationPathQueryParameters3D::get_navigation_layers);
187
188
ClassDB::bind_method(D_METHOD("set_metadata_flags", "flags"), &NavigationPathQueryParameters3D::set_metadata_flags);
189
ClassDB::bind_method(D_METHOD("get_metadata_flags"), &NavigationPathQueryParameters3D::get_metadata_flags);
190
191
ClassDB::bind_method(D_METHOD("set_simplify_path", "enabled"), &NavigationPathQueryParameters3D::set_simplify_path);
192
ClassDB::bind_method(D_METHOD("get_simplify_path"), &NavigationPathQueryParameters3D::get_simplify_path);
193
194
ClassDB::bind_method(D_METHOD("set_simplify_epsilon", "epsilon"), &NavigationPathQueryParameters3D::set_simplify_epsilon);
195
ClassDB::bind_method(D_METHOD("get_simplify_epsilon"), &NavigationPathQueryParameters3D::get_simplify_epsilon);
196
197
ClassDB::bind_method(D_METHOD("set_included_regions", "regions"), &NavigationPathQueryParameters3D::set_included_regions);
198
ClassDB::bind_method(D_METHOD("get_included_regions"), &NavigationPathQueryParameters3D::get_included_regions);
199
200
ClassDB::bind_method(D_METHOD("set_excluded_regions", "regions"), &NavigationPathQueryParameters3D::set_excluded_regions);
201
ClassDB::bind_method(D_METHOD("get_excluded_regions"), &NavigationPathQueryParameters3D::get_excluded_regions);
202
203
ClassDB::bind_method(D_METHOD("set_path_return_max_length", "length"), &NavigationPathQueryParameters3D::set_path_return_max_length);
204
ClassDB::bind_method(D_METHOD("get_path_return_max_length"), &NavigationPathQueryParameters3D::get_path_return_max_length);
205
206
ClassDB::bind_method(D_METHOD("set_path_return_max_radius", "radius"), &NavigationPathQueryParameters3D::set_path_return_max_radius);
207
ClassDB::bind_method(D_METHOD("get_path_return_max_radius"), &NavigationPathQueryParameters3D::get_path_return_max_radius);
208
209
ClassDB::bind_method(D_METHOD("set_path_search_max_polygons", "max_polygons"), &NavigationPathQueryParameters3D::set_path_search_max_polygons);
210
ClassDB::bind_method(D_METHOD("get_path_search_max_polygons"), &NavigationPathQueryParameters3D::get_path_search_max_polygons);
211
212
ClassDB::bind_method(D_METHOD("set_path_search_max_distance", "distance"), &NavigationPathQueryParameters3D::set_path_search_max_distance);
213
ClassDB::bind_method(D_METHOD("get_path_search_max_distance"), &NavigationPathQueryParameters3D::get_path_search_max_distance);
214
215
ADD_PROPERTY(PropertyInfo(Variant::RID, "map"), "set_map", "get_map");
216
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "start_position"), "set_start_position", "get_start_position");
217
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "target_position"), "set_target_position", "get_target_position");
218
ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_layers", PROPERTY_HINT_LAYERS_3D_NAVIGATION), "set_navigation_layers", "get_navigation_layers");
219
ADD_PROPERTY(PropertyInfo(Variant::INT, "pathfinding_algorithm", PROPERTY_HINT_ENUM, "AStar"), "set_pathfinding_algorithm", "get_pathfinding_algorithm");
220
ADD_PROPERTY(PropertyInfo(Variant::INT, "path_postprocessing", PROPERTY_HINT_ENUM, "Corridorfunnel,Edgecentered,None"), "set_path_postprocessing", "get_path_postprocessing");
221
ADD_PROPERTY(PropertyInfo(Variant::INT, "metadata_flags", PROPERTY_HINT_FLAGS, "Include Types,Include RIDs,Include Owners"), "set_metadata_flags", "get_metadata_flags");
222
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "simplify_path"), "set_simplify_path", "get_simplify_path");
223
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "simplify_epsilon"), "set_simplify_epsilon", "get_simplify_epsilon");
224
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "excluded_regions", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_excluded_regions", "get_excluded_regions");
225
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "included_regions", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_included_regions", "get_included_regions");
226
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_return_max_length"), "set_path_return_max_length", "get_path_return_max_length");
227
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_return_max_radius"), "set_path_return_max_radius", "get_path_return_max_radius");
228
ADD_PROPERTY(PropertyInfo(Variant::INT, "path_search_max_polygons"), "set_path_search_max_polygons", "get_path_search_max_polygons");
229
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_search_max_distance"), "set_path_search_max_distance", "get_path_search_max_distance");
230
231
BIND_ENUM_CONSTANT(PATHFINDING_ALGORITHM_ASTAR);
232
233
BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_CORRIDORFUNNEL);
234
BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_EDGECENTERED);
235
BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_NONE);
236
237
BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_NONE);
238
BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_TYPES);
239
BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_RIDS);
240
BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_OWNERS);
241
BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_ALL);
242
}
243
244