1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 14:32:55 +08:00

Improve editor selection rotation value wrapping

This fixes two issues the previous algorithm had:
1.  A half-turn rotation used to show up as -180°.
2.  Rotating more than 180° in one drag event would overwhelm it
    and cause the value to go outside its range.

This comes at the cost of a negligible performance hit,
since a division (modulo) is performed instead of just addition/subtraction.
This commit is contained in:
Micha Lehmann 2023-04-08 01:28:28 +02:00
parent f1de560d57
commit c827c2810b

View File

@ -134,10 +134,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
cumulativeRotation.Value = rawCumulativeRotation;
}
if (cumulativeRotation.Value < -180)
cumulativeRotation.Value += 360;
else if (cumulativeRotation.Value > 180)
cumulativeRotation.Value -= 360;
cumulativeRotation.Value = (cumulativeRotation.Value - 180) % 360 + 180;
HandleRotate?.Invoke((float)cumulativeRotation.Value - oldRotation);
}