1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 18:07:23 +08:00

Fix slider relative rotation calculation

This commit is contained in:
Henry Lin 2022-04-01 11:41:45 +08:00
parent 998df5a4fe
commit af3835083c

View File

@ -47,10 +47,9 @@ namespace osu.Game.Rulesets.Osu.Utils
DistanceFromPrevious = relativePosition.Length
});
if (hitObject is Slider)
if (hitObject is Slider slider)
{
var endPositionVector = hitObject.EndPosition - hitObject.Position;
float absoluteRotation = (float)Math.Atan2(endPositionVector.Y, endPositionVector.X);
float absoluteRotation = getSliderRotation(slider);
positionInfo.Rotation = absoluteRotation - absoluteAngle;
absoluteAngle = absoluteRotation;
}
@ -161,8 +160,10 @@ namespace osu.Game.Rulesets.Osu.Utils
if (!(current.HitObject is Slider slider))
return;
absoluteAngle = (float)Math.Atan2(posRelativeToPrev.Y, posRelativeToPrev.X);
Vector2 centreOfMassOriginal = calculateCentreOfMass(slider);
Vector2 centreOfMassModified = rotateVector(centreOfMassOriginal, current.PositionInfo.Rotation - current.RotationOriginal);
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);
@ -379,7 +380,6 @@ namespace osu.Game.Rulesets.Osu.Utils
public Vector2 PositionOriginal { get; }
public Vector2 PositionModified { get; set; }
public Vector2 EndPositionModified { get; set; }
public float RotationOriginal { get; }
public ObjectPositionInfo PositionInfo { get; }
public OsuHitObject HitObject => PositionInfo.HitObject;
@ -389,15 +389,6 @@ namespace osu.Game.Rulesets.Osu.Utils
PositionInfo = positionInfo;
PositionModified = PositionOriginal = HitObject.Position;
EndPositionModified = HitObject.EndPosition;
if (HitObject is Slider slider)
{
RotationOriginal = getSliderRotation(slider);
}
else
{
RotationOriginal = 0;
}
}
}
}