godotengine / godotengine/godot-cpp
Objects are not unwrapped when returned through parameters
- Dominant language
- C++
- Stars
- 2.7k
- Forks
- 809
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 8
Description
The [unwrapping](https://github.com/godotengine/godot-cpp/blob/9d1c396c54fc3bdfcc7da4f3abcb52b14f6cce8f/include/godot_cpp/core/method_ptrcall.hpp#L175) of objects, that typically happens when you return a godot-cpp `Object*` back to the engine, doesn't seem to happen when it's returned as part of a result struct that's passed as a parameter, such as the [`collider`](https://github.com/godotengine/godot/blob/2267646bf4c29acf1342951d8726626817c742bd/servers/physics_server_3d.h#L155) field on [`PhysicsServer3DExtensionRayResult`](https://github.com/godotengine/godot/blob/2267646bf4c29acf1342951d8726626817c742bd/servers/extensions/physics_server_3d_extension.h#L114) that's passed to [`PhysicsDirectSpaceState3DExtension::_intersect_ray`](https://github.com/godotengine/godot/blob/2267646bf4c29acf1342951d8726626817c742bd/servers/extensions/physics_server_3d_extension.h#L131).
This leads to having to employ workarounds such as either manually unwrapping the object, by directly grabbing its internal `_owner` field, or calling the internal GDExtension function `object_get_instance_from_id` with the object's instance ID. In either case you're forced to also (incorrectly) cast the resulting pointer to a godot-cpp `Object*`, since the generated interface still expects that type.
Normally I'd include steps to reproduce the problem and a minimal repro project, but seeing as how this involves result structs for `PhysicsDirectSpaceState3D` you need quite a lot of boilerplate to even get to the point where you can call this. So I'm hoping the description will be sufficient for someone familiar with the space. If not, I'd be happy to elaborate further.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.