Skip to content

Commit

Permalink
Bring back clamping in osu! scale handler
Browse files Browse the repository at this point in the history
Being able to flip doesn't really feel all that good and `master` was
already clamping, so let's just bring that back for now. Flipping can be
reconsidered in a follow-up if it actually can be made to behave well.
  • Loading branch information
bdach committed May 23, 2024
1 parent f7bccca commit 3e34b2d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion osu.Game.Rulesets.Osu/Edit/OsuSelectionScaleHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Logging;
using osu.Framework.Utils;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
Expand Down Expand Up @@ -120,6 +121,8 @@ public override void Commit()

private void scaleSlider(Slider slider, Vector2 scale, Vector2[] originalPathPositions, PathType?[] originalPathTypes)
{
scale = Vector2.ComponentMax(scale, new Vector2(Precision.FLOAT_EPSILON));

// Maintain the path types in case they were defaulted to bezier at some point during scaling
for (int i = 0; i < slider.Path.ControlPoints.Count; i++)
{
Expand Down Expand Up @@ -178,7 +181,8 @@ private Vector2 getClampedScale(Quad selectionQuad, Vector2 origin, Vector2 scal
if (!Precision.AlmostEquals(selectionQuad.BottomRight.Y - origin.Y, 0))
scale.Y = selectionQuad.BottomRight.Y - origin.Y < 0 ? MathHelper.Clamp(scale.Y, br2.Y, br1.Y) : MathHelper.Clamp(scale.Y, br1.Y, br2.Y);

return scale;
Logger.Log($"scale = {scale}");
return Vector2.ComponentMax(scale, new Vector2(Precision.FLOAT_EPSILON));
}

private void moveSelectionInBounds()
Expand Down

0 comments on commit 3e34b2d

Please sign in to comment.