From 94bc0bd9193d5e361bbe657d59a492467f129721 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Mon, 1 Feb 2021 00:42:00 -0500 Subject: Rename Vector2 clamped to limit_length and add limit_length to Vector3 --- .../glue/GodotSharp/GodotSharp/Core/Vector2.cs | 38 +++++++++++----------- .../glue/GodotSharp/GodotSharp/Core/Vector3.cs | 19 +++++++++++ 2 files changed, 38 insertions(+), 19 deletions(-) (limited to 'modules') diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs index ebfe70aa82..c9bf415622 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs @@ -159,25 +159,6 @@ namespace Godot return new Vector2(Mathf.Ceil(x), Mathf.Ceil(y)); } - /// - /// Returns the vector with a maximum length by limiting its length to `length`. - /// - /// The length to limit to. - /// The vector with its length limited. - public Vector2 Clamped(real_t length) - { - var v = this; - real_t l = Length(); - - if (l > 0 && length < l) - { - v /= l; - v *= length; - } - - return v; - } - /// /// Returns the cross product of this vector and `b`. /// @@ -334,6 +315,25 @@ namespace Godot ); } + /// + /// Returns the vector with a maximum length by limiting its length to `length`. + /// + /// The length to limit to. + /// The vector with its length limited. + public Vector2 LimitLength(real_t length = 1.0f) + { + Vector2 v = this; + real_t l = Length(); + + if (l > 0 && length < l) + { + v /= l; + v *= length; + } + + return v; + } + /// /// Returns the axis of the vector's largest value. See . /// If both components are equal, this method returns . diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs index 3b895bbbf6..14aeac41d0 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs @@ -312,6 +312,25 @@ namespace Godot ); } + /// + /// Returns the vector with a maximum length by limiting its length to `length`. + /// + /// The length to limit to. + /// The vector with its length limited. + public Vector3 LimitLength(real_t length = 1.0f) + { + Vector3 v = this; + real_t l = Length(); + + if (l > 0 && length < l) + { + v /= l; + v *= length; + } + + return v; + } + /// /// Returns the axis of the vector's largest value. See . /// If all components are equal, this method returns . -- cgit v1.2.3