//--------------- Serialize / Deserialize -------------------- public static byte[] Serialize(MeshDataSnapshot input) { if (input.worldObjects == null) return null; int iMax = input.worldObjects.Count; if (iMax == 0) return new byte[0]; ComposedByteStream stream = ComposedByteStream.FetchStream(iMax); for (int i = 0; i < iMax; i++) stream.AddStream(SWorldObject.Serialize(input.worldObjects[i])); return stream.Compose(); }
public static MeshDataSnapshot Deserialize(byte[] input) { if (input == null || input.Length == 0) return null; MeshDataSnapshot result = new MeshDataSnapshot(); ComposedByteStream stream = ComposedByteStream.FromByteArray(input); if (stream == null) return null; int iMax = stream.streamCount; result.worldObjects = new List<SWorldObject>(iMax); for (int i = 0; i < iMax; i++) result.worldObjects.Add(SWorldObject.Deserialize(stream.ReadNextStream<byte>())); stream.Dispose(); return result; }
//Todo:Add material data and make all dispose calls recursive. public override void Dispose() { base.Dispose(); if (header != null) header.Dispose(); if (systemInfo != null) systemInfo.Dispose(); if (debugLogs != null) debugLogs.Dispose(); if (humanInput != null) humanInput.Dispose(); if (meshData != null) meshData.Dispose(); if (particleData != null) particleData.Dispose(); if (materialData != null) materialData.Dispose(); if (gameObjectsSnapshot != null) gameObjectsSnapshot.Dispose(); header = null; systemInfo = null; debugLogs = null; humanInput = null; meshData = null; particleData = null; materialData = null; gameObjectsSnapshot = null; screenCapture = null; }