mirror of
https://github.com/ppy/osu.git
synced 2026-05-27 03:31:23 +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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user