1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 20:33:37 +08:00

Assert default origin not null in rotation handle

This commit is contained in:
OliBomby 2024-09-23 11:37:42 +02:00
parent 92b5650ff8
commit a9ebfbe431
2 changed files with 4 additions and 3 deletions

View File

@ -84,6 +84,7 @@ namespace osu.Game.Tests.Visual.Editing
targetContainer = getTargetContainer();
initialRotation = targetContainer!.Rotation;
DefaultOrigin = ToLocalSpace(targetContainer.ToScreenSpace(Vector2.Zero));
base.Begin();
}

View File

@ -77,6 +77,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
base.OnDrag(e);
if (rotationHandler == null || !rotationHandler.OperationInProgress.Value) return;
rawCumulativeRotation += convertDragEventToAngleOfRotation(e);
applyRotation(shouldSnap: e.ShiftPressed);
@ -114,9 +116,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
private float convertDragEventToAngleOfRotation(DragEvent e)
{
// Adjust coordinate system to the center of the selection
Vector2 center = rotationHandler?.DefaultOrigin is not null
? selectionBox.ToLocalSpace(rotationHandler.ToScreenSpace(rotationHandler.DefaultOrigin.Value))
: selectionBox.DrawSize / 2;
Vector2 center = selectionBox.ToLocalSpace(rotationHandler!.ToScreenSpace(rotationHandler!.DefaultOrigin!.Value));
float startAngle = MathF.Atan2(e.LastMousePosition.Y - center.Y, e.LastMousePosition.X - center.X);
float endAngle = MathF.Atan2(e.MousePosition.Y - center.Y, e.MousePosition.X - center.X);