From bef2440b2333db5f98d30fc5327d69c347961612 Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidoS@users.noreply.github.com> Date: Fri, 28 Jun 2024 09:32:03 -0500 Subject: [PATCH] [VisualCloneFix] nullcheck bone --- Portals/format.json | 1 + VisualCloneFix/Patches.cs | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 Portals/format.json diff --git a/Portals/format.json b/Portals/format.json new file mode 100644 index 0000000..d3c7457 --- /dev/null +++ b/Portals/format.json @@ -0,0 +1 @@ + "None" diff --git a/VisualCloneFix/Patches.cs b/VisualCloneFix/Patches.cs index 608763a..286b268 100644 --- a/VisualCloneFix/Patches.cs +++ b/VisualCloneFix/Patches.cs @@ -101,10 +101,14 @@ public static class Patches int[] vertexIndices = new int[sharedMesh.vertexCount]; // Pre-map bone transforms to their exclusion ids if applicable - int[] boneIndexToExclusionId = new int[renderer.bones.Length]; - for (int i = 0; i < renderer.bones.Length; i++) - if (exclusions.TryGetValue(renderer.bones[i], out FPRExclusion exclusion)) - boneIndexToExclusionId[i] = ((MeshHiderExclusion)exclusion.behaviour).id; + var bones = renderer.bones; + int[] boneIndexToExclusionId = new int[bones.Length]; + for (int i = 0; i < bones.Length; i++) + { + Transform bone = bones[i]; + if (bone != null && exclusions.TryGetValue(bone, out FPRExclusion exclusion)) + boneIndexToExclusionId[i] = ((MeshHiderExclusion)(exclusion.behaviour)).id; + } const float minWeightThreshold = 0.2f; for (int i = 0; i < boneWeights.Length; i++)