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

MeltyPlayer / MeltyTool / 17574188774

09 Sep 2025 06:45AM UTC coverage: 39.98% (-2.3%) from 42.309%
17574188774

push

github

MeltyPlayer
Okay, hopefully fixed the models now???

5774 of 16361 branches covered (35.29%)

Branch coverage included in aggregate %.

2 of 2 new or added lines in 1 file covered. (100.0%)

935 existing lines in 47 files now uncovered.

24391 of 59090 relevant lines covered (41.28%)

74782.62 hits per line

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

0.0
/FinModelUtility/Fin/Fin/src/math/TextureTransformManager.cs
1
using System.Collections.Generic;
2
using System.Numerics;
3

4
using fin.data.indexable;
5
using fin.math.matrix.four;
6
using fin.math.matrix.three;
7
using fin.math.rotations;
8
using fin.model;
9
using fin.util.time;
10

11
namespace fin.math;
12

13
public interface IReadOnlyTextureTransformManager {
14
  (bool is2d, Matrix3x2 twoDMatrix, Matrix4x4 threeDMatrix)? GetMatrix(
15
      IReadOnlyTexture texture);
16
}
17

18
public interface ITextureTransformManager : IReadOnlyTextureTransformManager {
19
  void Clear();
20

21
  void CalculateMatrices(
22
      IReadOnlyList<IReadOnlyTexture> textures,
23
      (IReadOnlyModelAnimation, float)? animationAndFrame
24
  );
25
}
26

27
public class TextureTransformManager : ITextureTransformManager {
28
  private readonly IndexableDictionary<IReadOnlyTexture, (bool is2d, Matrix3x2
×
29
      twoDMatrix, Matrix4x4 threeDMatrix)> texturesToMatrices_ = new();
×
30

31
  public void Clear() => this.texturesToMatrices_.Clear();
×
32

33
  public void CalculateMatrices(
34
      IReadOnlyList<IReadOnlyTexture> textures,
35
      (IReadOnlyModelAnimation, float)? animationAndFrame) {
×
36
    var animation = animationAndFrame?.Item1;
×
37
    var frame = animationAndFrame?.Item2;
×
38

39
    // Intentionally looping by index to avoid allocating an enumerator.
40
    for (var i = 0; i < textures.Count; ++i) {
×
41
      var texture = textures[i];
×
42
      Vector3? animationTranslation = null;
×
UNCOV
43
      Vector3? animationRotation = null;
×
UNCOV
44
      Vector3? animationScale = null;
×
45

46
      // The pose of the animation, if available.
47
      IReadOnlyTextureTracks? textureTracks = null;
×
UNCOV
48
      animation?.TextureTracks.TryGetValue(texture, out textureTracks);
×
49
      if (textureTracks != null) {
×
50
        // Only gets the values from the animation if the frame is at least partially defined.
51
        if (textureTracks.Translations?.HasAnyData ?? false) {
×
52
          if (textureTracks.Translations.TryGetAtFrame(
×
53
                  frame.Value,
×
54
                  out var outAnimationTranslation)) {
×
55
            animationTranslation = outAnimationTranslation;
×
UNCOV
56
          }
×
57
        }
×
58

59
        if (textureTracks.Rotations?.HasAnyData ?? false) {
×
60
          if (textureTracks.Rotations.TryGetAtFrame(
×
61
                  frame.Value,
×
62
                  out var outAnimationRotation)) {
×
63
            animationRotation = outAnimationRotation.ToEulerRadians();
×
UNCOV
64
          }
×
65
        }
×
66

67
        if (textureTracks.Scales?.HasAnyData ?? false) {
×
68
          if (textureTracks.Scales.TryGetAtFrame(
×
69
                  frame.Value,
×
70
                  out var outAnimationScale)) {
×
71
            animationScale = outAnimationScale;
×
72
          }
×
UNCOV
73
        }
×
UNCOV
74
      }
×
75

76
      // Uses the animation pose instead of the root pose when available.
77
      var transform = texture.TextureTransform;
×
78
      var center = transform.Center;
×
79
      var translation = animationTranslation ?? transform.Translation;
×
UNCOV
80
      var rotation = animationRotation ?? transform.RotationRadians;
×
81
      var scale = animationScale ?? transform.Scale;
×
82

83
      var isTransform3d = transform.IsTransform3d;
×
84

85
      if (isTransform3d) {
×
86
        this.texturesToMatrices_[texture] = (
×
87
            false,
×
88
            default,
×
89
            CalculateTextureTransform3d_(texture,
×
90
                                         center,
×
91
                                         translation,
×
92
                                         rotation,
×
93
                                         scale));
×
94
      } else {
×
95
        this.texturesToMatrices_[texture] = (
×
96
            true,
×
97
            CalculateTextureTransform2d_(texture,
×
98
                                         center,
×
99
                                         translation,
×
100
                                         rotation,
×
101
                                         scale),
×
102
            default);
×
103
      }
×
UNCOV
104
    }
×
UNCOV
105
  }
×
106

107
  private static Matrix3x2 CalculateTextureTransform2d_(
108
      IReadOnlyTexture texture,
109
      Vector3? textureCenter,
110
      Vector3? textureTranslation,
111
      Vector3? textureRotationRadians,
UNCOV
112
      Vector3? textureScale) {
×
113
    var scrollingTexture = texture as IScrollingTexture;
×
114

115
    if ((textureTranslation == null && scrollingTexture == null) &&
×
116
        textureScale == null &&
×
UNCOV
117
        textureRotationRadians == null) {
×
UNCOV
118
      return Matrix3x2.Identity;
×
119
    }
120

UNCOV
121
    var secondsSinceStart
×
122
        = (float) FrameTime.ElapsedTimeSinceApplicationOpened.TotalSeconds;
×
123

124
    Vector2? center = null;
×
125
    if (textureCenter != null) {
×
UNCOV
126
      center = textureCenter.Value.Xy();
×
127
    }
×
128

129
    Vector2? translation = null;
×
130
    if (textureTranslation != null || scrollingTexture != null) {
×
131
      translation = new Vector2((textureTranslation?.X ?? 0) +
×
132
                                secondsSinceStart *
×
133
                                (scrollingTexture?.ScrollSpeedX ?? 0),
×
134
                                (textureTranslation?.Y ?? 0) +
×
135
                                secondsSinceStart *
×
UNCOV
136
                                (scrollingTexture?.ScrollSpeedY ?? 0));
×
137
    }
×
138

139
    Vector2? scale = null;
×
140
    if (textureScale != null) {
×
UNCOV
141
      scale = textureScale.Value.Xy();
×
142
    }
×
143

144
    return SystemMatrix3x2Util.FromCtrss(center,
×
145
                                         translation,
×
146
                                         textureRotationRadians?.Z,
×
147
                                         scale,
×
UNCOV
148
                                         null);
×
UNCOV
149
  }
×
150

151
  private static Matrix4x4 CalculateTextureTransform3d_(
152
      IReadOnlyTexture texture,
153
      Vector3? textureCenter,
154
      Vector3? textureTranslation,
155
      Vector3? textureRotationRadians,
UNCOV
156
      Vector3? textureScale) {
×
157
    var scrollingTexture = texture as IScrollingTexture;
×
158

159
    if ((textureTranslation == null && scrollingTexture == null) &&
×
160
        textureScale == null &&
×
UNCOV
161
        textureRotationRadians == null) {
×
UNCOV
162
      return Matrix4x4.Identity;
×
163
    }
164

UNCOV
165
    var secondsSinceStart
×
166
        = (float) FrameTime.ElapsedTimeSinceApplicationOpened.TotalSeconds;
×
167

168
    Vector3? translation = null;
×
169
    if (textureTranslation != null || scrollingTexture != null) {
×
170
      translation = new Vector3((textureTranslation?.X ?? 0) +
×
171
                                secondsSinceStart *
×
172
                                (scrollingTexture?.ScrollSpeedX ?? 0),
×
173
                                (textureTranslation?.Y ?? 0) +
×
174
                                secondsSinceStart *
×
175
                                (scrollingTexture?.ScrollSpeedY ?? 0),
×
UNCOV
176
                                textureTranslation?.Z ?? 0);
×
177
    }
×
178

179
    Quaternion? rotation = null;
×
180
    if (textureRotationRadians != null) {
×
181
      rotation = QuaternionUtil.CreateZyxRadians(textureRotationRadians.Value.X,
×
182
                                          textureRotationRadians.Value.Y,
×
UNCOV
183
                                          textureRotationRadians.Value.Z);
×
184
    }
×
185

UNCOV
186
    return SystemMatrix4x4Util.FromCtrs(textureCenter, translation, rotation, textureScale);
×
UNCOV
187
  }
×
188

189
  public (bool is2d, Matrix3x2 twoDMatrix, Matrix4x4 threeDMatrix)? GetMatrix(
UNCOV
190
      IReadOnlyTexture texture) => this.texturesToMatrices_[texture];
×
191
}
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