mirror of
https://github.com/ppy/osu.git
synced 2025-02-12 00:42:55 +08:00
Update usage of MathUtils
This commit is contained in:
parent
6455c0583b
commit
b53b752e54
@ -51,7 +51,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
// multiply the SPM by 1.01 to ensure that the spinner is completed. if the calculation is left exact,
|
// multiply the SPM by 1.01 to ensure that the spinner is completed. if the calculation is left exact,
|
||||||
// some spinners may not complete due to very minor decimal loss during calculation
|
// some spinners may not complete due to very minor decimal loss during calculation
|
||||||
float rotationSpeed = (float)(1.01 * spinner.HitObject.SpinsRequired / spinner.HitObject.Duration);
|
float rotationSpeed = (float)(1.01 * spinner.HitObject.SpinsRequired / spinner.HitObject.Duration);
|
||||||
spinner.RotationTracker.AddRotation(MathUtils.RadiansToDegrees((float)rateIndependentElapsedTime * rotationSpeed * MathF.PI * 2.0f));
|
spinner.RotationTracker.AddRotation(float.RadiansToDegrees((float)rateIndependentElapsedTime * rotationSpeed * MathF.PI * 2.0f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
float aimRotation = MathUtils.RadiansToDegrees(MathF.Atan2(aimRotationVector.Y - Position.Y, aimRotationVector.X - Position.X));
|
float aimRotation = float.RadiansToDegrees(MathF.Atan2(aimRotationVector.Y - Position.Y, aimRotationVector.X - Position.X));
|
||||||
while (Math.Abs(aimRotation - Arrow.Rotation) > 180)
|
while (Math.Abs(aimRotation - Arrow.Rotation) > 180)
|
||||||
aimRotation += aimRotation < Arrow.Rotation ? 360 : -360;
|
aimRotation += aimRotation < Arrow.Rotation ? 360 : -360;
|
||||||
|
|
||||||
|
@ -342,7 +342,7 @@ namespace osu.Game.Rulesets.Osu.Replays
|
|||||||
// 0.05 rad/ms, or ~477 RPM, as per stable.
|
// 0.05 rad/ms, or ~477 RPM, as per stable.
|
||||||
// the redundant conversion from RPM to rad/ms is here for ease of testing custom SPM specs.
|
// the redundant conversion from RPM to rad/ms is here for ease of testing custom SPM specs.
|
||||||
const float spin_rpm = 0.05f / (2 * MathF.PI) * 60000;
|
const float spin_rpm = 0.05f / (2 * MathF.PI) * 60000;
|
||||||
float radsPerMillisecond = MathUtils.DegreesToRadians(spin_rpm * 360) / 60000;
|
float radsPerMillisecond = float.DegreesToRadians(spin_rpm * 360) / 60000;
|
||||||
|
|
||||||
switch (h)
|
switch (h)
|
||||||
{
|
{
|
||||||
|
@ -66,7 +66,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
|||||||
|
|
||||||
if (mousePosition is Vector2 pos)
|
if (mousePosition is Vector2 pos)
|
||||||
{
|
{
|
||||||
float thisAngle = -MathUtils.RadiansToDegrees(MathF.Atan2(pos.X - DrawSize.X / 2, pos.Y - DrawSize.Y / 2));
|
float thisAngle = -float.RadiansToDegrees(MathF.Atan2(pos.X - DrawSize.X / 2, pos.Y - DrawSize.Y / 2));
|
||||||
float delta = lastAngle == null ? 0 : thisAngle - lastAngle.Value;
|
float delta = lastAngle == null ? 0 : thisAngle - lastAngle.Value;
|
||||||
|
|
||||||
// Normalise the delta to -180 .. 180
|
// Normalise the delta to -180 .. 180
|
||||||
|
@ -246,7 +246,7 @@ namespace osu.Game.Rulesets.Osu.Statistics
|
|||||||
// Likewise sin(pi/2)=1 and sin(3pi/2)=-1, whereas we actually want these values to appear on the bottom/top respectively, so the y-coordinate also needs to be inverted.
|
// Likewise sin(pi/2)=1 and sin(3pi/2)=-1, whereas we actually want these values to appear on the bottom/top respectively, so the y-coordinate also needs to be inverted.
|
||||||
//
|
//
|
||||||
// We also need to apply the anti-clockwise rotation.
|
// We also need to apply the anti-clockwise rotation.
|
||||||
double rotatedAngle = finalAngle - MathUtils.DegreesToRadians(rotation);
|
double rotatedAngle = finalAngle - float.DegreesToRadians(rotation);
|
||||||
var rotatedCoordinate = -1 * new Vector2((float)Math.Cos(rotatedAngle), (float)Math.Sin(rotatedAngle));
|
var rotatedCoordinate = -1 * new Vector2((float)Math.Cos(rotatedAngle), (float)Math.Sin(rotatedAngle));
|
||||||
|
|
||||||
Vector2 localCentre = new Vector2(points_per_dimension - 1) / 2;
|
Vector2 localCentre = new Vector2(points_per_dimension - 1) / 2;
|
||||||
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Utils;
|
|
||||||
using osu.Game.Beatmaps.Legacy;
|
using osu.Game.Beatmaps.Legacy;
|
||||||
using osu.Game.IO;
|
using osu.Game.IO;
|
||||||
using osu.Game.Storyboards;
|
using osu.Game.Storyboards;
|
||||||
@ -230,7 +229,7 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
{
|
{
|
||||||
float startValue = Parsing.ParseFloat(split[4]);
|
float startValue = Parsing.ParseFloat(split[4]);
|
||||||
float endValue = split.Length > 5 ? Parsing.ParseFloat(split[5]) : startValue;
|
float endValue = split.Length > 5 ? Parsing.ParseFloat(split[5]) : startValue;
|
||||||
timelineGroup?.Rotation.Add(easing, startTime, endTime, MathUtils.RadiansToDegrees(startValue), MathUtils.RadiansToDegrees(endValue));
|
timelineGroup?.Rotation.Add(easing, startTime, endTime, float.RadiansToDegrees(startValue), float.RadiansToDegrees(endValue));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ namespace osu.Game.Graphics.Cursor
|
|||||||
if (dragRotationState == DragRotationState.Rotating && distance > 0)
|
if (dragRotationState == DragRotationState.Rotating && distance > 0)
|
||||||
{
|
{
|
||||||
Vector2 offset = e.MousePosition - positionMouseDown;
|
Vector2 offset = e.MousePosition - positionMouseDown;
|
||||||
float degrees = MathUtils.RadiansToDegrees(MathF.Atan2(-offset.X, offset.Y)) + 24.3f;
|
float degrees = float.RadiansToDegrees(MathF.Atan2(-offset.X, offset.Y)) + 24.3f;
|
||||||
|
|
||||||
// Always rotate in the direction of least distance
|
// Always rotate in the direction of least distance
|
||||||
float diff = (degrees - activeCursor.Rotation) % 360;
|
float diff = (degrees - activeCursor.Rotation) % 360;
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Extensions;
|
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
{
|
{
|
||||||
public partial class OsuNumberBox : OsuTextBox
|
public partial class OsuNumberBox : OsuTextBox
|
||||||
{
|
{
|
||||||
protected override bool AllowIme => false;
|
protected override bool AllowIme => false;
|
||||||
|
|
||||||
protected override bool CanAddCharacter(char character) => character.IsAsciiDigit();
|
protected override bool CanAddCharacter(char character) => char.IsAsciiDigit(character);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.Toolkit.HighPerformance;
|
using Microsoft.Toolkit.HighPerformance;
|
||||||
using osu.Framework.Extensions;
|
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
using SharpCompress.Archives.Zip;
|
using SharpCompress.Archives.Zip;
|
||||||
using SixLabors.ImageSharp.Memory;
|
using SixLabors.ImageSharp.Memory;
|
||||||
@ -36,7 +35,7 @@ namespace osu.Game.IO.Archives
|
|||||||
var owner = MemoryAllocator.Default.Allocate<byte>((int)entry.Size);
|
var owner = MemoryAllocator.Default.Allocate<byte>((int)entry.Size);
|
||||||
|
|
||||||
using (Stream s = entry.OpenEntryStream())
|
using (Stream s = entry.OpenEntryStream())
|
||||||
s.ReadToFill(owner.Memory.Span);
|
s.ReadExactly(owner.Memory.Span);
|
||||||
|
|
||||||
return new MemoryOwnerMemoryStream(owner);
|
return new MemoryOwnerMemoryStream(owner);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ using osu.Framework.Graphics.Primitives;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Input.Handlers.Tablet;
|
using osu.Framework.Input.Handlers.Tablet;
|
||||||
using osu.Framework.Utils;
|
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -196,7 +195,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
var matrix = Matrix3.Identity;
|
var matrix = Matrix3.Identity;
|
||||||
|
|
||||||
MatrixExtensions.TranslateFromLeft(ref matrix, offset);
|
MatrixExtensions.TranslateFromLeft(ref matrix, offset);
|
||||||
MatrixExtensions.RotateFromLeft(ref matrix, MathUtils.DegreesToRadians(rotation.Value));
|
MatrixExtensions.RotateFromLeft(ref matrix, float.DegreesToRadians(rotation.Value));
|
||||||
|
|
||||||
usableAreaQuad *= matrix;
|
usableAreaQuad *= matrix;
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ namespace osu.Game.Overlays.Settings
|
|||||||
{
|
{
|
||||||
protected override bool AllowIme => false;
|
protected override bool AllowIme => false;
|
||||||
|
|
||||||
protected override bool CanAddCharacter(char character) => character.IsAsciiDigit();
|
protected override bool CanAddCharacter(char character) => char.IsAsciiDigit(character);
|
||||||
|
|
||||||
public new void NotifyInputError() => base.NotifyInputError();
|
public new void NotifyInputError() => base.NotifyInputError();
|
||||||
}
|
}
|
||||||
|
@ -209,13 +209,13 @@ namespace osu.Game.Screens.Menu
|
|||||||
if (audioData[i] < amplitude_dead_zone)
|
if (audioData[i] < amplitude_dead_zone)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
float rotation = MathUtils.DegreesToRadians(i / (float)bars_per_visualiser * 360 + j * 360 / visualiser_rounds);
|
float rotation = float.DegreesToRadians(i / (float)bars_per_visualiser * 360 + j * 360 / visualiser_rounds);
|
||||||
float rotationCos = MathF.Cos(rotation);
|
float rotationCos = MathF.Cos(rotation);
|
||||||
float rotationSin = MathF.Sin(rotation);
|
float rotationSin = MathF.Sin(rotation);
|
||||||
// taking the cos and sin to the 0..1 range
|
// taking the cos and sin to the 0..1 range
|
||||||
var barPosition = new Vector2(rotationCos / 2 + 0.5f, rotationSin / 2 + 0.5f) * size;
|
var barPosition = new Vector2(rotationCos / 2 + 0.5f, rotationSin / 2 + 0.5f) * size;
|
||||||
|
|
||||||
var barSize = new Vector2(size * MathF.Sqrt(2 * (1 - MathF.Cos(MathUtils.DegreesToRadians(360f / bars_per_visualiser)))) / 2f, bar_length * audioData[i]);
|
var barSize = new Vector2(size * MathF.Sqrt(2 * (1 - MathF.Cos(float.DegreesToRadians(360f / bars_per_visualiser)))) / 2f, bar_length * audioData[i]);
|
||||||
// The distance between the position and the sides of the bar.
|
// The distance between the position and the sides of the bar.
|
||||||
var bottomOffset = new Vector2(-rotationSin * barSize.X / 2, rotationCos * barSize.X / 2);
|
var bottomOffset = new Vector2(-rotationSin * barSize.X / 2, rotationCos * barSize.X / 2);
|
||||||
// The distance between the bottom side of the bar and the top side.
|
// The distance between the bottom side of the bar and the top side.
|
||||||
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
using osu.Framework.Utils;
|
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -28,8 +27,8 @@ namespace osu.Game.Utils
|
|||||||
point.Y -= origin.Y;
|
point.Y -= origin.Y;
|
||||||
|
|
||||||
Vector2 ret;
|
Vector2 ret;
|
||||||
ret.X = point.X * MathF.Cos(MathUtils.DegreesToRadians(angle)) + point.Y * MathF.Sin(MathUtils.DegreesToRadians(angle));
|
ret.X = point.X * MathF.Cos(float.DegreesToRadians(angle)) + point.Y * MathF.Sin(float.DegreesToRadians(angle));
|
||||||
ret.Y = point.X * -MathF.Sin(MathUtils.DegreesToRadians(angle)) + point.Y * MathF.Cos(MathUtils.DegreesToRadians(angle));
|
ret.Y = point.X * -MathF.Sin(float.DegreesToRadians(angle)) + point.Y * MathF.Cos(float.DegreesToRadians(angle));
|
||||||
|
|
||||||
ret.X += origin.X;
|
ret.X += origin.X;
|
||||||
ret.Y += origin.Y;
|
ret.Y += origin.Y;
|
||||||
|
Loading…
Reference in New Issue
Block a user