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

MeltyPlayer / MeltyTool / 20982513833

14 Jan 2026 04:35AM UTC coverage: 41.138% (-0.8%) from 41.907%
20982513833

push

github

MeltyPlayer
Fixed broken shader source tests.

6752 of 18485 branches covered (36.53%)

Branch coverage included in aggregate %.

28650 of 67572 relevant lines covered (42.4%)

64006.02 hits per line

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

94.07
/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 sealed 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;
268,713✔
26

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

30
  public IReadOnlyList<TKeyframe> Definitions => this.impl_;
545,739✔
31
  public bool HasAnyData => this.Definitions.Count > 0;
225,823✔
32

33
  public int AnimationLength => sharedConfig.AnimationLength;
×
34
  public bool Looping => sharedConfig.Looping;
×
35

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

39
  public bool TryGetAtFrame(float frame, out T value) {
4,540,156✔
40
    switch (this.impl_.TryGetPrecedingAndFollowingKeyframes(
4,540,156✔
41
                frame,
4,540,156✔
42
                sharedConfig,
4,540,156✔
43
                this.IndividualConfig,
4,540,156✔
44
                out var precedingKeyframe,
4,540,156✔
45
                out var followingKeyframe,
4,540,156✔
46
                out var normalizedFrame)) {
4,540,156✔
47
      case InterpolationDataType.PRECEDING_AND_FOLLOWING:
48
        value = interpolator.Interpolate(precedingKeyframe,
3,616,273✔
49
                                         followingKeyframe,
3,616,273✔
50
                                         normalizedFrame,
3,616,273✔
51
                                         sharedConfig);
3,616,273✔
52
        return true;
3,616,273✔
53

54
      case InterpolationDataType.PRECEDING_ONLY:
55
        value = precedingKeyframe.ValueOut;
427,053✔
56
        return true;
427,053✔
57

58
      default:
59
      case InterpolationDataType.NONE:
60
        if (this.IndividualConfig.DefaultValue?.Try(out value) ?? false) {
993,657✔
61
          return true;
496,827✔
62
        }
63

64
        value = default!;
3✔
65
        return false;
3✔
66
    }
67
  }
4,540,156✔
68

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

83
  public void GetAllFrames(Span<T> dst) {
36,044✔
84
    T defaultValue = default!;
36,044✔
85
    this.IndividualConfig.DefaultValue?.Try(out defaultValue);
36,044!
86
    dst.Fill(defaultValue);
36,044✔
87
    if (this.impl_.Count == 0) {
45,254✔
88
      return;
9,210✔
89
    }
90

91
    var from = this.impl_[0];
26,834✔
92
    if (!sharedConfig.Looping) {
39,832✔
93
      dst[(int) MathF.Ceiling(from.Frame)..].Fill(from.ValueOut);
12,998✔
94
    }
12,998✔
95

96
    for (var k = 1; k < this.impl_.Count; ++k) {
341,446✔
97
      var to = this.impl_[k];
95,926✔
98
      this.AddFrames_(dst, from, to);
95,926✔
99
      from = to;
95,926✔
100
    }
95,926✔
101

102
    if (sharedConfig.Looping) {
40,670✔
103
      this.AddFrames_(dst, this.impl_[^1], this.impl_[0]);
13,836✔
104
    } else {
26,834✔
105
      var last = this.impl_[^1];
12,998✔
106
      var lastFrame = (int) MathF.Ceiling(last.Frame);
12,998✔
107
      if (lastFrame < dst.Length) {
13,101✔
108
        dst[lastFrame..].Fill(last.ValueOut);
103✔
109
      }
103✔
110
    }
12,998✔
111
  }
36,044✔
112

113
  private void AddFrames_(Span<T> dst, TKeyframe from, TKeyframe to) {
109,762✔
114
    var fromFrame = (int) MathF.Ceiling(from.Frame);
109,762✔
115
    var toFrame = (int) MathF.Ceiling(to.Frame);
109,762✔
116

117
    if (toFrame < fromFrame) {
110,578✔
118
      toFrame += dst.Length;
816✔
119
    }
816✔
120

121
    for (var i = fromFrame; i < toFrame; ++i) {
2,387,498✔
122
      var normalizedFrame = i % dst.Length;
722,658✔
123
      dst[normalizedFrame]
722,658✔
124
          = interpolator.Interpolate(from, to, normalizedFrame, sharedConfig);
722,658✔
125
    }
722,658✔
126
  }
109,762✔
127

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

138
    tangentKeyframes = null;
42,508✔
139
    keyframes = this.impl_.Select(k => (k.Frame, k.ValueOut)).ToArray();
1,776,826✔
140

141
    return true;
42,508✔
142
  }
42,508✔
143
}
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