Apply the same change to `HandleFlip`

This commit is contained in:
Dean Herbert 2022-09-15 19:55:18 +09:00
parent c203a030c1
commit 4af76b9f48
1 changed files with 9 additions and 12 deletions

View File

@ -127,16 +127,13 @@ public override bool HandleFlip(Direction direction, bool flipOverOrigin)
{
didFlip = true;
var controlPoints = slider.Path.ControlPoints.Select(p =>
new PathControlPoint(new Vector2(
(direction == Direction.Horizontal ? -1 : 1) * p.Position.X,
(direction == Direction.Vertical ? -1 : 1) * p.Position.Y
), p.Type)).ToArray();
// 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);
foreach (var cp in slider.Path.ControlPoints)
{
cp.Position = new Vector2(
(direction == Direction.Horizontal ? -1 : 1) * cp.Position.X,
(direction == Direction.Vertical ? -1 : 1) * cp.Position.Y
);
}
}
}
@ -186,8 +183,8 @@ public override bool HandleRotation(float delta)
if (h is IHasPath path)
{
foreach (PathControlPoint t in path.Path.ControlPoints)
t.Position = RotatePointAroundOrigin(t.Position, Vector2.Zero, delta);
foreach (PathControlPoint cp in path.Path.ControlPoints)
cp.Position = RotatePointAroundOrigin(cp.Position, Vector2.Zero, delta);
}
}