navigation_path_query_parameters_3d.cpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. #include "navigation_path_query_parameters_3d.h"
  31. void NavigationPathQueryParameters3D::set_pathfinding_algorithm(const NavigationPathQueryParameters3D::PathfindingAlgorithm p_pathfinding_algorithm) {
  32. pathfinding_algorithm = p_pathfinding_algorithm;
  33. }
  34. NavigationPathQueryParameters3D::PathfindingAlgorithm NavigationPathQueryParameters3D::get_pathfinding_algorithm() const {
  35. return pathfinding_algorithm;
  36. }
  37. void NavigationPathQueryParameters3D::set_path_postprocessing(const NavigationPathQueryParameters3D::PathPostProcessing p_path_postprocessing) {
  38. path_postprocessing = p_path_postprocessing;
  39. }
  40. NavigationPathQueryParameters3D::PathPostProcessing NavigationPathQueryParameters3D::get_path_postprocessing() const {
  41. return path_postprocessing;
  42. }
  43. void NavigationPathQueryParameters3D::set_map(RID p_map) {
  44. map = p_map;
  45. }
  46. RID NavigationPathQueryParameters3D::get_map() const {
  47. return map;
  48. }
  49. void NavigationPathQueryParameters3D::set_start_position(Vector3 p_start_position) {
  50. start_position = p_start_position;
  51. }
  52. Vector3 NavigationPathQueryParameters3D::get_start_position() const {
  53. return start_position;
  54. }
  55. void NavigationPathQueryParameters3D::set_target_position(Vector3 p_target_position) {
  56. target_position = p_target_position;
  57. }
  58. Vector3 NavigationPathQueryParameters3D::get_target_position() const {
  59. return target_position;
  60. }
  61. void NavigationPathQueryParameters3D::set_navigation_layers(uint32_t p_navigation_layers) {
  62. navigation_layers = p_navigation_layers;
  63. }
  64. uint32_t NavigationPathQueryParameters3D::get_navigation_layers() const {
  65. return navigation_layers;
  66. }
  67. void NavigationPathQueryParameters3D::set_metadata_flags(BitField<NavigationPathQueryParameters3D::PathMetadataFlags> p_flags) {
  68. metadata_flags = (int64_t)p_flags;
  69. }
  70. BitField<NavigationPathQueryParameters3D::PathMetadataFlags> NavigationPathQueryParameters3D::get_metadata_flags() const {
  71. return (int64_t)metadata_flags;
  72. }
  73. void NavigationPathQueryParameters3D::set_simplify_path(bool p_enabled) {
  74. simplify_path = p_enabled;
  75. }
  76. bool NavigationPathQueryParameters3D::get_simplify_path() const {
  77. return simplify_path;
  78. }
  79. void NavigationPathQueryParameters3D::set_simplify_epsilon(real_t p_epsilon) {
  80. simplify_epsilon = MAX(0.0, p_epsilon);
  81. }
  82. real_t NavigationPathQueryParameters3D::get_simplify_epsilon() const {
  83. return simplify_epsilon;
  84. }
  85. void NavigationPathQueryParameters3D::set_included_regions(const TypedArray<RID> &p_regions) {
  86. _included_regions.resize(p_regions.size());
  87. for (uint32_t i = 0; i < _included_regions.size(); i++) {
  88. _included_regions[i] = p_regions[i];
  89. }
  90. }
  91. TypedArray<RID> NavigationPathQueryParameters3D::get_included_regions() const {
  92. TypedArray<RID> r_regions;
  93. r_regions.resize(_included_regions.size());
  94. for (uint32_t i = 0; i < _included_regions.size(); i++) {
  95. r_regions[i] = _included_regions[i];
  96. }
  97. return r_regions;
  98. }
  99. void NavigationPathQueryParameters3D::set_excluded_regions(const TypedArray<RID> &p_regions) {
  100. _excluded_regions.resize(p_regions.size());
  101. for (uint32_t i = 0; i < _excluded_regions.size(); i++) {
  102. _excluded_regions[i] = p_regions[i];
  103. }
  104. }
  105. TypedArray<RID> NavigationPathQueryParameters3D::get_excluded_regions() const {
  106. TypedArray<RID> r_regions;
  107. r_regions.resize(_excluded_regions.size());
  108. for (uint32_t i = 0; i < _excluded_regions.size(); i++) {
  109. r_regions[i] = _excluded_regions[i];
  110. }
  111. return r_regions;
  112. }
  113. void NavigationPathQueryParameters3D::set_path_return_max_length(float p_length) {
  114. path_return_max_length = MAX(0.0, p_length);
  115. }
  116. float NavigationPathQueryParameters3D::get_path_return_max_length() const {
  117. return path_return_max_length;
  118. }
  119. void NavigationPathQueryParameters3D::set_path_return_max_radius(float p_radius) {
  120. path_return_max_radius = MAX(0.0, p_radius);
  121. }
  122. float NavigationPathQueryParameters3D::get_path_return_max_radius() const {
  123. return path_return_max_radius;
  124. }
  125. void NavigationPathQueryParameters3D::set_path_search_max_polygons(int p_max_polygons) {
  126. path_search_max_polygons = p_max_polygons;
  127. }
  128. int NavigationPathQueryParameters3D::get_path_search_max_polygons() const {
  129. return path_search_max_polygons;
  130. }
  131. void NavigationPathQueryParameters3D::set_path_search_max_distance(float p_distance) {
  132. path_search_max_distance = MAX(0.0, p_distance);
  133. }
  134. float NavigationPathQueryParameters3D::get_path_search_max_distance() const {
  135. return path_search_max_distance;
  136. }
  137. void NavigationPathQueryParameters3D::_bind_methods() {
  138. ClassDB::bind_method(D_METHOD("set_pathfinding_algorithm", "pathfinding_algorithm"), &NavigationPathQueryParameters3D::set_pathfinding_algorithm);
  139. ClassDB::bind_method(D_METHOD("get_pathfinding_algorithm"), &NavigationPathQueryParameters3D::get_pathfinding_algorithm);
  140. ClassDB::bind_method(D_METHOD("set_path_postprocessing", "path_postprocessing"), &NavigationPathQueryParameters3D::set_path_postprocessing);
  141. ClassDB::bind_method(D_METHOD("get_path_postprocessing"), &NavigationPathQueryParameters3D::get_path_postprocessing);
  142. ClassDB::bind_method(D_METHOD("set_map", "map"), &NavigationPathQueryParameters3D::set_map);
  143. ClassDB::bind_method(D_METHOD("get_map"), &NavigationPathQueryParameters3D::get_map);
  144. ClassDB::bind_method(D_METHOD("set_start_position", "start_position"), &NavigationPathQueryParameters3D::set_start_position);
  145. ClassDB::bind_method(D_METHOD("get_start_position"), &NavigationPathQueryParameters3D::get_start_position);
  146. ClassDB::bind_method(D_METHOD("set_target_position", "target_position"), &NavigationPathQueryParameters3D::set_target_position);
  147. ClassDB::bind_method(D_METHOD("get_target_position"), &NavigationPathQueryParameters3D::get_target_position);
  148. ClassDB::bind_method(D_METHOD("set_navigation_layers", "navigation_layers"), &NavigationPathQueryParameters3D::set_navigation_layers);
  149. ClassDB::bind_method(D_METHOD("get_navigation_layers"), &NavigationPathQueryParameters3D::get_navigation_layers);
  150. ClassDB::bind_method(D_METHOD("set_metadata_flags", "flags"), &NavigationPathQueryParameters3D::set_metadata_flags);
  151. ClassDB::bind_method(D_METHOD("get_metadata_flags"), &NavigationPathQueryParameters3D::get_metadata_flags);
  152. ClassDB::bind_method(D_METHOD("set_simplify_path", "enabled"), &NavigationPathQueryParameters3D::set_simplify_path);
  153. ClassDB::bind_method(D_METHOD("get_simplify_path"), &NavigationPathQueryParameters3D::get_simplify_path);
  154. ClassDB::bind_method(D_METHOD("set_simplify_epsilon", "epsilon"), &NavigationPathQueryParameters3D::set_simplify_epsilon);
  155. ClassDB::bind_method(D_METHOD("get_simplify_epsilon"), &NavigationPathQueryParameters3D::get_simplify_epsilon);
  156. ClassDB::bind_method(D_METHOD("set_included_regions", "regions"), &NavigationPathQueryParameters3D::set_included_regions);
  157. ClassDB::bind_method(D_METHOD("get_included_regions"), &NavigationPathQueryParameters3D::get_included_regions);
  158. ClassDB::bind_method(D_METHOD("set_excluded_regions", "regions"), &NavigationPathQueryParameters3D::set_excluded_regions);
  159. ClassDB::bind_method(D_METHOD("get_excluded_regions"), &NavigationPathQueryParameters3D::get_excluded_regions);
  160. ClassDB::bind_method(D_METHOD("set_path_return_max_length", "length"), &NavigationPathQueryParameters3D::set_path_return_max_length);
  161. ClassDB::bind_method(D_METHOD("get_path_return_max_length"), &NavigationPathQueryParameters3D::get_path_return_max_length);
  162. ClassDB::bind_method(D_METHOD("set_path_return_max_radius", "radius"), &NavigationPathQueryParameters3D::set_path_return_max_radius);
  163. ClassDB::bind_method(D_METHOD("get_path_return_max_radius"), &NavigationPathQueryParameters3D::get_path_return_max_radius);
  164. ClassDB::bind_method(D_METHOD("set_path_search_max_polygons", "max_polygons"), &NavigationPathQueryParameters3D::set_path_search_max_polygons);
  165. ClassDB::bind_method(D_METHOD("get_path_search_max_polygons"), &NavigationPathQueryParameters3D::get_path_search_max_polygons);
  166. ClassDB::bind_method(D_METHOD("set_path_search_max_distance", "distance"), &NavigationPathQueryParameters3D::set_path_search_max_distance);
  167. ClassDB::bind_method(D_METHOD("get_path_search_max_distance"), &NavigationPathQueryParameters3D::get_path_search_max_distance);
  168. ADD_PROPERTY(PropertyInfo(Variant::RID, "map"), "set_map", "get_map");
  169. ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "start_position"), "set_start_position", "get_start_position");
  170. ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "target_position"), "set_target_position", "get_target_position");
  171. ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_layers", PROPERTY_HINT_LAYERS_3D_NAVIGATION), "set_navigation_layers", "get_navigation_layers");
  172. ADD_PROPERTY(PropertyInfo(Variant::INT, "pathfinding_algorithm", PROPERTY_HINT_ENUM, "AStar"), "set_pathfinding_algorithm", "get_pathfinding_algorithm");
  173. ADD_PROPERTY(PropertyInfo(Variant::INT, "path_postprocessing", PROPERTY_HINT_ENUM, "Corridorfunnel,Edgecentered,None"), "set_path_postprocessing", "get_path_postprocessing");
  174. ADD_PROPERTY(PropertyInfo(Variant::INT, "metadata_flags", PROPERTY_HINT_FLAGS, "Include Types,Include RIDs,Include Owners"), "set_metadata_flags", "get_metadata_flags");
  175. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "simplify_path"), "set_simplify_path", "get_simplify_path");
  176. ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "simplify_epsilon"), "set_simplify_epsilon", "get_simplify_epsilon");
  177. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "excluded_regions", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_excluded_regions", "get_excluded_regions");
  178. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "included_regions", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_included_regions", "get_included_regions");
  179. ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_return_max_length"), "set_path_return_max_length", "get_path_return_max_length");
  180. ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_return_max_radius"), "set_path_return_max_radius", "get_path_return_max_radius");
  181. ADD_PROPERTY(PropertyInfo(Variant::INT, "path_search_max_polygons"), "set_path_search_max_polygons", "get_path_search_max_polygons");
  182. ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_search_max_distance"), "set_path_search_max_distance", "get_path_search_max_distance");
  183. BIND_ENUM_CONSTANT(PATHFINDING_ALGORITHM_ASTAR);
  184. BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_CORRIDORFUNNEL);
  185. BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_EDGECENTERED);
  186. BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_NONE);
  187. BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_NONE);
  188. BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_TYPES);
  189. BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_RIDS);
  190. BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_OWNERS);
  191. BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_ALL);
  192. }