From 773d034a30a5abc1a214e028e44b0452b60cb503 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 1 Sep 2010 15:15:30 +0200 Subject: [PATCH] Changed: #964 Skip over deleted bones in skinning when exporting from max. --- .../nel_mesh_lib/export_skinning.cpp | 102 +++++++++++------- 1 file changed, 61 insertions(+), 41 deletions(-) diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_skinning.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_skinning.cpp index c1809508f..57f742972 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_skinning.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_skinning.cpp @@ -748,15 +748,20 @@ uint CExportNel::buildSkinning (CMesh::CMeshBuild& buildMesh, const TInodePtrInt { if (blendedInterface) { - // Get the bone weight - float weight=blendedInterface->GetWeight(bone); - // Get node INode *node=blendedInterface->GetNode(bone); - nlassert (node); - - // Insert in the map - weightMap.insert (std::map::value_type (weight, node)); + if (node == NULL) + { + nlwarning("node == NULL; bone = %i / %i", bone, boneCount); + } + else + { + // Get the bone weight + float weight=blendedInterface->GetWeight(bone); + + // Insert in the map + weightMap.insert (std::map::value_type (weight, node)); + } } else { @@ -1191,49 +1196,64 @@ void CExportNel::addSkeletonBindPos (INode& skinedNode, mapBoneBindPos& boneBind for (boneIndex=0; boneIndexGetNode(boneIndex); + INode *bone = blendedInterface->GetNode(boneIndex); - // Get the bind matrix of the bone - Matrix3 bindPos; - int res=physiqueInterface->GetInitNodeTM (bone, bindPos); - nlassert (res==MATRIX_RETURNED); - - // Add an entry inthe map - if (boneBindPos.insert (mapBoneBindPos::value_type (bone, bindPos)).second) + if (bone == NULL) { -#ifdef NL_DEBUG - // *** Debug info + nlwarning("bone == NULL; boneIndex = %i / %i", boneIndex, count); + } + else + { + // Get the bind matrix of the bone + Matrix3 bindPos; + int res = physiqueInterface->GetInitNodeTM (bone, bindPos); - // Bone name - std::string boneName=getName (*bone); + if (res != MATRIX_RETURNED) + { + nlwarning("res != MATRIX_RETURNED; res = %i; boneIndex = %i / %i", res, boneIndex, count); + nlwarning("bone = %i", (uint32)(void *)bone); + std::string boneName = getName (*bone); + nlwarning("boneName = %s", boneName.c_str()); + nlassert(false); + } - // Local matrix - Matrix3 nodeTM; - nodeTM=bone->GetNodeTM (0); + // Add an entry inthe map + if (boneBindPos.insert (mapBoneBindPos::value_type (bone, bindPos)).second) + { + #ifdef NL_DEBUG + // *** Debug info - // Offset matrix - Matrix3 offsetScaleTM (TRUE); - Matrix3 offsetRotTM (TRUE); - Matrix3 offsetPosTM (TRUE); - ApplyScaling (offsetScaleTM, bone->GetObjOffsetScale ()); - offsetRotTM.SetRotate (bone->GetObjOffsetRot ()); - offsetPosTM.SetTrans (bone->GetObjOffsetPos ()); - Matrix3 offsetTM = offsetScaleTM * offsetRotTM * offsetPosTM; + // Bone name + std::string boneName=getName (*bone); - // Local + offset matrix - Matrix3 nodeOffsetTM = offsetTM * nodeTM; + // Local matrix + Matrix3 nodeTM; + nodeTM=bone->GetNodeTM (0); - // Init TM - Matrix3 initTM; - int res=physiqueInterface->GetInitNodeTM (bone, initTM); - nlassert (res==MATRIX_RETURNED); + // Offset matrix + Matrix3 offsetScaleTM (TRUE); + Matrix3 offsetRotTM (TRUE); + Matrix3 offsetPosTM (TRUE); + ApplyScaling (offsetScaleTM, bone->GetObjOffsetScale ()); + offsetRotTM.SetRotate (bone->GetObjOffsetRot ()); + offsetPosTM.SetTrans (bone->GetObjOffsetPos ()); + Matrix3 offsetTM = offsetScaleTM * offsetRotTM * offsetPosTM; - // invert - initTM.Invert(); - Matrix3 compNode=nodeTM*initTM; - Matrix3 compOffsetNode=nodeOffsetTM*initTM; - Matrix3 compOffsetNode2=nodeOffsetTM*initTM; + // Local + offset matrix + Matrix3 nodeOffsetTM = offsetTM * nodeTM; + + // Init TM + Matrix3 initTM; + int res=physiqueInterface->GetInitNodeTM (bone, initTM); + nlassert (res==MATRIX_RETURNED); + + // invert + initTM.Invert(); + Matrix3 compNode=nodeTM*initTM; + Matrix3 compOffsetNode=nodeOffsetTM*initTM; + Matrix3 compOffsetNode2=nodeOffsetTM*initTM; #endif // NL_DEBUG + } } } }