// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== proc setupCollideMembrane( string $membrane, string $meshes[] ) { int $numMeshes = size( $meshes ); string $collideIn = ($membrane + ".collideMesh"); string $inPlug = `connectionInfo -sfd $collideIn`; if( $inPlug != "" ){ string $con[] = `listConnections $collideIn`; string $inNode = $con[0]; disconnectAttr $inPlug $collideIn; if( nodeType($inNode) == "polyUnite"){ delete $inNode; } } if( $numMeshes == 1 ){ connectAttr ($meshes[0] + ".worldMesh[0]") $collideIn; } else if( $numMeshes > 1 ){ string $unite = `createNode polyUnite`; for( $i = 0; $i < $numMeshes; $i++ ){ string $mesh = $meshes[$i]; connectAttr ($mesh + ".outMesh") ($unite + ".inputPoly["+$i+"]"); connectAttr ($mesh + ".worldMatrix[0]") ($unite + ".inputMat["+$i+"]"); } connectAttr ($unite + ".output") $collideIn; } } global proc collideMembrane() { string $membranes[], $meshes[]; string $allMeshes[] = `ls -sl -ni -dag -type mesh`; int $numMeshes = 0; int $numMembranes = 0; string $mesh; for( $mesh in $allMeshes ){ string $membrane = `findTypeInHistory $mesh "membrane" 0 1`; if( $membrane == "" ){ $meshes[$numMeshes] = $mesh; $numMeshes++; } else { $membranes[$numMembranes] = $membrane; $numMembranes++; } } if( $numMembranes < 1 ){ warning( (uiRes("m_collideMembrane.kNoMembrane"))); return; } for( $i = 0; $i < $numMembranes; $i++ ){ setupCollideMembrane( $membranes[$i], $meshes ); } }