mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 06:52:53 +08:00
Merge pull request #20308 from peppy/fix-slider-rotation-slowness
Fix slider rotation causing thousands of new drawables to be created
This commit is contained in:
commit
fe46acb136
@ -66,11 +66,14 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
cachePoints(slider);
|
cachePoints(slider);
|
||||||
|
|
||||||
sliderVersion = slider.Path.Version.GetBoundCopy();
|
sliderVersion = slider.Path.Version.GetBoundCopy();
|
||||||
sliderVersion.BindValueChanged(_ =>
|
|
||||||
|
// schedule ensure that updates are only applied after all operations from a single frame are applied.
|
||||||
|
// this avoids inadvertently changing the slider path type for batch operations.
|
||||||
|
sliderVersion.BindValueChanged(_ => Scheduler.AddOnce(() =>
|
||||||
{
|
{
|
||||||
cachePoints(slider);
|
cachePoints(slider);
|
||||||
updatePathType();
|
updatePathType();
|
||||||
});
|
}));
|
||||||
|
|
||||||
controlPoint.Changed += updateMarkerDisplay;
|
controlPoint.Changed += updateMarkerDisplay;
|
||||||
|
|
||||||
|
@ -127,16 +127,13 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
{
|
{
|
||||||
didFlip = true;
|
didFlip = true;
|
||||||
|
|
||||||
var controlPoints = slider.Path.ControlPoints.Select(p =>
|
foreach (var cp in slider.Path.ControlPoints)
|
||||||
new PathControlPoint(new Vector2(
|
{
|
||||||
(direction == Direction.Horizontal ? -1 : 1) * p.Position.X,
|
cp.Position = new Vector2(
|
||||||
(direction == Direction.Vertical ? -1 : 1) * p.Position.Y
|
(direction == Direction.Horizontal ? -1 : 1) * cp.Position.X,
|
||||||
), p.Type)).ToArray();
|
(direction == Direction.Vertical ? -1 : 1) * cp.Position.Y
|
||||||
|
);
|
||||||
// Importantly, update as a single operation so automatic adjustment of control points to different
|
}
|
||||||
// curve types does not unexpectedly trigger and change the slider's shape.
|
|
||||||
slider.Path.ControlPoints.Clear();
|
|
||||||
slider.Path.ControlPoints.AddRange(controlPoints);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,13 +183,8 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
|
|
||||||
if (h is IHasPath path)
|
if (h is IHasPath path)
|
||||||
{
|
{
|
||||||
var controlPoints = path.Path.ControlPoints.Select(p =>
|
foreach (PathControlPoint cp in path.Path.ControlPoints)
|
||||||
new PathControlPoint(RotatePointAroundOrigin(p.Position, Vector2.Zero, delta), p.Type)).ToArray();
|
cp.Position = RotatePointAroundOrigin(cp.Position, Vector2.Zero, delta);
|
||||||
|
|
||||||
// Importantly, update as a single operation so automatic adjustment of control points to different
|
|
||||||
// curve types does not unexpectedly trigger and change the slider's shape.
|
|
||||||
path.Path.ControlPoints.Clear();
|
|
||||||
path.Path.ControlPoints.AddRange(controlPoints);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user