Extract crossTrackWeight helper, disable debug output in tests
This commit is contained in:
@@ -280,6 +280,15 @@ func (tl *Timeline) updateTrackDeepest(b *Block, cue string, trackDeepest map[tr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tl *Timeline) crossTrackWeight(trg *Block, baseWeight uint64, cue string, tdRead map[trackCueKey]*Block) uint64 {
|
||||||
|
deep := tdRead[trackCueKey{track: trg.Track, cue: cue}]
|
||||||
|
if deep == nil || deep.weight+1 <= baseWeight {
|
||||||
|
return baseWeight
|
||||||
|
}
|
||||||
|
tl.debugf("trackDeepest read {%s, %s} = %s (w=%d): bumping %s from %d to %d", trg.Track, cue, deep.ID, deep.weight, trg.ID, baseWeight, deep.weight+1)
|
||||||
|
return deep.weight + 1
|
||||||
|
}
|
||||||
|
|
||||||
func (tl *Timeline) setWeightRecursive(b *Block, weight uint64, cue string, tdRead, tdWrite map[trackCueKey]*Block) bool {
|
func (tl *Timeline) setWeightRecursive(b *Block, weight uint64, cue string, tdRead, tdWrite map[trackCueKey]*Block) bool {
|
||||||
changed := tl.setWeight(b, weight)
|
changed := tl.setWeight(b, weight)
|
||||||
tl.updateTrackDeepest(b, cue, tdWrite)
|
tl.updateTrackDeepest(b, cue, tdWrite)
|
||||||
@@ -294,22 +303,16 @@ func (tl *Timeline) setWeightRecursive(b *Block, weight uint64, cue string, tdRe
|
|||||||
trg := tl.Blocks[target.Block]
|
trg := tl.Blocks[target.Block]
|
||||||
targetWeight := b.weight + 1
|
targetWeight := b.weight + 1
|
||||||
tw := tdWrite
|
tw := tdWrite
|
||||||
if trg.Track != b.Track {
|
|
||||||
if b.Track != cueTrackID {
|
if trg.Track != b.Track && b.Track != cueTrackID {
|
||||||
if deep := tdRead[trackCueKey{track: trg.Track, cue: cue}]; deep != nil {
|
targetWeight = tl.crossTrackWeight(trg, targetWeight, cue, tdRead)
|
||||||
if deep.weight+1 > targetWeight {
|
|
||||||
tl.debugf("trackDeepest read {%s, %s} = %s (w=%d): bumping %s from %d to %d", trg.Track, cue, deep.ID, deep.weight, trg.ID, targetWeight, deep.weight+1)
|
|
||||||
targetWeight = deep.weight + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tw = nil
|
tw = nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
changed = tl.setWeightRecursive(trg, targetWeight, cue, tdRead, tw) || changed
|
changed = tl.setWeightRecursive(trg, targetWeight, cue, tdRead, tw) || changed
|
||||||
if trg.Track == b.Track {
|
if trg.Track == b.Track {
|
||||||
changed = tl.setWeight(b, trg.weight-1) || changed
|
changed = tl.setWeight(b, trg.weight-1) || changed
|
||||||
}
|
}
|
||||||
// TODO: needs to go to other targets
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed
|
return changed
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand/v2"
|
"math/rand/v2"
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -32,7 +31,7 @@ func TestBuildTimelineSeed11(t *testing.T) {
|
|||||||
if err := show.Validate(); err != nil {
|
if err := show.Validate(); err != nil {
|
||||||
t.Fatalf("validate: %v", err)
|
t.Fatalf("validate: %v", err)
|
||||||
}
|
}
|
||||||
_, err := BuildTimelineDebug(show, os.Stderr)
|
_, err := BuildTimeline(show)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("BuildTimeline failed: %v", err)
|
t.Fatalf("BuildTimeline failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user