navigation_path_query_parameters_3d.cpp 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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::_bind_methods() {
  114. ClassDB::bind_method(D_METHOD("set_pathfinding_algorithm", "pathfinding_algorithm"), &NavigationPathQueryParameters3D::set_pathfinding_algorithm);
  115. ClassDB::bind_method(D_METHOD("get_pathfinding_algorithm"), &NavigationPathQueryParameters3D::get_pathfinding_algorithm);
  116. ClassDB::bind_method(D_METHOD("set_path_postprocessing", "path_postprocessing"), &NavigationPathQueryParameters3D::set_path_postprocessing);
  117. ClassDB::bind_method(D_METHOD("get_path_postprocessing"), &NavigationPathQueryParameters3D::get_path_postprocessing);
  118. ClassDB::bind_method(D_METHOD("set_map", "map"), &NavigationPathQueryParameters3D::set_map);
  119. ClassDB::bind_method(D_METHOD("get_map"), &NavigationPathQueryParameters3D::get_map);
  120. ClassDB::bind_method(D_METHOD("set_start_position", "start_position"), &NavigationPathQueryParameters3D::set_start_position);
  121. ClassDB::bind_method(D_METHOD("get_start_position"), &NavigationPathQueryParameters3D::get_start_position);
  122. ClassDB::bind_method(D_METHOD("set_target_position", "target_position"), &NavigationPathQueryParameters3D::set_target_position);
  123. ClassDB::bind_method(D_METHOD("get_target_position"), &NavigationPathQueryParameters3D::get_target_position);
  124. ClassDB::bind_method(D_METHOD("set_navigation_layers", "navigation_layers"), &NavigationPathQueryParameters3D::set_navigation_layers);
  125. ClassDB::bind_method(D_METHOD("get_navigation_layers"), &NavigationPathQueryParameters3D::get_navigation_layers);
  126. ClassDB::bind_method(D_METHOD("set_metadata_flags", "flags"), &NavigationPathQueryParameters3D::set_metadata_flags);
  127. ClassDB::bind_method(D_METHOD("get_metadata_flags"), &NavigationPathQueryParameters3D::get_metadata_flags);
  128. ClassDB::bind_method(D_METHOD("set_simplify_path", "enabled"), &NavigationPathQueryParameters3D::set_simplify_path);
  129. ClassDB::bind_method(D_METHOD("get_simplify_path"), &NavigationPathQueryParameters3D::get_simplify_path);
  130. ClassDB::bind_method(D_METHOD("set_simplify_epsilon", "epsilon"), &NavigationPathQueryParameters3D::set_simplify_epsilon);
  131. ClassDB::bind_method(D_METHOD("get_simplify_epsilon"), &NavigationPathQueryParameters3D::get_simplify_epsilon);
  132. ClassDB::bind_method(D_METHOD("set_included_regions", "regions"), &NavigationPathQueryParameters3D::set_included_regions);
  133. ClassDB::bind_method(D_METHOD("get_included_regions"), &NavigationPathQueryParameters3D::get_included_regions);
  134. ClassDB::bind_method(D_METHOD("set_excluded_regions", "regions"), &NavigationPathQueryParameters3D::set_excluded_regions);
  135. ClassDB::bind_method(D_METHOD("get_excluded_regions"), &NavigationPathQueryParameters3D::get_excluded_regions);
  136. ADD_PROPERTY(PropertyInfo(Variant::RID, "map"), "set_map", "get_map");
  137. ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "start_position"), "set_start_position", "get_start_position");
  138. ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "target_position"), "set_target_position", "get_target_position");
  139. ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_layers", PROPERTY_HINT_LAYERS_3D_NAVIGATION), "set_navigation_layers", "get_navigation_layers");
  140. ADD_PROPERTY(PropertyInfo(Variant::INT, "pathfinding_algorithm", PROPERTY_HINT_ENUM, "AStar"), "set_pathfinding_algorithm", "get_pathfinding_algorithm");
  141. ADD_PROPERTY(PropertyInfo(Variant::INT, "path_postprocessing", PROPERTY_HINT_ENUM, "Corridorfunnel,Edgecentered,None"), "set_path_postprocessing", "get_path_postprocessing");
  142. ADD_PROPERTY(PropertyInfo(Variant::INT, "metadata_flags", PROPERTY_HINT_FLAGS, "Include Types,Include RIDs,Include Owners"), "set_metadata_flags", "get_metadata_flags");
  143. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "simplify_path"), "set_simplify_path", "get_simplify_path");
  144. ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "simplify_epsilon"), "set_simplify_epsilon", "get_simplify_epsilon");
  145. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "excluded_regions", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_excluded_regions", "get_excluded_regions");
  146. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "included_regions", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_included_regions", "get_included_regions");
  147. BIND_ENUM_CONSTANT(PATHFINDING_ALGORITHM_ASTAR);
  148. BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_CORRIDORFUNNEL);
  149. BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_EDGECENTERED);
  150. BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_NONE);
  151. BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_NONE);
  152. BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_TYPES);
  153. BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_RIDS);
  154. BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_OWNERS);
  155. BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_ALL);
  156. }