-
Notifications
You must be signed in to change notification settings - Fork 2
/
AtlasDesc.cs
102 lines (89 loc) · 2.89 KB
/
AtlasDesc.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System;
using System.Collections.Generic;
using LODGenerator.Common;
namespace LODGenerator
{
public struct AtlasDesc
{
public string SourceTexture;
public string AtlasTexture;
public string AtlasTextureN;
public string AtlasTextureS;
public float posU;
public float posV;
public float scaleU;
public float scaleV;
public float minU;
public float maxU;
public float minV;
public float maxV;
public UInt64 before;
public UInt64 after;
public float averageU;
public float averageV;
public bool miniatlas;
}
static class AtlasList
{
static Dictionary<string, AtlasDesc> _list;
static AtlasList()
{
_list = new Dictionary<string, AtlasDesc>();
}
public static void Set(string key, AtlasDesc value)
{
_list.Add(key, value);
}
public static AtlasDesc Get(string key)
{
return _list[key];
}
public static bool Contains(string key)
{
return _list.ContainsKey(key);
}
public static void BeforeAdd(string key, int value)
{
AtlasDesc at = _list[key];
at.before += (uint)value;
_list[key] = at;
}
public static void AfterAdd(string key, int value)
{
AtlasDesc at = _list[key];
at.after += (uint)value;
_list[key] = at;
}
public static float GetAverageU(string key)
{
return _list[key].averageU;
}
public static void SetAverageU(string key, float value)
{
AtlasDesc at = _list[key];
at.averageU = value;
_list[key] = at;
}
public static float GetAverageV(string key)
{
return _list[key].averageV;
}
public static void SetAverageV(string key, float value)
{
AtlasDesc at = _list[key];
at.averageV = value;
_list[key] = at;
}
public static void WriteStats(LogFile logFile)
{
foreach (KeyValuePair<string, AtlasDesc> keyValuePair in _list)
{
if (keyValuePair.Value.before != 0 && keyValuePair.Value.before * 1.25 < keyValuePair.Value.after || keyValuePair.Value.averageU > 100 || keyValuePair.Value.averageV > 100)
{
string texture = keyValuePair.Key.Replace("textures\\", "").Replace("lowres\\", "");
logFile.WriteLog(texture + ": " + keyValuePair.Value.before + " -> " + keyValuePair.Value.after + " | " + keyValuePair.Value.averageU + ", " +keyValuePair.Value.averageV);
}
}
}
}
}