mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 08:26:00 +01:00
Fix segment repeating + cleanup speed calculation (#4557)
This commit is contained in:
parent
dad4ab6a6f
commit
15aac68a14
1 changed files with 9 additions and 15 deletions
|
|
@ -44,8 +44,6 @@ type Action struct {
|
||||||
// Pos is the place in percent to move to.
|
// Pos is the place in percent to move to.
|
||||||
Pos int `json:"pos"`
|
Pos int `json:"pos"`
|
||||||
|
|
||||||
Slope float64
|
|
||||||
Intensity int64
|
|
||||||
Speed float64
|
Speed float64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -136,8 +134,7 @@ func (funscript *Script) UpdateIntensityAndSpeed() {
|
||||||
|
|
||||||
var t1, t2 int64
|
var t1, t2 int64
|
||||||
var p1, p2 int
|
var p1, p2 int
|
||||||
var slope float64
|
var intensity float64
|
||||||
var intensity int64
|
|
||||||
for i := range funscript.Actions {
|
for i := range funscript.Actions {
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
continue
|
continue
|
||||||
|
|
@ -147,13 +144,10 @@ func (funscript *Script) UpdateIntensityAndSpeed() {
|
||||||
p1 = funscript.Actions[i].Pos
|
p1 = funscript.Actions[i].Pos
|
||||||
p2 = funscript.Actions[i-1].Pos
|
p2 = funscript.Actions[i-1].Pos
|
||||||
|
|
||||||
slope = math.Min(math.Max(1/(2*float64(t1-t2)/1000), 0), 20)
|
speed := math.Abs(float64(p1 - p2))
|
||||||
intensity = int64(slope * math.Abs((float64)(p1-p2)))
|
intensity = float64(speed/float64(t1-t2)) * 1000
|
||||||
speed := math.Abs(float64(p1-p2)) / float64(t1-t2) * 1000
|
|
||||||
|
|
||||||
funscript.Actions[i].Slope = slope
|
funscript.Actions[i].Speed = intensity
|
||||||
funscript.Actions[i].Intensity = intensity
|
|
||||||
funscript.Actions[i].Speed = speed
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -294,7 +288,7 @@ func (funscript Script) getGradientTable(numSegments int, sceneDurationMilli int
|
||||||
}
|
}
|
||||||
segments[segment].at = a.At
|
segments[segment].at = a.At
|
||||||
segments[segment].count++
|
segments[segment].count++
|
||||||
segments[segment].intensity += int(a.Intensity)
|
segments[segment].intensity += int(a.Speed)
|
||||||
segments[segment].yRange[0] = averageTop
|
segments[segment].yRange[0] = averageTop
|
||||||
segments[segment].yRange[1] = averageBottom
|
segments[segment].yRange[1] = averageBottom
|
||||||
}
|
}
|
||||||
|
|
@ -303,7 +297,7 @@ func (funscript Script) getGradientTable(numSegments int, sceneDurationMilli int
|
||||||
|
|
||||||
// Fill in gaps in segments
|
// Fill in gaps in segments
|
||||||
for i := 0; i < numSegments; i++ {
|
for i := 0; i < numSegments; i++ {
|
||||||
segmentTS := int64(float64(i) / float64(numSegments))
|
segmentTS := (maxts / int64(numSegments)) * int64(i)
|
||||||
|
|
||||||
// Empty segment - fill it with the previous up to backfillThreshold ms
|
// Empty segment - fill it with the previous up to backfillThreshold ms
|
||||||
if segments[i].count == 0 {
|
if segments[i].count == 0 {
|
||||||
|
|
@ -340,12 +334,12 @@ func getSegmentColor(intensity float64) colorful.Color {
|
||||||
colorBlack, _ := colorful.Hex("#0f001e")
|
colorBlack, _ := colorful.Hex("#0f001e")
|
||||||
colorBackground, _ := colorful.Hex("#30404d") // Same as GridCard bg
|
colorBackground, _ := colorful.Hex("#30404d") // Same as GridCard bg
|
||||||
|
|
||||||
var stepSize = 60.0
|
var stepSize = 125.0
|
||||||
var f float64
|
var f float64
|
||||||
var c colorful.Color
|
var c colorful.Color
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case intensity <= 0.001:
|
case intensity <= 25:
|
||||||
c = colorBackground
|
c = colorBackground
|
||||||
case intensity <= 1*stepSize:
|
case intensity <= 1*stepSize:
|
||||||
f = (intensity - 0*stepSize) / stepSize
|
f = (intensity - 0*stepSize) / stepSize
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue