mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 14:17:26 +08:00
Take circle radius into account when clamping hit objects to playfield
This commit is contained in:
parent
f5134c7fc2
commit
cca26d4651
@ -66,6 +66,11 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
private const byte border_distance_x = 192;
|
||||
private const byte border_distance_y = 144;
|
||||
|
||||
/// <summary>
|
||||
/// The extent of rotation towards playfield centre when a circle is near the edge
|
||||
/// </summary>
|
||||
private const float edge_rotation_multiplier = 0.75f;
|
||||
|
||||
/// <summary>
|
||||
/// Duration of the undimming animation
|
||||
/// </summary>
|
||||
@ -295,14 +300,16 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
|
||||
var newPosition = Vector2.Add(lastPos, relativePos);
|
||||
|
||||
if (newPosition.Y < 0)
|
||||
newPosition.Y = 0;
|
||||
else if (newPosition.Y > OsuPlayfield.BASE_SIZE.Y)
|
||||
newPosition.Y = OsuPlayfield.BASE_SIZE.Y;
|
||||
if (newPosition.X < 0)
|
||||
newPosition.X = 0;
|
||||
else if (newPosition.X > OsuPlayfield.BASE_SIZE.X)
|
||||
newPosition.X = OsuPlayfield.BASE_SIZE.X;
|
||||
var radius = (float)obj.Radius;
|
||||
|
||||
if (newPosition.Y < radius)
|
||||
newPosition.Y = radius;
|
||||
else if (newPosition.Y > OsuPlayfield.BASE_SIZE.Y - radius)
|
||||
newPosition.Y = OsuPlayfield.BASE_SIZE.Y - radius;
|
||||
if (newPosition.X < radius)
|
||||
newPosition.X = radius;
|
||||
else if (newPosition.X > OsuPlayfield.BASE_SIZE.X - radius)
|
||||
newPosition.X = OsuPlayfield.BASE_SIZE.X - radius;
|
||||
|
||||
obj.Position = newPosition;
|
||||
|
||||
@ -390,7 +397,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
return rotateVectorTowardsVector(
|
||||
posRelativeToPrev,
|
||||
Vector2.Subtract(playfieldMiddle, prevPosChanged),
|
||||
Math.Min(1, relativeRotationDistance * 0.75f)
|
||||
Math.Min(1, relativeRotationDistance * edge_rotation_multiplier)
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user