// =========================================================================== // 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: 20 Feb 2002 // // Description: // Returns a command to rebuild the initial state of a fluid, // to preserve contents when the resolution has changed. // global proc string rebuildFluidInitialStateCmd( string $cmd, string $optionVar ) { string $preCmd = ""; string $postCmd = ""; if( !`exists getActiveFluidShapes` ) { source "getFluidShape.mel"; } string $activeFluids[] = getActiveFluidShapes(); int $rebuildIC = `optionVar -query $optionVar`; for( $fluid in $activeFluids ) { string $icCaches[] = eval( "listConnections \"" + $fluid + ".diskCacheIC\"" ); // Only rebuild the IC cache, if there IS one. // if( size($icCaches) > 0 ) { if( $rebuildIC ) { float $currTime = `currentTime -q`; // Go back to the start of the IC cache // $preCmd = ( "currentTime `fluidCacheInfo -sf -ic " + $fluid + "`; " ); // Resave the initial state, and return to the current time // $postCmd = ( "performSetFluidState 0; " + "currentTime " + $currTime + "; " ); } else { string $msg = (uiRes("m_rebuildFluidInitialStateCmd.kResamplingExtendingMessage")); string $no = (uiRes("m_rebuildFluidInitialStateCmd.kNo")); string $lastChance = `confirmDialog -title (uiRes("m_rebuildFluidInitialStateCmd.kWarning")) -message $msg -button (uiRes("m_rebuildFluidInitialStateCmd.kYes")) -button $no -defaultButton $no -cancelButton $no -dismissString $no`; // If they've cancelled, then set things up so // nothing important gets executed. // if( $lastChance == $no ) { $cmd = ""; } } } } $postCmd = ( $postCmd + "fluidCheckResolutionAgainstCaches; " ); return ( $preCmd + $cmd + $postCmd ); }