Skip to content

Commit

Permalink
Support reading bones for v34 mesh
Browse files Browse the repository at this point in the history
  • Loading branch information
PikminGuts92 committed Sep 6, 2022
1 parent 630e5ce commit 57c334d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Src/Core/Mackiloha/IO/Serializers/MeshSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Mackiloha.IO.Serializers
public class MeshSerializer : AbstractSerializer
{
public MeshSerializer(MiloSerializer miloSerializer) : base(miloSerializer) { }

public override void ReadFromStream(AwesomeReader ar, ISerializable data)
{
var mesh = data as Mesh;
Expand All @@ -33,7 +33,7 @@ public override void ReadFromStream(AwesomeReader ar, ISerializable data)
break;
default:
throw new Exception($"Unexpected number, got {mesh.Unknown}");
}
}

var num = ar.ReadInt32();
if (!(num == 0 || num == 1))
Expand Down Expand Up @@ -121,15 +121,15 @@ public override void ReadFromStream(AwesomeReader ar, ISerializable data)

if (groupSizes.Select(x => (int)x).Sum() != mesh.Faces.Count)
throw new Exception("Sum should equal count of faces");

var charCount = ar.ReadInt32();
ar.BaseStream.Position -= 4;

// Read bones
mesh.Bones.Clear();
if (charCount > 0)
{
if (version >= 36)
if (version >= 34)
{
// Uses variable length bone count
ar.BaseStream.Position += 4;
Expand Down Expand Up @@ -272,7 +272,7 @@ public override void WriteToStream(AwesomeWriter aw, ISerializable data)
// Write group sizes
aw.Write((int)mesh.Groups.Count);
mesh.Groups.ForEach(x => aw.Write((byte)x.Size));

const int boneCount = 4; // Always 4?
var bones = mesh.Bones
.Take(boneCount)
Expand Down

0 comments on commit 57c334d

Please sign in to comment.