// =========================================================================== // 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 blendShapeDeleteInBetweenTarget(string $bsn, int $heroTargetIndex, int $inBetweenTargetIndex ) { string $attr = $bsn + ".inputTarget"; int $inTgtIndices[] = `getAttr -multiIndices $attr`; int $needsReset = 0; for( $index in $inTgtIndices ) { $attr = $bsn + ".inputTarget[" + $index + "].inputTargetGroup[" + $heroTargetIndex + "].inputTargetItem"; int $inBetweenIndices[] = `getAttr -multiIndices $attr`; if(intArrayFind($inBetweenTargetIndex, 0, $inBetweenIndices) != -1) { // Turn off the edit status if the deleted in-between target is currently sculpted. $attr = $bsn + ".inputTarget[" + $index + "].sculptTargetIndex"; int $sculptTargetIdx = `getAttr $attr`; if ($sculptTargetIdx == $heroTargetIndex) { $attr = $bsn + ".inputTarget[" + $index + "].sculptInbetweenWeight"; float $sculptInbetweenWeight = `getAttr $attr`; $sculptInbetweenWeight = blendShapeWeightRoundoff($sculptInbetweenWeight, 3); int $sculptInbetweenIndex = 5000 + $sculptInbetweenWeight * 1000; if( $sculptInbetweenIndex != 6000 && $sculptInbetweenIndex == $inBetweenTargetIndex ) { setSculptTargetIndex($bsn, $heroTargetIndex, 1, 1.0); $needsReset = 1; } } // Remove the in-between target. $attr = $bsn + ".inputTarget[" + $index + "].inputTargetGroup[" + $heroTargetIndex + "].inputTargetItem[" + $inBetweenTargetIndex + "]"; removeMultiInstance -b true $attr; } } if( $needsReset == 1 ) { sculptTarget -e -target -1 $bsn; } $attr = $bsn + ".inbetweenInfoGroup[" + $heroTargetIndex + "].inbetweenInfo"; int $inbetweenInfoIndices[] = `getAttr -multiIndices $attr`; if(intArrayFind($inBetweenTargetIndex, 0, $inbetweenInfoIndices) != -1) { // Reset the in-between target name to "IB" to make sure undo/redo can work properly. $attr = $bsn + ".inbetweenInfoGroup[" + $heroTargetIndex + "].inbetweenInfo[" + $inBetweenTargetIndex + "].inbetweenTargetName"; setAttr $attr -type "string" "IB"; // Reset the in-between target type to 0 to make sure undo/redo can work properly. $attr = $bsn + ".inbetweenInfoGroup[" + $heroTargetIndex + "].inbetweenInfo[" + $inBetweenTargetIndex + "].inbetweenTargetType"; setAttr $attr 0; // Reset the in-between interpolation type to 0 to make sure undo/redo can work properly. $attr = $bsn + ".inbetweenInfoGroup[" + $heroTargetIndex + "].inbetweenInfo[" + $inBetweenTargetIndex + "].interpolation"; setAttr $attr 0; // Reset the in-between target interpolationCurve to make sure undo/redo can work properly. $attr = $bsn + ".inbetweenInfoGroup[" + $heroTargetIndex + "].inbetweenInfo[" + $inBetweenTargetIndex + "].interpolationCurve"; int $curvePoints[] = `getAttr -mi $attr`; int $curvePointNum = size($curvePoints); for ($i = 0; $i < $curvePointNum; $i++) { $attr = $bsn + ".inbetweenInfoGroup[" + $heroTargetIndex + "].inbetweenInfo[" + $inBetweenTargetIndex + "].interpolationCurve[" + $curvePoints[$i] + "]."; string $curvePositionAttr = $attr + "curvePosition"; string $curveCurveAttr = $attr + "curveValue"; if($i == $curvePointNum) // Set the last point to 1 1 to make sure the curve is valid { setAttr $curvePositionAttr 1; setAttr $curveCurveAttr 1; } else { setAttr $curvePositionAttr 0; setAttr $curveCurveAttr 0; } } // Reset the in-between target visibility to 0 to make sure undo/redo can work properly. $attr = $bsn + ".inbetweenInfoGroup[" + $heroTargetIndex + "].inbetweenInfo[" + $inBetweenTargetIndex + "].inbetweenVisibility"; setAttr $attr 0; // Remove the in-between info $attr = $bsn + ".inbetweenInfoGroup[" + $heroTargetIndex + "].inbetweenInfo[" + $inBetweenTargetIndex + "]"; removeMultiInstance -b true $attr; } }