From d024979e84155a745f56d239f8b87c49c8b067bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Fri, 18 Jan 2019 10:46:52 +0100 Subject: GDScript: Fix return value of "lerp" builtin Fixes #25082, fixes #24709. --- doc/classes/@GDScript.xml | 7 +++++-- doc/classes/Shape2D.xml | 4 ++-- modules/gdscript/gdscript_functions.cpp | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/classes/@GDScript.xml b/doc/classes/@GDScript.xml index 601b1385ae..072eec800f 100644 --- a/doc/classes/@GDScript.xml +++ b/doc/classes/@GDScript.xml @@ -539,7 +539,7 @@ - + @@ -549,8 +549,11 @@ Linearly interpolates between two values by a normalized value. + If the [code]from[/code] and [code]to[/code] arguments are of type [int] or [float], the return value is a [float]. + If both are of the same vector type ([Vector2], [Vector3] or [Color]), the return value will be of the same type ([code]lerp[/code] then calls the vector type's [code]linear_interpolate[/code] method). [codeblock] - lerp(1, 3, 0.5) # returns 2 + lerp(0, 4, 0.75) # returns 3.0 + lerp(Vector2(1, 5), Vector2(3, 2), 0.5) # returns Vector2(2, 3.5) [/codeblock] diff --git a/doc/classes/Shape2D.xml b/doc/classes/Shape2D.xml index 96b8a77d9e..fc773faf5e 100644 --- a/doc/classes/Shape2D.xml +++ b/doc/classes/Shape2D.xml @@ -27,7 +27,7 @@ - + @@ -59,7 +59,7 @@ - + diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp index 6c1a796ca0..44d44462ca 100644 --- a/modules/gdscript/gdscript_functions.cpp +++ b/modules/gdscript/gdscript_functions.cpp @@ -1565,7 +1565,8 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) { } break; case MATH_LERP: { MethodInfo mi("lerp", PropertyInfo(Variant::NIL, "from"), PropertyInfo(Variant::NIL, "to"), PropertyInfo(Variant::REAL, "weight")); - mi.return_val.type = Variant::REAL; + mi.return_val.type = Variant::NIL; + mi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; return mi; } break; case MATH_INVERSE_LERP: { -- cgit v1.2.3