Merge branch 'RuanLucasGD-Inputs'
This commit is contained in:
@@ -267,6 +267,19 @@ namespace FlaxEngine
|
||||
/// <remarks>This method may be preferred to <see cref="Float2.Length" /> when only a relative length is needed and speed is of the essence.</remarks>
|
||||
public float LengthSquared => X * X + Y * Y;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the normalized vector. Returned vector has length equal 1.
|
||||
/// </summary>
|
||||
public Float2 Normalized
|
||||
{
|
||||
get
|
||||
{
|
||||
Float2 result = this;
|
||||
result.Normalize();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the vector into a unit vector.
|
||||
/// </summary>
|
||||
|
||||
@@ -301,6 +301,19 @@ namespace FlaxEngine
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the normalized vector. Returned vector has length equal 1.
|
||||
/// </summary>
|
||||
public Vector2 Normalized
|
||||
{
|
||||
get
|
||||
{
|
||||
Vector2 result = this;
|
||||
result.Normalize();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an array containing the elements of the vector.
|
||||
/// </summary>
|
||||
|
||||
@@ -223,6 +223,15 @@ public:
|
||||
return Vector2Base(-X, -Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates a normalized vector that has length equal to 1.
|
||||
/// </summary>
|
||||
Vector2Base GetNormalized() const
|
||||
{
|
||||
const T rcp = 1.0f / Length();
|
||||
return Vector2Base(X * rcp, Y * rcp);
|
||||
}
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// Performs vector normalization (scales vector up to unit length).
|
||||
|
||||
@@ -31,6 +31,15 @@ void Gamepad::ResetState()
|
||||
_mappedPrevState.Clear();
|
||||
}
|
||||
|
||||
bool Gamepad::IsAnyButtonDown() const
|
||||
{
|
||||
// TODO: optimize with SIMD
|
||||
bool result = false;
|
||||
for (auto e : _state.Buttons)
|
||||
result |= e;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Gamepad::Update(EventQueue& queue)
|
||||
{
|
||||
// Copy state
|
||||
|
||||
@@ -164,6 +164,11 @@ public:
|
||||
return _mappedState.Buttons[static_cast<int32>(button)] && !_mappedPrevState.Buttons[static_cast<int32>(button)];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if any gamepad button is currently pressed.
|
||||
/// </summary>
|
||||
API_PROPERTY() bool IsAnyButtonDown() const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the gamepad button up state (true if was released during the current frame).
|
||||
/// </summary>
|
||||
|
||||
@@ -183,6 +183,15 @@ void Mouse::OnMouseDown(const Float2& position, const MouseButton button, Window
|
||||
e.MouseData.Position = position;
|
||||
}
|
||||
|
||||
bool Mouse::IsAnyButtonDown() const
|
||||
{
|
||||
// TODO: optimize with SIMD
|
||||
bool result = false;
|
||||
for (auto e : Mouse::_state.MouseButtons)
|
||||
result |= e;
|
||||
return result;
|
||||
}
|
||||
|
||||
void Mouse::OnMouseUp(const Float2& position, const MouseButton button, Window* target)
|
||||
{
|
||||
Event& e = _queue.AddOne();
|
||||
|
||||
@@ -64,6 +64,11 @@ public:
|
||||
return _state.MousePosition;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if any mouse button is currently pressed.
|
||||
/// </summary>
|
||||
API_PROPERTY() bool IsAnyButtonDown() const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the delta position of the mouse in the screen-space coordinates.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user