Exemple #1
0
 def _updateLegacyRenderLayerVisibility(self):
     """ Update layer visibility. Note that we always edit layer member
         to maintain consistency and let the update logic optimize as needed for performance.
         For instance, VP2 will not update its scene representation for invisible layers.
     """
     # Note: deltas are not being computed yet so we are
     #  doing a reset on the associated old render layer for now.
     #
     # Note: Still no delta computation but at least there is no processing
     #  if the list of selected nodes did not changed.        
     try:
         with profiler.ProfilerMgr('RenderLayer::_updateLegacyRenderLayerVisibility'):
             currentlySelectedNodeNames = self.getMembers()
             if currentlySelectedNodeNames!=self._currentlyVisibleNodeNames:
                 legacyRenderLayerName = self._getLegacyNodeName()
                 # Clear out old membership
                 legacyLayer.removeNodes(legacyRenderLayerName)
                 # Add in nodes from enabled collections only
                 legacyLayer.appendNodes(legacyRenderLayerName, currentlySelectedNodeNames)
                 # Preserve the new list of nodes
                 self.setMemberNodesCache(currentlySelectedNodeNames)
         self.needsMembershipUpdate = False
         self.itemChanged()
     
     finally:
         self.isUpdatingMembership = False
Exemple #2
0
    def unapply(self):
        """Unapply overrides for all collections in this render layer."""
        with profiler.ProfilerMgr('RenderLayer::unapplyOverrides'):
            for col in nodeList.reverseListGenerator(self):
                col.unapply()
                RenderLayerSwitchObservable.getInstance().notifyRenderLayerSwitchObserver()

        self.needsApplyUpdate = False
def removeNodes(legacyRenderLayerName):
    with profiler.ProfilerMgr('legacyRenderLayer::removeNodes'):
        nodeList = cmds.editRenderLayerMembers(legacyRenderLayerName,
                                               query=True,
                                               fullNames=True)
        if nodeList:
            nodes = [node for node in nodeList if cmds.objExists(node)]
            cmds.editRenderLayerMembers(legacyRenderLayerName,
                                        nodes,
                                        remove=True)
Exemple #4
0
    def createCollection(self, collectionName):
        """ Create and append a new Collection

            @type collectionName: string
            @param collectionName: Name of collection to create
        """
        with profiler.ProfilerMgr('createCollection'):
            c = collection.create(collectionName)
            self.appendCollection(c)
            # Note: No need to update visibility here since it's an empty collection
            # which will not modify membership. 
            return c
Exemple #5
0
    def switchToLayerUsingLegacyName(self, renderLayerName):
        """ Set the argument render layer as the visible render layer """

        with profiler.ProfilerMgr('RenderSetup::switchToLayerUsingLegacyName'):
            renderLayer = None
            if renderLayerName != "defaultRenderLayer":
                renderLayers = self.getRenderLayers()
                for layer in renderLayers:
                    if layer._getLegacyNodeName() == renderLayerName:
                        renderLayer = layer
                        break
                if renderLayer is None:
                    cmds.warning(kUnknownLegacyRenderLayer % renderLayerName)

            self.switchToLayer(renderLayer)
def setRenderable(legacyRenderLayerName, value):
    with profiler.ProfilerMgr('legacyRenderLayer::setRenderable'):
        cmds.setAttr(legacyRenderLayerName + '.renderable', value)
def isRenderable(legacyRenderLayerName):
    with profiler.ProfilerMgr('legacyRenderLayer::isRenderable'):
        return cmds.getAttr(legacyRenderLayerName + '.renderable')
def isVisible(legacyRenderLayerName):
    with profiler.ProfilerMgr('legacyRenderLayer::isVisible'):
        currentName = cmds.editRenderLayerGlobals(query=True,
                                                  currentRenderLayer=True)
        return legacyRenderLayerName == currentName
def makeVisible(legacyRenderLayerName):
    with profiler.ProfilerMgr('legacyRenderLayer::makeVisible'):
        OpenMayaRender.MRenderSetupPrivate._switchToLegacyRenderLayer(
            legacyRenderLayerName)
def appendNodes(legacyRenderLayerName, nodeNames):
    with profiler.ProfilerMgr('legacyRenderLayer::appendNodes'):
        cmds.editRenderLayerMembers(legacyRenderLayerName,
                                    list(nodeNames),
                                    noRecurse=True)
def delete(legacyRenderLayerName):
    with profiler.ProfilerMgr('legacyRenderLayer::delete'):
        cmds.delete(legacyRenderLayerName)
def rename(oldLegacyRenderLayerName, newParentName):
    with profiler.ProfilerMgr('rename'):
        cmds.rename(oldLegacyRenderLayerName, 'rs_%s' % newParentName)
def create(parentName):
    with profiler.ProfilerMgr('create'):
        newName = 'rs_%s' % parentName
        return cmds.createRenderLayer(name=newName, empty=True)
Exemple #14
0
 def createRenderLayer(self, renderLayerName):
     """ Create and append a new Render Layer """
     with profiler.ProfilerMgr('RenderSetup::createRenderLayer'):
         layer = renderLayer.create(renderLayerName)
         self.appendRenderLayer(layer)
         return layer
Exemple #15
0
    def getMembers(self):
        """ Get the names of the layer's DAG node members.

            The layer's members are DAG nodes selected by the layer's
            collections, based on whether a collection is enabled or solo'ed. 
            
            @rtype: list
            @return: list of node names. Empty if none found.
        """

        with profiler.ProfilerMgr('RenderLayer::getMembers'):

            # Collection membership has the following properties:
            #
            # o The union of top-level collection members defines the
            #   render layer membership.
            # o Sub-collections filter their parent's objects, so they are
            #   always subsets of their parents.
            # o Collections exclude objects when disabled, and include
            #   objects when enabled.
            # o Explicitly including / excluding a DAG parent
            #   includes / excludes its children.
            # o Collections are processed in depth-first order, lowest
            #   priority to highest priority.  Later, higher-priority
            #   collection exclusions or inclusions replace earlier,
            #   lower-priority ones.
            #
            # Collection membership is also determined by a collection's
            # isolate select boolean flag.  Conceptually, isolate select is
            # a mode where only isolate selected collections are considered
            # when determining render layer membership.  Isolate select
            # mode is on when one or more collections are isolate
            # selected.  Isolate select has the following additional
            # properties:
            # 
            # o All ancestor collections of an isolate selected collections
            #   are enabled.  They do not contribute to render layer
            #   membership, but their overrides will be applied.  This is
            #   to support use cases where ancestor collections modify a
            #   child collection's transform: keeping the ancestors of that
            #   child enabled keeps the parent transform of the child
            #   collection's objects unchanged.
            # o All descendant collections of an isolate selected
            #   collection are enabled, and contribute to render layer
            #   membership.  Conceptually, isolate selecting a collection
            #   includes that collection's subtree into the render layer.
            #
            # The algorithm for determining membership proceeds
            # sequentially on the depth-first ordering of collections,
            # adding in members from enabled collections, and excluding
            # members from disabled collections.
            #
            # There is one important complexity that stems from the fact
            # that setting a DAG parent as member implicitly makes its
            # children members as well.  If only a subset of its children
            # must be excluded, we cannot make the parent member of the
            # layer.

            members = memberSet.MemberSet()
            
            if not self.hasLightsCollectionInstance():
                lights = itertools.ifilter(None, (commonUtils.nameToDagPath(name) for name in cmds.ls(type=cmds.listNodeTypes('light'))))
                reduce(lambda memberset,path: members.include(path), lights, members)
            
            isolateSelectMode = not cmds.about(batch=True) and (self.getNumIsolatedChildren() > 0)
            
            for c in traverse.depthFirst(self, memberTraversal):
                if not isinstance(c, collection.Collection):
                    continue

                # In isolate select mode, if a collection isn't isolate selected and
                # has no isolate selected ancestors, it's ignored.
                hasNoIsolatedAncestors = (c.getNumIsolatedAncestors() == 0)
                if isolateSelectMode and not c.isIsolateSelected() and hasNoIsolatedAncestors and \
                    not isinstance(c, collection.LightsCollection) and not isinstance(c, collection.LightsChildCollection):
                    # Lights cannot be isolate selected.  The following ensures they're visible when other collections are isolate selected.  
                    # MAYA-70684: a more maintainable solution should be found.
                    continue

                # The collection selector has a cache, which will always be hit once on
                # layer switching (to apply overrides).  Therefore, there is no need to
                # cache or be lazy in accessing the collection's members.
                nodes = [n for n in c.getSelector().getAbsoluteNames() if n.startswith('|')]
                paths = itertools.ifilter(None, (commonUtils.nameToDagPath(path) for path in nodes)) 
                
                mtd = memberSet.MemberSet.include if c.isEnabled() else memberSet.MemberSet.exclude
                reduce(lambda memberset,path: mtd(members, path), paths, members)
            
            included = set(p.fullPathName() for p in members.paths())

            return included