Closed danielytics closed 4 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.
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.
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.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).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).
@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...
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?
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.
I'd like math functions to be added like in the engine, under a Math
namespace, for two reasons:
double
but used as float
(because of real_t
), but in engine they are wrapped in such a way both float
and double
are available as overloads
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.