mirror of https://github.com/ppy/osu
Fix crash when attempting to scale two hitobjects on the same axis
This commit is contained in:
parent
78a53bf245
commit
87176edca1
|
@ -157,10 +157,16 @@ public override bool HandleScale(Vector2 scale, Anchor reference)
|
|||
|
||||
foreach (var h in hitObjects)
|
||||
{
|
||||
h.Position = new Vector2(
|
||||
quad.TopLeft.X + (h.X - quad.TopLeft.X) / quad.Width * (quad.Width + scale.X),
|
||||
quad.TopLeft.Y + (h.Y - quad.TopLeft.Y) / quad.Height * (quad.Height + scale.Y)
|
||||
);
|
||||
var newPosition = h.Position;
|
||||
|
||||
// guard against no-ops and NaN.
|
||||
if (scale.X != 0 && quad.Width > 0)
|
||||
newPosition.X = quad.TopLeft.X + (h.X - quad.TopLeft.X) / quad.Width * (quad.Width + scale.X);
|
||||
|
||||
if (scale.Y != 0 && quad.Height > 0)
|
||||
newPosition.Y = quad.TopLeft.Y + (h.Y - quad.TopLeft.Y) / quad.Height * (quad.Height + scale.Y);
|
||||
|
||||
h.Position = newPosition;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue