Skip to content

Commit

Permalink
texture caching
Browse files Browse the repository at this point in the history
  • Loading branch information
NefariousTechSupport committed Jul 31, 2022
1 parent 023416d commit e11f2df
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions LibLunacy/AssetLoader.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
namespace LibLunacy
{
//Assets are managed here and whenever an asset needs to reference another, that is done here
public class AssetLoader
{
public FileManager fm;

public Dictionary<ulong, CMoby> mobys = new Dictionary<ulong, CMoby>();
public Dictionary<ulong, CTie> ties = new Dictionary<ulong, CTie>();
public Dictionary<ulong, CShader> shaders = new Dictionary<ulong, CShader>();
Expand Down Expand Up @@ -115,7 +116,6 @@ private void LoadShadersNew()
MemoryStream shaderms = new MemoryStream(shaderdat);
IGFile igshader = new IGFile(shaderms);
CShader shader = new CShader(igshader, this);
//Console.WriteLine($"shader {i.ToString("X04")} albedo offset is {shader.name}");
shaders.Add(shaderPtrs[i].tuid, shader);
}
}
Expand Down
9 changes: 5 additions & 4 deletions LibLunacy/FileManager.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
namespace LibLunacy
{
//Files are loaded here
public class FileManager
{
public string folderPath = string.Empty;

public Dictionary<string, IGFile> igfiles = new Dictionary<string, IGFile>();
public Dictionary<string, Stream> rawfiles = new Dictionary<string, Stream>();
public Dictionary<string, IGFile> igfiles = new Dictionary<string, IGFile>(); //Actual IGFiles
public Dictionary<string, Stream> rawfiles = new Dictionary<string, Stream>(); //Raw data, includes files containing nothing but IGFiles

public bool isOld { get; private set; }
public bool isOld { get; private set; } //if true, old filesystem, else new filesystem

public void LoadFolder(string folderPath)
{
Expand All @@ -31,7 +32,7 @@ public void LoadFolder(string folderPath)
LoadFile("gameplay.dat", false);
LoadFile("assetlookup.dat", false);

//Load raw files, a lot of these are actually a bunch of IGFiles, however the files themselves are not IGFiles
//Load raw files, a lot of these files contain a bunch of IGFiles, however the files themselves are not IGFiles
LoadFile("mobys.dat", true);
LoadFile("ties.dat", true);
LoadFile("textures.dat", true);
Expand Down
10 changes: 5 additions & 5 deletions Lunacy/AssetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ public class AssetManager

public void Initialize(AssetLoader al)
{
//TODO: cache textures and materials
//foreach(KeyValuePair<uint, CTexture> ctex in al.textures)
//{
// textures.Add(ctex.Key, new Texture(ctex.Value));
//}
//TODO: cache materials
foreach(KeyValuePair<uint, CTexture> ctex in al.textures)
{
textures.Add(ctex.Key, new Texture(ctex.Value));
}
foreach(KeyValuePair<ulong, CMoby> moby in al.mobys)
{
mobys.Add(moby.Key, new DrawableListList(moby.Value));
Expand Down
4 changes: 2 additions & 2 deletions Lunacy/Drawable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public Drawable(CMoby moby, CMoby.MobyMesh mesh)
SetVertexPositions(vPositions);
SetVertexTexCoords(vTexCoords);
SetIndices(indices);
Texture? tex = (mesh.shader.albedo == null ? null : new Texture(mesh.shader.albedo));
Texture? tex = (mesh.shader.albedo == null ? null : AssetManager.Singleton.textures[mesh.shader.albedo.id]);
SetMaterial(new Material(MaterialManager.materials["stdv;ulitf"], tex));
}
public Drawable(CTie tie, CTie.TieMesh mesh)
Expand All @@ -34,7 +34,7 @@ public Drawable(CTie tie, CTie.TieMesh mesh)
SetVertexPositions(vPositions);
SetVertexTexCoords(vTexCoords);
SetIndices(indices);
Texture? tex = (mesh.shader.albedo == null ? null : new Texture(mesh.shader.albedo));
Texture? tex = (mesh.shader.albedo == null ? null : AssetManager.Singleton.textures[mesh.shader.albedo.id]);
SetMaterial(new Material(MaterialManager.materials["stdv;ulitf"], tex));
}
public Drawable(ref Zone.NewTFrag mesh)
Expand Down

0 comments on commit e11f2df

Please sign in to comment.