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

Add aspect ratio locking and flip support to skin editor #12780

Merged
merged 6 commits into from
May 13, 2021

Conversation

peppy
Copy link
Member

@peppy peppy commented May 13, 2021

This should be considered temporary implementation along with the rest, intended to get the initial release into a roughly usable state. Please be easy on the review as it will get replaced with an abstracted version of OsuSelectionHandler in the very near future.

@pull-request-size pull-request-size bot added size/S and removed size/M labels May 13, 2021
Comment on lines 161 to 164
if (reference.HasFlagFast(Anchor.x0) || reference.HasFlagFast(Anchor.x2))
scale.Y = scale.X;
else
scale.X = scale.Y;
Copy link
Collaborator

Choose a reason for hiding this comment

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

What was the intention here? Asking because the else branch seems effectively dead here. I've breakpointed on it and it seems to be unreachable. To explain what I mean:

    x0  x1  x2
    |   |   |
y0 -O---O---O-
    |   |   |
y1 -O---+---O-
    |   |   |
y2 -O---O---O-
    |   |   |

The Os indicate where the reference anchors are on a selection box. The first conditional eliminates the middle ones, which makes sense. But after excluding them from further deliberations (marking via X):

    x0  x1  x2
    |   |   |
y0 -O---X---O-
    |   |   |
y1 -X---+---X-
    |   |   |
y2 -O---X---O-
    |   |   |

all the reference anchors left have Anchor.x0 or Anchor.x2...

Copy link
Member Author

Choose a reason for hiding this comment

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

i'm not actually sure, but it felt okay. this code will likely be removed/replaced within the next week, so just killing that line is fine for now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think what may have been wanted is

if (scale.X != 0 && scale.Y != 0)
    scale.X = scale.Y = Math.Max(scale.X, scale.Y);
else if (scale.X != 0)
    scale.Y = scale.X;
else if (scale.Y != 0)
    scale.X = scale.Y;

The misleading part about all this is that scale is all deltas, not the actual full final scale.

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried that initially but it doesn't work amazingly because as you say, it's arriving as deltas and therefore not in a stable state.

mThats why i chose to leave all the decisions based on the dragged anchor alone.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fair enough. I'll just kill the else branch and leave a TODO for now, then...

bdach added 2 commits May 13, 2021 17:50
The previous implementation was checking if the `x0` or `x2` anchors
were selected to decide on which way to transfer the drawable's scale,
but that check actually ends up being always true for corner anchors. To
visualise, this is how the corner anchors correspond to `Anchor` flags:

    x0  x1  x2
    |   |   |
y0 -O---O---O-
    |   |   |
y1 -O---+---O-
    |   |   |
y2 -O---O---O-
    |   |   |

The Os indicate where the reference anchors are on a selection box.
The first conditional eliminates the middle ones, which makes sense.
But after excluding them from further deliberations (marking via X):

    x0  x1  x2
    |   |   |
y0 -O---X---O-
    |   |   |
y1 -X---+---X-
    |   |   |
y2 -O---X---O-
    |   |   |

The remaining anchors always have `x0` or `x2` set. So to avoid
confusion, just always transfer one way for now. At some point this
should be torn out in favour of an actual implementation of the desired
behaviour.
@peppy peppy merged commit 10f008a into ppy:master May 13, 2021
@peppy peppy deleted the skin-blueprint-aspect-lock branch May 13, 2021 16:55
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