Skip to content
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

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

Closed
danielytics opened this issue Mar 5, 2018 · 7 comments · Fixed by #451
Closed

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

danielytics opened this issue Mar 5, 2018 · 7 comments · Fixed by #451
Labels
enhancement This is an enhancement on the current functionality

Comments

@danielytics
Copy link
Contributor

Are the GDScript built-in functions (as listed here http://docs.godotengine.org/en/3.0/classes/[email protected]) 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
Copy link
Contributor

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
Copy link
Contributor Author

danielytics commented Mar 6, 2018

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.

  • I'm thinking at least clamp, lerp, cartesian2polar, db2linear, deg2rad, sign, inverse_lerp, linear2db, load, nearest_po2, polar2cartesian, rad2deg, range, range_lerp, stepify, wrapf and wrapi.
  • Color8 and ColorN are not needed as the functionality already exists in the core/Color class.
  • The random number generation functions should probably wrap the functions in godot/core/math/math_funcs.cpp (ideally all of the above would be wrapped from godot too, but I dunno how much effort that is versus reimplementing them).

@jacksondus
Copy link

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
Copy link
Collaborator

@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...

@BastiaanOlij BastiaanOlij added the enhancement This is an enhancement on the current functionality label Nov 23, 2018
@ricardoalcantara
Copy link

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
Copy link

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
Copy link
Collaborator

Zylann commented Mar 27, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is an enhancement on the current functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants