mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 11:02:57 +08:00
USe MathF
in all applicable places
This commit is contained in:
parent
3bebc88306
commit
72cb3d6ad6
@ -174,11 +174,11 @@ namespace osu.Game.Rulesets.Osu.Utils
|
||||
/// <returns>The rotated vector.</returns>
|
||||
private static Vector2 rotateVector(Vector2 vector, float rotation)
|
||||
{
|
||||
float angle = (float)Math.Atan2(vector.Y, vector.X) + rotation;
|
||||
float angle = MathF.Atan2(vector.Y, vector.X) + rotation;
|
||||
float length = vector.Length;
|
||||
return new Vector2(
|
||||
length * (float)Math.Cos(angle),
|
||||
length * (float)Math.Sin(angle)
|
||||
length * MathF.Cos(angle),
|
||||
length * MathF.Sin(angle)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Osu.Utils
|
||||
foreach (OsuHitObject hitObject in hitObjects)
|
||||
{
|
||||
Vector2 relativePosition = hitObject.Position - previousPosition;
|
||||
float absoluteAngle = (float)Math.Atan2(relativePosition.Y, relativePosition.X);
|
||||
float absoluteAngle = MathF.Atan2(relativePosition.Y, relativePosition.X);
|
||||
float relativeAngle = absoluteAngle - previousAngle;
|
||||
|
||||
ObjectPositionInfo positionInfo;
|
||||
@ -141,15 +141,15 @@ namespace osu.Game.Rulesets.Osu.Utils
|
||||
{
|
||||
Vector2 earliestPosition = beforePrevious?.HitObject.EndPosition ?? playfield_centre;
|
||||
Vector2 relativePosition = previous.HitObject.Position - earliestPosition;
|
||||
previousAbsoluteAngle = (float)Math.Atan2(relativePosition.Y, relativePosition.X);
|
||||
previousAbsoluteAngle = MathF.Atan2(relativePosition.Y, relativePosition.X);
|
||||
}
|
||||
}
|
||||
|
||||
float absoluteAngle = previousAbsoluteAngle + current.PositionInfo.RelativeAngle;
|
||||
|
||||
var posRelativeToPrev = new Vector2(
|
||||
current.PositionInfo.DistanceFromPrevious * (float)Math.Cos(absoluteAngle),
|
||||
current.PositionInfo.DistanceFromPrevious * (float)Math.Sin(absoluteAngle)
|
||||
current.PositionInfo.DistanceFromPrevious * MathF.Cos(absoluteAngle),
|
||||
current.PositionInfo.DistanceFromPrevious * MathF.Sin(absoluteAngle)
|
||||
);
|
||||
|
||||
Vector2 lastEndPosition = previous?.EndPositionModified ?? playfield_centre;
|
||||
@ -161,13 +161,13 @@ namespace osu.Game.Rulesets.Osu.Utils
|
||||
if (!(current.HitObject is Slider slider))
|
||||
return;
|
||||
|
||||
absoluteAngle = (float)Math.Atan2(posRelativeToPrev.Y, posRelativeToPrev.X);
|
||||
absoluteAngle = MathF.Atan2(posRelativeToPrev.Y, posRelativeToPrev.X);
|
||||
|
||||
Vector2 centreOfMassOriginal = calculateCentreOfMass(slider);
|
||||
Vector2 centreOfMassModified = rotateVector(centreOfMassOriginal, current.PositionInfo.Rotation + absoluteAngle - getSliderRotation(slider));
|
||||
centreOfMassModified = RotateAwayFromEdge(current.PositionModified, centreOfMassModified);
|
||||
|
||||
float relativeRotation = (float)Math.Atan2(centreOfMassModified.Y, centreOfMassModified.X) - (float)Math.Atan2(centreOfMassOriginal.Y, centreOfMassOriginal.X);
|
||||
float relativeRotation = MathF.Atan2(centreOfMassModified.Y, centreOfMassModified.X) - MathF.Atan2(centreOfMassOriginal.Y, centreOfMassOriginal.X);
|
||||
if (!Precision.AlmostEquals(relativeRotation, 0))
|
||||
RotateSlider(slider, relativeRotation);
|
||||
}
|
||||
@ -346,7 +346,7 @@ namespace osu.Game.Rulesets.Osu.Utils
|
||||
private static float getSliderRotation(Slider slider)
|
||||
{
|
||||
var endPositionVector = slider.Path.PositionAt(1);
|
||||
return (float)Math.Atan2(endPositionVector.Y, endPositionVector.X);
|
||||
return MathF.Atan2(endPositionVector.Y, endPositionVector.X);
|
||||
}
|
||||
|
||||
public class ObjectPositionInfo
|
||||
|
Loading…
Reference in New Issue
Block a user