Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions TombLib/TombLib/LevelData/Compilers/Rooms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,8 @@ private tr_room BuildRoom(Room room)
},
Lighting1 = 0,
Lighting2 = 0,
Attributes = 0
Attributes = 0,
Normal = normal
};

// Pack the light according to chosen lighting model
Expand Down Expand Up @@ -709,7 +710,12 @@ private tr_room BuildRoom(Room room)
}
else
{
existingIndex = roomVertices.IndexOf(v => v.Position == trVertex.Position && v.Color == trVertex.Color);
existingIndex = roomVertices.IndexOf(v =>
v.Position == trVertex.Position &&
v.Lighting1 == trVertex.Lighting1 &&
v.Attributes == trVertex.Attributes &&
v.Lighting2 == trVertex.Lighting2 &&
v.Normal == trVertex.Normal);
if (existingIndex == -1)
{
existingIndex = roomVertices.Count;
Expand Down
1 change: 1 addition & 0 deletions TombLib/TombLib/LevelData/Compilers/TombEngine/Rooms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ private TombEngineRoom BuildRoom(Room room)
var span = CollectionsMarshal.AsSpan(roomVertices);
for (int i = 0; (uint)i < (uint)span.Length; i++)
if (span[i].Position == trVertex.Position &&
span[i].Normal == trVertex.Normal &&
span[i].Color == trVertex.Color &&
span[i].DoubleSided == trVertex.DoubleSided)
{
Expand Down
12 changes: 10 additions & 2 deletions TombLib/TombLib/LevelData/Room.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1870,6 +1870,8 @@ public void GetGeometryStatistics(out int vertices, out int faces)

// Apply the transform to the vertex
var position = MathC.HomogenousTransform(vertex.Position, worldTransform);
var normal = MathC.HomogenousTransform(vertex.Normal, normalTransform);
normal = Vector3.Normalize(normal);
var trVertex = new tr_room_vertex
{
Position = new tr_vertex
Expand All @@ -1880,7 +1882,8 @@ public void GetGeometryStatistics(out int vertices, out int faces)
},
Lighting1 = 0,
Lighting2 = 0,
Attributes = 0
Attributes = 0,
Normal = normal
};

// HACK: Find a vertex with same coordinates and merge with it.
Expand All @@ -1896,7 +1899,12 @@ public void GetGeometryStatistics(out int vertices, out int faces)
}
else
{
existingIndex = roomVertices.IndexOf(v => v.Position == trVertex.Position && v.Color == trVertex.Color);
existingIndex = roomVertices.IndexOf(v =>
v.Position == trVertex.Position &&
v.Lighting1 == trVertex.Lighting1 &&
v.Attributes == trVertex.Attributes &&
v.Lighting2 == trVertex.Lighting2 &&
v.Normal == trVertex.Normal);
if (existingIndex == -1)
{
existingIndex = roomVertices.Count;
Expand Down