Skip to content

Commit

Permalink
Reuse tex infos in wireframe mode
Browse files Browse the repository at this point in the history
Resolves #722.
  • Loading branch information
lahm86 committed Jul 15, 2024
1 parent 2523def commit 08720d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## [Unreleased](https://github.com/LostArtefacts/TR-Rando/compare/V1.9.1...master) - xxxx-xx-xx
- fixed wireframe mode potentially exceeding texture limits and preventing levels from loading (#722)
- fixed docile bird monsters causing multiple Laras to spawn in remastered levels (#723)
- fixed the incomplete skidoo model in TR2R when it appears anywhere other than Tibetan Foothills (#721)
- fixed secrets on triangle portals not triggering in TR3 (#727)
Expand Down
16 changes: 13 additions & 3 deletions TRRandomizerCore/Textures/Wireframing/AbstractTRWireframer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void Apply(L level, WireframeData<E> data)

TRTexturePacker packer = CreatePacker(level);
DeleteTextures(packer);
level.ResetUnusedTextures();
Queue<int> textureSlots = new(level.GetFreeTextureSlots());

TRSize roomSize = GetLargestSize(roomSizes);
roomSize.RoundDown();
Expand All @@ -107,8 +107,17 @@ public void Apply(L level, WireframeData<E> data)

ushort StoreTexture(TRTextileSegment segment)
{
level.ObjectTextures.Add(segment.Texture as TRObjectTexture);
return (ushort)(level.ObjectTextures.Count - 1);
if (textureSlots.TryDequeue(out int slot))
{
level.ObjectTextures[slot] = segment.Texture as TRObjectTexture;
}
else
{
slot = level.ObjectTextures.Count;
level.ObjectTextures.Add(segment.Texture as TRObjectTexture);
}

return (ushort)slot;
}

ushort roomTextureIndex = StoreTexture(roomTexture);
Expand All @@ -134,6 +143,7 @@ ushort StoreTexture(TRTextileSegment segment)
ResetMeshTextures(modelRemap, specialTextureRemap);
TidyModels(level);
SetSkyboxVisible(level);
level.ResetUnusedTextures();
}

private void RetainCustomTextures(L level)
Expand Down

0 comments on commit 08720d6

Please sign in to comment.