From e76f6f870d5e2947a90a22e3035b5bb37423bdb3 Mon Sep 17 00:00:00 2001 From: nichinichisou Date: Mon, 16 Nov 2026 18:57:26 +0800 Subject: [PATCH 1/2] fix(MeshHelper): implied fourth bone weight of compressed meshes Compressed meshes store up to three 5-bit weights per vertex and imply the fourth one when they do not add up to 31. The running sum counts 5-bit units since #338, but the implied weight was still computed as 1 - sum, which gives a negative weight (-24 for weights 10, 10, 5). It is now (31 - sum) / 31, so the four weights of a vertex add up to 1. --- UnityPy/helpers/MeshHelper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnityPy/helpers/MeshHelper.py b/UnityPy/helpers/MeshHelper.py index edbd6bee..c51312dc 100644 --- a/UnityPy/helpers/MeshHelper.py +++ b/UnityPy/helpers/MeshHelper.py @@ -608,7 +608,7 @@ def decompress_compressed_mesh(self): # we read three weights, but they don't add up to one. calculate the fourth one, and read # missing bone index. continue with next vertex. elif j == 3: # - boneWeights[vertexIndex][j] = 1 - sum + boneWeights[vertexIndex][j] = (31 - sum) / 31 boneIndices[vertexIndex][j] = next(boneIndicesIterator) vertexIndex += 1 From 994faecad3729af2f1cdd3bac6d392003af85c30 Mon Sep 17 00:00:00 2001 From: nichinichisou Date: Mon, 16 Nov 2026 18:57:28 +0800 Subject: [PATCH 2/2] fix(MeshHelper): offset of the third and later compressed UV sets With m_UVInfo set, a compressed mesh stores its texture coordinate sets back to back in m_UV. The read offset was assigned the size of the current set instead of advancing by it, so every set after the second one was read from the position of the second set and came back as a copy of it. The offset now accumulates, as the sets are stored. --- UnityPy/helpers/MeshHelper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnityPy/helpers/MeshHelper.py b/UnityPy/helpers/MeshHelper.py index c51312dc..9a4556e6 100644 --- a/UnityPy/helpers/MeshHelper.py +++ b/UnityPy/helpers/MeshHelper.py @@ -508,7 +508,7 @@ def decompress_compressed_mesh(self): shape=(uvDim,), ) setattr(self, f"m_UV{uv_channel}", m_UV) - uvSrcOffset = uvDim * m_VertexCount + uvSrcOffset += uvDim * m_VertexCount else: self.m_UV0 = unpack_floats(m_CompressedMesh.m_UV, 0, m_VertexCount * 2, shape=(2,)) if m_CompressedMesh.m_UV.m_NumItems >= m_VertexCount * 4: