-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update godot internal API to match godot-cpp API #11055
Comments
Godot itself does use underscores as well, the method is
This is because of performance benefits of using a passed Using the version that takes an argument in c++ is generally more performant as you don't need to create and pass data in the same way |
Updated 1. with another function example, not bind_methods. There are multiple like these also.
|
The new example for 1 isn't the same method though, the first is a public method the second is a private internal bind, the former calls the latter, it's like |
The difference is that the one without the underscore should be called, and the one without shouldn't, except internally, like how you don't call |
I'd personally be for changing the signature (the arguments and return value) of these sort of virtual methods to match godot-cpp. (The underscore thing is a little trickier, because in some cases the non-underscore version is a non-virtual C++ function that may call the Godot virtual method, and so we need to have two separate names to distinguish them.)
I'm not 100% sure there would be a performance issue. In the "olden days", I think you would definitely be right: using the linked list passed by reference means we're just allocating a new item each time we add one, without any re-allocation or copying. But with modern CPUs, I suspect it would be a wash overall: re-allocating the array each time it was expanded would be somewhat slower, but we would gain when looping over the array because they'd be in contiguous memory. I think the only way to really know would be to try it and measure. The rest of things in the proposal I'm less convinced about: I think the macros and includes could be handled on the godot-cpp side. However, there are some other naming mismatches that I think we should fix on the Godot side, for example, these PRs from @aaronfranke:
In general, I think we've got to look at each category of API mismatch on a case-by-case basis. |
For performance you have a lot of overhead with typed arrays, because of checking and |
Ah, and I forgot we're actually using We could maybe do more on the godot-cpp side to normalize those? Like, we could hand-write the virtual functions that take |
For the problem of Dictionary vs PropertyInfo, can we allow the Dictionary version (that starts with an underscore) to be used from both modules and GDExtension, while the PropertyInfo version (no underscore prefix) can be kept as internal-only? This way it's possible to use the Dictionary version in both, even if it's a bit slower than it otherwise could be. |
Describe the project you are working on
Godot Sandbox In-editor scripting and sandboxing for Godot and many other addons/modules
Describe the problem or limitation you are having in your project
Writting an addon using gdextension (godot-cpp) and building it also as a module (godot).
Here godot-cpp has the
get_singleton
function, godot doesn't. Would be nice to even duplicate that function so the code works same for both.Here it seems that one function is caleld
get_resource_file_system
, one is calledget_resource_filesystem
. Would be nice that if they match.NOTE: for all these cases, there are multiple cases, not just these individual ones. These are classes or problems.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Part 1. The includes
There is already proposal for making sure godot-cpp generates includes that point to both godot-cpp and godot: #9212. There is also a PR for it godotengine/godot-cpp#1415 that adds a compatibility layer to godot-cpp:
eg.
Part 2. Some macros
After this, the writter of the addon, needs to just update the
using namespace godot;
part and create aSCsub
and can use the existing build systems for both gdextension and module builds.Eg.
For the defines, they would look like:
Part 3. Godot changes
As said above in the limitations chapter, some functions in godot either don't match, don't exist, have extra parameters or different names. Where it's possible to fix this by a macro, thats ok. Where no, it would be really nice if we change the function to match godot-cpp. I would even say we don't do that ugly macro and instead make the godot function (o underscore) also match the godot-cpp function naming.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Changin godot internal API (functions) to match godot-cpp one. (it would be incremental change).
Downsides of this proposal:
If people have modules, they need to update them. But if they do, they would in theory be able to migrate also to support addons too out of the box, so it would be a necesary change for those people. A big project that does this, supports both addon/module is godot voxel, and you can see there how many ifdefs there are.
If this enhancement will not be used often, can it be worked around with a few lines of script?
Is there a reason why this should be core and not an add-on in the asset library?
EDIT: Updated 1. with another function example, not bind_methods.
The text was updated successfully, but these errors were encountered: