Skip to content

Commit

Permalink
Cleanup duplicate function
Browse files Browse the repository at this point in the history
  • Loading branch information
PassiveModding committed Jul 27, 2024
1 parent 5df477b commit 29ce15c
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions Meddle/Meddle.Utils/Export/Material.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public Material(string path, MtrlFile file, Dictionary<string, TexFile> texFiles
{
HandlePath = path;
InitFromFile(file);
InitTextures(file, texFiles, shpkFile);
InitTextures(file, texFiles.ToDictionary(x => x.Key, x => Texture.GetResource(x.Value)), shpkFile);
}

private void InitTextures(MtrlFile file, Dictionary<string, TextureResource> texFiles, ShpkFile shpkFile)
Expand All @@ -127,28 +127,6 @@ private void InitTextures(MtrlFile file, Dictionary<string, TextureResource> tex

Textures = textures;
}

private void InitTextures(MtrlFile file, Dictionary<string, TexFile> texFiles, ShpkFile shpkFile)
{
var textures = new List<Texture>();
var texturePaths = file.GetTexturePaths();
for (var i = 0; i < file.Samplers.Length; i++)
{
var sampler = file.Samplers[i];
if (sampler.TextureIndex != byte.MaxValue)
{
var texture = file.TextureOffsets[sampler.TextureIndex];
var path = texturePaths[texture.Offset];
if (!texFiles.TryGetValue(path, out var texFile))
throw new ArgumentException($"Texture {path} not found");
var texObj = new Texture(Texture.GetResource(texFile), path, sampler.Flags, sampler.SamplerId, shpkFile);

textures.Add(texObj);
}
}

Textures = textures;
}

private void InitFromFile(MtrlFile file)
{
Expand Down

0 comments on commit 29ce15c

Please sign in to comment.