-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Fix path control points losing curve type on save/reload or undo #29446
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
osu.Game.Rulesets.Osu.Tests/Editor/TestSceneSliderChangeStates.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Linq; | ||
using NUnit.Framework; | ||
using osu.Game.Beatmaps; | ||
using osu.Game.Rulesets.Objects; | ||
using osu.Game.Rulesets.Objects.Types; | ||
using osu.Game.Rulesets.Osu.Objects; | ||
using osu.Game.Tests.Beatmaps; | ||
using osuTK; | ||
|
||
namespace osu.Game.Rulesets.Osu.Tests.Editor | ||
{ | ||
public partial class TestSceneSliderChangeStates : TestSceneOsuEditor | ||
{ | ||
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset, false); | ||
|
||
[TestCase(SplineType.Catmull)] | ||
[TestCase(SplineType.BSpline)] | ||
[TestCase(SplineType.Linear)] | ||
[TestCase(SplineType.PerfectCurve)] | ||
public void TestSliderRetainsCurveTypes(SplineType splineType) | ||
{ | ||
Slider? slider = null; | ||
PathType pathType = new PathType(splineType); | ||
|
||
AddStep("add slider", () => EditorBeatmap.Add(slider = new Slider | ||
{ | ||
StartTime = 500, | ||
Path = new SliderPath(new[] | ||
{ | ||
new PathControlPoint(Vector2.Zero, pathType), | ||
new PathControlPoint(new Vector2(200, 0), pathType), | ||
}) | ||
})); | ||
AddAssert("slider has correct spline type", () => ((Slider)EditorBeatmap.HitObjects[0]).Path.ControlPoints.All(p => p.Type == pathType)); | ||
AddStep("remove object", () => EditorBeatmap.Remove(slider)); | ||
AddAssert("slider removed", () => EditorBeatmap.HitObjects.Count == 0); | ||
addUndoSteps(); | ||
AddAssert("slider not removed", () => EditorBeatmap.HitObjects.Count == 1); | ||
AddAssert("slider has correct spline type", () => ((Slider)EditorBeatmap.HitObjects[0]).Path.ControlPoints.All(p => p.Type == pathType)); | ||
} | ||
|
||
private void addUndoSteps() => AddStep("undo", () => Editor.Undo()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I get what the other change is going for, but what is this one doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prevents perfect curve type anchors from losing curve type on undo/redo/reload if the segment has <3 anchors or they are colinear. We already have editor features that prevent you from creating invalid sliders, so its unnecessary to do this in parsing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dunno if I agree with that, people still manually edit beatmaps and will continue to do so regardless of if we want that or not. We need protections against such stuff on decode.
The collinearity check getting skipped is especially alarming to me since its purpose is to prevent circular approximations with arbitrarily large radii, which is generally numerically unstable and can lead to various strange things happening.
I'd want to know which scenarios this "breaks" specifically to make a judgement call on whether this removal is worth the potential tradeoffs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are already protections against colinearity in perfect curve sliders built into the path calculation. Its already trivial to make a circular slider with arbitrarily large radii inside the editor, so parsing doesn't seem like the right place for those protections anyways.
osu/osu.Game/Rulesets/Objects/SliderPath.cs
Lines 335 to 345 in 4ee5a12
The only thing that makes sense to convert in parsing is perfect curve segments with >3 anchors. These are invalid and impossible to make inside the editor.