Skip to content

Commit

Permalink
Calculate spinners velocity before theoretical velocity.
Browse files Browse the repository at this point in the history
It *should* fix all spinner discrepancies
  • Loading branch information
Wieku committed Sep 12, 2023
1 parent e462365 commit d64df01
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions app/rulesets/osu/spinner.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type spinnerstate struct {
rotationCount int64
lastRotationCount int64
scoringRotationCount int64
rotationCountF float64
rotationCountF float32
rotationCountFD float64
frameVariance float64
theoreticalVelocity float64
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d64df01

Please sign in to comment.