d4rkc0d3r / d4rkAvatarOptimizer

d4rkpl4y3r's VRChat Avatar 3.0 optimizer
MIT License
402 stars 17 forks source link

Index out of range exception #34

Closed SnowMser closed 1 year ago

SnowMser commented 1 year ago

no matter what settings i use i get this error

IndexOutOfRangeException: Index was outside the bounds of the array.
d4rkAvatarOptimizer+<>c__DisplayClass119_3.<CombineSkinnedMeshes>b__18 (System.Int32 i) (at Packages/d4rkpl4y3r.d4rkavataroptimizer/Editor/d4rkAvatarOptimizer.cs:2531)
System.Linq.Enumerable+SelectIPartitionIterator`2[TSource,TResult].PreallocatingToArray (System.Int32 count) (at <351e49e2a5bf4fd6beabb458ce2255f3>:0)
System.Linq.Enumerable+SelectIPartitionIterator`2[TSource,TResult].ToArray () (at <351e49e2a5bf4fd6beabb458ce2255f3>:0)
System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable`1[T] source) (at <351e49e2a5bf4fd6beabb458ce2255f3>:0)
d4rkAvatarOptimizer.CombineSkinnedMeshes () (at Packages/d4rkpl4y3r.d4rkavataroptimizer/Editor/d4rkAvatarOptimizer.cs:2530)
d4rkAvatarOptimizer.Optimize () (at Packages/d4rkpl4y3r.d4rkavataroptimizer/Editor/d4rkAvatarOptimizer.cs:95)
d4rkAvatarOptimizerEditor.OnInspectorGUI () (at Packages/d4rkpl4y3r.d4rkavataroptimizer/Editor/d4rkAvatarOptimizerEditor.cs:959)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass58_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <a259d3c004024353a2c217da97495055>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
d4rkc0d3r commented 1 year ago

From the looks of this error message it seems like you have a skinned mesh that is in a faulty state. Specifically one that has a mismatched amount of bones and bindposes. To find which mesh is the culprit you can use the exclusion list.

  1. Put all skinned meshes in the exclusion list. Now it should finish the optimization without error but also don't optimize anything really.
  2. Remove 1 of the meshes and click optimize again.
  3. Repeat the previous step until the error appears again. Then you know which mesh is the problem.

Tbh I don't know how to really fix this bug as having a differently sized bindpose array from the bone array makes no sense.

SnowMser commented 1 year ago

well even after excluding all the meshes im left with this error

IndexOutOfRangeException: Index was outside the bounds of the array.
d4rkAvatarOptimizerEditor.OnInspectorGUI () (at Packages/d4rkpl4y3r.d4rkavataroptimizer/Editor/d4rkAvatarOptimizerEditor.cs:1005)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass58_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <a259d3c004024353a2c217da97495055>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
SnowMser commented 1 year ago

Actually it spamming the console aswell with the message

d4rkc0d3r commented 1 year ago

For the second issue, I don't know what causes it. My best guess was meshes with 0 materials but that doesn't reproduce the error on my end.

d4rkc0d3r commented 1 year ago

I've added some extra guarding code without being able to reproduce the original issue. If you have time it would be nice if you could check if the problem still persists in v2.2.0 The secondary issue should be fixed in the newest version as I could reproduce it eventually.