// =========================================================================== // 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. // =========================================================================== global proc denormalizeCurve (int $removeNormalizer, string $curveName) { if (!`objExists $curveName`) { return; } if (!isAnimCurve($curveName) || `reference -isNodeReferenced $curveName`) { return; } string $curveDests[] = `listConnections -source false -skipConversionNodes 1 ($curveName+".output")`; if (size ($curveDests) == 0) { return; } string $curveDest = $curveDests[0]; string $normalizerType = "curveNormalizerLinear"; if (`nodeType $curveName` == "animCurveTA") { $normalizerType = "curveNormalizerAngle"; } if ((size($curveDest) == 0) || (`nodeType $curveDest` != $normalizerType)) { return; } float $scalarValue = `getAttr ($curveDest + ".scalar")`; int $keyCount = `getAttr -size ($curveName+".ktv")`; int $key; setAttr ($curveDest+".scalar") 1.0; scaleKey -valueScale $scalarValue $curveName; if (`bufferCurve -exists $curveName`) { bufferCurve -swap $curveName; scaleKey -valueScale $scalarValue $curveName; bufferCurve -swap $curveName; } if ($removeNormalizer) { string $outputName = $curveDest+"output"; string $originalAttrs[] = `listConnections -source false -skipConversionNodes true -plugs true ($curveDest+".output")`; string $originalAttr = ""; if (size($originalAttrs) > 0) { $originalAttr = $originalAttrs[0]; } disconnectAttr ($curveName+".output") ($curveDest+".animInput"); if ($originalAttr != "") { disconnectAttr ($curveDest+".output") $originalAttr; connectAttr ($curveName+".output") $originalAttr; } delete $curveDest; } }