navigation_path_query_parameters_2d.cpp 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /**************************************************************************/
  2. /* navigation_path_query_parameters_2d.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_2d.h"
  31. void NavigationPathQueryParameters2D::set_pathfinding_algorithm(const NavigationPathQueryParameters2D::PathfindingAlgorithm p_pathfinding_algorithm) {
  32. pathfinding_algorithm = p_pathfinding_algorithm;
  33. }
  34. NavigationPathQueryParameters2D::PathfindingAlgorithm NavigationPathQueryParameters2D::get_pathfinding_algorithm() const {
  35. return pathfinding_algorithm;
  36. }
  37. void NavigationPathQueryParameters2D::set_path_postprocessing(const NavigationPathQueryParameters2D::PathPostProcessing p_path_postprocessing) {
  38. path_postprocessing = p_path_postprocessing;
  39. }
  40. NavigationPathQueryParameters2D::PathPostProcessing NavigationPathQueryParameters2D::get_path_postprocessing() const {
  41. return path_postprocessing;
  42. }
  43. void NavigationPathQueryParameters2D::set_map(RID p_map) {
  44. map = p_map;
  45. }
  46. RID NavigationPathQueryParameters2D::get_map() const {
  47. return map;
  48. }
  49. void NavigationPathQueryParameters2D::set_start_position(Vector2 p_start_position) {
  50. start_position = p_start_position;
  51. }
  52. Vector2 NavigationPathQueryParameters2D::get_start_position() const {
  53. return start_position;
  54. }
  55. void NavigationPathQueryParameters2D::set_target_position(Vector2 p_target_position) {
  56. target_position = p_target_position;
  57. }
  58. Vector2 NavigationPathQueryParameters2D::get_target_position() const {
  59. return target_position;
  60. }
  61. void NavigationPathQueryParameters2D::set_navigation_layers(uint32_t p_navigation_layers) {
  62. navigation_layers = p_navigation_layers;
  63. }
  64. uint32_t NavigationPathQueryParameters2D::get_navigation_layers() const {
  65. return navigation_layers;
  66. }
  67. void NavigationPathQueryParameters2D::set_metadata_flags(BitField<NavigationPathQueryParameters2D::PathMetadataFlags> p_flags) {
  68. metadata_flags = (int64_t)p_flags;
  69. }
  70. BitField<NavigationPathQueryParameters2D::PathMetadataFlags> NavigationPathQueryParameters2D::get_metadata_flags() const {
  71. return (int64_t)metadata_flags;
  72. }
  73. void NavigationPathQueryParameters2D::set_simplify_path(bool p_enabled) {
  74. simplify_path = p_enabled;
  75. }
  76. bool NavigationPathQueryParameters2D::get_simplify_path() const {
  77. return simplify_path;
  78. }
  79. void NavigationPathQueryParameters2D::set_simplify_epsilon(real_t p_epsilon) {
  80. simplify_epsilon = MAX(0.0, p_epsilon);
  81. }
  82. real_t NavigationPathQueryParameters2D::get_simplify_epsilon() const {
  83. return simplify_epsilon;
  84. }
  85. void NavigationPathQueryParameters2D::_bind_methods() {
  86. ClassDB::bind_method(D_METHOD("set_pathfinding_algorithm", "pathfinding_algorithm"), &NavigationPathQueryParameters2D::set_pathfinding_algorithm);
  87. ClassDB::bind_method(D_METHOD("get_pathfinding_algorithm"), &NavigationPathQueryParameters2D::get_pathfinding_algorithm);
  88. ClassDB::bind_method(D_METHOD("set_path_postprocessing", "path_postprocessing"), &NavigationPathQueryParameters2D::set_path_postprocessing);
  89. ClassDB::bind_method(D_METHOD("get_path_postprocessing"), &NavigationPathQueryParameters2D::get_path_postprocessing);
  90. ClassDB::bind_method(D_METHOD("set_map", "map"), &NavigationPathQueryParameters2D::set_map);
  91. ClassDB::bind_method(D_METHOD("get_map"), &NavigationPathQueryParameters2D::get_map);
  92. ClassDB::bind_method(D_METHOD("set_start_position", "start_position"), &NavigationPathQueryParameters2D::set_start_position);
  93. ClassDB::bind_method(D_METHOD("get_start_position"), &NavigationPathQueryParameters2D::get_start_position);
  94. ClassDB::bind_method(D_METHOD("set_target_position", "target_position"), &NavigationPathQueryParameters2D::set_target_position);
  95. ClassDB::bind_method(D_METHOD("get_target_position"), &NavigationPathQueryParameters2D::get_target_position);
  96. ClassDB::bind_method(D_METHOD("set_navigation_layers", "navigation_layers"), &NavigationPathQueryParameters2D::set_navigation_layers);
  97. ClassDB::bind_method(D_METHOD("get_navigation_layers"), &NavigationPathQueryParameters2D::get_navigation_layers);
  98. ClassDB::bind_method(D_METHOD("set_metadata_flags", "flags"), &NavigationPathQueryParameters2D::set_metadata_flags);
  99. ClassDB::bind_method(D_METHOD("get_metadata_flags"), &NavigationPathQueryParameters2D::get_metadata_flags);
  100. ClassDB::bind_method(D_METHOD("set_simplify_path", "enabled"), &NavigationPathQueryParameters2D::set_simplify_path);
  101. ClassDB::bind_method(D_METHOD("get_simplify_path"), &NavigationPathQueryParameters2D::get_simplify_path);
  102. ClassDB::bind_method(D_METHOD("set_simplify_epsilon", "epsilon"), &NavigationPathQueryParameters2D::set_simplify_epsilon);
  103. ClassDB::bind_method(D_METHOD("get_simplify_epsilon"), &NavigationPathQueryParameters2D::get_simplify_epsilon);
  104. ADD_PROPERTY(PropertyInfo(Variant::RID, "map"), "set_map", "get_map");
  105. ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "start_position"), "set_start_position", "get_start_position");
  106. ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "target_position"), "set_target_position", "get_target_position");
  107. ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_layers", PROPERTY_HINT_LAYERS_2D_NAVIGATION), "set_navigation_layers", "get_navigation_layers");
  108. ADD_PROPERTY(PropertyInfo(Variant::INT, "pathfinding_algorithm", PROPERTY_HINT_ENUM, "AStar"), "set_pathfinding_algorithm", "get_pathfinding_algorithm");
  109. ADD_PROPERTY(PropertyInfo(Variant::INT, "path_postprocessing", PROPERTY_HINT_ENUM, "Corridorfunnel,Edgecentered,None"), "set_path_postprocessing", "get_path_postprocessing");
  110. ADD_PROPERTY(PropertyInfo(Variant::INT, "metadata_flags", PROPERTY_HINT_FLAGS, "Include Types,Include RIDs,Include Owners"), "set_metadata_flags", "get_metadata_flags");
  111. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "simplify_path"), "set_simplify_path", "get_simplify_path");
  112. ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "simplify_epsilon"), "set_simplify_epsilon", "get_simplify_epsilon");
  113. BIND_ENUM_CONSTANT(PATHFINDING_ALGORITHM_ASTAR);
  114. BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_CORRIDORFUNNEL);
  115. BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_EDGECENTERED);
  116. BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_NONE);
  117. BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_NONE);
  118. BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_TYPES);
  119. BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_RIDS);
  120. BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_OWNERS);
  121. BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_ALL);
  122. }