// =========================================================================== // 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. // =========================================================================== // // Procedure(s) : // removeObjectShaderInstances // removeSingleObjectShaderInstances // shaderUsedByObjects // // For a list of objects, find it's shaders, // and remove shader instance usage. // // Last Updated : Sept 18, 2000 // global proc string[] shadersUsedByObjects(string $objList[]) { string $shaders[]; int $numObj = size($objList); if ($numObj == 0) return $shaders; $shaders = `listSets -type 1 -ets -o $objList[0]`; //print ("Initial list:"); print $shaders; print ("\n"); for ($i=1; $i<$numObj; $i++) { $sh = `listSets -type 1 -ets -o $objList[$i]`; //print ("Add to list:"); print $sh; print ("\n"); int $nShaders_j = size($sh); int $nShaders_k = size($shaders); // Scan new list for ($j=0; $j<$nShaders_j; $j++) { string $scanShader = $sh[$j]; // Against old list int $found = 0; for ($k=0; $k<$nShaders_k; $k++) { if ($shaders[$k] == $scanShader) { //print ("Shader " + $scanShader + " already exists\n"); $found = 1; break; } } if ($found == 0) { //print ("Add shader " + $scanShader + "at entry " + $nShaders_k + "\n"); $shaders[$nShaders_k] = $scanShader; } } } //print ("Final result:\n"); //print $shaders; print ("\n"); return $shaders; } global proc removeObjectShaderInstances(string $objList[]) { if (size($objList) == 0) return; string $shaderList[] = `shadersUsedByObjects $objList`; for ($i=0; $i