Ejemplo n.º 1
0
 def findIn(self, nodeNames, includeSelf=True):
     '''Generator that returns all the collections in that layer that contain at least on of the 
     object in nodeNames. Optionally also returns self (with includeSelf=True) if the object is in the layer.'''
     found = False
     for collection in utils.getCollectionsRecursive(self):
         if next((n for n in nodeNames if n in collection.getSelector().names()), False):
             found = True
             yield collection
     
     if includeSelf:
         if found:
             yield self
         elif not self.hasLightsCollectionInstance():
             lightTypes = cmds.listNodeTypes('light')
             def isLight(name):
                 return next((t for t in lightTypes if cmds.objectType(name, isAType=t)), False)
             if next((n for n in nodeNames if isLight(n)), False):
                 yield self
Ejemplo n.º 2
0
    def updateConnectionOverrideWrapper(*args, **kwargs):
        override = args[0]  # args[0] = self (Override)
        layer = override.getRenderLayer()
        if not StackContext.empty() or not layer or not layer.isVisible():
            # Only do the expensive update (with PivotGuards/unapply/apply) if updating the connection override in isolation,
            # effectively assuming that if (not StackContext.empty()), something (collection or layer) in that apply/unapply stack
            # is already doing the necessary work to make sure that selectors listen/invalidate caches correctly or layer should
            # tell it may need to be refreshed (layer.needsRefresh() = True)

            # if we're currently applying layer => previous selectors are already deactivated => nothing special to do
            # if we're currently unapplying layer => all selectors will listen and invalidate caches
            # if we're currently applying collection (postApply) => layer will tell it may need to be refreshed
            # if we're currently unapplying collection (detach) => layer will tell it may need to be refreshed
            f(*args, **kwargs)
            return

        needsApplyUpdate = layer.needsApplyUpdate
        pivot = None
        # use a PivotGuard on the override to make sure that every collection
        # before the override is not listening the scene changes (1)
        with PivotGuard(override):
            # update call (2)
            f(*args, **kwargs)
            # find the next pivot from where we'd need to unapply/reapply layer to make it truthful to that connection change
            # (subsequent collection may be populated differently because of that connection change
            #  => they should then apply to a different set of nodes)
            pivot = next((c for c in utils.getCollectionsRecursive(layer) \
                if c.getSelector().isDirty() and c.name() not in PivotGuard.lockedNames), None)

        if pivot:
            # something was dirtied after the connection override update
            # => reapply layer from that point
            with PivotGuard(pivot):
                layer.unapply()
                layer.apply()
            # what triggered needsApplyUpdate to be True could have been before
            # the updated connection override (and there's currently no way to determine that)
            # => it could be false to say the layer doesn't need apply update anymore
            # layer.apply() sets needsApplyUpdate to False => reset it to its previous value
            layer.needsApplyUpdate = needsApplyUpdate
Ejemplo n.º 3
0
def getCollections(renderLayers):
    for rl in renderLayers:
        for collection in utils.getCollectionsRecursive(rl):
            yield collection
Ejemplo n.º 4
0
 def conclude(self):
     self.element.getSelector().activate()
     for c in utils.getCollectionsRecursive(self.element):
         c.getSelector().activate()