/
LipAnimationFrame.cs
58 lines (51 loc) · 1.77 KB
/
LipAnimationFrame.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#nullable enable
using System;
using System.Runtime.InteropServices;
namespace Mochineko.FacialExpressions.LipSync
{
/// <summary>
/// A frame of lip animation.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public readonly struct LipAnimationFrame : IEquatable<LipAnimationFrame>
{
/// <summary>
/// Sample of lip morphing.
/// </summary>
public readonly LipSample sample;
/// <summary>
/// Duration of this frame in seconds.
/// </summary>
public readonly float durationSeconds;
/// <summary>
/// Creates a new instance of <see cref="LipAnimationFrame"/>.
/// </summary>
/// <param name="sample">Sample of lip morphing.</param>
/// <param name="durationSeconds">Duration of this frame in seconds.</param>
/// <exception cref="ArgumentOutOfRangeException"></exception>
public LipAnimationFrame(LipSample sample, float durationSeconds)
{
if (durationSeconds < 0f)
{
throw new ArgumentOutOfRangeException(
nameof(durationSeconds), durationSeconds,
"Duration must be greater than or equal to 0.");
}
this.sample = sample;
this.durationSeconds = durationSeconds;
}
public bool Equals(LipAnimationFrame other)
{
return sample.Equals(other.sample)
&& durationSeconds.Equals(other.durationSeconds);
}
public override bool Equals(object? obj)
{
return obj is LipAnimationFrame other && Equals(other);
}
public override int GetHashCode()
{
return HashCode.Combine(sample, durationSeconds);
}
}
}