navigation_path_query_parameters_3d.cpp 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. switch (p_pathfinding_algorithm) {
  33. case PATHFINDING_ALGORITHM_ASTAR: {
  34. parameters.pathfinding_algorithm = NavigationUtilities::PathfindingAlgorithm::PATHFINDING_ALGORITHM_ASTAR;
  35. } break;
  36. default: {
  37. WARN_PRINT_ONCE("No match for used PathfindingAlgorithm - fallback to default");
  38. parameters.pathfinding_algorithm = NavigationUtilities::PathfindingAlgorithm::PATHFINDING_ALGORITHM_ASTAR;
  39. } break;
  40. }
  41. }
  42. NavigationPathQueryParameters3D::PathfindingAlgorithm NavigationPathQueryParameters3D::get_pathfinding_algorithm() const {
  43. switch (parameters.pathfinding_algorithm) {
  44. case NavigationUtilities::PathfindingAlgorithm::PATHFINDING_ALGORITHM_ASTAR:
  45. return PATHFINDING_ALGORITHM_ASTAR;
  46. default:
  47. WARN_PRINT_ONCE("No match for used PathfindingAlgorithm - fallback to default");
  48. return PATHFINDING_ALGORITHM_ASTAR;
  49. }
  50. }
  51. void NavigationPathQueryParameters3D::set_path_postprocessing(const NavigationPathQueryParameters3D::PathPostProcessing p_path_postprocessing) {
  52. switch (p_path_postprocessing) {
  53. case PATH_POSTPROCESSING_CORRIDORFUNNEL: {
  54. parameters.path_postprocessing = NavigationUtilities::PathPostProcessing::PATH_POSTPROCESSING_CORRIDORFUNNEL;
  55. } break;
  56. case PATH_POSTPROCESSING_EDGECENTERED: {
  57. parameters.path_postprocessing = NavigationUtilities::PathPostProcessing::PATH_POSTPROCESSING_EDGECENTERED;
  58. } break;
  59. default: {
  60. WARN_PRINT_ONCE("No match for used PathPostProcessing - fallback to default");
  61. parameters.path_postprocessing = NavigationUtilities::PathPostProcessing::PATH_POSTPROCESSING_CORRIDORFUNNEL;
  62. } break;
  63. }
  64. }
  65. NavigationPathQueryParameters3D::PathPostProcessing NavigationPathQueryParameters3D::get_path_postprocessing() const {
  66. switch (parameters.path_postprocessing) {
  67. case NavigationUtilities::PathPostProcessing::PATH_POSTPROCESSING_CORRIDORFUNNEL:
  68. return PATH_POSTPROCESSING_CORRIDORFUNNEL;
  69. case NavigationUtilities::PathPostProcessing::PATH_POSTPROCESSING_EDGECENTERED:
  70. return PATH_POSTPROCESSING_EDGECENTERED;
  71. default:
  72. WARN_PRINT_ONCE("No match for used PathPostProcessing - fallback to default");
  73. return PATH_POSTPROCESSING_CORRIDORFUNNEL;
  74. }
  75. }
  76. void NavigationPathQueryParameters3D::set_map(const RID &p_map) {
  77. parameters.map = p_map;
  78. }
  79. const RID &NavigationPathQueryParameters3D::get_map() const {
  80. return parameters.map;
  81. }
  82. void NavigationPathQueryParameters3D::set_start_position(const Vector3 &p_start_position) {
  83. parameters.start_position = p_start_position;
  84. }
  85. const Vector3 &NavigationPathQueryParameters3D::get_start_position() const {
  86. return parameters.start_position;
  87. }
  88. void NavigationPathQueryParameters3D::set_target_position(const Vector3 &p_target_position) {
  89. parameters.target_position = p_target_position;
  90. }
  91. const Vector3 &NavigationPathQueryParameters3D::get_target_position() const {
  92. return parameters.target_position;
  93. }
  94. void NavigationPathQueryParameters3D::set_navigation_layers(uint32_t p_navigation_layers) {
  95. parameters.navigation_layers = p_navigation_layers;
  96. }
  97. uint32_t NavigationPathQueryParameters3D::get_navigation_layers() const {
  98. return parameters.navigation_layers;
  99. }
  100. void NavigationPathQueryParameters3D::set_metadata_flags(BitField<NavigationPathQueryParameters3D::PathMetadataFlags> p_flags) {
  101. parameters.metadata_flags = (int64_t)p_flags;
  102. }
  103. BitField<NavigationPathQueryParameters3D::PathMetadataFlags> NavigationPathQueryParameters3D::get_metadata_flags() const {
  104. return (int64_t)parameters.metadata_flags;
  105. }
  106. void NavigationPathQueryParameters3D::_bind_methods() {
  107. ClassDB::bind_method(D_METHOD("set_pathfinding_algorithm", "pathfinding_algorithm"), &NavigationPathQueryParameters3D::set_pathfinding_algorithm);
  108. ClassDB::bind_method(D_METHOD("get_pathfinding_algorithm"), &NavigationPathQueryParameters3D::get_pathfinding_algorithm);
  109. ClassDB::bind_method(D_METHOD("set_path_postprocessing", "path_postprocessing"), &NavigationPathQueryParameters3D::set_path_postprocessing);
  110. ClassDB::bind_method(D_METHOD("get_path_postprocessing"), &NavigationPathQueryParameters3D::get_path_postprocessing);
  111. ClassDB::bind_method(D_METHOD("set_map", "map"), &NavigationPathQueryParameters3D::set_map);
  112. ClassDB::bind_method(D_METHOD("get_map"), &NavigationPathQueryParameters3D::get_map);
  113. ClassDB::bind_method(D_METHOD("set_start_position", "start_position"), &NavigationPathQueryParameters3D::set_start_position);
  114. ClassDB::bind_method(D_METHOD("get_start_position"), &NavigationPathQueryParameters3D::get_start_position);
  115. ClassDB::bind_method(D_METHOD("set_target_position", "target_position"), &NavigationPathQueryParameters3D::set_target_position);
  116. ClassDB::bind_method(D_METHOD("get_target_position"), &NavigationPathQueryParameters3D::get_target_position);
  117. ClassDB::bind_method(D_METHOD("set_navigation_layers", "navigation_layers"), &NavigationPathQueryParameters3D::set_navigation_layers);
  118. ClassDB::bind_method(D_METHOD("get_navigation_layers"), &NavigationPathQueryParameters3D::get_navigation_layers);
  119. ClassDB::bind_method(D_METHOD("set_metadata_flags", "flags"), &NavigationPathQueryParameters3D::set_metadata_flags);
  120. ClassDB::bind_method(D_METHOD("get_metadata_flags"), &NavigationPathQueryParameters3D::get_metadata_flags);
  121. ADD_PROPERTY(PropertyInfo(Variant::RID, "map"), "set_map", "get_map");
  122. ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "start_position"), "set_start_position", "get_start_position");
  123. ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "target_position"), "set_target_position", "get_target_position");
  124. ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_layers", PROPERTY_HINT_LAYERS_3D_NAVIGATION), "set_navigation_layers", "get_navigation_layers");
  125. ADD_PROPERTY(PropertyInfo(Variant::INT, "pathfinding_algorithm", PROPERTY_HINT_ENUM, "AStar"), "set_pathfinding_algorithm", "get_pathfinding_algorithm");
  126. ADD_PROPERTY(PropertyInfo(Variant::INT, "path_postprocessing", PROPERTY_HINT_ENUM, "Corridorfunnel,Edgecentered"), "set_path_postprocessing", "get_path_postprocessing");
  127. ADD_PROPERTY(PropertyInfo(Variant::INT, "metadata_flags", PROPERTY_HINT_FLAGS, "Include Types,Include RIDs,Include Owners"), "set_metadata_flags", "get_metadata_flags");
  128. BIND_ENUM_CONSTANT(PATHFINDING_ALGORITHM_ASTAR);
  129. BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_CORRIDORFUNNEL);
  130. BIND_ENUM_CONSTANT(PATH_POSTPROCESSING_EDGECENTERED);
  131. BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_NONE);
  132. BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_TYPES);
  133. BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_RIDS);
  134. BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_OWNERS);
  135. BIND_BITFIELD_FLAG(PATH_METADATA_INCLUDE_ALL);
  136. }