diff options
author | Aaron Franke <arnfranke@yahoo.com> | 2020-11-10 14:30:02 -0500 |
---|---|---|
committer | Aaron Franke <arnfranke@yahoo.com> | 2020-11-10 14:30:07 -0500 |
commit | ee79fc627c18d26221adeae2b641ba81ba662184 (patch) | |
tree | 1a131ddc44aaa01c3b639b879c4028a4b840a2b5 /modules | |
parent | a80ec80b57f419d84d196fb46dcb5f194c880001 (diff) |
Minor clamp and float fixes
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdscript/gdscript_functions.cpp | 16 | ||||
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs | 3 |
2 files changed, 9 insertions, 10 deletions
diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp index 0942552ba8..3a7c1a8676 100644 --- a/modules/gdscript/gdscript_functions.cpp +++ b/modules/gdscript/gdscript_functions.cpp @@ -285,7 +285,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_ int64_t i = *p_args[0]; r_ret = i < 0 ? -1 : (i > 0 ? +1 : 0); } else if (p_args[0]->get_type() == Variant::FLOAT) { - real_t r = *p_args[0]; + double r = *p_args[0]; r_ret = r < 0.0 ? -1.0 : (r > 0.0 ? +1.0 : 0.0); } else { r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; @@ -510,8 +510,8 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_ VALIDATE_ARG_NUM(0); VALIDATE_ARG_NUM(1); - real_t a = *p_args[0]; - real_t b = *p_args[1]; + double a = *p_args[0]; + double b = *p_args[1]; r_ret = MAX(a, b); } @@ -527,8 +527,8 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_ VALIDATE_ARG_NUM(0); VALIDATE_ARG_NUM(1); - real_t a = *p_args[0]; - real_t b = *p_args[1]; + double a = *p_args[0]; + double b = *p_args[1]; r_ret = MIN(a, b); } @@ -545,9 +545,9 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_ VALIDATE_ARG_NUM(1); VALIDATE_ARG_NUM(2); - real_t a = *p_args[0]; - real_t b = *p_args[1]; - real_t c = *p_args[2]; + double a = *p_args[0]; + double b = *p_args[1]; + double c = *p_args[2]; r_ret = CLAMP(a, b, c); } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs index 06bbe98497..bc0f81b2a7 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Transform2D.cs @@ -221,8 +221,7 @@ namespace Godot real_t dot = v1.Dot(v2); - // Clamp dot to [-1, 1] - dot = dot < -1.0f ? -1.0f : (dot > 1.0f ? 1.0f : dot); + dot = Mathf.Clamp(dot, -1.0f, 1.0f); Vector2 v; |