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

MeltyPlayer / MeltyTool / 19622977055

24 Nov 2025 04:05AM UTC coverage: 41.989% (+2.1%) from 39.89%
19622977055

push

github

MeltyPlayer
Switched float precision to fix broken tests.

6747 of 18131 branches covered (37.21%)

Branch coverage included in aggregate %.

28639 of 66144 relevant lines covered (43.3%)

65384.8 hits per line

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

90.53
/FinModelUtility/Fin/Fin/src/animation/types/vector3/SeparateVector3Keyframes.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Numerics;
5

6
using fin.animation.interpolation;
7
using fin.animation.keyframes;
8
using fin.math.interpolation;
9
using fin.util.asserts;
10

11
using NoAlloq;
12

13
namespace fin.animation.types.vector3;
14

15
public sealed class SeparateVector3Keyframes<TKeyframe>(
19,695✔
16
    ISharedInterpolationConfig sharedConfig,
19,695✔
17
    IKeyframeInterpolator<TKeyframe, float> interpolator,
19,695✔
18
    IndividualInterpolationConfig<float>? individualConfigX,
19,695✔
19
    IndividualInterpolationConfig<float>? individualConfigY,
19,695✔
20
    IndividualInterpolationConfig<float>? individualConfigZ)
19,695✔
21
    : ISeparateVector3Keyframes<TKeyframe>
22
    where TKeyframe : IKeyframe<float> {
23
  public SeparateVector3Keyframes(
24
      ISharedInterpolationConfig sharedConfig,
25
      IKeyframeInterpolator<TKeyframe, float> interpolator,
26
      IndividualInterpolationConfig<float>? individualConfig = null)
27
      : this(sharedConfig,
2✔
28
             interpolator,
2✔
29
             individualConfig,
2✔
30
             individualConfig,
2✔
31
             individualConfig) { }
6✔
32

33
  public IReadOnlyList<IInterpolatableKeyframes<TKeyframe, float>> Axes { get; }
501,648✔
34
    = [
19,695✔
35
        new InterpolatedKeyframes<TKeyframe, float>(
19,695✔
36
            sharedConfig,
19,695✔
37
            interpolator,
19,695✔
38
            individualConfigX),
19,695✔
39
        new InterpolatedKeyframes<TKeyframe, float>(
19,695✔
40
            sharedConfig,
19,695✔
41
            interpolator,
19,695✔
42
            individualConfigY),
19,695✔
43
        new InterpolatedKeyframes<TKeyframe, float>(
19,695✔
44
            sharedConfig,
19,695✔
45
            interpolator,
19,695✔
46
            individualConfigZ),
19,695✔
47
    ];
19,695✔
48

49
  public bool TryGetAtFrame(float frame, out Vector3 value) {
20✔
50
    value = default;
20✔
51

52
    if (!this.Axes[0]
20!
53
             .TryGetAtFrameOrDefault(frame, individualConfigX, out var x)) {
20✔
54
      return false;
×
55
    }
56

57
    if (!this.Axes[1]
20!
58
             .TryGetAtFrameOrDefault(frame, individualConfigY, out var y)) {
20✔
59
      return false;
×
60
    }
61

62
    if (!this.Axes[2]
20!
63
             .TryGetAtFrameOrDefault(frame, individualConfigZ, out var z)) {
20✔
64
      return false;
×
65
    }
66

67
    value = new Vector3(x, y, z);
20✔
68
    return true;
20✔
69
  }
20✔
70

71
  public void GetAllFrames(Span<Vector3> dst) {
11,980✔
72
    Span<float> x = stackalloc float[dst.Length];
11,980✔
73
    Span<float> y = stackalloc float[dst.Length];
11,980✔
74
    Span<float> z = stackalloc float[dst.Length];
11,980✔
75

76
    this.Axes[0].GetAllFrames(x);
11,980✔
77
    this.Axes[1].GetAllFrames(y);
11,980✔
78
    this.Axes[2].GetAllFrames(z);
11,980✔
79

80
    for (var i = 0; i < dst.Length; ++i) {
1,967,531✔
81
      dst[i] = new Vector3(x[i], y[i], z[i]);
647,857✔
82
    }
647,857✔
83
  }
11,980✔
84

85
  public bool TryGetSimpleKeyframes(
86
      out IReadOnlyList<(float frame, Vector3 value)> keyframes,
87
      out IReadOnlyList<(Vector3 tangentIn, Vector3 tangentOut)>?
88
          tangentKeyframes) {
17,065✔
89
    var xAxis = this.Axes[0];
17,065✔
90
    var yAxis = this.Axes[1];
17,065✔
91
    var zAxis = this.Axes[2];
17,065✔
92

93
    if (!xAxis.HasAnyData && !yAxis.HasAnyData && !zAxis.HasAnyData) {
17,065!
94
      keyframes = [];
×
95
      tangentKeyframes = null;
×
96
      return true;
×
97
    }
98

99
    Span<(IInterpolatableKeyframes<TKeyframe, float> keyframes,
17,065✔
100
        IInterpolatableKeyframes<KeyframeWithTangents<float>, float>? keyframesWithTangents,
17,065✔
101
        IndividualInterpolationConfig<float>? config)> axes = [
17,065✔
102
        (xAxis,
17,065✔
103
         xAxis as IInterpolatableKeyframes<KeyframeWithTangents<float>, float>,
17,065✔
104
         individualConfigX),
17,065✔
105
        (yAxis,
17,065✔
106
         yAxis as IInterpolatableKeyframes<KeyframeWithTangents<float>, float>,
17,065✔
107
         individualConfigY),
17,065✔
108
        (zAxis,
17,065✔
109
         zAxis as IInterpolatableKeyframes<KeyframeWithTangents<float>, float>,
17,065✔
110
         individualConfigZ),
17,065✔
111
    ];
17,065✔
112

113
    if (axes.Any(a => !a.keyframes.HasAnyData &&
68,260!
114
                      !(a.config?.DefaultValue?.Try(out _) ?? false))) {
68,260✔
115
      keyframes = null!;
×
116
      tangentKeyframes = null;
×
117
      return false;
×
118
    }
119

120
    var unionKeyframes
17,065✔
121
        = xAxis.Definitions
17,065✔
122
               .Concat(yAxis.Definitions)
17,065✔
123
               .Concat(zAxis.Definitions)
17,065✔
124
               .Select(keyframe => keyframe.Frame)
360,003✔
125
               .Distinct()
17,065✔
126
               .Order()
17,065✔
127
               .ToArray();
17,065✔
128

129
    var unionKeyframeCount = unionKeyframes.Length;
17,065✔
130

131
    {
17,065✔
132
      var mutableKeyframes = new (float, Vector3)[unionKeyframeCount];
17,065✔
133
      for (var k = 0; k < unionKeyframeCount; ++k) {
485,510✔
134
        var keyframe = unionKeyframes[k];
150,460✔
135
        var value = new Vector3();
150,460✔
136

137
        for (var i = 0; i < axes.Length; ++i) {
1,655,060✔
138
          var axis = axes[i];
451,380✔
139
          Asserts.True(
451,380✔
140
              axis.keyframes.TryGetAtFrameOrDefault(keyframe,
451,380✔
141
                                                    axis.config,
451,380✔
142
                                                    out var axisValue));
451,380✔
143
          value[i] = axisValue;
451,380✔
144
        }
451,380✔
145

146
        mutableKeyframes[k] = (keyframe, value);
150,460✔
147
      }
150,460✔
148

149
      keyframes = mutableKeyframes;
17,065✔
150
    }
17,065✔
151

152
    if (axes.Any(a => a.keyframesWithTangents == null)) {
66,282✔
153
      tangentKeyframes = null;
1,978✔
154
    } else {
17,065✔
155
      var mutableTangentKeyframes = new (Vector3, Vector3)[unionKeyframeCount];
15,087✔
156

157
      for (var k = 0; k < unionKeyframeCount; ++k) {
297,062✔
158
        var keyframe = unionKeyframes[k];
96,948✔
159

160
        var tangentIn = new Vector3();
96,948✔
161
        var tangentOut = new Vector3();
96,948✔
162

163
        for (var i = 0; i < axes.Length; ++i) {
976,079✔
164
          var axis = axes[i];
268,713✔
165
          if (!HermiteInterpolationUtil.TryGetTangent(
268,713✔
166
                  axis.keyframesWithTangents!,
268,713✔
167
                  keyframe,
268,713✔
168
                  out var axisTangentIn,
268,713✔
169
                  out var axisTangentOut)) {
280,691✔
170
            tangentKeyframes = null;
11,978✔
171
            return false;
11,978✔
172
          }
173

174
          tangentIn[i] = axisTangentIn;
256,735✔
175
          tangentOut[i] = axisTangentOut;
256,735✔
176
        }
256,735✔
177

178
        mutableTangentKeyframes[k] = (tangentIn, tangentOut);
84,970✔
179
      }
84,970✔
180

181
      tangentKeyframes = mutableTangentKeyframes;
3,109✔
182
    }
3,109✔
183

184
    return true;
5,087✔
185
  }
17,065✔
186
}
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