Skip to content

Commit

Permalink
Fix mirrored textures (LostArtefacts#649)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahm86 authored May 4, 2024
1 parent d14cf45 commit 0ec7c0a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ private static void MirrorObjectTextures(ISet<ushort> textureReferences, List<TR
{
foreach (ushort textureRef in textureReferences)
{
objectTextures[textureRef].FlipHorizontal();
objectTextures[textureRef].FlipVertical();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private static void MirrorObjectTextures(ISet<ushort> textureReferences, List<TR
{
foreach (ushort textureRef in textureReferences)
{
objectTextures[textureRef].FlipHorizontal();
objectTextures[textureRef].FlipVertical();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private void MirrorObjectTextures(List<TRObjectTexture> levelTextures)
{
foreach (ushort textureRef in Textures)
{
levelTextures[textureRef].FlipHorizontal();
levelTextures[textureRef].FlipVertical();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,26 @@ public class EMMirrorStaticMeshFunction : BaseEMFunction

public override void ApplyToLevel(TR1Level level)
{
IEnumerable<TRMesh> meshes = level.StaticMeshes
.Where(kvp => MeshIDs.Contains(kvp.Key - TR1Type.SceneryBase))
.Select(kvp => kvp.Value.Mesh);

MirrorMeshes(meshes);
MirrorMeshes(level.StaticMeshes);
}

public override void ApplyToLevel(TR2Level level)
{
IEnumerable<TRMesh> meshes = level.StaticMeshes
.Where(kvp => MeshIDs.Contains(kvp.Key - TR2Type.SceneryBase))
.Select(kvp => kvp.Value.Mesh);

MirrorMeshes(meshes);
MirrorMeshes(level.StaticMeshes);
}

public override void ApplyToLevel(TR3Level level)
{
IEnumerable<TRMesh> meshes = level.StaticMeshes
.Where(kvp => MeshIDs.Contains(kvp.Key - TR3Type.SceneryBase))
.Select(kvp => kvp.Value.Mesh);

MirrorMeshes(meshes);
MirrorMeshes(level.StaticMeshes);
}

private static void MirrorMeshes(IEnumerable<TRMesh> meshes)
private void MirrorMeshes<T>(TRDictionary<T, TRStaticMesh> staticMeshes)
where T : Enum
{
IEnumerable<TRMesh> meshes = staticMeshes
.Where(kvp => MeshIDs.Contains((uint)(object)kvp.Key))
.Select(kvp => kvp.Value.Mesh);

foreach (TRMesh mesh in meshes)
{
foreach (TRVertex vert in mesh.Vertices)
Expand Down

0 comments on commit 0ec7c0a

Please sign in to comment.