// =========================================================================== // 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. // =========================================================================== // // // // Description: // If nodeName is already in the selection list, this returns the index // of nodeName in the ordered selection list. Otherwise, if nodeName // was just selected and is not already in the ordered selection list, this // returns -1 // proc int fltSelectionIndex( string $nodeName, string $componentName) { global string $selectedLPs[]; int $i; for ( $i = 0; $i < size($selectedLPs) ; $i += 2 ) { if ( ($selectedLPs[ $i ] == $nodeName) && ($selectedLPs[ $i + 1 ] == $componentName) ) return $i; } return -1; } // // Description: // Maintains a list of the selected light points in the order // in which they were selected. // global proc fltSelectInOrder() { global string $selectedLPs[] = {""}; string $newSelectedLPs[]; int $isStillSelected[]; string $lpQuery[] = `fltLightPoints -q`; int $i; int $cursor = 0; int $foundIndex; for ( $i = size($lpQuery) - 2; $i >= 0; $i -= 2 ) { $foundIndex = fltSelectionIndex( $lpQuery[$i], $lpQuery[$i+1] ); if ( $foundIndex == -1 ) { $newSelectedLPs[$cursor] = $lpQuery[$i]; $newSelectedLPs[$cursor + 1] = $lpQuery[$i+1]; $cursor += 2; } else { $isStillSelected[$foundIndex] = true; } } for ( $i = 0; $i < size($selectedLPs); $i += 2 ) { if ( $isStillSelected[$i] ) { $newSelectedLPs[$cursor] = $selectedLPs[$i]; $newSelectedLPs[$cursor+1] = $selectedLPs[$i+1]; $cursor += 2; } } $selectedLPs = $newSelectedLPs; }