mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 11:02:57 +08:00
Use a bigger sample step to calculate slider center of mass
This commit is contained in:
parent
72cb3d6ad6
commit
610d2dc1a3
@ -323,13 +323,19 @@ namespace osu.Game.Rulesets.Osu.Utils
|
||||
/// <returns>The centre of mass of the slider.</returns>
|
||||
private static Vector2 calculateCentreOfMass(Slider slider)
|
||||
{
|
||||
if (slider.Distance < 1) return Vector2.Zero;
|
||||
const double sample_step = 50;
|
||||
|
||||
// just sample the start and end positions if the slider is too short
|
||||
if (slider.Distance <= sample_step)
|
||||
{
|
||||
return Vector2.Divide(slider.Path.PositionAt(1), 2);
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
Vector2 sum = Vector2.Zero;
|
||||
double pathDistance = slider.Distance;
|
||||
|
||||
for (double i = 0; i < pathDistance; i++)
|
||||
for (double i = 0; i < pathDistance; i += sample_step)
|
||||
{
|
||||
sum += slider.Path.PositionAt(i / pathDistance);
|
||||
count++;
|
||||
|
Loading…
Reference in New Issue
Block a user