godotengine / godot-cpp

C++ bindings for the Godot script API
MIT License
1.74k stars 576 forks source link

Are the GDScript built-in functions available in GDNative? #107

Closed danielytics closed 4 years ago

danielytics commented 6 years ago

Are the GDScript built-in functions (as listed here http://docs.godotengine.org/en/3.0/classes/class_@gdscript.html) available from GDNative? Obviously many of the math functions are available in cstdlib and cmath, but not all, for example clamp, lerp, wrapf and it would also be useful if the same random number generator could be used globally.

karroffel commented 6 years ago

No, unfortunately not, they have to be hardcoded and not all of them have been implemented yet.

The only functions implemented are for printing, Godot::print().

New ones should be implemented in the same class, but for now we need workarounds.

danielytics commented 6 years ago

If you let me know what you want for this, I'll be happy to open a PR. Its unfortunate that code can't be reused as it feels a little nasty to have the same code implemented multiple times within the engine, but I guess I'd rather have them duplicated than not available.

jacksondus commented 6 years ago

The main things I need for my own project is the mesh modification library. I was looking to do some large-scale procedural mesh generation, and GDScript is much too slow and regular C feels too archaic (eg, no built-in object oriented libraries, etc).

BastiaanOlij commented 5 years ago

@jacksondus shameless plug: https://github.com/BastiaanOlij/gdprocmesh

@danielytics if you're still up for it I think it would be nice to have some of those functions implemented. Not sure what the best place for them would be though...

ricardoalcantara commented 5 years ago

Hey! Can't we include the Godot files instead of re-implement it, when we build the godot-cpp? Or maybe make that interface with Godot:: like the print implementation?

ricardoalcantara commented 5 years ago

I achieve to use godot's source code in my gdnative sample, I added the {godot_path} and {godot_path}/platform/{x11/...} in my CPPPATH and I could use it without issue.

Zylann commented 4 years ago

I'd like math functions to be added like in the engine, under a Math namespace, for two reasons: