• 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

0.0
/FinModelUtility/Fin/Fin/src/model/processing/TextureTransformBaking.cs
1
using System.Collections.Generic;
2
using System.Linq;
3
using System.Numerics;
4

5
using fin.data.indexable;
6

7
namespace fin.model.processing;
8

9
public static class TextureTransformBaking {
10
  public static bool TryToBakeTextureTransforms(IModel model) {
×
11
    var skin = model.Skin;
×
12
    var vertices = skin.Vertices;
×
13

14
    var textureTransformByVertex
×
15
        = new IndexableDictionary<IReadOnlyVertex, IReadOnlyTextureTransform
×
16
            ?>(vertices.Count);
×
17

18
    var transforms = new HashSet<ITextureTransform>();
×
19

20
    // Gathers all transforms, makes sure each vertex only ever needs one.
21
    // Otherwise, fail early.
22
    foreach (var mesh in skin.Meshes) {
×
23
      foreach (var primitive in mesh.Primitives) {
×
24
        var material = primitive.Material;
×
25

26
        if (!TryToGetTextureTransform_(material, out var newTransform)) {
×
27
          return false;
×
28
        }
29

30
        if (newTransform != null) {
×
31
          transforms.Add(newTransform);
×
32
        }
×
33

34
        foreach (var vertex in primitive.Vertices.Distinct()) {
×
35
          if (!textureTransformByVertex.TryGetValue(
×
36
                  vertex,
×
37
                  out IReadOnlyTextureTransform oldTransform)) {
×
38
            textureTransformByVertex[vertex] = newTransform;
×
39
          } else if (!Equals(oldTransform, newTransform)) {
×
40
            return false;
×
41
          }
42
        }
×
43
      }
×
44
    }
×
45

46
    // Applies transforms to all UVs.
47
    foreach (var vertex in vertices) {
×
48
      if (!textureTransformByVertex.TryGetValue(vertex, out var transform)) {
×
49
        continue;
×
50
      }
51

52
      if (Equals(transform, null)) {
×
53
        continue;
×
54
      }
55

56
      var matrix = transform.AsMatrix();
×
57

58
      switch (vertex) {
×
59
        case IMultiUvVertex multiUvVertex: {
×
60
          for (var i = 0; i < multiUvVertex.UvCount; ++i) {
×
61
            var uv = multiUvVertex.GetUv(i);
×
62
            if (uv == null) {
×
63
              continue;
×
64
            }
65
            
66
            multiUvVertex.SetUv(i, Vector2.Transform(uv.Value, matrix));
×
67
          }
×
68

69
          break;
×
70
        }
71
        case ISingleUvVertex singleUvVertex: {
×
72
          var uv = singleUvVertex.GetUv();
×
73
          if (uv == null) {
×
74
            continue;
×
75
          }
76

77
          singleUvVertex.SetUv(Vector2.Transform(uv.Value, matrix));
×
78
          break;
×
79
        }
80
      }
81
    }
×
82

83
    // Clears all transforms.
84
    foreach (var transform in transforms) {
×
85
      transform.SetCenter2d(0, 0);
×
86
      transform.SetTranslation2d(0, 0);
×
87
      transform.SetRotationRadians2d(0);
×
88
      transform.SetScale2d(1, 1);
×
89
    }
×
90

91
    return true;
×
92
  }
×
93

94
  private static bool TryToGetTextureTransform_(
95
      IReadOnlyMaterial? material,
96
      out ITextureTransform? textureTransform) {
×
97
    if (material == null) {
×
98
      textureTransform = null;
×
99
      return true;
×
100
    }
101

102
    var distinctTextures = material.Textures.Distinct();
×
103
    var distinctTextureCount = distinctTextures.Count();
×
104
    if (distinctTextureCount == 0) {
×
105
      textureTransform = null;
×
106
      return true;
×
107
    }
108

109
    var singleTextureTransform
×
110
        = distinctTextures.Select(t => t.TextureTransform)
×
111
                          .Distinct()
×
112
                          .SingleOrDefault();
×
113
    if (singleTextureTransform == null) {
×
NEW
114
      textureTransform = null;
×
115
      return false;
×
116
    }
117

118
    textureTransform = singleTextureTransform as ITextureTransform;
×
119
    return true;
×
120
  }
×
121
}
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