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

MeltyPlayer / MeltyTool / 17723681353

15 Sep 2025 06:01AM UTC coverage: 39.974% (-0.02%) from 39.997%
17723681353

push

github

MeltyPlayer
Set up logic that will soon write JUST the keyframes in the output GLTF file, which results in WAY smaller files. I'm a total idiot for doing it any other way for so long.

5777 of 16369 branches covered (35.29%)

Branch coverage included in aggregate %.

0 of 38 new or added lines in 10 files covered. (0.0%)

24412 of 59152 relevant lines covered (41.27%)

75169.94 hits per line

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

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

7
using fin.animation.interpolation;
8

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

11
namespace fin.animation.keyframes;
12

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

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

26
  public ISharedInterpolationConfig SharedConfig => sharedConfig;
×
27

28
  public IndividualInterpolationConfig<T> IndividualConfig
29
    => individualConfig ?? IndividualInterpolationConfig<T>.DEFAULT;
12,189,275✔
30

31
  public IReadOnlyList<TKeyframe> Definitions => this.impl_;
149,642✔
32
  public bool HasAnyData => this.Definitions.Count > 0;
149,634✔
33

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

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

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

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

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

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

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

89
    var from = this.impl_[0];
84,603✔
90
    if (!sharedConfig.Looping) {
111,975✔
91
      dst[(int) MathF.Ceiling(from.Frame)..].Fill(from.ValueOut);
27,372✔
92
    }
27,372✔
93

94
    for (var k = 1; k < this.impl_.Count; ++k) {
6,250,161✔
95
      var to = this.impl_[k];
2,026,985✔
96
      this.AddFrames_(dst, from, to);
2,026,985✔
97
      from = to;
2,026,985✔
98
    }
2,026,985✔
99

100
    if (sharedConfig.Looping) {
141,834✔
101
      this.AddFrames_(dst, this.impl_[^1], this.impl_[0]);
57,231✔
102
    } else {
84,603✔
103
      var last = this.impl_[^1];
27,372✔
104
      var lastFrame = (int) MathF.Ceiling(last.Frame);
27,372✔
105
      if (lastFrame < dst.Length) {
41,849✔
106
        dst[lastFrame..].Fill(last.ValueOut);
14,477✔
107
      }
14,477✔
108
    }
27,372✔
109
  }
93,813✔
110

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

115
    if (toFrame < fromFrame) {
2,117,008✔
116
      toFrame += dst.Length;
32,792✔
117
    }
32,792✔
118

119
    for (var i = fromFrame; i < toFrame; ++i) {
13,418,425✔
120
      var normalizedFrame = i % dst.Length;
3,083,331✔
121
      dst[normalizedFrame]
3,083,331✔
122
          = interpolator.Interpolate(from, to, normalizedFrame, sharedConfig);
3,083,331✔
123
    }
3,083,331✔
124
  }
2,084,216✔
125

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

NEW
136
    tangentKeyframes = null;
×
NEW
137
    keyframes = this.impl_.Select(k => (k.Frame, k.ValueOut)).ToArray();
×
138

NEW
139
    return true;
×
NEW
140
  }
×
141
}
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