navigation_path_query_result_2d.cpp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /**************************************************************************/
  2. /* navigation_path_query_result_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_result_2d.h"
  31. void NavigationPathQueryResult2D::set_path(const Vector<Vector2> &p_path) {
  32. path = p_path;
  33. }
  34. const Vector<Vector2> &NavigationPathQueryResult2D::get_path() const {
  35. return path;
  36. }
  37. void NavigationPathQueryResult2D::set_path_types(const Vector<int32_t> &p_path_types) {
  38. path_types = p_path_types;
  39. }
  40. const Vector<int32_t> &NavigationPathQueryResult2D::get_path_types() const {
  41. return path_types;
  42. }
  43. void NavigationPathQueryResult2D::set_path_rids(const TypedArray<RID> &p_path_rids) {
  44. path_rids = p_path_rids;
  45. }
  46. TypedArray<RID> NavigationPathQueryResult2D::get_path_rids() const {
  47. return path_rids;
  48. }
  49. void NavigationPathQueryResult2D::set_path_owner_ids(const Vector<int64_t> &p_path_owner_ids) {
  50. path_owner_ids = p_path_owner_ids;
  51. }
  52. const Vector<int64_t> &NavigationPathQueryResult2D::get_path_owner_ids() const {
  53. return path_owner_ids;
  54. }
  55. void NavigationPathQueryResult2D::reset() {
  56. path.clear();
  57. path_types.clear();
  58. path_rids.clear();
  59. path_owner_ids.clear();
  60. }
  61. void NavigationPathQueryResult2D::set_data(const LocalVector<Vector2> &p_path, const LocalVector<int32_t> &p_path_types, const LocalVector<RID> &p_path_rids, const LocalVector<int64_t> &p_path_owner_ids) {
  62. path.clear();
  63. path_types.clear();
  64. path_rids.clear();
  65. path_owner_ids.clear();
  66. {
  67. path.resize(p_path.size());
  68. Vector2 *w = path.ptrw();
  69. const Vector2 *r = p_path.ptr();
  70. for (uint32_t i = 0; i < p_path.size(); i++) {
  71. w[i] = r[i];
  72. }
  73. }
  74. {
  75. path_types.resize(p_path_types.size());
  76. int32_t *w = path_types.ptrw();
  77. const int32_t *r = p_path_types.ptr();
  78. for (uint32_t i = 0; i < p_path_types.size(); i++) {
  79. w[i] = r[i];
  80. }
  81. }
  82. {
  83. path_rids.resize(p_path_rids.size());
  84. for (uint32_t i = 0; i < p_path_rids.size(); i++) {
  85. path_rids[i] = p_path_rids[i];
  86. }
  87. }
  88. {
  89. path_owner_ids.resize(p_path_owner_ids.size());
  90. int64_t *w = path_owner_ids.ptrw();
  91. const int64_t *r = p_path_owner_ids.ptr();
  92. for (uint32_t i = 0; i < p_path_owner_ids.size(); i++) {
  93. w[i] = r[i];
  94. }
  95. }
  96. }
  97. void NavigationPathQueryResult2D::_bind_methods() {
  98. ClassDB::bind_method(D_METHOD("set_path", "path"), &NavigationPathQueryResult2D::set_path);
  99. ClassDB::bind_method(D_METHOD("get_path"), &NavigationPathQueryResult2D::get_path);
  100. ClassDB::bind_method(D_METHOD("set_path_types", "path_types"), &NavigationPathQueryResult2D::set_path_types);
  101. ClassDB::bind_method(D_METHOD("get_path_types"), &NavigationPathQueryResult2D::get_path_types);
  102. ClassDB::bind_method(D_METHOD("set_path_rids", "path_rids"), &NavigationPathQueryResult2D::set_path_rids);
  103. ClassDB::bind_method(D_METHOD("get_path_rids"), &NavigationPathQueryResult2D::get_path_rids);
  104. ClassDB::bind_method(D_METHOD("set_path_owner_ids", "path_owner_ids"), &NavigationPathQueryResult2D::set_path_owner_ids);
  105. ClassDB::bind_method(D_METHOD("get_path_owner_ids"), &NavigationPathQueryResult2D::get_path_owner_ids);
  106. ClassDB::bind_method(D_METHOD("reset"), &NavigationPathQueryResult2D::reset);
  107. ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR2_ARRAY, "path"), "set_path", "get_path");
  108. ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "path_types"), "set_path_types", "get_path_types");
  109. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "path_rids", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_path_rids", "get_path_rids");
  110. ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT64_ARRAY, "path_owner_ids"), "set_path_owner_ids", "get_path_owner_ids");
  111. BIND_ENUM_CONSTANT(PATH_SEGMENT_TYPE_REGION);
  112. BIND_ENUM_CONSTANT(PATH_SEGMENT_TYPE_LINK);
  113. }