mirror of
https://github.com/ppy/osu
synced 2025-01-10 08:09:40 +00:00
Improve osu!catch caught fruit placement algorithm
This commit is contained in:
parent
68807a90ec
commit
3e1002fbf3
@ -53,6 +53,11 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
/// </summary>
|
||||
public const double BASE_SPEED = 1.0;
|
||||
|
||||
/// <summary>
|
||||
/// The amount by which caught fruit should be scaled down to fit on the plate.
|
||||
/// </summary>
|
||||
private const float caught_fruit_scale_adjust = 0.5f;
|
||||
|
||||
[NotNull]
|
||||
private readonly Container trailsTarget;
|
||||
|
||||
@ -240,7 +245,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
|
||||
if (result.IsHit)
|
||||
{
|
||||
var positionInStack = computePositionInStack(new Vector2(palpableObject.X - X, 0), palpableObject.DisplaySize.X / 2);
|
||||
var positionInStack = computePositionInStack(new Vector2(palpableObject.X - X, 0), palpableObject.DisplaySize.X);
|
||||
|
||||
if (CatchFruitOnPlate)
|
||||
placeCaughtObject(palpableObject, positionInStack);
|
||||
@ -470,7 +475,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
caughtObject.CopyStateFrom(drawableObject);
|
||||
caughtObject.Anchor = Anchor.TopCentre;
|
||||
caughtObject.Position = position;
|
||||
caughtObject.Scale /= 2;
|
||||
caughtObject.Scale *= caught_fruit_scale_adjust;
|
||||
|
||||
caughtObjectContainer.Add(caughtObject);
|
||||
|
||||
@ -480,19 +485,21 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
|
||||
private Vector2 computePositionInStack(Vector2 position, float displayRadius)
|
||||
{
|
||||
const float radius_div_2 = CatchHitObject.OBJECT_RADIUS / 2;
|
||||
const float allowance = 10;
|
||||
// this is taken from osu-stable (lenience should be 10 * 10 at standard scale).
|
||||
const float lenience_adjust = 10 / CatchHitObject.OBJECT_RADIUS;
|
||||
|
||||
while (caughtObjectContainer.Any(f => Vector2Extensions.Distance(f.Position, position) < (displayRadius + radius_div_2) / (allowance / 2)))
|
||||
float adjustedRadius = displayRadius * lenience_adjust;
|
||||
float checkDistance = MathF.Pow(adjustedRadius, 2);
|
||||
|
||||
// offset fruit vertically to better place "above" the plate.
|
||||
position.Y -= 5;
|
||||
|
||||
while (caughtObjectContainer.Any(f => Vector2Extensions.DistanceSquared(f.Position, position) < checkDistance))
|
||||
{
|
||||
float diff = (displayRadius + radius_div_2) / allowance;
|
||||
|
||||
position.X += (RNG.NextSingle() - 0.5f) * diff * 2;
|
||||
position.Y -= RNG.NextSingle() * diff;
|
||||
position.X += RNG.NextSingle(-adjustedRadius, adjustedRadius);
|
||||
position.Y -= RNG.NextSingle(0, 5);
|
||||
}
|
||||
|
||||
position.X = Math.Clamp(position.X, -CatcherArea.CATCHER_SIZE / 2, CatcherArea.CATCHER_SIZE / 2);
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user