// =========================================================================== // 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. // =========================================================================== // // // Creation Date: 2005 // // Description: // Get a list of Ccloth or nParticle objects for caching. // // global proc string[] getNclothObjectsToCache(int $showError) { string $shapes[] = getGeometriesToCache(); string $objsToCache[]; // look for the xforms of hair systems and pfx hairs as well // because getGeometries to cache only gets deformable shapes string $obj; string $sel[] = `ls -sl -type transform`; for ($selObj in $sel) { string $objects[] = `listRelatives -pa -ni -shapes -type hairSystem -typ pfxHair $selObj`; for( $obj in $objects ) { $shapes[size($shapes)] = $obj; } } if (0 == size($shapes)) { $objsToCache = `ls -sl -type nBase`; } else { string $shape; for ($shape in $shapes) { string $nType = nodeType( $shape ); if($nType != "hairSystem" && $nType != "pfxHair") { // don't want to find cloth or particles from hair by accident string $nBase = findTypeInHistory($shape,"nBase", 0, 1); if (size($nBase)) { $objsToCache[size($objsToCache)] = $nBase; } } string $nHair = findTypeInHistory($shape,"hairSystem", 0, 1); if (size($nHair)) { $objsToCache[size($objsToCache)] = $nHair; } } } // append any additional geometries that are in cache groups with // the specified geometries // int $ii, $objCount = size($objsToCache); for ($ii = 0; $ii < $objCount; $ii++) { string $caches[] = findExistingCaches($objsToCache[$ii]); for ($cache in $caches) { string $geoms[] = `cacheFile -q -geometry $cache`; for ($geom in $geoms) { string $isNBase[] = `ls -type nBase $geom`; if (size($isNBase) > 0) { if (0 == stringArrayCount($geom,$objsToCache)) { $objsToCache[size($objsToCache)] = $geom; } } } } } // if both the mesh and the nCloth node were selected, there could be duplicates in this list $objsToCache = stringArrayRemoveDuplicates( $objsToCache ); if ($showError && 0 == size($objsToCache)) { error((uiRes("m_getNclothObjectsToCache.kSelectClothError"))); } return $objsToCache; }