diff options
Diffstat (limited to 'modules/mono/glue')
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs | 19 | ||||
-rw-r--r-- | modules/mono/glue/gd_glue.cpp | 23 |
2 files changed, 30 insertions, 12 deletions
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs index ef42374041..a3afc83222 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs @@ -323,6 +323,16 @@ namespace Godot } /// <summary> + /// Returns a normally-distributed pseudo-random number, using Box-Muller transform with the specified <c>mean</c> and a standard <c>deviation</c>. + /// This is also called Gaussian distribution. + /// </summary> + /// <returns>A random normally-distributed <see langword="float"/> number.</returns> + public static double Randfn(double mean, double deviation) + { + return godot_icall_GD_randfn(mean, deviation); + } + + /// <summary> /// Returns a random unsigned 32-bit integer. /// Use remainder to obtain a random value in the interval <c>[0, N - 1]</c> (where N is smaller than 2^32). /// </summary> @@ -564,19 +574,22 @@ namespace Godot internal static extern void godot_icall_GD_printt(object[] what); [MethodImpl(MethodImplOptions.InternalCall)] - internal static extern float godot_icall_GD_randf(); + internal static extern void godot_icall_GD_randomize(); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern uint godot_icall_GD_randi(); [MethodImpl(MethodImplOptions.InternalCall)] - internal static extern void godot_icall_GD_randomize(); + internal static extern float godot_icall_GD_randf(); + + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern int godot_icall_GD_randi_range(int from, int to); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern double godot_icall_GD_randf_range(double from, double to); [MethodImpl(MethodImplOptions.InternalCall)] - internal static extern int godot_icall_GD_randi_range(int from, int to); + internal static extern double godot_icall_GD_randfn(double mean, double deviation); [MethodImpl(MethodImplOptions.InternalCall)] internal static extern uint godot_icall_GD_rand_seed(ulong seed, out ulong newSeed); diff --git a/modules/mono/glue/gd_glue.cpp b/modules/mono/glue/gd_glue.cpp index a2ff868f65..07ddf5d945 100644 --- a/modules/mono/glue/gd_glue.cpp +++ b/modules/mono/glue/gd_glue.cpp @@ -182,26 +182,30 @@ void godot_icall_GD_printt(MonoArray *p_what) { print_line(str); } -float godot_icall_GD_randf() { - return Math::randf(); +void godot_icall_GD_randomize() { + Math::randomize(); } uint32_t godot_icall_GD_randi() { return Math::rand(); } -void godot_icall_GD_randomize() { - Math::randomize(); +float godot_icall_GD_randf() { + return Math::randf(); } -double godot_icall_GD_randf_range(double from, double to) { +int32_t godot_icall_GD_randi_range(int32_t from, int32_t to) { return Math::random(from, to); } -int32_t godot_icall_GD_randi_range(int32_t from, int32_t to) { +double godot_icall_GD_randf_range(double from, double to) { return Math::random(from, to); } +double godot_icall_GD_randfn(double mean, double deviation) { + return Math::randfn(mean, deviation); +} + uint32_t godot_icall_GD_rand_seed(uint64_t seed, uint64_t *newSeed) { uint32_t ret = Math::rand_from_seed(&seed); *newSeed = seed; @@ -300,11 +304,12 @@ void godot_register_gd_icalls() { GDMonoUtils::add_internal_call("Godot.GD::godot_icall_GD_printraw", godot_icall_GD_printraw); GDMonoUtils::add_internal_call("Godot.GD::godot_icall_GD_prints", godot_icall_GD_prints); GDMonoUtils::add_internal_call("Godot.GD::godot_icall_GD_printt", godot_icall_GD_printt); - GDMonoUtils::add_internal_call("Godot.GD::godot_icall_GD_randf", godot_icall_GD_randf); - GDMonoUtils::add_internal_call("Godot.GD::godot_icall_GD_randi", godot_icall_GD_randi); GDMonoUtils::add_internal_call("Godot.GD::godot_icall_GD_randomize", godot_icall_GD_randomize); - GDMonoUtils::add_internal_call("Godot.GD::godot_icall_GD_randf_range", godot_icall_GD_randf_range); + GDMonoUtils::add_internal_call("Godot.GD::godot_icall_GD_randi", godot_icall_GD_randi); + GDMonoUtils::add_internal_call("Godot.GD::godot_icall_GD_randf", godot_icall_GD_randf); GDMonoUtils::add_internal_call("Godot.GD::godot_icall_GD_randi_range", godot_icall_GD_randi_range); + GDMonoUtils::add_internal_call("Godot.GD::godot_icall_GD_randf_range", godot_icall_GD_randf_range); + GDMonoUtils::add_internal_call("Godot.GD::godot_icall_GD_randfn", godot_icall_GD_randfn); GDMonoUtils::add_internal_call("Godot.GD::godot_icall_GD_rand_seed", godot_icall_GD_rand_seed); GDMonoUtils::add_internal_call("Godot.GD::godot_icall_GD_seed", godot_icall_GD_seed); GDMonoUtils::add_internal_call("Godot.GD::godot_icall_GD_str", godot_icall_GD_str); |