| 258 | } |
| 259 | |
| 260 | NodePath NodePath::slice(int p_begin, int p_end) const { |
| 261 | const int name_count = get_name_count(); |
| 262 | const int total_count = get_total_name_count(); |
| 263 | |
| 264 | int begin = CLAMP(p_begin, -total_count, total_count); |
| 265 | if (begin < 0) { |
| 266 | begin += total_count; |
| 267 | } |
| 268 | int end = CLAMP(p_end, -total_count, total_count); |
| 269 | if (end < 0) { |
| 270 | end += total_count; |
| 271 | } |
| 272 | const int sub_begin = MAX(begin - name_count, 0); |
| 273 | const int sub_end = MAX(end - name_count, 0); |
| 274 | |
| 275 | const Vector<StringName> names = get_names().slice(begin, end); |
| 276 | const Vector<StringName> sub_names = get_subnames().slice(sub_begin, sub_end); |
| 277 | const bool absolute = is_absolute() && (begin == 0); |
| 278 | return NodePath(names, sub_names, absolute); |
| 279 | } |
| 280 | |
| 281 | NodePath NodePath::rel_path_to(const NodePath &p_np) const { |
| 282 | ERR_FAIL_COND_V(!is_absolute(), NodePath()); |