From 810a34ac33c47af32920b6eb4b8250adcf05c1b2 Mon Sep 17 00:00:00 2001
From: Tazpn <tazpn@users.sourceforge.net>
Date: Thu, 10 Aug 2006 00:55:59 +0000
Subject: [PATCH] Set the num weights to 4 so Oblivion meshes import/export
 more correctly.  Want to rewrite this with less hardcoded numbers in the
 future.

---
 NifImport/ImportMeshAndSkin.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/NifImport/ImportMeshAndSkin.cpp b/NifImport/ImportMeshAndSkin.cpp
index ef7e435..6ed6702 100644
--- a/NifImport/ImportMeshAndSkin.cpp
+++ b/NifImport/ImportMeshAndSkin.cpp
@@ -312,6 +312,15 @@ bool NifImporter::ImportSkin(ImpNode *node, NiTriBasedGeomRef triGeom)
    if (ISkin *skin = (ISkin *) skinMod->GetInterface(I_SKIN)){
       ISkinImportData* iskinImport = (ISkinImportData*) skinMod->GetInterface(I_SKINIMPORTDATA);
 
+      // Set the num weights to 4.  Yes its in the nif but Shon doesn't like to expose those values 
+      //   and the value always seems to be 4 anyway.  I'd also this be more dynamic than hard coded numbers
+      //   but I cant figure out the correct values to pass the scripting engine from here so I'm giving up.
+      int numWeightsPerVertex = 4;
+      IParamBlock2 *params = skinMod->GetParamBlockByID(2/*advanced*/);
+      params->SetValue(0x7/*bone_Limit*/, 0, numWeightsPerVertex);
+      //RefTargetHandle advanced = skinMod->GetReference(3);
+      //setMAXScriptValue(advanced, "bone_Limit", 0, numWeightsPerVertex);
+
       Matrix3 m3 = TOMATRIX3(data->GetOverallTransform());
       Matrix3 im3 = Inverse(m3);
       iskinImport->SetSkinTm(tnode, m3, m3); // ???
-- 
GitLab