From 6694c119d069d8ff8dc5290d38d2d33625f07807 Mon Sep 17 00:00:00 2001 From: Chaosus Date: Sun, 14 Jul 2019 07:30:45 +0300 Subject: Added lerp_angles built-in function Co-authored-by: Xrayez Co-authored-by: DleanJeans --- modules/mono/glue/Managed/Files/Mathf.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'modules/mono/glue') diff --git a/modules/mono/glue/Managed/Files/Mathf.cs b/modules/mono/glue/Managed/Files/Mathf.cs index 2d8c63fe7f..6c1a51fcf9 100644 --- a/modules/mono/glue/Managed/Files/Mathf.cs +++ b/modules/mono/glue/Managed/Files/Mathf.cs @@ -185,6 +185,12 @@ namespace Godot return from + (to - from) * weight; } + public static real_t LerpAngle(real_t from, real_t to, real_t weight) { + real_t difference = (to - from) % Mathf.Tau; + real_t distance = ((2 * difference) % Mathf.Tau) - difference; + return from + distance * weight; + } + public static real_t Log(real_t s) { return (real_t)Math.Log(s); -- cgit v1.2.3