public static void MergeLogFiles() { List <WLentry> entriesList = new List <WLentry>(); string[] files = System.IO.Directory.GetFiles(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath)); foreach (string file in files) { if (IsNeededFile(file)) { using (System.IO.StreamReader input = new System.IO.StreamReader(System.IO.File.Open(file, System.IO.FileMode.Open))) { bool firstLine = true; while (input.Peek() >= 0) { string line = input.ReadLine(); if (firstLine) { firstLine = false; continue; } string[] collumns = line.Split(MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR); System.Diagnostics.Debug.Assert(collumns.Length == 6, "Wrong columns count: " + collumns.Length); bool founded = false; foreach (WLentry entry in entriesList) { if (entry.lod1Asset == collumns[0] && entry.lod0Asset == collumns[3]) { founded = true; break; } } if (!founded) { WLentry newEntry = new WLentry(); newEntry.lod1Asset = collumns[0]; newEntry.lod1Triangles = collumns[1]; newEntry.lod1Type = collumns[2]; newEntry.lod0Asset = collumns[3]; newEntry.lod0Triangles = collumns[4]; newEntry.lod0Type = collumns[5]; entriesList.Add(newEntry); } } input.Close(); } } } using (System.IO.StreamWriter output = new System.IO.StreamWriter(System.IO.File.Open("models-usage-statistics-WL_ALL-MISSIONS-MERGED.csv", System.IO.FileMode.Create))) { output.WriteLine("lodX AssetName" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "lodX Triangles" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "lodX Type" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "lodX-1 AssetName" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "lodX-1 Triangles" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "lodX-1 Type"); foreach (WLentry entry in entriesList) { output.WriteLine(entry.lod1Asset + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + entry.lod1Triangles + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + entry.lod1Type + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + entry.lod0Asset + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + entry.lod0Triangles + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + entry.lod0Type); } output.Flush(); output.Close(); } }
public static void LogUsageInformation() { if (MinerWars.AppCode.Game.Missions.MyMissions.ActiveMission == null) { return; } m_counts = new Dictionary <MyModelsEnum, int>(); m_wrong_models = new List <WLentry>(); foreach (MyEntity e in MyEntities.GetEntities()) { if (MyModelsStatisticsConstants.MODEL_STATISTICS_WRONG_LODS_ONLY) { if (e.ModelLod0 != null && e.ModelLod1 != null && e.ModelLod0.GetTrianglesCount() < e.ModelLod1.GetTrianglesCount() * 2) { bool founded = false; foreach (WLentry entry in m_wrong_models) { if (entry.lod1Asset == e.ModelLod1.AssetName && entry.lod0Asset == e.ModelLod0.AssetName) { founded = true; break; } } if (!founded) { WLentry entry = new WLentry(); entry.lod1Asset = e.ModelLod1.AssetName; entry.lod1Triangles = MyModels.m_modelsByAssertName[e.ModelLod1.AssetName].GetTrianglesCount().ToString(); entry.lod1Type = "LOD1"; entry.lod0Asset = e.ModelLod0.AssetName; entry.lod0Triangles = MyModels.m_modelsByAssertName[e.ModelLod0.AssetName].GetTrianglesCount().ToString(); entry.lod0Type = "LOD0"; m_wrong_models.Add(entry); } } if (e.ModelLod1 != null && e.ModelLod2 != null && e.ModelLod1.GetTrianglesCount() < e.ModelLod2.GetTrianglesCount() * 2) { bool founded = false; foreach (WLentry entry in m_wrong_models) { if (entry.lod1Asset == e.ModelLod2.AssetName && entry.lod0Asset == e.ModelLod1.AssetName) { founded = true; break; } } if (!founded) { WLentry entry = new WLentry(); entry.lod1Asset = e.ModelLod2.AssetName; entry.lod1Triangles = MyModels.m_modelsByAssertName[e.ModelLod2.AssetName].GetTrianglesCount().ToString(); entry.lod1Type = "LOD2"; entry.lod0Asset = e.ModelLod1.AssetName; entry.lod0Triangles = MyModels.m_modelsByAssertName[e.ModelLod1.AssetName].GetTrianglesCount().ToString(); entry.lod0Type = "LOD1"; m_wrong_models.Add(entry); } } if (e.ModelLod0 != null && e.ModelCollision != null && e.ModelLod0.GetTrianglesCount() < e.ModelCollision.GetTrianglesCount() * 2) { bool founded = false; foreach (WLentry entry in m_wrong_models) { if (entry.lod1Asset == e.ModelCollision.AssetName && entry.lod0Asset == e.ModelLod0.AssetName) { founded = true; break; } } if (!founded) { WLentry entry = new WLentry(); entry.lod1Asset = e.ModelCollision.AssetName; entry.lod1Triangles = MyModels.m_modelsByAssertName[e.ModelCollision.AssetName].GetTrianglesCount().ToString(); entry.lod1Type = "COL"; entry.lod0Asset = e.ModelLod0.AssetName; entry.lod0Triangles = MyModels.m_modelsByAssertName[e.ModelLod0.AssetName].GetTrianglesCount().ToString(); entry.lod0Type = "LOD0"; m_wrong_models.Add(entry); } } } if (e.ModelLod0 != null) { MyModelsEnum en = e.ModelLod0.ModelEnum; if (m_counts.ContainsKey(en)) { ++m_counts[en]; } else { m_counts[en] = 1; } } if (e.ModelLod1 != null) { MyModelsEnum en = e.ModelLod1.ModelEnum; if (m_counts.ContainsKey(en)) { ++m_counts[en]; } else { m_counts[en] = 1; } } if (e.ModelLod2 != null) { MyModelsEnum en = e.ModelLod2.ModelEnum; if (m_counts.ContainsKey(en)) { ++m_counts[en]; } else { m_counts[en] = 1; } } if (e.ModelCollision != null) { MyModelsEnum en = e.ModelCollision.ModelEnum; if (m_counts.ContainsKey(en)) { ++m_counts[en]; } else { m_counts[en] = 1; } } ParseEntityChildrensForLog(e.Children); } foreach (MyModel m in MyModels.m_models) { if (!m_counts.ContainsKey(m.ModelEnum)) { m_counts[m.ModelEnum] = 0; } } string activeMissionName = MinerWars.AppCode.Game.Missions.MyMissions.ActiveMission != null?MinerWars.AppCode.Game.Missions.MyMissions.ActiveMission.DebugName.ToString() : MyModelsStatisticsConstants.ACTUAL_MISSION_FOR_MODEL_STATISTICS.ToString(); activeMissionName = activeMissionName.Replace(' ', '-').ToString().ToLower(); if (MyModelsStatisticsConstants.MODEL_STATISTICS_WRONG_LODS_ONLY) { using (System.IO.StreamWriter output = new System.IO.StreamWriter(System.IO.File.Open("models-usage-statistics-WL_" + activeMissionName + ".csv", System.IO.FileMode.Create))) { output.WriteLine("lodX AssetName" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "lodX Triangles" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "lodX Type" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "lodX-1 AssetName" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "lodX-1 Triangles" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "lodX-1 Type"); foreach (WLentry entry in m_wrong_models) { output.WriteLine(entry.lod1Asset + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + entry.lod1Triangles + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + entry.lod1Type + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + entry.lod0Asset + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + entry.lod0Triangles + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + entry.lod0Type); } output.Flush(); output.Close(); } } using (System.IO.StreamWriter output = new System.IO.StreamWriter(System.IO.File.Open("models-usage-statistics-N_" + activeMissionName + ".csv", System.IO.FileMode.Create))) { output.WriteLine("Model name" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "Used X-times" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "VB size [MB]" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "IB size [MB]" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "LoadData/LoadContent"); foreach (KeyValuePair <MyModelsEnum, int> kvp in m_counts) { string assetName = MyModels.GetModelAssetName(kvp.Key); string LS; if (!MyModels.m_modelsByAssertName[assetName].LoadedData) { continue; LS = "X"; } else { if (!MyModels.m_modelsByAssertName[assetName].LoadedContent) { LS = "LD"; } else { LS = "LC"; } } output.WriteLine(assetName + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + kvp.Value.ToString() + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + Math.Round(MyModels.m_modelsByAssertName[assetName].GetVBSize / 1024.0 / 1024.0, 4).ToString() + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + Math.Round(MyModels.m_modelsByAssertName[assetName].GetIBSize / 1024.0 / 1024.0, 4).ToString() + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + LS); } output.Flush(); output.Close(); } m_counts = null; GC.Collect(); if (MyModelsStatisticsConstants.GET_MODEL_STATISTICS_AUTOMATICALLY && MyModelsStatisticsConstants.MISSIONS_TO_GET_MODEL_STATISTICS_FROM.Length > (++MyModelsStatisticsConstants.ACTUAL_MISSION_FOR_MODEL_STATISTICS + 1)) { GUI.MyGuiScreenMainMenu.StartMission(MyModelsStatisticsConstants.MISSIONS_TO_GET_MODEL_STATISTICS_FROM[MyModelsStatisticsConstants.ACTUAL_MISSION_FOR_MODEL_STATISTICS]); } else { MergeLogFiles(); } }
private static void ParseEntityChildrensForLog(KeenSoftwareHouse.Library.Collections.ObservableCollection <MyEntity> entityCollection) { if (entityCollection == null) { return; } foreach (MyEntity e in entityCollection) { if (MyModelsStatisticsConstants.MODEL_STATISTICS_WRONG_LODS_ONLY) { if (e.ModelLod0 != null && e.ModelLod1 != null && e.ModelLod0.GetTrianglesCount() < e.ModelLod1.GetTrianglesCount() * 2) { bool founded = false; foreach (WLentry entry in m_wrong_models) { if (entry.lod1Asset == e.ModelLod1.AssetName && entry.lod0Asset == e.ModelLod0.AssetName) { founded = true; break; } } if (!founded) { WLentry entry = new WLentry(); entry.lod1Asset = e.ModelLod1.AssetName; entry.lod1Triangles = MyModels.m_modelsByAssertName[e.ModelLod1.AssetName].GetTrianglesCount().ToString(); entry.lod1Type = "LOD1"; entry.lod0Asset = e.ModelLod0.AssetName; entry.lod0Triangles = MyModels.m_modelsByAssertName[e.ModelLod0.AssetName].GetTrianglesCount().ToString(); entry.lod0Type = "LOD0"; m_wrong_models.Add(entry); } } if (e.ModelLod1 != null && e.ModelLod2 != null && e.ModelLod1.GetTrianglesCount() < e.ModelLod2.GetTrianglesCount() * 2) { bool founded = false; foreach (WLentry entry in m_wrong_models) { if (entry.lod1Asset == e.ModelLod2.AssetName && entry.lod0Asset == e.ModelLod1.AssetName) { founded = true; break; } } if (!founded) { WLentry entry = new WLentry(); entry.lod1Asset = e.ModelLod2.AssetName; entry.lod1Triangles = MyModels.m_modelsByAssertName[e.ModelLod2.AssetName].GetTrianglesCount().ToString(); entry.lod1Type = "LOD2"; entry.lod0Asset = e.ModelLod1.AssetName; entry.lod0Triangles = MyModels.m_modelsByAssertName[e.ModelLod1.AssetName].GetTrianglesCount().ToString(); entry.lod0Type = "LOD1"; m_wrong_models.Add(entry); } } if (e.ModelLod0 != null && e.ModelCollision != null && e.ModelLod0.GetTrianglesCount() < e.ModelCollision.GetTrianglesCount() * 2) { bool founded = false; foreach (WLentry entry in m_wrong_models) { if (entry.lod1Asset == e.ModelCollision.AssetName && entry.lod0Asset == e.ModelLod0.AssetName) { founded = true; break; } } if (!founded) { WLentry entry = new WLentry(); entry.lod1Asset = e.ModelCollision.AssetName; entry.lod1Triangles = MyModels.m_modelsByAssertName[e.ModelCollision.AssetName].GetTrianglesCount().ToString(); entry.lod1Type = "COL"; entry.lod0Asset = e.ModelLod0.AssetName; entry.lod0Triangles = MyModels.m_modelsByAssertName[e.ModelLod0.AssetName].GetTrianglesCount().ToString(); entry.lod0Type = "LOD0"; m_wrong_models.Add(entry); } } } if (e.ModelLod0 != null) { MyModelsEnum en = e.ModelLod0.ModelEnum; if (m_counts.ContainsKey(en)) { ++m_counts[en]; } else { m_counts[en] = 1; } } if (e.ModelLod1 != null) { MyModelsEnum en = e.ModelLod1.ModelEnum; if (m_counts.ContainsKey(en)) { ++m_counts[en]; } else { m_counts[en] = 1; } } if (e.ModelLod2 != null) { MyModelsEnum en = e.ModelLod2.ModelEnum; if (m_counts.ContainsKey(en)) { ++m_counts[en]; } else { m_counts[en] = 1; } } if (e.ModelCollision != null) { MyModelsEnum en = e.ModelCollision.ModelEnum; if (m_counts.ContainsKey(en)) { ++m_counts[en]; } else { m_counts[en] = 1; } } ParseEntityChildrensForLog(e.Children); } }
public static void MergeLogFiles() { List<WLentry> entriesList = new List<WLentry>(); string[] files = System.IO.Directory.GetFiles(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath)); foreach (string file in files) { if (IsNeededFile(file)) { using (System.IO.StreamReader input = new System.IO.StreamReader(System.IO.File.Open(file, System.IO.FileMode.Open))) { bool firstLine = true; while (input.Peek() >= 0) { string line = input.ReadLine(); if (firstLine) { firstLine = false; continue; } string[] collumns = line.Split(MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR); System.Diagnostics.Debug.Assert(collumns.Length == 6, "Wrong columns count: " + collumns.Length); bool founded = false; foreach (WLentry entry in entriesList) { if (entry.lod1Asset == collumns[0] && entry.lod0Asset == collumns[3]) { founded = true; break; } } if (!founded) { WLentry newEntry = new WLentry(); newEntry.lod1Asset = collumns[0]; newEntry.lod1Triangles = collumns[1]; newEntry.lod1Type = collumns[2]; newEntry.lod0Asset = collumns[3]; newEntry.lod0Triangles = collumns[4]; newEntry.lod0Type = collumns[5]; entriesList.Add(newEntry); } } input.Close(); } } } using (System.IO.StreamWriter output = new System.IO.StreamWriter(System.IO.File.Open("models-usage-statistics-WL_ALL-MISSIONS-MERGED.csv", System.IO.FileMode.Create))) { output.WriteLine("lodX AssetName" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "lodX Triangles" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "lodX Type" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "lodX-1 AssetName" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "lodX-1 Triangles" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "lodX-1 Type"); foreach (WLentry entry in entriesList) { output.WriteLine(entry.lod1Asset + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + entry.lod1Triangles + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + entry.lod1Type + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + entry.lod0Asset + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + entry.lod0Triangles + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + entry.lod0Type); } output.Flush(); output.Close(); } }
public static void LogUsageInformation() { if (MinerWars.AppCode.Game.Missions.MyMissions.ActiveMission == null) return; m_counts = new Dictionary<MyModelsEnum, int>(); m_wrong_models = new List<WLentry>(); foreach (MyEntity e in MyEntities.GetEntities()) { if (MyModelsStatisticsConstants.MODEL_STATISTICS_WRONG_LODS_ONLY) { if (e.ModelLod0 != null && e.ModelLod1 != null && e.ModelLod0.GetTrianglesCount() < e.ModelLod1.GetTrianglesCount() * 2) { bool founded = false; foreach (WLentry entry in m_wrong_models) { if (entry.lod1Asset == e.ModelLod1.AssetName && entry.lod0Asset == e.ModelLod0.AssetName) { founded = true; break; } } if (!founded) { WLentry entry = new WLentry(); entry.lod1Asset = e.ModelLod1.AssetName; entry.lod1Triangles = MyModels.m_modelsByAssertName[e.ModelLod1.AssetName].GetTrianglesCount().ToString(); entry.lod1Type = "LOD1"; entry.lod0Asset = e.ModelLod0.AssetName; entry.lod0Triangles = MyModels.m_modelsByAssertName[e.ModelLod0.AssetName].GetTrianglesCount().ToString(); entry.lod0Type = "LOD0"; m_wrong_models.Add(entry); } } if (e.ModelLod1 != null && e.ModelLod2 != null && e.ModelLod1.GetTrianglesCount() < e.ModelLod2.GetTrianglesCount() * 2) { bool founded = false; foreach (WLentry entry in m_wrong_models) { if (entry.lod1Asset == e.ModelLod2.AssetName && entry.lod0Asset == e.ModelLod1.AssetName) { founded = true; break; } } if (!founded) { WLentry entry = new WLentry(); entry.lod1Asset = e.ModelLod2.AssetName; entry.lod1Triangles = MyModels.m_modelsByAssertName[e.ModelLod2.AssetName].GetTrianglesCount().ToString(); entry.lod1Type = "LOD2"; entry.lod0Asset = e.ModelLod1.AssetName; entry.lod0Triangles = MyModels.m_modelsByAssertName[e.ModelLod1.AssetName].GetTrianglesCount().ToString(); entry.lod0Type = "LOD1"; m_wrong_models.Add(entry); } } if (e.ModelLod0 != null && e.ModelCollision != null && e.ModelLod0.GetTrianglesCount() < e.ModelCollision.GetTrianglesCount() * 2) { bool founded = false; foreach (WLentry entry in m_wrong_models) { if (entry.lod1Asset == e.ModelCollision.AssetName && entry.lod0Asset == e.ModelLod0.AssetName) { founded = true; break; } } if (!founded) { WLentry entry = new WLentry(); entry.lod1Asset = e.ModelCollision.AssetName; entry.lod1Triangles = MyModels.m_modelsByAssertName[e.ModelCollision.AssetName].GetTrianglesCount().ToString(); entry.lod1Type = "COL"; entry.lod0Asset = e.ModelLod0.AssetName; entry.lod0Triangles = MyModels.m_modelsByAssertName[e.ModelLod0.AssetName].GetTrianglesCount().ToString(); entry.lod0Type = "LOD0"; m_wrong_models.Add(entry); } } } if (e.ModelLod0 != null) { MyModelsEnum en = e.ModelLod0.ModelEnum; if (m_counts.ContainsKey(en)) ++m_counts[en]; else m_counts[en] = 1; } if (e.ModelLod1 != null) { MyModelsEnum en = e.ModelLod1.ModelEnum; if (m_counts.ContainsKey(en)) ++m_counts[en]; else m_counts[en] = 1; } if (e.ModelLod2 != null) { MyModelsEnum en = e.ModelLod2.ModelEnum; if (m_counts.ContainsKey(en)) ++m_counts[en]; else m_counts[en] = 1; } if (e.ModelCollision != null) { MyModelsEnum en = e.ModelCollision.ModelEnum; if (m_counts.ContainsKey(en)) ++m_counts[en]; else m_counts[en] = 1; } ParseEntityChildrensForLog(e.Children); } foreach (MyModel m in MyModels.m_models) { if (!m_counts.ContainsKey(m.ModelEnum)) m_counts[m.ModelEnum] = 0; } string activeMissionName = MinerWars.AppCode.Game.Missions.MyMissions.ActiveMission != null ? MinerWars.AppCode.Game.Missions.MyMissions.ActiveMission.DebugName.ToString() : MyModelsStatisticsConstants.ACTUAL_MISSION_FOR_MODEL_STATISTICS.ToString(); activeMissionName = activeMissionName.Replace(' ', '-').ToString().ToLower(); if (MyModelsStatisticsConstants.MODEL_STATISTICS_WRONG_LODS_ONLY) { using (System.IO.StreamWriter output = new System.IO.StreamWriter(System.IO.File.Open("models-usage-statistics-WL_" + activeMissionName + ".csv", System.IO.FileMode.Create))) { output.WriteLine("lodX AssetName" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "lodX Triangles" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "lodX Type" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "lodX-1 AssetName" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "lodX-1 Triangles" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "lodX-1 Type"); foreach (WLentry entry in m_wrong_models) { output.WriteLine(entry.lod1Asset + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + entry.lod1Triangles + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + entry.lod1Type + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + entry.lod0Asset + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + entry.lod0Triangles + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + entry.lod0Type); } output.Flush(); output.Close(); } } using (System.IO.StreamWriter output = new System.IO.StreamWriter(System.IO.File.Open("models-usage-statistics-N_" + activeMissionName + ".csv", System.IO.FileMode.Create))) { output.WriteLine("Model name" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "Used X-times" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "VB size [MB]" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "IB size [MB]" + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + "LoadData/LoadContent"); foreach (KeyValuePair<MyModelsEnum, int> kvp in m_counts) { string assetName = MyModels.GetModelAssetName(kvp.Key); string LS; if (!MyModels.m_modelsByAssertName[assetName].LoadedData) { continue; LS = "X"; } else { if (!MyModels.m_modelsByAssertName[assetName].LoadedContent) { LS = "LD"; } else { LS = "LC"; } } output.WriteLine(assetName + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + kvp.Value.ToString() + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + Math.Round(MyModels.m_modelsByAssertName[assetName].GetVBSize / 1024.0 / 1024.0, 4).ToString() + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + Math.Round(MyModels.m_modelsByAssertName[assetName].GetIBSize / 1024.0 / 1024.0, 4).ToString() + MyModelsStatisticsConstants.MODEL_STATISTICS_CSV_SEPARATOR + LS); } output.Flush(); output.Close(); } m_counts = null; GC.Collect(); if (MyModelsStatisticsConstants.GET_MODEL_STATISTICS_AUTOMATICALLY && MyModelsStatisticsConstants.MISSIONS_TO_GET_MODEL_STATISTICS_FROM.Length > (++MyModelsStatisticsConstants.ACTUAL_MISSION_FOR_MODEL_STATISTICS + 1)) { GUI.MyGuiScreenMainMenu.StartMission(MyModelsStatisticsConstants.MISSIONS_TO_GET_MODEL_STATISTICS_FROM[MyModelsStatisticsConstants.ACTUAL_MISSION_FOR_MODEL_STATISTICS]); } else { MergeLogFiles(); } }
private static void ParseEntityChildrensForLog(KeenSoftwareHouse.Library.Collections.ObservableCollection<MyEntity> entityCollection) { if (entityCollection == null) return; foreach (MyEntity e in entityCollection) { if (MyModelsStatisticsConstants.MODEL_STATISTICS_WRONG_LODS_ONLY) { if (e.ModelLod0 != null && e.ModelLod1 != null && e.ModelLod0.GetTrianglesCount() < e.ModelLod1.GetTrianglesCount() * 2) { bool founded = false; foreach (WLentry entry in m_wrong_models) { if (entry.lod1Asset == e.ModelLod1.AssetName && entry.lod0Asset == e.ModelLod0.AssetName) { founded = true; break; } } if (!founded) { WLentry entry = new WLentry(); entry.lod1Asset = e.ModelLod1.AssetName; entry.lod1Triangles = MyModels.m_modelsByAssertName[e.ModelLod1.AssetName].GetTrianglesCount().ToString(); entry.lod1Type = "LOD1"; entry.lod0Asset = e.ModelLod0.AssetName; entry.lod0Triangles = MyModels.m_modelsByAssertName[e.ModelLod0.AssetName].GetTrianglesCount().ToString(); entry.lod0Type = "LOD0"; m_wrong_models.Add(entry); } } if (e.ModelLod1 != null && e.ModelLod2 != null && e.ModelLod1.GetTrianglesCount() < e.ModelLod2.GetTrianglesCount() * 2) { bool founded = false; foreach (WLentry entry in m_wrong_models) { if (entry.lod1Asset == e.ModelLod2.AssetName && entry.lod0Asset == e.ModelLod1.AssetName) { founded = true; break; } } if (!founded) { WLentry entry = new WLentry(); entry.lod1Asset = e.ModelLod2.AssetName; entry.lod1Triangles = MyModels.m_modelsByAssertName[e.ModelLod2.AssetName].GetTrianglesCount().ToString(); entry.lod1Type = "LOD2"; entry.lod0Asset = e.ModelLod1.AssetName; entry.lod0Triangles = MyModels.m_modelsByAssertName[e.ModelLod1.AssetName].GetTrianglesCount().ToString(); entry.lod0Type = "LOD1"; m_wrong_models.Add(entry); } } if (e.ModelLod0 != null && e.ModelCollision != null && e.ModelLod0.GetTrianglesCount() < e.ModelCollision.GetTrianglesCount() * 2) { bool founded = false; foreach (WLentry entry in m_wrong_models) { if (entry.lod1Asset == e.ModelCollision.AssetName && entry.lod0Asset == e.ModelLod0.AssetName) { founded = true; break; } } if (!founded) { WLentry entry = new WLentry(); entry.lod1Asset = e.ModelCollision.AssetName; entry.lod1Triangles = MyModels.m_modelsByAssertName[e.ModelCollision.AssetName].GetTrianglesCount().ToString(); entry.lod1Type = "COL"; entry.lod0Asset = e.ModelLod0.AssetName; entry.lod0Triangles = MyModels.m_modelsByAssertName[e.ModelLod0.AssetName].GetTrianglesCount().ToString(); entry.lod0Type = "LOD0"; m_wrong_models.Add(entry); } } } if (e.ModelLod0 != null) { MyModelsEnum en = e.ModelLod0.ModelEnum; if (m_counts.ContainsKey(en)) ++m_counts[en]; else m_counts[en] = 1; } if (e.ModelLod1 != null) { MyModelsEnum en = e.ModelLod1.ModelEnum; if (m_counts.ContainsKey(en)) ++m_counts[en]; else m_counts[en] = 1; } if (e.ModelLod2 != null) { MyModelsEnum en = e.ModelLod2.ModelEnum; if (m_counts.ContainsKey(en)) ++m_counts[en]; else m_counts[en] = 1; } if (e.ModelCollision != null) { MyModelsEnum en = e.ModelCollision.ModelEnum; if (m_counts.ContainsKey(en)) ++m_counts[en]; else m_counts[en] = 1; } ParseEntityChildrensForLog(e.Children); } }