Merge pull request #27062 from smoogipoo/fix-heatmap-offset

Fix hit accuracy heatmap points being offset
This commit is contained in:
Bartłomiej Dach 2024-02-06 18:02:30 +01:00 committed by GitHub
commit 2a11d37995
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 2 deletions

View File

@ -54,7 +54,7 @@ namespace osu.Game.Rulesets.Osu.Tests
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(130)
Size = new Vector2(300)
}
};
});
@ -85,6 +85,30 @@ namespace osu.Game.Rulesets.Osu.Tests
AddStep("return user input", () => InputManager.UseParentInput = true);
}
[Test]
public void TestAllPoints()
{
AddStep("add points", () =>
{
float minX = object1.DrawPosition.X - object1.DrawSize.X / 2;
float maxX = object1.DrawPosition.X + object1.DrawSize.X / 2;
float minY = object1.DrawPosition.Y - object1.DrawSize.Y / 2;
float maxY = object1.DrawPosition.Y + object1.DrawSize.Y / 2;
for (int i = 0; i < 10; i++)
{
for (float x = minX; x <= maxX; x += 0.5f)
{
for (float y = minY; y <= maxY; y += 0.5f)
{
accuracyHeatmap.AddPoint(object2.Position, object1.Position, new Vector2(x, y), RNG.NextSingle(10, 500));
}
}
}
});
}
protected override bool OnMouseDown(MouseDownEvent e)
{
accuracyHeatmap.AddPoint(object2.Position, object1.Position, background.ToLocalSpace(e.ScreenSpaceMouseDownPosition), 50);

View File

@ -191,7 +191,7 @@ namespace osu.Game.Rulesets.Osu.Statistics
for (int c = 0; c < points_per_dimension; c++)
{
HitPointType pointType = Vector2.Distance(new Vector2(c, r), centre) <= innerRadius
HitPointType pointType = Vector2.Distance(new Vector2(c + 0.5f, r + 0.5f), centre) <= innerRadius
? HitPointType.Hit
: HitPointType.Miss;