godotengine / godotengine/godot-cpp

NodePath is missing constructors with `Vector<StringName>`

Open
#1,766 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.7k
Forks
809
Avg merge
1d 3h
Merged PRs (30d)
8

Description

### Godot version

4.4.stable

### godot-cpp version

4d8c05f405929480ef2eed7300447c4647da2d6f

### System information

macOS 14.6.1

### Issue description

In the core engine, NodePath has the following constructors:

```cpp
NodePath(const Vector &p_path, bool p_absolute);
NodePath(const Vector &p_path, const Vector &p_subpath, bool p_absolute);
```

These seem to be missing in godot-cpp. They're not in the generated NodePath header because the bindings don't have `Vector`. We could manually add them in a separate header, but would that just convert it to a slash-delimited String and have the engine re-parse it, or should we have the engine expose `TypedArray` functions?

Easy work-around:

```cpp
NodePath _make_node_path(const Vector &p_path) const {
#if GDEXTENSION
PackedStringArray path_array;
for (const StringName &name : p_path) {
path_array.push_back(name);
}
String path_str = String("/").join(path_array);
return NodePath(path_str);
#elif GODOT_MODULE
return NodePath(p_path, false);
#endif
}
```

### Steps to reproduce

N/A

### Minimal reproduction project

N/A

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.