@@ -535,16 +535,19 @@ private void CalculateMeshOffsets()
535535 if ( mesh == otherMesh )
536536 break ;
537537
538- foreach ( var bone in mesh . Bones )
538+ if ( mesh . HasBones && otherMesh . HasBones )
539539 {
540- foreach ( var otherBone in otherMesh . Bones )
540+ foreach ( var bone in mesh . Bones )
541541 {
542- if ( bone . Name == otherBone . Name )
542+ foreach ( var otherBone in otherMesh . Bones )
543543 {
544- var offset = ConvertMatrix ( bone . OffsetMatrix ) * Matrix . Invert ( ConvertMatrix ( otherBone . OffsetMatrix ) ) ;
545- meshOffsets [ Tuple . Create ( mesh , otherMesh ) ] = offset ;
546- meshOffsets [ Tuple . Create ( otherMesh , mesh ) ] = Matrix . Invert ( offset ) ;
547- break ;
544+ if ( bone . Name == otherBone . Name )
545+ {
546+ var offset = ConvertMatrix ( bone . OffsetMatrix ) * Matrix . Invert ( ConvertMatrix ( otherBone . OffsetMatrix ) ) ;
547+ meshOffsets [ Tuple . Create ( mesh , otherMesh ) ] = offset ;
548+ meshOffsets [ Tuple . Create ( otherMesh , mesh ) ] = Matrix . Invert ( offset ) ;
549+ break ;
550+ }
548551 }
549552 }
550553 }
@@ -585,11 +588,14 @@ private void CalculateMeshOffsets()
585588 if ( otherMesh != mesh && ! meshOffsets . ContainsKey ( Tuple . Create ( mesh , otherMesh ) ) )
586589 continue ;
587590
588- foreach ( var bone in otherMesh . Bones )
591+ if ( otherMesh . HasBones )
589592 {
590- var boneNode = scene . RootNode . FindNode ( bone . Name ) ;
591- if ( ! referenceMeshes . ContainsKey ( boneNode ) )
592- referenceMeshes . Add ( boneNode , mesh ) ;
593+ foreach ( var bone in otherMesh . Bones )
594+ {
595+ var boneNode = scene . RootNode . FindNode ( bone . Name ) ;
596+ if ( ! referenceMeshes . ContainsKey ( boneNode ) )
597+ referenceMeshes . Add ( boneNode , mesh ) ;
598+ }
593599 }
594600 }
595601 }
0 commit comments