mirror of
https://github.com/ppy/osu.git
synced 2024-11-15 17:17:26 +08:00
Assert default origin not null in rotation handle
This commit is contained in:
parent
92b5650ff8
commit
a9ebfbe431
@ -84,6 +84,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
targetContainer = getTargetContainer();
|
||||
initialRotation = targetContainer!.Rotation;
|
||||
DefaultOrigin = ToLocalSpace(targetContainer.ToScreenSpace(Vector2.Zero));
|
||||
|
||||
base.Begin();
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user