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

Round object coordinates to nearest integers on legacy export rather than truncating #31305

Merged
merged 3 commits into from
Jan 1, 2025

Conversation

bdach
Copy link
Collaborator

@bdach bdach commented Dec 27, 2024

RFC. Closes #31256.

This is an RFC because of 0d16ed0. The lowdown is that the truncating was actually silently being done by LegacyBeatmapDecoder:

Vector2 pos =
formatVersion >= LegacyBeatmapEncoder.FIRST_LAZER_VERSION
? new Vector2(Parsing.ParseFloat(split[0], Parsing.MAX_COORDINATE_VALUE), Parsing.ParseFloat(split[1], Parsing.MAX_COORDINATE_VALUE))
: new Vector2((int)Parsing.ParseFloat(split[0], Parsing.MAX_COORDINATE_VALUE), (int)Parsing.ParseFloat(split[1], Parsing.MAX_COORDINATE_VALUE));

I very explicitly do not want to be touching decoder logic for this, I want this change to be limited to the legacy export, which leaves very few options. We do not have a cloning / "reconstruct this hitobject with this property changed" facility available (#25467 says hi again), so exposing setters is about the only escape hatch available at this stage.

There are a few other code paths in the decoder preconditioned on FIRST_LAZER_VERSION:

if (formatVersion < LegacyBeatmapEncoder.FIRST_LAZER_VERSION)
{
if (vertices.Length + endPointLength != 3)
type = PathType.BEZIER;
else if (isLinear(points[0], points[1], endPoint ?? points[2]))
{
// osu-stable special-cased colinear perfect curves to a linear path
type = PathType.LINEAR;
}
}

if (type == PathType.CATMULL && endIndex > 1 && formatVersion < LegacyBeatmapEncoder.FIRST_LAZER_VERSION)
continue;

but I'm ignoring these at least until I find out whether everyone else is going to scoff at me for trying to do this in this way or not. Most likely I'll be ignoring these until someone complains.

Copy link
Member

@peppy peppy left a comment

Choose a reason for hiding this comment

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

I'm on board with this change.

@peppy peppy requested a review from smoogipoo December 28, 2024 23:25
@smoogipoo
Copy link
Contributor

!diffcalc

Copy link

@smoogipoo smoogipoo merged commit 9da27b5 into ppy:master Jan 1, 2025
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Saving a legacy beatmap truncates decimal instead of rounding
3 participants