// =========================================================================== // 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: Oct 1 2002 // // Description: // Helper proc to determine what should be saved in a fluid diskCache // // proc verifyGridsAreCached( int $uiSettings[], string $methodAttrs[], int $dynamic[], int $static[], string $oboxName, string $addButtonLabel ) // // Description: // Make sure the user knows about any Grid attributes // on active fluids that might be omitted from the cache, // and give him a chance to add them. // // The following parameters are all arrays of the same size, // with corresponding elements // // $uiSettings[] is a boolean array representing the state of // the checkboxes in the "create cache" UI. // // $methodAttrs[] is the array of attribute names whose values // indicate whether the attribute is Grid. // // $dynamic[] is the array of values for each of the $methodAttrs // that indicates Dynamic Grid. // // $static[] is the array of values for each of the $methodAttrs // that indicates Static Grid. // // If the user elects to cache a Grid Attr that would have // been originally omitted from the cache, the $uiSettings[] // array values will be updated appropriately. // { int $count = size( $uiSettings ); if(( $count != size( $methodAttrs ) ) || ( $count != size( $dynamic ) ) || ( $count != size( $static ) )) { error (uiRes("m_applyFluidDiskCacheOptions.kArraySizeError")); return; } if( !`exists getActiveFluidShapes` ) { source "getFluidShape.mel"; } string $fluids[] = getActiveFluidShapes(); int $i; int $dialogPosted = false; int $updateUI = false; for( $f in $fluids ) { for( $i = 0; $i < $count; $i++ ) { int $isDynamic = `getAttr ($f + $methodAttrs[$i])` == $dynamic[$i]; int $isStatic = `getAttr ($f + $methodAttrs[$i])` == $static[$i]; int $isGrid = $isDynamic || $isStatic; if( !$isGrid || $uiSettings[$i] ) { continue; } // The user will lose the data from $newEnd to $end. // Make sure he knows this. // if( !$dialogPosted ) { string $title = (uiRes("m_applyFluidDiskCacheOptions.kWarning")); string $message = (uiRes("m_applyFluidDiskCacheOptions.kFluidMessage")); $message = `format -s $f -s $oboxName -s $addButtonLabel $message`; string $continue = (uiRes("m_applyFluidDiskCacheOptions.kContinue")); string $lastChance = `confirmDialog -title $title -message $message -messageAlign "left" -button $addButtonLabel -button $continue -defaultButton $continue -cancelButton $continue -dismissString $continue`; if( $lastChance == $addButtonLabel ) { $updateUI = true; } $dialogPosted = true; } if( $updateUI ) { $uiSettings[$i] = true; } } } } global proc applyFluidDiskCacheOptions( int $uiSettings[], string $oboxName, string $addButtonLabel ) // // Description: // Applies the write-to-cache settings saved in the optionVars // to the active fluids. // { string $methodAttrs[] = { ".densityMethod", ".velocityMethod", ".temperatureMethod", ".fuelMethod", ".colorMethod", ".coordinateMethod", ".falloffMethod" }; int $dynamic[] = { 2, 2, 2, 2, 2, 1, 1 }; // no dynamic setting, use same as static int $static[] = { 1, 1, 1, 2, // no static setting, use same as dynamic 1, 1, // no static setting, use same as dynamic 1 }; // no dynamic setting, use same as static // See if the user wants to change the cache settings // based on the dynamic AND static grid status of the // attributes in the fluids he wants to cache. // verifyGridsAreCached( $uiSettings, $methodAttrs, $dynamic, $static, $oboxName, $addButtonLabel ); // Update the settings based on the users response... // $density = $uiSettings[0]; $velocity = $uiSettings[1]; $temperature = $uiSettings[2]; $fuel = $uiSettings[3]; $color = $uiSettings[4]; $textureCoords = $uiSettings[5]; $falloff = $uiSettings[6]; if( !`exists getActiveFluidShapes` ) { source "getFluidShape.mel"; } string $fluids[] = `getActiveFluidShapes`; for( $f in $fluids ) { setAttr ($f + ".cacheDensity") $uiSettings[0]; setAttr ($f + ".cacheVelocity") $uiSettings[1]; setAttr ($f + ".cacheTemperature") $uiSettings[2]; setAttr ($f + ".cacheReaction") $uiSettings[3]; setAttr ($f + ".cacheColor") $uiSettings[4]; setAttr ($f + ".cacheTextureCoordinates") $uiSettings[5]; setAttr ($f + ".cacheFalloff") $uiSettings[6]; } }