Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clamp scale with lower and upper bounds #30080

Merged
merged 6 commits into from
Oct 14, 2024
Merged

Conversation

OliBomby
Copy link
Contributor

@OliBomby OliBomby commented Oct 1, 2024

This is mostly a code quality upgrade.
Reworked ClampScaleToPlayfieldBounds to clamp the scale value to both a upper bound and an upper bound. Previously only did an upper bound. With this it supports negative scale values. I also added comments to make it more clear what is going on there.

There is this rare situation where the lower bound equals 1, previously it would allow you to scale this by 0.5 which would direct the circle off-screen.
osu Game Rulesets Osu Tests_Y9keZwEQY8

@bdach
Copy link
Collaborator

bdach commented Oct 3, 2024

I'm kinda confused by this PR in general.

With this it supports negative scale values.

Is this used anywhere?

This is mostly a code quality upgrade.

It is? Even in light of the previous quoted statement?

There is this rare situation where the lower bound equals 1, previously it would allow you to scale this by 0.5 which would direct the circle off-screen.

In what circumstances is this possible?

osu.Game.Rulesets.Osu/Edit/OsuSelectionScaleHandler.cs Outdated Show resolved Hide resolved
Comment on lines +297 to +300
if (Precision.AlmostEquals(p.X, 0))
(sLowerBounds.X, sUpperBounds.X) = (float.NegativeInfinity, float.PositiveInfinity);
if (Precision.AlmostEquals(p.Y, 0))
(sLowerBounds.Y, sUpperBounds.Y) = (float.NegativeInfinity, float.PositiveInfinity);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this?

@OliBomby
Copy link
Contributor Author

OliBomby commented Oct 3, 2024

With this it supports negative scale values.

Is this used anywhere?

Currently not yet, but Marvin considered adding negative scaling to the selection box which is WIP
https://github.com/minetoblend/osu/tree/feature/select-box-negative-scale

This is mostly a code quality upgrade.

It is? Even in light of the previous quoted statement?

Maybe not entirely accurate statement. It started as a slight feature enhancement for the lower bound stuff, but in the end the code quality became a lot more self-explaining, so I think its a code quality upgrade too.

There is this rare situation where the lower bound equals 1, previously it would allow you to scale this by 0.5 which would direct the circle off-screen.

In what circumstances is this possible?

It's the circumstances shown in the screenshot. It has a rotated grid and scaling on one axis, so a decrease in scaling moves the circle straight towards the grid's X axis which increases the Y coordinate out of bounds.

@bdach bdach self-requested a review October 11, 2024 12:59
bdach added a commit to bdach/osu that referenced this pull request Oct 11, 2024
Spotted in passing when reviewing ppy#30080.
The popover would very arbitrarily revert to scaling by Y axis if both
checkboxes were checked off.

Not sure how this passed review.
@bdach bdach merged commit 74675c8 into ppy:master Oct 14, 2024
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants