diff --git a/Source/Engine/Core/Math/Vector2.cs b/Source/Engine/Core/Math/Vector2.cs index 25c25ca21..cd1849383 100644 --- a/Source/Engine/Core/Math/Vector2.cs +++ b/Source/Engine/Core/Math/Vector2.cs @@ -301,6 +301,19 @@ namespace FlaxEngine } } + /// + /// Gets the normalized vector. Returned vector has length equal 1. + /// + public Vector2 Normalized + { + get + { + Vector2 result = this; + result.Normalize(); + return result; + } + } + /// /// Creates an array containing the elements of the vector. /// diff --git a/Source/Engine/Core/Math/Vector2.h b/Source/Engine/Core/Math/Vector2.h index 2b8c80293..2f7a143c4 100644 --- a/Source/Engine/Core/Math/Vector2.h +++ b/Source/Engine/Core/Math/Vector2.h @@ -223,6 +223,15 @@ public: return Vector2Base(-X, -Y); } + /// + /// Calculates a normalized vector that has length equal to 1. + /// + Vector2Base GetNormalized() const + { + const T rcp = 1.0f / Length(); + return Vector2Base(X * rcp, Y * rcp); + } + public: /// /// Performs vector normalization (scales vector up to unit length). diff --git a/Source/Engine/Input/Input.cpp b/Source/Engine/Input/Input.cpp index 2fc75a15e..027c40bf2 100644 --- a/Source/Engine/Input/Input.cpp +++ b/Source/Engine/Input/Input.cpp @@ -17,8 +17,6 @@ #include "Engine/Profiler/ProfilerCPU.h" #include "Engine/Serialization/JsonTools.h" -#include "Engine/Debug/DebugLog.h" - struct AxisEvaluation { float RawValue;