// =========================================================================== // 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. // =========================================================================== // -*- mode: c -*- // // Procedure Name: // forceRender // // Description: // Given a render target argument, unconditionally render it // after rendering all its dependencies. // global proc forceRender(string $renderTarget) { global string $gRenderViewRenderTarget; if ( objectType($renderTarget) != "renderTarget" ) { string $msg = (uiRes("m_forceRender.kNotARenderTarget")); error(`format -stringArg $renderTarget $msg`); } // Get the merged render tasks for the current camera and current // render layer. Store the original render target, to restore it later. string $camera = getCurrentCamera(); string $renderLayer = `editRenderLayerGlobals -q -currentRenderLayer`; string $oldRenderTarget = $gRenderViewRenderTarget; string $tasks[] = `getRenderTasks -c $camera -rl $renderLayer $renderTarget`; string $task; for ($task in $tasks) { // FIXME The render target really needs to be an attribute on a // render globals node, so that attribute changed notification can // be used to propagate changes to the UI. For now, since the // render target is only in a dynamically-built UI, this is not // yet an issue. python("task = " + $task); $gRenderViewRenderTarget = python("task['renderTarget']"); string $taskCamera = python("task['camera']"); string $taskRenderLayer = python("task['renderLayer']"); editRenderLayerGlobals("-currentRenderLayer", $taskRenderLayer); trace("Rendering render target " + $gRenderViewRenderTarget + "\n"); renderWindowRenderCamera("redoPreviousRender", "renderView", $taskCamera); } // Restore the original render layer and render target. $gRenderViewRenderTarget = $oldRenderTarget; editRenderLayerGlobals("-currentRenderLayer", $renderLayer); }