From 9081c9b32ece84e372796b09e7c278ad24baa293 Mon Sep 17 00:00:00 2001 From: Samuele Lorefice Date: Tue, 25 Feb 2025 18:27:37 +0100 Subject: [PATCH] Unrolled loops so the debugger works --- BlendFile/Reader.cs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/BlendFile/Reader.cs b/BlendFile/Reader.cs index 9906782..7b4e265 100644 --- a/BlendFile/Reader.cs +++ b/BlendFile/Reader.cs @@ -98,16 +98,16 @@ public class Reader { blockOffset += t.GetCustomAttribute()!.Size; } } - objects.AsParallel().ForAll(x => - { - FieldInfo[] fieldInfo = x.Value.GetType().GetFields(); - fieldInfo.Where(fldInfo => fldInfo.GetCustomAttribute()!.IsPointer).ToList().ForEach(f => - { - var addr = GetBlockFieldDataOffset(x.Key.Item1, f.GetCustomAttribute()!.OriginalIndex, fieldInfo); - var obj = objects.GetValueOrDefault((addr, f.FieldType)); - if (obj != null) f.SetValue(x.Value, obj); - }); - }); + foreach (var obj in objects) { + FieldInfo[] fieldInfo = obj.Value.GetType().GetFields(); + var list = fieldInfo.Where(fldInfo => fldInfo.GetCustomAttribute()!.IsPointer).ToList(); + + foreach(var f in list) { + var addr = GetBlockFieldDataOffset(obj.Key.Item1, f.GetCustomAttribute()!.OriginalIndex, fieldInfo); + var newobj = objects.GetValueOrDefault((addr, f.FieldType)); + if (newobj != null) f.SetValue(obj.Value, newobj); + } + } } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -163,7 +163,6 @@ public class Reader { if(value == null){ //if the data could not be converted //Check if the field is a pointer to another DNA structure - //if (dnaTypes.Values.FirstOrDefault(x => x.GetCustomAttribute()!.OriginalName == attrib.OriginalType) != null) { if (dnaTypesDb.ContainsKey(attrib.OriginalType)) { //Create a new instance of the DNA structure type object? newObj = ActivateInstance(attrib.OriginalType);