From 96609815ecc2a9edf9ad6b460355a055e6e10914 Mon Sep 17 00:00:00 2001 From: Wiktor Kocielski Date: Tue, 11 Apr 2023 15:56:46 +0300 Subject: [PATCH] Fix C++ API for Vector2/3 Normalization --- Source/Engine/Core/Math/Vector2.h | 5 +++-- Source/Engine/Core/Math/Vector3.h | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/Engine/Core/Math/Vector2.h b/Source/Engine/Core/Math/Vector2.h index 2f7a143c4..32372e42d 100644 --- a/Source/Engine/Core/Math/Vector2.h +++ b/Source/Engine/Core/Math/Vector2.h @@ -228,8 +228,9 @@ public: /// Vector2Base GetNormalized() const { - const T rcp = 1.0f / Length(); - return Vector2Base(X * rcp, Y * rcp); + Vector2Base Result(X, Y); + Result.Normalize(); + return Result; } public: diff --git a/Source/Engine/Core/Math/Vector3.h b/Source/Engine/Core/Math/Vector3.h index 18daa8934..ff548316a 100644 --- a/Source/Engine/Core/Math/Vector3.h +++ b/Source/Engine/Core/Math/Vector3.h @@ -254,8 +254,9 @@ public: /// Vector3Base GetNormalized() const { - const T rcp = 1.0f / Length(); - return Vector3Base(X * rcp, Y * rcp, Z * rcp); + Vector3Base Result(X, Y, Z); + Result.Normalize(); + return Result; } public: