From a983977e6afd7f9dca73b05bec843873357ba4e0 Mon Sep 17 00:00:00 2001 From: Alexei Dobrohotov Date: Tue, 23 May 2023 00:58:59 +0300 Subject: [PATCH] Fix NiSkinData loading for >4.2.1.0 --- components/nif/data.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/components/nif/data.cpp b/components/nif/data.cpp index fd94c5753a..54fdea6f8c 100644 --- a/components/nif/data.cpp +++ b/components/nif/data.cpp @@ -338,9 +338,9 @@ namespace Nif && nif->getVersion() <= NIFStream::generateVersion(10, 1, 0, 0)) partitions.read(nif); - // Has vertex weights flag - if (nif->getVersion() > NIFStream::generateVersion(4, 2, 1, 0) && !nif->getBoolean()) - return; + bool hasVertexWeights = true; + if (nif->getVersion() > NIFStream::generateVersion(4, 2, 1, 0)) + hasVertexWeights = nif->getBoolean(); bones.resize(boneNum); for (BoneInfo& bi : bones) @@ -351,8 +351,12 @@ namespace Nif bi.boundSphereCenter = nif->getVector3(); bi.boundSphereRadius = nif->getFloat(); - // Number of vertex weights - bi.weights.resize(nif->getUShort()); + size_t numVertices = nif->getUShort(); + + if (!hasVertexWeights) + continue; + + bi.weights.resize(numVertices); for (size_t j = 0; j < bi.weights.size(); j++) { bi.weights[j].vertex = nif->getUShort();