-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor OsuDifficultyHitObject for readability/understandability #15774
Refactor OsuDifficultyHitObject for readability/understandability #15774
Conversation
@@ -50,7 +50,7 @@ private double strainValueOf(DifficultyHitObject current) | |||
if (osuLastObj.BaseObject is Slider && withSliders) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirm that this is still correct as osuLastObj
here? Looks weird with the changes inside this conditional now reading from one index back while the conditional itself isn't.
(it probably is, just a hard change to read due to how complex things are)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of the reasons for me changing it, because it was using osuCurrObj.TravelDistance
to access the travel distance of osuLastObj
.
So yes, this condition is still fine as it is, the only change is that the properties apply directly to the relevant hitobject now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To add on as to why - all these blocks of code try to do (perhaps not explained enough in the leading comments?) is to calculate the velocity through a previous slider into the current object. One part is stored in the previous object (travel), and the other is stored in the current object (jump / movement, however you want to think about it).
Don't merge this yet as I realised my testing was flawed. Will unblock after re-confirming SR is unaffected. |
Found an issue and re-tested, looks okay now. |
/// <remarks> | ||
/// This is bounded by <see cref="JumpDistance"/>, but may be smaller if a more natural path is able to be taken through a preceding slider. | ||
/// </remarks> | ||
public double MovementDistance { get; private set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename it to something like MinimumMovementDistance
? Overall distance/time fields could use better naming so that it can be more obvious which does what without reading docs every time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to MinimumJumpDistance
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't looked at diffcalc for a while but the transformation generally looks correct to me. Just want to clarify one xmldoc (there's also a nitpick in this review but I don't care about it very much)
osu.Game.Rulesets.Osu/Difficulty/Preprocessing/OsuDifficultyHitObject.cs
Outdated
Show resolved
Hide resolved
I've applied some renames + documented a bit more thoroughly. Let me know if this is understandable now. |
Yep, seems much better to me now |
The latest update to docs/names looks good to me now, but there is a merge conflict here and I'm unsure whether my resolution is correct... I think this would be the correct one? diff --cc osu.Game.Rulesets.Osu/Difficulty/Skills/Speed.cs
index 75a9b13bdf,4f87767fa7..ca89236258
--- a/osu.Game.Rulesets.Osu/Difficulty/Skills/Speed.cs
+++ b/osu.Game.Rulesets.Osu/Difficulty/Skills/Speed.cs
@@@ -154,8 -154,7 +154,7 @@@ namespace osu.Game.Rulesets.Osu.Difficu
if (strainTime < min_speed_bonus)
speedBonus = 1 + 0.75 * Math.Pow((min_speed_bonus - strainTime) / speed_balancing_factor, 2);
- double travelDistance = osuPrevObj?.TravelDistance ?? 0;
- double distance = Math.Min(single_spacing_threshold, travelDistance + osuCurrObj.LazyJumpDistance);
- double distance = Math.Min(single_spacing_threshold, osuCurrObj.TravelDistance + osuCurrObj.MovementDistance);
++ double distance = Math.Min(single_spacing_threshold, osuCurrObj.TravelDistance + osuCurrObj.MinimumJumpDistance);
return (speedBonus + speedBonus * Math.Pow(distance / single_spacing_threshold, 3.5)) / strainTime;
} |
// 2. <======o==>---o | ||
// |______| | ||
// | ||
// Where "<==>" represents a slider, and "o" represents where the cursor needs to be for either hitobject (for a slider, this is the lazy cursor position). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend representing the cursor location with something that isn't a "o". This reads as if it's hitobjects, which can make for confusion here. How about using a *
or x
or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
// | / | ||
// o | ||
// x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't quite understand what this diagram is trying to explain, but as long as others can maybe it's okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diagrams show how the natural movement path of a player changes depending on what the angle of a follow-up circle is, and how using the lazy cursor end is completely fine in diagram 1 ("players will cut the slider short in order to move to the next object"), but will overestimate the perceived jump distance in diagram 2 ("players will follow the slider through to its visual extent").
I don't know how to better explain it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I supposed to know that there's a second object below the slider in the first diagram? So the "x" represents the position of the slider ball and also the position of the next object here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it represents the final position your cursor needs to be in a slider given the most lazy movements (following at the edge of the follow circle at all times) + the -36ms offset for the last slider tick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the downwards movement implies there's something beneath it right? If so it's be nice to show that next object to give more context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe they should be shown using o
after all, and the documentation should not mention anything about the cursor position. The cursor movement is shown by the single-width line, which should be ample to explain the concept here.
Might help to split the diagram out into two versions beside each other: one with the "lazy" movement and one with the "correct" movement (ie the one denoted by /
). Feels weird showing both on the same diagram.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've restructured it, see if it's better now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, much better.
@bdach I've resolved conflicts, note that your patch is slightly incorrect because this PR moves |
I recommend going through this PR per-commit as the diff is a little bit of a mess.
TravelDistance
andTravelTime
stored information about the previous hitobject, in the current hitobject. I've made these two store information about the current hitobject only.MovementDistance
is calculated.I've tested that SR and difficulty attributes don't change compared to current master.