From 82e9923be3b0f36978735f67ddea74c1dbce9007 Mon Sep 17 00:00:00 2001
From: Ruan Lucas <79365912+RuanLucasGD@users.noreply.github.com>
Date: Thu, 26 Jan 2023 08:54:15 -0400
Subject: [PATCH] change IsAnyKeyDown to IsAnyButtonDown and add
Float2.Normalized
---
Source/Engine/Core/Math/Float2.cs | 13 +++++++++++++
Source/Engine/Input/Gamepad.cpp | 2 +-
Source/Engine/Input/Gamepad.h | 2 +-
Source/Engine/Input/Input.cpp | 2 +-
Source/Engine/Input/Mouse.h | 4 ++--
5 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/Source/Engine/Core/Math/Float2.cs b/Source/Engine/Core/Math/Float2.cs
index 276c0c713..15f412d6e 100644
--- a/Source/Engine/Core/Math/Float2.cs
+++ b/Source/Engine/Core/Math/Float2.cs
@@ -267,6 +267,19 @@ namespace FlaxEngine
/// This method may be preferred to when only a relative length is needed and speed is of the essence.
public float LengthSquared => X * X + Y * Y;
+ ///
+ /// Gets the normalized vector. Returned vector has length equal 1.
+ ///
+ public Float2 Normalized
+ {
+ get
+ {
+ Float2 result = this;
+ result.Normalize();
+ return result;
+ }
+ }
+
///
/// Converts the vector into a unit vector.
///
diff --git a/Source/Engine/Input/Gamepad.cpp b/Source/Engine/Input/Gamepad.cpp
index b7133dfbe..278dc5961 100644
--- a/Source/Engine/Input/Gamepad.cpp
+++ b/Source/Engine/Input/Gamepad.cpp
@@ -31,7 +31,7 @@ void Gamepad::ResetState()
_mappedPrevState.Clear();
}
-bool Gamepad::IsAnyKeyDown() const
+bool Gamepad::IsAnyButtonDown() const
{
// TODO: optimize with SIMD
bool result = false;
diff --git a/Source/Engine/Input/Gamepad.h b/Source/Engine/Input/Gamepad.h
index 1fa0f20b8..27a53a716 100644
--- a/Source/Engine/Input/Gamepad.h
+++ b/Source/Engine/Input/Gamepad.h
@@ -167,7 +167,7 @@ public:
///
/// Checks if any gamepad button is currently pressed.
///
- API_PROPERTY() bool IsAnyKeyDown() const;
+ API_PROPERTY() bool IsAnyButtonDown() const;
///
/// Gets the gamepad button up state (true if was released during the current frame).
diff --git a/Source/Engine/Input/Input.cpp b/Source/Engine/Input/Input.cpp
index 027c40bf2..7a4547c62 100644
--- a/Source/Engine/Input/Input.cpp
+++ b/Source/Engine/Input/Input.cpp
@@ -183,7 +183,7 @@ void Mouse::OnMouseDown(const Float2& position, const MouseButton button, Window
e.MouseData.Position = position;
}
-bool Mouse::IsAnyKeyDown() const
+bool Mouse::IsAnyButtonDown() const
{
// TODO: optimize with SIMD
bool result = false;
diff --git a/Source/Engine/Input/Mouse.h b/Source/Engine/Input/Mouse.h
index e137948bb..7fc2be75a 100644
--- a/Source/Engine/Input/Mouse.h
+++ b/Source/Engine/Input/Mouse.h
@@ -65,9 +65,9 @@ public:
}
///
- /// Checks if any mouse key is currently pressed.
+ /// Checks if any mouse button is currently pressed.
///
- API_PROPERTY() bool IsAnyKeyDown() const;
+ API_PROPERTY() bool IsAnyButtonDown() const;
///
/// Gets the delta position of the mouse in the screen-space coordinates.