Skip to content

Commit

Permalink
KeyFrameData にリネーム
Browse files Browse the repository at this point in the history
  • Loading branch information
nasshu2916 committed Nov 16, 2024
1 parent 728f377 commit a208564
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
30 changes: 9 additions & 21 deletions Assets/ArtNet/Editor/DmxRecorder/TimelineConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ private static void SaveAsset<T>(T asset, string directory, string fileName) whe
public class TimelineUniverse
{
public int Universe { get; }
private List<DmxFrameData>[] ChannelDmxFrameData { get; }
private List<KeyFrameData>[] ChannelDmxFrameData { get; }

public TimelineUniverse(int groupKey, IReadOnlyCollection<UniverseData> universeData)
{
Universe = groupKey;
ChannelDmxFrameData = new List<DmxFrameData>[512];
ChannelDmxFrameData = new List<KeyFrameData>[512];

for (var i = 0; i < ChannelDmxFrameData.Length; i++)
{
ChannelDmxFrameData[i] = universeData.Where(x => x.Values.Length > i)
.Select(x => new DmxFrameData((float) x.Time, x.Values[i]))
.Select(x => new KeyFrameData((float) x.Time, x.Values[i]))
.OrderBy(x => x.Time).ToList();
}
}
Expand All @@ -96,7 +96,7 @@ public TimelineUniverse(int universe, AnimationClip clip)
{
Universe = universe;
var curveBindings = AnimationUtility.GetCurveBindings(clip);
ChannelDmxFrameData = new List<DmxFrameData>[512];
ChannelDmxFrameData = new List<KeyFrameData>[512];
for (var i = 0; i < ChannelDmxFrameData.Length; i++)
{
var propertyName = $"Ch{i + 1:D3}";
Expand All @@ -108,7 +108,7 @@ public TimelineUniverse(int universe, AnimationClip clip)

if (curve is null) continue;

ChannelDmxFrameData[i] = curve.keys.Select(x => new DmxFrameData((int) (x.time * 1000), (byte) x.value)).ToList();
ChannelDmxFrameData[i] = curve.keys.Select(x => new KeyFrameData((int) (x.time * 1000), (byte) x.value)).ToList();
}
}

Expand Down Expand Up @@ -185,7 +185,7 @@ public void ThinOutUnchangedFrames()
if (dmxFrameData.Count == 0) continue;

var latest = dmxFrameData[0];
var newDmxFrameData = new List<DmxFrameData> { dmxFrameData[0] };
var newDmxFrameData = new List<KeyFrameData> { dmxFrameData[0] };

for (var j = 1; j < dmxFrameData.Count - 1; j++)
{
Expand All @@ -203,9 +203,9 @@ public void ThinOutUnchangedFrames()
}

private static bool IsOmittedFrame(
DmxFrameData prev,
DmxFrameData current,
DmxFrameData next,
KeyFrameData prev,
KeyFrameData current,
KeyFrameData next,
float tolerance = 0.01f)
{
var prevDiff = current.Value - prev.Value;
Expand Down Expand Up @@ -235,16 +235,4 @@ public IEnumerable<UniverseData> ToUniverseData()
return universeData;
}
}

public struct DmxFrameData
{
public float Time { get; }
public byte Value { get; }

public DmxFrameData(float time, byte value)
{
Time = time;
Value = value;
}
}
}
14 changes: 14 additions & 0 deletions Assets/ArtNet/Editor/KeyFrameData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace ArtNet.Editor
{
public struct KeyFrameData
{
public float Time { get; }
public byte Value { get; }

public KeyFrameData(float time, byte value)
{
Time = time;
Value = value;
}
}
}
3 changes: 3 additions & 0 deletions Assets/ArtNet/Editor/KeyFrameData.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a208564

Please sign in to comment.