Skip to content
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

Heatmap fix segment repeating #4557

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions internal/manager/generator_interactive_heatmap_speed.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ type Action struct {
// Pos is the place in percent to move to.
Pos int `json:"pos"`

Slope float64
Intensity int64
Speed float64
Speed float64
}

type GradientTable []struct {
Expand Down Expand Up @@ -136,8 +134,7 @@ func (funscript *Script) UpdateIntensityAndSpeed() {

var t1, t2 int64
var p1, p2 int
var slope float64
var intensity int64
var intensity float64
for i := range funscript.Actions {
if i == 0 {
continue
Expand All @@ -147,13 +144,10 @@ func (funscript *Script) UpdateIntensityAndSpeed() {
p1 = funscript.Actions[i].Pos
p2 = funscript.Actions[i-1].Pos

slope = math.Min(math.Max(1/(2*float64(t1-t2)/1000), 0), 20)
intensity = int64(slope * math.Abs((float64)(p1-p2)))
speed := math.Abs(float64(p1-p2)) / float64(t1-t2) * 1000
speed := math.Abs(float64(p1 - p2))
intensity = float64(speed/float64(t1-t2)) * 1000

funscript.Actions[i].Slope = slope
funscript.Actions[i].Intensity = intensity
funscript.Actions[i].Speed = speed
funscript.Actions[i].Speed = intensity
}
}

Expand Down Expand Up @@ -294,7 +288,7 @@ func (funscript Script) getGradientTable(numSegments int, sceneDurationMilli int
}
segments[segment].at = a.At
segments[segment].count++
segments[segment].intensity += int(a.Intensity)
segments[segment].intensity += int(a.Speed)
segments[segment].yRange[0] = averageTop
segments[segment].yRange[1] = averageBottom
}
Expand All @@ -303,7 +297,7 @@ func (funscript Script) getGradientTable(numSegments int, sceneDurationMilli int

// Fill in gaps in segments
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
if segments[i].count == 0 {
Expand Down Expand Up @@ -340,12 +334,12 @@ func getSegmentColor(intensity float64) colorful.Color {
colorBlack, _ := colorful.Hex("#0f001e")
colorBackground, _ := colorful.Hex("#30404d") // Same as GridCard bg

var stepSize = 60.0
var stepSize = 125.0
var f float64
var c colorful.Color

switch {
case intensity <= 0.001:
case intensity <= 25:
c = colorBackground
case intensity <= 1*stepSize:
f = (intensity - 0*stepSize) / stepSize
Expand Down
Loading