// =========================================================================== // 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: 21 Nov 2001 // // Description: // Editing of fluid disk caches requires a local // copy of the cache file to be stored in the // the directory specified by the "diskCache -tmp" // command. For performance reasons during playback // or rendering, you may wish to turn off creation // of these local copies by setting the ".cacheLocally" // attribute on the fluid's diskCache node to "false." // Note that operations like Truncate and Append will // fail for caches that do not have the "cacheLocally" // attribute enabled. // global proc int fluidDiskCacheHasLocalCopy() { int $hasLocal = true; int $localFound = true; string $diskCachePath; string $cache; if( !`exists getActiveFluidShapes` ) { source "getFluidShape.mel"; } // For all active fluids... // string $fluidShapes[] = `getActiveFluidShapes`; for( $f in $fluidShapes ) { $cache = fluidPlaybackCacheName( $f ); // If there's one cache... // if( size( $cache ) ) { // And it has the copyLocally attr... // string $attr[] = `ls ($cache + ".copyLocally")`; if( size( $attr ) ) { // And the copyLocally attr is set to false... // $hasLocal = `getAttr ($cache + ".copyLocally")`; if( $hasLocal ) { // Make sure the local copy exists... // verifyWorkspaceFileRule( "diskCache", "data" ); string $diskCacheDir = ( `workspace -q -rootDirectory` + `workspace -fileRuleEntry "diskCache"` ); string $hiddenName = `getAttr ($cache + ".hiddenCacheName")`; $diskCachePath = $diskCacheDir + "/" + $hiddenName; $localFound = `file -q -exists $diskCachePath`; } else { // Stop processing, can't edit, no local copy... // break; } } } } if( !$hasLocal ) { if( !$localFound ) { string $fmt = (uiRes("m_fluidDiskCacheHasLocalCopy.kNoLocalDiskCache")); error(`format -s $diskCachePath $fmt`); } else { string $fmt = (uiRes("m_fluidDiskCacheHasLocalCopy.kCannotEditDiskCache")); error(`format -s $cache $fmt`); } } return $hasLocal; }