Skip to content

Commit

Permalink
Fix TerrainInstanceInfo v0 reading and writing (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueCube3310 authored Jan 22, 2025
1 parent 9ba5f0e commit ea57190
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Source/SharpNeedle/HedgehogEngine/Mirage/TerrainInstanceInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ public override void Read(BinaryObjectReader reader)
ModelName = reader.ReadStringOffset();
Transform = Matrix4x4.Transpose(reader.ReadValueOffset<Matrix4x4>());
Name = reader.ReadStringOffset();
LightGroups = DataVersion >= 5
? reader.ReadObject<BinaryList<BinaryPointer<LightIndexMeshGroup>>>().Unwind()
: new List<LightIndexMeshGroup>(2) { reader.ReadObject<LightIndexMeshGroup>() };

if (DataVersion >= 5)
LightGroups = reader.ReadObject<BinaryList<BinaryPointer<LightIndexMeshGroup>>>().Unwind();
else if(DataVersion > 0)
LightGroups = new List<LightIndexMeshGroup>(2) { reader.ReadObject<LightIndexMeshGroup>() };
}

public override void Write(BinaryObjectWriter writer)
Expand All @@ -45,7 +47,7 @@ public override void Write(BinaryObjectWriter writer)
writer.WriteObjectOffset(group);
});
}
else
else if (DataVersion > 0)
{
if (LightGroups.Count == 1)
LightGroups[0].Write(writer);
Expand Down

0 comments on commit ea57190

Please sign in to comment.