@@ -486,7 +486,15 @@ importFbxMesh(ImportFbxContext& ctx, FbxMesh* fbxMesh, int parent)
486486 if (clusterCount > 0 ) {
487487 isSkinnedMesh = true ;
488488 FbxCluster* firstCluster = skin->GetCluster (0 );
489+ if (firstCluster == nullptr ) {
490+ TF_WARN (" Skin: %d does not have a first cluster.\n " , i);
491+ continue ;
492+ }
489493 FbxNode* firstlink = firstCluster->GetLink ();
494+ if (firstlink == nullptr ) {
495+ TF_WARN (" Skin: %d first cluster does not have a first link.\n " , i);
496+ continue ;
497+ }
490498 size_t skeletonIndex = ctx.skeletonsMap [firstlink];
491499
492500 ctx.meshSkinsMap [meshIndex] = skeletonIndex;
@@ -503,7 +511,15 @@ importFbxMesh(ImportFbxContext& ctx, FbxMesh* fbxMesh, int parent)
503511
504512 for (int j = 0 ; j < clusterCount; j++) {
505513 FbxCluster* cluster = skin->GetCluster (j);
514+ if (cluster == nullptr ) {
515+ TF_WARN (" No cluster at skin index %d.\n " , j);
516+ continue ;
517+ }
506518 FbxNode* link = cluster->GetLink ();
519+ if (link == nullptr ) {
520+ TF_WARN (" No link at skin index %d.\n " , j);
521+ continue ;
522+ }
507523
508524 size_t jointIndex = ctx.bonesMap [link];
509525
@@ -527,11 +543,28 @@ importFbxMesh(ImportFbxContext& ctx, FbxMesh* fbxMesh, int parent)
527543 int clusterControlPointIndicesCount = cluster->GetControlPointIndicesCount ();
528544 int * clusterControlPointIndices = cluster->GetControlPointIndices ();
529545 double * pointsWeights = cluster->GetControlPointWeights ();
546+ if (clusterControlPointIndices == nullptr ) {
547+ TF_WARN (" No cluster control point indices for skin cluster: %d.\n " , j);
548+ continue ;
549+ }
550+ if (pointsWeights == nullptr ) {
551+ TF_WARN (" No point weights for skin cluster: %d.\n " , j);
552+ continue ;
553+ }
530554 for (int k = 0 ; k < clusterControlPointIndicesCount; k++) {
531555 int controlPointIndex = clusterControlPointIndices[k];
532- double influenceWeight = pointsWeights[k];
533- indexes[controlPointIndex].push_back (jointIndex);
534- weights[controlPointIndex].push_back (influenceWeight);
556+ if (controlPointIndex > indexes.size () || controlPointIndex > weights.size ()) {
557+ TF_WARN (" Control Point Index outside of index or weight bounds. index: %d "
558+ " Index Size: %d Weight Size: %d" ,
559+ controlPointIndex,
560+ indexes.size (),
561+ weights.size ());
562+ continue ;
563+ } else {
564+ double influenceWeight = pointsWeights[k];
565+ indexes[controlPointIndex].push_back (jointIndex);
566+ weights[controlPointIndex].push_back (influenceWeight);
567+ }
535568 }
536569 }
537570 }
@@ -2001,6 +2034,16 @@ importFbxNodes(ImportFbxContext& ctx, FbxNode* fbxNode, int parent)
20012034 auto [nodeIndex, node] = ctx.usd ->addNode (parent);
20022035 node.name = fbxNode->GetName ();
20032036
2037+ if (!fbxNode->GetVisibility ()) {
2038+ node.markedInvisible = true ;
2039+ }
2040+ if (!fbxNode->VisibilityInheritance .Get ()) { // True by default
2041+ TF_WARN (" importFbxNodes: Node %s does not inherit visibility (VisibilityInheritance = "
2042+ " false). This is currently unsupported. The node is set as %s" ,
2043+ fbxNode->GetName (),
2044+ node.markedInvisible ? " invisible" : " visible" );
2045+ }
2046+
20042047 ctx.nodeMap [fbxNode] = nodeIndex;
20052048
20062049 TF_DEBUG_MSG (FILE_FORMAT_FBX, " importFbx: node %s\n " , node.name .c_str ());
0 commit comments