Skip to content

Commit

Permalink
Added recording cut functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
pfcDorn committed Oct 16, 2023
1 parent 30743f0 commit 91b8b50
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Runtime/Scripts/Timeline/GLTFRecorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,30 @@ public void SampleIfChanged(double time)
lastSample = value;
}
}

public void CutTrack(double start, double end)
{
var copySamples = new Dictionary<double, object>(samples);
samples.Clear();
bool isFirst = true;
foreach (var k in copySamples)
{
if (k.Key >= start && k.Key <= end)
{
if (isFirst)
{
samples.Add(0, k.Value);
isFirst = false;
}
else
samples.Add(k.Key - start, k.Value);
}
}

var last = samples.Last();
if (last.Key != (end-start))
samples.Add((end-start), last.Value);
}
}

public void Update(double time)
Expand All @@ -210,6 +234,22 @@ public void Update(double time)
}
}

public void CutRecording(double start, double end)
{
if (start == 0d && end >= lastRecordedTime)
return;

foreach (var d in data)
{
foreach (var track in d.Value.tracks)
{
track.CutTrack(start, end);
}
}

lastRecordedTime-=start-(lastRecordedTime-end);
}

public void StartRecording(double time)
{
startTime = time;
Expand Down

0 comments on commit 91b8b50

Please sign in to comment.