Skip to content

Commit

Permalink
Renamed "Keyframe" to "KeyframeDefinition".
Browse files Browse the repository at this point in the history
  • Loading branch information
MeltyPlayer committed Jun 27, 2024
1 parent cdc7a19 commit ebc4dd7
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public class KeyframeDefinitionsTests {
impl.SetKeyframe(4, "4");

AssertKeyframes_(impl,
new Keyframe<string>(0, "0"),
new Keyframe<string>(1, "1"),
new Keyframe<string>(2, "2"),
new Keyframe<string>(3, "3"),
new Keyframe<string>(4, "4")
new KeyframeDefinition<string>(0, "0"),
new KeyframeDefinition<string>(1, "1"),
new KeyframeDefinition<string>(2, "2"),
new KeyframeDefinition<string>(3, "3"),
new KeyframeDefinition<string>(4, "4")
);
}

Expand All @@ -32,7 +32,7 @@ public class KeyframeDefinitionsTests {
impl.SetKeyframe(1, "second");
impl.SetKeyframe(1, "third");

AssertKeyframes_(impl, new Keyframe<string>(1, "third"));
AssertKeyframes_(impl, new KeyframeDefinition<string>(1, "third"));
}

[Test]
Expand All @@ -46,11 +46,11 @@ public class KeyframeDefinitionsTests {
impl.SetKeyframe(0, "0");

AssertKeyframes_(impl,
new Keyframe<string>(0, "0"),
new Keyframe<string>(1, "1"),
new Keyframe<string>(2, "2"),
new Keyframe<string>(4, "4"),
new Keyframe<string>(5, "5")
new KeyframeDefinition<string>(0, "0"),
new KeyframeDefinition<string>(1, "1"),
new KeyframeDefinition<string>(2, "2"),
new KeyframeDefinition<string>(4, "4"),
new KeyframeDefinition<string>(5, "5")
);
}

Expand All @@ -65,11 +65,11 @@ public class KeyframeDefinitionsTests {
impl.SetKeyframe(7, "7");

AssertKeyframes_(impl,
new Keyframe<string>(0, "0"),
new Keyframe<string>(2, "2"),
new Keyframe<string>(5, "5"),
new Keyframe<string>(7, "7"),
new Keyframe<string>(9, "9")
new KeyframeDefinition<string>(0, "0"),
new KeyframeDefinition<string>(2, "2"),
new KeyframeDefinition<string>(5, "5"),
new KeyframeDefinition<string>(7, "7"),
new KeyframeDefinition<string>(9, "9")
);
}

Expand All @@ -82,9 +82,9 @@ public class KeyframeDefinitionsTests {
impl.SetKeyframe(123, "123");

AssertKeyframes_(impl,
new Keyframe<string>(2, "2"),
new Keyframe<string>(123, "123"),
new Keyframe<string>(1000, "1000")
new KeyframeDefinition<string>(2, "2"),
new KeyframeDefinition<string>(123, "123"),
new KeyframeDefinition<string>(1000, "1000")
);
}

Expand All @@ -96,11 +96,11 @@ public class KeyframeDefinitionsTests {
impl.SetKeyframe(2, "second");
impl.SetKeyframe(4, "third");

Assert.AreEqual(new Keyframe<string>(0, "first"),
Assert.AreEqual(new KeyframeDefinition<string>(0, "first"),
impl.GetKeyframeAtIndex(0));
Assert.AreEqual(new Keyframe<string>(2, "second"),
Assert.AreEqual(new KeyframeDefinition<string>(2, "second"),
impl.GetKeyframeAtIndex(1));
Assert.AreEqual(new Keyframe<string>(4, "third"),
Assert.AreEqual(new KeyframeDefinition<string>(4, "third"),
impl.GetKeyframeAtIndex(2));
}

Expand All @@ -112,19 +112,19 @@ public class KeyframeDefinitionsTests {
impl.SetKeyframe(2, "second");
impl.SetKeyframe(4, "third");

AssertKeyframe_(new Keyframe<string>(0, default),
AssertKeyframe_(new KeyframeDefinition<string>(0, default),
impl.GetKeyframeAtFrame(-1));
AssertKeyframe_(new Keyframe<string>(0, "first"),
AssertKeyframe_(new KeyframeDefinition<string>(0, "first"),
impl.GetKeyframeAtFrame(0));
AssertKeyframe_(new Keyframe<string>(0, "first"),
AssertKeyframe_(new KeyframeDefinition<string>(0, "first"),
impl.GetKeyframeAtFrame(1));
AssertKeyframe_(new Keyframe<string>(2, "second"),
AssertKeyframe_(new KeyframeDefinition<string>(2, "second"),
impl.GetKeyframeAtFrame(2));
AssertKeyframe_(new Keyframe<string>(2, "second"),
AssertKeyframe_(new KeyframeDefinition<string>(2, "second"),
impl.GetKeyframeAtFrame(3));
AssertKeyframe_(new Keyframe<string>(4, "third"),
AssertKeyframe_(new KeyframeDefinition<string>(4, "third"),
impl.GetKeyframeAtFrame(4));
AssertKeyframe_(new Keyframe<string>(4, "third"),
AssertKeyframe_(new KeyframeDefinition<string>(4, "third"),
impl.GetKeyframeAtFrame(5));
}

Expand All @@ -136,19 +136,19 @@ public class KeyframeDefinitionsTests {
impl.SetKeyframe(2, "second");
impl.SetKeyframe(0, "first");

AssertKeyframe_(new Keyframe<string>(0, default),
AssertKeyframe_(new KeyframeDefinition<string>(0, default),
impl.GetKeyframeAtFrame(-1));
AssertKeyframe_(new Keyframe<string>(0, "first"),
AssertKeyframe_(new KeyframeDefinition<string>(0, "first"),
impl.GetKeyframeAtFrame(0));
AssertKeyframe_(new Keyframe<string>(0, "first"),
AssertKeyframe_(new KeyframeDefinition<string>(0, "first"),
impl.GetKeyframeAtFrame(1));
AssertKeyframe_(new Keyframe<string>(2, "second"),
AssertKeyframe_(new KeyframeDefinition<string>(2, "second"),
impl.GetKeyframeAtFrame(2));
AssertKeyframe_(new Keyframe<string>(2, "second"),
AssertKeyframe_(new KeyframeDefinition<string>(2, "second"),
impl.GetKeyframeAtFrame(3));
AssertKeyframe_(new Keyframe<string>(4, "third"),
AssertKeyframe_(new KeyframeDefinition<string>(4, "third"),
impl.GetKeyframeAtFrame(4));
AssertKeyframe_(new Keyframe<string>(4, "third"),
AssertKeyframe_(new KeyframeDefinition<string>(4, "third"),
impl.GetKeyframeAtFrame(5));
}

Expand All @@ -160,19 +160,19 @@ public class KeyframeDefinitionsTests {
impl.SetKeyframe(0, "first");
impl.SetKeyframe(2, "second");

AssertKeyframe_(new Keyframe<string>(0, default),
AssertKeyframe_(new KeyframeDefinition<string>(0, default),
impl.GetKeyframeAtFrame(-1));
AssertKeyframe_(new Keyframe<string>(0, "first"),
AssertKeyframe_(new KeyframeDefinition<string>(0, "first"),
impl.GetKeyframeAtFrame(0));
AssertKeyframe_(new Keyframe<string>(0, "first"),
AssertKeyframe_(new KeyframeDefinition<string>(0, "first"),
impl.GetKeyframeAtFrame(1));
AssertKeyframe_(new Keyframe<string>(2, "second"),
AssertKeyframe_(new KeyframeDefinition<string>(2, "second"),
impl.GetKeyframeAtFrame(2));
AssertKeyframe_(new Keyframe<string>(2, "second"),
AssertKeyframe_(new KeyframeDefinition<string>(2, "second"),
impl.GetKeyframeAtFrame(3));
AssertKeyframe_(new Keyframe<string>(4, "third"),
AssertKeyframe_(new KeyframeDefinition<string>(4, "third"),
impl.GetKeyframeAtFrame(4));
AssertKeyframe_(new Keyframe<string>(4, "third"),
AssertKeyframe_(new KeyframeDefinition<string>(4, "third"),
impl.GetKeyframeAtFrame(5));
}

Expand Down Expand Up @@ -256,11 +256,11 @@ public class KeyframeDefinitionsTests {
}
}

private void AssertKeyframe_(Keyframe<string>? expected,
Keyframe<string>? actual)
private void AssertKeyframe_(KeyframeDefinition<string>? expected,
KeyframeDefinition<string>? actual)
=> Assert.AreEqual(expected, actual);

private void AssertKeyframes_(KeyframeDefinitions<string> actual,
params Keyframe<string>[] expected)
params KeyframeDefinition<string>[] expected)
=> Asserts.SequenceEqual(expected, actual.Definitions);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public class KeyframeDefinitionsWithBinarySearchTests {
Assert.False(performedBinarySearch4);

AssertKeyframes_(impl,
new Keyframe<string>(0, "0"),
new Keyframe<string>(1, "1"),
new Keyframe<string>(2, "2"),
new Keyframe<string>(3, "3"),
new Keyframe<string>(4, "4")
new KeyframeDefinition<string>(0, "0"),
new KeyframeDefinition<string>(1, "1"),
new KeyframeDefinition<string>(2, "2"),
new KeyframeDefinition<string>(3, "3"),
new KeyframeDefinition<string>(4, "4")
);
}

Expand All @@ -46,7 +46,7 @@ public class KeyframeDefinitionsWithBinarySearchTests {
impl.SetKeyframe(1, "third", out var performedBinarySearch3);
Assert.False(performedBinarySearch3);

AssertKeyframes_(impl, new Keyframe<string>(1, "third"));
AssertKeyframes_(impl, new KeyframeDefinition<string>(1, "third"));
}

[Test]
Expand All @@ -69,11 +69,11 @@ public class KeyframeDefinitionsWithBinarySearchTests {
Assert.True(performedBinarySearch0);

AssertKeyframes_(impl,
new Keyframe<string>(0, "0"),
new Keyframe<string>(1, "1"),
new Keyframe<string>(2, "2"),
new Keyframe<string>(4, "4"),
new Keyframe<string>(5, "5")
new KeyframeDefinition<string>(0, "0"),
new KeyframeDefinition<string>(1, "1"),
new KeyframeDefinition<string>(2, "2"),
new KeyframeDefinition<string>(4, "4"),
new KeyframeDefinition<string>(5, "5")
);
}

Expand All @@ -88,11 +88,11 @@ public class KeyframeDefinitionsWithBinarySearchTests {
impl.SetKeyframe(7, "7");

AssertKeyframes_(impl,
new Keyframe<string>(0, "0"),
new Keyframe<string>(2, "2"),
new Keyframe<string>(5, "5"),
new Keyframe<string>(7, "7"),
new Keyframe<string>(9, "9")
new KeyframeDefinition<string>(0, "0"),
new KeyframeDefinition<string>(2, "2"),
new KeyframeDefinition<string>(5, "5"),
new KeyframeDefinition<string>(7, "7"),
new KeyframeDefinition<string>(9, "9")
);
}

Expand All @@ -105,9 +105,9 @@ public class KeyframeDefinitionsWithBinarySearchTests {
impl.SetKeyframe(123, "123");

AssertKeyframes_(impl,
new Keyframe<string>(2, "2"),
new Keyframe<string>(123, "123"),
new Keyframe<string>(1000, "1000")
new KeyframeDefinition<string>(2, "2"),
new KeyframeDefinition<string>(123, "123"),
new KeyframeDefinition<string>(1000, "1000")
);
}

Expand All @@ -119,11 +119,11 @@ public class KeyframeDefinitionsWithBinarySearchTests {
impl.SetKeyframe(2, "second");
impl.SetKeyframe(4, "third");

Assert.AreEqual(new Keyframe<string>(0, "first"),
Assert.AreEqual(new KeyframeDefinition<string>(0, "first"),
impl.GetKeyframeAtIndex(0));
Assert.AreEqual(new Keyframe<string>(2, "second"),
Assert.AreEqual(new KeyframeDefinition<string>(2, "second"),
impl.GetKeyframeAtIndex(1));
Assert.AreEqual(new Keyframe<string>(4, "third"),
Assert.AreEqual(new KeyframeDefinition<string>(4, "third"),
impl.GetKeyframeAtIndex(2));
}

Expand All @@ -135,19 +135,19 @@ public class KeyframeDefinitionsWithBinarySearchTests {
impl.SetKeyframe(2, "second");
impl.SetKeyframe(4, "third");

AssertKeyframe_(new Keyframe<string>(0, default),
AssertKeyframe_(new KeyframeDefinition<string>(0, default),
impl.GetKeyframeAtFrame(-1));
AssertKeyframe_(new Keyframe<string>(0, "first"),
AssertKeyframe_(new KeyframeDefinition<string>(0, "first"),
impl.GetKeyframeAtFrame(0));
AssertKeyframe_(new Keyframe<string>(0, "first"),
AssertKeyframe_(new KeyframeDefinition<string>(0, "first"),
impl.GetKeyframeAtFrame(1));
AssertKeyframe_(new Keyframe<string>(2, "second"),
AssertKeyframe_(new KeyframeDefinition<string>(2, "second"),
impl.GetKeyframeAtFrame(2));
AssertKeyframe_(new Keyframe<string>(2, "second"),
AssertKeyframe_(new KeyframeDefinition<string>(2, "second"),
impl.GetKeyframeAtFrame(3));
AssertKeyframe_(new Keyframe<string>(4, "third"),
AssertKeyframe_(new KeyframeDefinition<string>(4, "third"),
impl.GetKeyframeAtFrame(4));
AssertKeyframe_(new Keyframe<string>(4, "third"),
AssertKeyframe_(new KeyframeDefinition<string>(4, "third"),
impl.GetKeyframeAtFrame(5));
}

Expand Down Expand Up @@ -231,11 +231,11 @@ public class KeyframeDefinitionsWithBinarySearchTests {
}
}

private void AssertKeyframe_(Keyframe<string>? expected,
Keyframe<string>? actual)
private void AssertKeyframe_(KeyframeDefinition<string>? expected,
KeyframeDefinition<string>? actual)
=> Assert.AreEqual(expected, actual);

private void AssertKeyframes_(KeyframeDefinitionsWithBinarySearch<string> actual,
params Keyframe<string>[] expected)
params KeyframeDefinition<string>[] expected)
=> Asserts.SequenceEqual(expected, actual.Definitions);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public interface IReadOnlyInterpolatedTrack<TInterpolated> : ITrack {


public interface IImplTrack<TValue> : ITrack {
IReadOnlyList<Keyframe<ValueAndTangents<TValue>>> Keyframes { get; }
IReadOnlyList<KeyframeDefinition<ValueAndTangents<TValue>>> Keyframes { get; }

[MethodImpl(MethodImplOptions.AggressiveInlining)]
void SetKeyframe(int frame, TValue value, string frameType = "")
Expand Down Expand Up @@ -73,7 +73,7 @@ void SetKeyframe(int frame, TValue value, float? tangent, string frameType = "")
AnimationInterpolationConfig? config = null
);

Keyframe<ValueAndTangents<TValue>>? GetKeyframe(int frame);
KeyframeDefinition<ValueAndTangents<TValue>>? GetKeyframe(int frame);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

namespace fin.animation.keyframes;

public readonly record struct Keyframe<T>(
public readonly record struct KeyframeDefinition<T>(
int Frame,
T Value,
string FrameType = "")
: IComparable<Keyframe<T>>, IEquatable<Keyframe<T>> {
: IComparable<KeyframeDefinition<T>>, IEquatable<KeyframeDefinition<T>> {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Keyframe<T> other)
public int CompareTo(KeyframeDefinition<T> other)
=> this.Frame - other.Frame;

public bool Equals(Keyframe<T> other)
public bool Equals(KeyframeDefinition<T> other)
=> this.Frame == other.Frame &&
(this.Value?.Equals(other.Value) ??
this.Value == null && other.Value == null);
Expand Down
Loading

0 comments on commit ebc4dd7

Please sign in to comment.