• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MeltyPlayer / MeltyTool / 17993985084

25 Sep 2025 01:17AM UTC coverage: 39.931%. Remained the same
17993985084

push

github

MeltyPlayer
Used concrete types throughout solution.

5826 of 16491 branches covered (35.33%)

Branch coverage included in aggregate %.

44 of 85 new or added lines in 38 files covered. (51.76%)

1 existing line in 1 file now uncovered.

24549 of 59577 relevant lines covered (41.21%)

71883.78 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.83
/FinModelUtility/Fin/Fin/src/animation/keyframes/InterpolatedKeyframes.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Runtime.CompilerServices;
5

6
using fin.animation.interpolation;
7

8
using static fin.animation.keyframes.KeyframesUtil;
9

10
namespace fin.animation.keyframes;
11

12
public interface IInterpolatableKeyframes<TKeyframe, T>
13
    : IKeyframes<TKeyframe>,
14
      IConfiguredInterpolatable<T> where TKeyframe : IKeyframe<T>;
15

16
public class InterpolatedKeyframes<TKeyframe, T>(
271,443✔
17
    ISharedInterpolationConfig sharedConfig,
271,443✔
18
    IKeyframeInterpolator<TKeyframe, T> interpolator,
271,443✔
19
    IndividualInterpolationConfig<T>? individualConfig = null)
271,443✔
20
    : IInterpolatableKeyframes<TKeyframe, T>
21
    where TKeyframe : IKeyframe<T> {
22
  private readonly List<TKeyframe> impl_
271,443✔
23
      = new(individualConfig?.InitialCapacity ?? 0);
271,443✔
24

25
  public ISharedInterpolationConfig SharedConfig => sharedConfig;
×
26

27
  public IndividualInterpolationConfig<T> IndividualConfig
28
    => individualConfig ?? IndividualInterpolationConfig<T>.DEFAULT;
12,114,226✔
29

30
  public IReadOnlyList<TKeyframe> Definitions => this.impl_;
228,060✔
31
  public bool HasAnyData => this.Definitions.Count > 0;
192,202✔
32

33
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
34
  public void Add(TKeyframe keyframe) => this.impl_.AddKeyframe(keyframe);
3,475,261✔
35

36
  public bool TryGetAtFrame(float frame, out T value) {
4,088,776✔
37
    switch (this.impl_.TryGetPrecedingAndFollowingKeyframes(
4,088,776✔
38
                frame,
4,088,776✔
39
                sharedConfig,
4,088,776✔
40
                this.IndividualConfig,
4,088,776✔
41
                out var precedingKeyframe,
4,088,776✔
42
                out var followingKeyframe,
4,088,776✔
43
                out var normalizedFrame)) {
4,088,776✔
44
      case InterpolationDataType.PRECEDING_AND_FOLLOWING:
45
        value = interpolator.Interpolate(precedingKeyframe,
3,276,059✔
46
                                         followingKeyframe,
3,276,059✔
47
                                         normalizedFrame,
3,276,059✔
48
                                         sharedConfig);
3,276,059✔
49
        return true;
3,276,059✔
50

51
      case InterpolationDataType.PRECEDING_ONLY:
52
        value = precedingKeyframe.ValueOut;
375,118✔
53
        return true;
375,118✔
54

55
      default:
56
      case InterpolationDataType.NONE:
57
        if (this.IndividualConfig.DefaultValue?.Try(out value) ?? false) {
875,195✔
58
          return true;
437,596✔
59
        }
60

61
        value = default;
3✔
62
        return false;
3✔
63
    }
64
  }
4,088,776✔
65

66
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
67
  public InterpolationDataType TryGetPrecedingAndFollowingKeyframes(
68
      float frame,
69
      out TKeyframe precedingKeyframe,
70
      out TKeyframe followingKeyframe,
71
      out float normalizedFrame)
72
    => this.impl_.TryGetPrecedingAndFollowingKeyframes(
7,569,087✔
73
        frame,
7,569,087✔
74
        sharedConfig,
7,569,087✔
75
        this.IndividualConfig,
7,569,087✔
76
        out precedingKeyframe,
7,569,087✔
77
        out followingKeyframe,
7,569,087✔
78
        out normalizedFrame);
7,569,087✔
79

80
  public void GetAllFrames(Span<T> dst) {
18,764✔
81
    T defaultValue = default!;
18,764✔
82
    this.IndividualConfig.DefaultValue?.Try(out defaultValue);
18,764!
83
    dst.Fill(defaultValue);
18,764✔
84
    if (this.impl_.Count == 0) {
27,974✔
85
      return;
9,210✔
86
    }
87

88
    var from = this.impl_[0];
9,554✔
89
    if (!sharedConfig.Looping) {
16,867✔
90
      dst[(int) MathF.Ceiling(from.Frame)..].Fill(from.ValueOut);
7,313✔
91
    }
7,313✔
92

93
    for (var k = 1; k < this.impl_.Count; ++k) {
347,626✔
94
      var to = this.impl_[k];
109,506✔
95
      this.AddFrames_(dst, from, to);
109,506✔
96
      from = to;
109,506✔
97
    }
109,506✔
98

99
    if (sharedConfig.Looping) {
11,795✔
100
      this.AddFrames_(dst, this.impl_[^1], this.impl_[0]);
2,241✔
101
    } else {
9,554✔
102
      var last = this.impl_[^1];
7,313✔
103
      var lastFrame = (int) MathF.Ceiling(last.Frame);
7,313✔
104
      if (lastFrame < dst.Length) {
7,551✔
105
        dst[lastFrame..].Fill(last.ValueOut);
238✔
106
      }
238✔
107
    }
7,313✔
108
  }
18,764✔
109

110
  private void AddFrames_(Span<T> dst, TKeyframe from, TKeyframe to) {
111,747✔
111
    var fromFrame = (int) MathF.Ceiling(from.Frame);
111,747✔
112
    var toFrame = (int) MathF.Ceiling(to.Frame);
111,747✔
113

114
    if (toFrame < fromFrame) {
113,478✔
115
      toFrame += dst.Length;
1,731✔
116
    }
1,731✔
117

118
    for (var i = fromFrame; i < toFrame; ++i) {
1,701,339✔
119
      var normalizedFrame = i % dst.Length;
492,615✔
120
      dst[normalizedFrame]
492,615✔
121
          = interpolator.Interpolate(from, to, normalizedFrame, sharedConfig);
492,615✔
122
    }
492,615✔
123
  }
111,747✔
124

125
  public bool TryGetSimpleKeyframes(
126
      out IReadOnlyList<(float frame, T value)> keyframes,
127
      out IReadOnlyList<(T tangentIn, T tangentOut)>? tangentKeyframes) {
42,508✔
128
    // TODO: Implement this
129
    if (this.impl_ is List<KeyframeWithTangents<T>>) {
42,508!
NEW
130
      keyframes = null;
×
NEW
131
      tangentKeyframes = null;
×
UNCOV
132
      return false;
×
133
    }
134

135
    tangentKeyframes = null;
42,508✔
136
    keyframes = this.impl_.Select(k => (k.Frame, k.ValueOut)).ToArray();
1,776,826✔
137

138
    return true;
42,508✔
139
  }
42,508✔
140
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc