From d64df0186fb21ca8006d64207d289b4a8ac358df Mon Sep 17 00:00:00 2001 From: Sebastian Krajewski Date: Thu, 31 Aug 2023 02:54:41 +0200 Subject: [PATCH] Calculate spinners velocity before theoretical velocity. It *should* fix all spinner discrepancies --- app/rulesets/osu/spinner.go | 66 ++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/app/rulesets/osu/spinner.go b/app/rulesets/osu/spinner.go index bf458e41..fe018032 100644 --- a/app/rulesets/osu/spinner.go +++ b/app/rulesets/osu/spinner.go @@ -14,7 +14,7 @@ type spinnerstate struct { rotationCount int64 lastRotationCount int64 scoringRotationCount int64 - rotationCountF float64 + rotationCountF float32 rotationCountFD float64 frameVariance float64 theoreticalVelocity float64 @@ -80,6 +80,36 @@ func (spinner *Spinner) UpdateFor(player *difficultyPlayer, time int64, _ bool) numFinishedTotal++ if player.cursor.IsReplayFrame && time > int64(spinner.hitSpinner.GetStartTime()) && time < int64(spinner.hitSpinner.GetEndTime()) { + maxAccelThisFrame := player.diff.GetModifiedTime(spinner.maxAcceleration * timeDiff) + + if player.diff.CheckModActive(difficulty.SpunOut) || player.diff.CheckModActive(difficulty.Relax2) { + state.currentVelocity = 0.03 + } else if state.theoreticalVelocity > state.currentVelocity { + accel := maxAccelThisFrame + if state.currentVelocity < 0 && player.diff.CheckModActive(difficulty.Relax) { + accel /= 4 + } + + state.currentVelocity += min(state.theoreticalVelocity-state.currentVelocity, accel) + } else { + accel := -maxAccelThisFrame + if state.currentVelocity > 0 && player.diff.CheckModActive(difficulty.Relax) { + accel /= 4 + } + + state.currentVelocity += max(state.theoreticalVelocity-state.currentVelocity, accel) + } + + state.currentVelocity = max(-0.05, min(state.currentVelocity, 0.05)) + + if len(spinner.players) == 1 { + if state.currentVelocity == 0 { + spinner.hitSpinner.PauseSpinSample() + } else { + spinner.hitSpinner.StartSpinSample() + } + } + decay1 := math.Pow(0.9, timeDiff/FrameTime) state.rpm = state.rpm*decay1 + (1.0-decay1)*(math.Abs(state.currentVelocity)*1000)/(math.Pi*2)*60 @@ -133,45 +163,15 @@ func (spinner *Spinner) UpdateFor(player *difficultyPlayer, time int64, _ bool) state.lastAngle = mouseAngle - maxAccelThisFrame := player.diff.GetModifiedTime(spinner.maxAcceleration * timeDiff) - - if player.diff.CheckModActive(difficulty.SpunOut) || player.diff.CheckModActive(difficulty.Relax2) { - state.currentVelocity = 0.03 - } else if state.theoreticalVelocity > state.currentVelocity { - accel := maxAccelThisFrame - if state.currentVelocity < 0 && player.diff.CheckModActive(difficulty.Relax) { - accel /= 4 - } - - state.currentVelocity += min(state.theoreticalVelocity-state.currentVelocity, accel) - } else { - accel := -maxAccelThisFrame - if state.currentVelocity > 0 && player.diff.CheckModActive(difficulty.Relax) { - accel /= 4 - } - - state.currentVelocity += max(state.theoreticalVelocity-state.currentVelocity, accel) - } - - state.currentVelocity = max(-0.05, min(state.currentVelocity, 0.05)) - - if len(spinner.players) == 1 { - if state.currentVelocity == 0 { - spinner.hitSpinner.PauseSpinSample() - } else { - spinner.hitSpinner.StartSpinSample() - } - } - rotationAddition := state.currentVelocity * timeDiff state.rotationCountFD += rotationAddition - state.rotationCountF += math.Abs(rotationAddition / math.Pi) + state.rotationCountF += float32(math.Abs(float64(float32(rotationAddition)) / math.Pi)) if len(spinner.players) == 1 { spinner.hitSpinner.SetRotation(player.diff.GetModifiedTime(state.rotationCountFD)) spinner.hitSpinner.SetRPM(state.rpm) - spinner.hitSpinner.UpdateCompletion(state.rotationCountF / float64(state.requirement)) + spinner.hitSpinner.UpdateCompletion(float64(state.rotationCountF) / float64(state.requirement)) } state.rotationCount = int64(state.rotationCountF)