| 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 | |
| 31 | #include "navigation_path_query_result_2d.h" |
| 32 | |
| 33 | void NavigationPathQueryResult2D::set_path(const Vector<Vector2> &p_path) { |
| 34 | path = p_path; |
| 35 | } |
| 36 | |
| 37 | const Vector<Vector2> &NavigationPathQueryResult2D::get_path() const { |
| 38 | return path; |
| 39 | } |
| 40 | |
| 41 | void NavigationPathQueryResult2D::set_path_types(const Vector<int32_t> &p_path_types) { |
| 42 | path_types = p_path_types; |
| 43 | } |
| 44 | |
| 45 | const Vector<int32_t> &NavigationPathQueryResult2D::get_path_types() const { |
| 46 | return path_types; |
| 47 | } |
| 48 | |
| 49 | void NavigationPathQueryResult2D::set_path_rids(const TypedArray<RID> &p_path_rids) { |
| 50 | path_rids = p_path_rids; |
| 51 | } |
| 52 | |
| 53 | TypedArray<RID> NavigationPathQueryResult2D::get_path_rids() const { |
| 54 | return path_rids; |
| 55 | } |
| 56 | |
| 57 | void NavigationPathQueryResult2D::set_path_owner_ids(const Vector<int64_t> &p_path_owner_ids) { |
| 58 | path_owner_ids = p_path_owner_ids; |
| 59 | } |
| 60 | |
| 61 | const Vector<int64_t> &NavigationPathQueryResult2D::get_path_owner_ids() const { |
| 62 | return path_owner_ids; |
| 63 | } |
| 64 | |
| 65 | void NavigationPathQueryResult2D::reset() { |
| 66 | path.clear(); |
| 67 | path_types.clear(); |
| 68 | path_rids.clear(); |
| 69 | path_owner_ids.clear(); |
| 70 | } |
| 71 | |
| 72 | 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) { |
| 73 | path.clear(); |
| 74 | path_types.clear(); |
| 75 | path_rids.clear(); |
| 76 | path_owner_ids.clear(); |
| 77 | |
| 78 | { |
| 79 | path.resize(p_path.size()); |
| 80 | Vector2 *w = path.ptrw(); |
| 81 | const Vector2 *r = p_path.ptr(); |
| 82 | for (uint32_t i = 0; i < p_path.size(); i++) { |
| 83 | w[i] = r[i]; |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | { |
| 88 | path_types.resize(p_path_types.size()); |
| 89 | int32_t *w = path_types.ptrw(); |
| 90 | const int32_t *r = p_path_types.ptr(); |
| 91 | for (uint32_t i = 0; i < p_path_types.size(); i++) { |
| 92 | w[i] = r[i]; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | { |
| 97 | path_rids.resize(p_path_rids.size()); |
| 98 | for (uint32_t i = 0; i < p_path_rids.size(); i++) { |
| 99 | path_rids[i] = p_path_rids[i]; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | { |
| 104 | path_owner_ids.resize(p_path_owner_ids.size()); |
| 105 | int64_t *w = path_owner_ids.ptrw(); |
| 106 | const int64_t *r = p_path_owner_ids.ptr(); |
| 107 | for (uint32_t i = 0; i < p_path_owner_ids.size(); i++) { |
| 108 | w[i] = r[i]; |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | void NavigationPathQueryResult2D::set_path_length(float p_length) { |
| 114 | path_length = p_length; |
| 115 | } |
| 116 | |
| 117 | float NavigationPathQueryResult2D::get_path_length() const { |
| 118 | return path_length; |
| 119 | } |
| 120 | |
| 121 | void NavigationPathQueryResult2D::_bind_methods() { |
| 122 | ClassDB::bind_method(D_METHOD("set_path", "path"), &NavigationPathQueryResult2D::set_path); |
| 123 | ClassDB::bind_method(D_METHOD("get_path"), &NavigationPathQueryResult2D::get_path); |
| 124 | |
| 125 | ClassDB::bind_method(D_METHOD("set_path_types", "path_types"), &NavigationPathQueryResult2D::set_path_types); |
| 126 | ClassDB::bind_method(D_METHOD("get_path_types"), &NavigationPathQueryResult2D::get_path_types); |
| 127 | |
| 128 | ClassDB::bind_method(D_METHOD("set_path_rids", "path_rids"), &NavigationPathQueryResult2D::set_path_rids); |
| 129 | ClassDB::bind_method(D_METHOD("get_path_rids"), &NavigationPathQueryResult2D::get_path_rids); |
| 130 | |
| 131 | ClassDB::bind_method(D_METHOD("set_path_owner_ids", "path_owner_ids"), &NavigationPathQueryResult2D::set_path_owner_ids); |
| 132 | ClassDB::bind_method(D_METHOD("get_path_owner_ids"), &NavigationPathQueryResult2D::get_path_owner_ids); |
| 133 | |
| 134 | ClassDB::bind_method(D_METHOD("set_path_length", "length"), &NavigationPathQueryResult2D::set_path_length); |
| 135 | ClassDB::bind_method(D_METHOD("get_path_length"), &NavigationPathQueryResult2D::get_path_length); |
| 136 | |
| 137 | ClassDB::bind_method(D_METHOD("reset"), &NavigationPathQueryResult2D::reset); |
| 138 | |
| 139 | ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR2_ARRAY, "path"), "set_path", "get_path"); |
| 140 | ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "path_types"), "set_path_types", "get_path_types"); |
| 141 | ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "path_rids", PROPERTY_HINT_ARRAY_TYPE, "RID"), "set_path_rids", "get_path_rids"); |
| 142 | ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT64_ARRAY, "path_owner_ids"), "set_path_owner_ids", "get_path_owner_ids"); |
| 143 | ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_length"), "set_path_length", "get_path_length"); |
| 144 | |
| 145 | BIND_ENUM_CONSTANT(PATH_SEGMENT_TYPE_REGION); |
| 146 | BIND_ENUM_CONSTANT(PATH_SEGMENT_TYPE_LINK); |
| 147 | } |