Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle XPMSE patch with engine #127

Merged
merged 3 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added PandoraPlus/FNIS.esp
Binary file not shown.
14 changes: 7 additions & 7 deletions PandoraPlus/MVVM/Model/Patch/Patchers/Skyrim/Hkx/PackFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ public bool Export()
IHavokObject rootObject;
ExportSuccess = true;
#if DEBUG
var debugOuputHandle = new FileInfo(OutputHandle.DirectoryName + "\\m_" + OutputHandle.Name + ".xml");

using (var writeStream = debugOuputHandle.Create())
{
Map.Save(writeStream);
}
using (var memoryStream = new MemoryStream())
{
Map.Save(memoryStream);
Expand All @@ -172,21 +178,15 @@ public bool Export()
serializer.Serialize(rootObject, binaryWriter, header);
}


var debugOuputHandle = new FileInfo(OutputHandle.FullName + ".xml");
debugOuputHandle = new FileInfo(OutputHandle.FullName + ".xml");

using (var writeStream = debugOuputHandle.Create())
{

var xmlSerializer = new HKX2.XmlSerializer();
xmlSerializer.Serialize(rootObject, header, writeStream);
}
debugOuputHandle = new FileInfo(debugOuputHandle.DirectoryName + "\\m_" + debugOuputHandle.Name);

using (var writeStream = debugOuputHandle.Create())
{
Map.Save(writeStream);
}

#else
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ public bool ValidateEventsAndVariables(PackFileGraph graph)
variableLowerBound -= 2;
for (int i = 0; i < eventNameElements.Count; i++)
{
eventIndices.Add(eventNameElements[i].Value, eventNameElements.Count - 1 - i);
if (!eventIndices.ContainsKey(eventNameElements[i].Value)) eventIndices.Add(eventNameElements[i].Value, eventNameElements.Count - 1 - i);
}
for (int i = 0; i < variableNameElements.Count; i++)
{
variableIndices.Add(variableNameElements[i].Value, variableNameElements.Count - 1 - i);
if (!variableIndices.ContainsKey(eventNameElements[i].Value)) variableIndices.Add(variableNameElements[i].Value, variableNameElements.Count - 1 - i);
}
return true;
}
Expand Down
41 changes: 32 additions & 9 deletions PandoraPlus/MVVM/Model/Patch/Patchers/Skyrim/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
Expand Down Expand Up @@ -34,17 +35,17 @@ public class Project
public PackFile SkeletonFile { get; private set; }
public PackFileGraph BehaviorFile { get; private set; }

public ProjectAnimData AnimData { get; set; }

public ProjectAnimData? AnimData { get; set; }

public Project()
{
Valid = false;
ProjectFile = new PackFile("");

#if DEBUG
throw new InvalidDataException("Could not initialize project because of invalid data");
#endif
}
public Project(PackFile projectFile)
{
Valid = false;
ProjectFile = projectFile;
Identifier = Path.GetFileNameWithoutExtension(ProjectFile.InputHandle.Name);
}
public Project(PackFile projectfile, PackFileCharacter characterfile, PackFile skeletonfile, PackFileGraph behaviorfile)
{
Expand Down Expand Up @@ -93,7 +94,7 @@ public List<string> MapFiles(PackFileCache cache)
return filesByName.Keys.ToList();
}
}
public static Project Load(PackFile projectFile, PackFileCache cache)
public static Project Create(PackFile projectFile, PackFileCache cache)
{
if (!projectFile.InputHandle.Exists) return new Project();

Expand All @@ -117,8 +118,30 @@ public static Project Load(PackFile projectFile, PackFileCache cache)

return project;
}
public bool Load(PackFileCache cache)
{
if (!ProjectFile.InputHandle.Exists) return false;

public static Project Load(FileInfo file, PackFileCache cache) => Load(cache.LoadPackFile(file), cache);
ProjectFile = ProjectFile;
CharacterFile = GetCharacterFile(ProjectFile, cache);
if (!CharacterFile.InputHandle.Exists) return false;

var (skeleton, behavior) = GetSkeletonAndBehaviorFile(ProjectFile, CharacterFile, cache);

SkeletonFile = skeleton;
if (!SkeletonFile.InputHandle.Exists) return false;

BehaviorFile = behavior;
if (!BehaviorFile.InputHandle.Exists) return false;

ProjectFile.ParentProject = this;
CharacterFile.ParentProject = this;
SkeletonFile.ParentProject = this;
BehaviorFile.ParentProject = this;

return true;
}
public static Project Load(FileInfo file, PackFileCache cache) => Create(cache.LoadPackFile(file), cache);

//public static Project Load(string projectFilePath) => Load(new PackFile(projectFilePath));

Expand Down
74 changes: 69 additions & 5 deletions PandoraPlus/MVVM/Model/Patch/Patchers/Skyrim/ProjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
using Pandora.Patch.Patchers.Skyrim.FNIS;
using Pandora.Patch.Patchers.Skyrim.Hkx;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Reflection.PortableExecutable;
using System.Runtime.CompilerServices;
using System.Text;
Expand All @@ -21,7 +23,6 @@ public class ProjectManager
{
private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
private Dictionary<string, Project> projectMap { get; set; } = new Dictionary<string, Project>();

private Dictionary<string, Project> fileProjectMap { get; set; } = new Dictionary<string, Project>();

private Dictionary<string, List<Project>> linkedProjectMap { get; set; } = new Dictionary<string, List<Project>>();
Expand Down Expand Up @@ -109,9 +110,59 @@ public void LoadTrackedProjects()
}
}
}
var stopwatch = Stopwatch.StartNew();
LoadProjects(projectPaths);
stopwatch.Stop();
Debug.WriteLine($"Projects loaded in {stopwatch.ElapsedMilliseconds}ms");
}
public void LoadProjects(List<string> projectPaths)
{
foreach (var projectPath in projectPaths)
{
LoadProject(projectPath);
var project = LoadProject(projectPath);
if (project == null) continue;
ExtractProject(project);
}
}
public void LoadProjectsParallel(List<string> projectPaths)
{
List<Project> projects = new List<Project>();
List<List<Project>> projectChunks = new List<List<Project>>();
foreach(var projectPath in projectPaths)
{
var project = LoadProjectHeader(projectPath);
if (project == null) continue;
projects.Add(project);
}
List<Project> buffer = new List<Project>();
for(int i = 0; i < projects.Count; i++)
{
buffer.Add(projects[i]);
if ((i % 10 == 0 && i > 0) || i == projects.Count-1)
{
var chunk = new List<Project>();
foreach(var project in buffer) { chunk.Add(project); }
projectChunks.Add(chunk);
buffer.Clear();
}
}
foreach(var chunk in projectChunks)
{
Parallel.ForEach(chunk, project =>
{
project.Load(packFileCache);
});
}
//Partitioner<Project> partitioner = Partitioner.Create(projects);

//Parallel.ForEach(partitioner, (project, loopstate) =>
//{
// project.Load(packFileCache);
//});

foreach (var project in projects)
{
ExtractProject(project);
}
}
public void ExtractProjects()
Expand All @@ -132,9 +183,9 @@ public async Task LoadProjectAsync(string projectFilePath)
//ExtractProject(project);

}
public void LoadProject(string projectFilePath)
public Project? LoadProject(string projectFilePath)
{
if (String.IsNullOrWhiteSpace(projectFilePath)) return;
if (String.IsNullOrWhiteSpace(projectFilePath)) return null;

lock (projectMap)
{
Expand All @@ -143,10 +194,23 @@ public void LoadProject(string projectFilePath)

projectMap.Add(project.Identifier, project);

lock (project) ExtractProject(project);
//lock (project) ExtractProject(project);
return project;
}

}
public Project? LoadProjectHeader(string projectFilePath)
{
if (String.IsNullOrEmpty(projectFilePath)) return null;
lock (projectMap)
{
var project = new Project(packFileCache.LoadPackFile(new FileInfo(Path.Join(templateFolder.FullName, projectFilePath))));

projectMap.Add(project.Identifier, project);

return project;
}
}

private void ExtractProject(Project project)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<hkobject name="#0028" class="hkbMirroredSkeletonInfo" signature="0xc6c2da4f">
<hkparam name="mirrorAxis">(1.000000 0.000000 0.000000 0.000000)</hkparam>
<!-- MOD_CODE ~xpmse~ OPEN -->
<hkparam name="bonePairMap" numelements="99">
0 1 2 3 4 5 9 10 11 6 7 8 15 16 17 12
13 14 18 19 20 21 22 23 24 25 26 30 31 32 27 28
29 33 34 35 36 37 39 38 41 40 42 43 45 44 46 48
47 49 51 50 56 57 58 59 52 53 54 55 60 61 62 63
64 65 66 82 83 84 85 86 87 88 89 90 91 92 93 94
95 96 67 68 69 70 71 72 73 74 75 76 77 78 79 80
81 97 98 99 100 101 102 103 104 105 106 107 108 109
110 111 112 113 114 115 116 117 118 119 120 121 122
123 124 125
</hkparam>
<!-- ORIGINAL -->
<hkparam name="bonePairMap" numelements="99">
0 1 2 3 4 5 9 10 11 6 7 8 15 16 17 12
13 14 18 19 20 21 22 23 24 25 26 30 31 32 27 28
29 33 34 35 36 37 39 38 41 40 42 43 45 44 46 48
47 49 51 50 56 57 58 59 52 53 54 55 60 61 62 63
64 65 66 82 83 84 85 86 87 88 89 90 91 92 93 94
95 96 67 68 69 70 71 72 73 74 75 76 77 78 79 80
81 97 98
</hkparam>
<!-- CLOSE -->
</hkobject>
108 changes: 108 additions & 0 deletions PandoraPlus/Nemesis_Engine/mod/xpmse/defaultfemale_character/#0031.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<hkobject name="#0031" class="hkbBoneWeightArray" signature="0xcd902b77">
<hkparam name="variableBindingSet">null</hkparam>
<hkparam name="boneWeights" numelements="99">
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
1.000000
0.000000
1.000000
0.000000
1.000000
0.000000
0.000000
0.000000
0.000000
1.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
1.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
0.000000
0.000000
<!-- MOD_CODE ~xpmse~ OPEN -->
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
<!-- CLOSE -->
</hkparam>
</hkobject>
Loading
Loading