MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / slice

Method slice

core/string/node_path.cpp:260–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258}
259
260NodePath 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
281NodePath NodePath::rel_path_to(const NodePath &p_np) const {
282 ERR_FAIL_COND_V(!is_absolute(), NodePath());

Callers

nothing calls this directly

Calls 4

CLAMPFunction · 0.85
MAXFunction · 0.85
NodePathClass · 0.70
sliceMethod · 0.65

Tested by

no test coverage detected