Skip to content

Commit

Permalink
Rename RoomData to Mesh (LostArtefacts#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahm86 authored Apr 29, 2024
1 parent c5ac7bf commit 8e499e7
Show file tree
Hide file tree
Showing 46 changed files with 491 additions and 370 deletions.
12 changes: 6 additions & 6 deletions TREnvironmentEditor/Model/BaseEMFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,29 @@ public static List<TRVertex> GetTileVertices(short x, short y, short z, bool asC

public static int CreateRoomVertex(TR1Room room, TRVertex vert, short lighting = 6574)
{
room.RoomData.Vertices.Add(new()
room.Mesh.Vertices.Add(new()
{
Lighting = lighting,
Vertex = vert
});
return room.RoomData.Vertices.Count - 1;
return room.Mesh.Vertices.Count - 1;
}

public static int CreateRoomVertex(TR2Room room, TRVertex vert, short lighting = 6574, short lighting2 = 6574)
{
room.RoomData.Vertices.Add(new()
room.Mesh.Vertices.Add(new()
{
Attributes = 32784, // This stops it shimmering if viewed from underwater, should be configurable
Lighting = lighting,
Lighting2 = lighting2,
Vertex = vert
});
return room.RoomData.Vertices.Count - 1;
return room.Mesh.Vertices.Count - 1;
}

public static int CreateRoomVertex(TR3Room room, TRVertex vert, short lighting = 6574, ushort colour = 6574, bool useCaustics = false, bool useWaveMovement = false)
{
room.RoomData.Vertices.Add(new()
room.Mesh.Vertices.Add(new()
{
Attributes = 32784,
Lighting = lighting,
Expand All @@ -80,7 +80,7 @@ public static int CreateRoomVertex(TR3Room room, TRVertex vert, short lighting =
UseWaveMovement = useWaveMovement,
Vertex = vert
});
return room.RoomData.Vertices.Count - 1;
return room.Mesh.Vertices.Count - 1;
}

/// <summary>
Expand Down
30 changes: 15 additions & 15 deletions TREnvironmentEditor/Model/Types/Mirroring/EMMirrorFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ private void MirrorRooms(TR1Level level)
Debug.Assert(room.Info.X >= 0);
// Flip room sprites separately as they don't sit on tile edges
List<TR1RoomVertex> processedVerts = new();
foreach (TRRoomSprite sprite in room.RoomData.Sprites)
foreach (TRRoomSprite sprite in room.Mesh.Sprites)
{
TR1RoomVertex roomVertex = room.RoomData.Vertices[sprite.Vertex];
TR1RoomVertex roomVertex = room.Mesh.Vertices[sprite.Vertex];

// Flip the old world coordinate, then subtract the new room position
int x = oldRoomX + roomVertex.Vertex.X;
Expand All @@ -315,7 +315,7 @@ private void MirrorRooms(TR1Level level)
}

// Flip the face vertices
foreach (TR1RoomVertex vert in room.RoomData.Vertices)
foreach (TR1RoomVertex vert in room.Mesh.Vertices)
{
if (processedVerts.Contains(vert))
{
Expand Down Expand Up @@ -374,9 +374,9 @@ private void MirrorRooms(TR2Level level)
Debug.Assert(room.Info.X >= 0);
// Flip room sprites separately as they don't sit on tile edges
List<TR2RoomVertex> processedVerts = new();
foreach (TRRoomSprite sprite in room.RoomData.Sprites)
foreach (TRRoomSprite sprite in room.Mesh.Sprites)
{
TR2RoomVertex roomVertex = room.RoomData.Vertices[sprite.Vertex];
TR2RoomVertex roomVertex = room.Mesh.Vertices[sprite.Vertex];

// Flip the old world coordinate, then subtract the new room position
int x = oldRoomX + roomVertex.Vertex.X;
Expand All @@ -389,7 +389,7 @@ private void MirrorRooms(TR2Level level)
}

// Flip the face vertices
foreach (TR2RoomVertex vert in room.RoomData.Vertices)
foreach (TR2RoomVertex vert in room.Mesh.Vertices)
{
if (processedVerts.Contains(vert))
{
Expand Down Expand Up @@ -448,9 +448,9 @@ private void MirrorRooms(TR3Level level)
Debug.Assert(room.Info.X >= 0);
// Flip room sprites separately as they don't sit on tile edges
List<TR3RoomVertex> processedVerts = new();
foreach (TRRoomSprite sprite in room.RoomData.Sprites)
foreach (TRRoomSprite sprite in room.Mesh.Sprites)
{
TR3RoomVertex roomVertex = room.RoomData.Vertices[sprite.Vertex];
TR3RoomVertex roomVertex = room.Mesh.Vertices[sprite.Vertex];

// Flip the old world coordinate, then subtract the new room position
int x = oldRoomX + roomVertex.Vertex.X;
Expand All @@ -463,7 +463,7 @@ private void MirrorRooms(TR3Level level)
}

// Flip the face vertices
foreach (TR3RoomVertex vert in room.RoomData.Vertices)
foreach (TR3RoomVertex vert in room.Mesh.Vertices)
{
if (processedVerts.Contains(vert))
{
Expand Down Expand Up @@ -1009,14 +1009,14 @@ private static void MirrorTextures(TR1Level level)
foreach (TR1Room room in level.Rooms)
{
// Invert the faces, otherwise they are inside out
foreach (TRFace4 f in room.RoomData.Rectangles)
foreach (TRFace4 f in room.Mesh.Rectangles)
{
Swap(f.Vertices, 0, 3);
Swap(f.Vertices, 1, 2);
textureReferences.Add(f.Texture);
}

foreach (TRFace3 f in room.RoomData.Triangles)
foreach (TRFace3 f in room.Mesh.Triangles)
{
Swap(f.Vertices, 0, 2);
textureReferences.Add(f.Texture);
Expand Down Expand Up @@ -1087,14 +1087,14 @@ private static void MirrorTextures(TR2Level level)
foreach (TR2Room room in level.Rooms)
{
// Invert the faces, otherwise they are inside out
foreach (TRFace4 f in room.RoomData.Rectangles)
foreach (TRFace4 f in room.Mesh.Rectangles)
{
Swap(f.Vertices, 0, 3);
Swap(f.Vertices, 1, 2);
textureReferences.Add(f.Texture);
}

foreach (TRFace3 f in room.RoomData.Triangles)
foreach (TRFace3 f in room.Mesh.Triangles)
{
Swap(f.Vertices, 0, 2);
textureReferences.Add(f.Texture);
Expand Down Expand Up @@ -1157,14 +1157,14 @@ private static void MirrorTextures(TR3Level level)
foreach (TR3Room room in level.Rooms)
{
// Invert the faces, otherwise they are inside out
foreach (TRFace4 f in room.RoomData.Rectangles)
foreach (TRFace4 f in room.Mesh.Rectangles)
{
Swap(f.Vertices, 0, 3);
Swap(f.Vertices, 1, 2);
textureReferences.Add((ushort)(f.Texture & 0x0fff));
}

foreach (TRFace3 f in room.RoomData.Triangles)
foreach (TRFace3 f in room.Mesh.Triangles)
{
Swap(f.Vertices, 0, 2);
textureReferences.Add((ushort)(f.Texture & 0x0fff));
Expand Down
Loading

0 comments on commit 8e499e7

Please sign in to comment.