- When using as sources and instances, masters will be created
- under a sibling of World named /Masters. Instanced USD prims will
- be of type "instance" and have no children.
- """,
- 'conditionalVisOps' : _offForArchiveCondVis,
-})
-
-
-
-
-gb.set('usePurposeBasedMaterialBinding', 0)
-nb.setHintsForParameter('usePurposeBasedMaterialBinding', {
- 'widget' : 'boolean',
-})
-
-gb.set('additionalBindingPurposeNames', FnAttribute.StringAttribute([], 1))
-
-nb.setHintsForParameter('additionalBindingPurposeNames', {
- 'widget' : 'sortableArray',
- 'conditionalVisOp' : 'notEqualTo',
- 'conditionalVisPath' : '../usePurposeBasedMaterialBinding',
- 'conditionalVisValue' : '',
-})
-
-
-
-gb.set('prePopulate', FnAttribute.IntAttribute(1))
-nb.setHintsForParameter('prePopulate', {
- 'widget' : 'checkBox',
- 'help' : """
- Controls USD pre-population. Pre-population loads all payloads
- and pre-populates the stage. Assuming the entire stage will be
- needed, this is more efficient since USD can use its internal
- multithreading.
- """,
- 'conditionalVisOps' : _offForArchiveCondVis,
- 'constant' : True,
-
-})
-
-gb.set('verbose', 0)
-nb.setHintsForParameter('verbose', {
- 'widget' : 'checkBox',
- 'help' : 'Output info during USD scene composition and scenegraph generation.',
- 'conditionalVisOps' : _offForArchiveCondVis,
- 'constant' : True,
-})
-
-
-
-gb.set('asArchive', 0)
-nb.setHintsForParameter('asArchive', {
- 'widget' : 'checkBox',
- 'help' : """
- If enabled, the specified location will be of type "usd archive" rather
- than loaded directly into the katana scene -- optionally with a proxy.
- """,
- 'constant' : True,
-})
-
-gb.set('includeProxyForArchive', 1)
-nb.setHintsForParameter('includeProxyForArchive', {
- 'widget' : 'checkBox',
- 'help' : """
- If enabled, the specified location will be of type "usd archive" rather
- than loaded directly into the katana scene -- optionally with a proxy.
- """,
-
- 'conditionalVisOp' : 'notEqualTo',
- 'conditionalVisPath' : '../asArchive',
- 'conditionalVisValue' : '0',
-
-})
-
-
-
-nb.setParametersTemplateAttr(gb.build())
-
-#-----------------------------------------------------------------------------
-
-# Given a graphState and the current parameter values, return the opArgs to
-# PxrUsdIn. This logic was previously exclusive to buildOpChain but was
-# refactored to be callable directly -- initially in service of flushStage
-def buildPxrUsdInOpArgsAtGraphState(self, graphState):
- gb = FnAttribute.GroupBuilder()
-
- frameTime = graphState.getTime()
-
- gb.set('fileName',
- self.getParameter('fileName').getValue(frameTime))
- gb.set('location',
- self.getParameter('location').getValue(frameTime))
-
- gb.set('isolatePath',
- self.getParameter('isolatePath').getValue(frameTime))
-
- gb.set('variants',
- self.getParameter('variants').getValue(frameTime))
-
- gb.set('ignoreLayerRegex',
- self.getParameter('ignoreLayerRegex').getValue(frameTime))
-
- gb.set('motionSampleTimes',
- self.getParameter('motionSampleTimes').getValue(frameTime))
-
- gb.set('verbose',
- int(self.getParameter('verbose').getValue(frameTime)))
-
- gb.set('instanceMode',
- self.getParameter('instanceMode').getValue(frameTime))
-
- gb.set('prePopulate',
- int(self.getParameter('prePopulate').getValue(frameTime)))
-
-
- if self.getParameter('usePurposeBasedMaterialBinding').getValue(frameTime):
- purposes = ["",]
-
- for p in self.getParameter('additionalBindingPurposeNames').getChildren():
- v = p.getValue(frameTime).strip()
- if v:
- purposes.append(v)
-
- gb.set('materialBindingPurposes', FnAttribute.StringAttribute(purposes, 1))
-
-
- sessionValues = (
- graphState.getDynamicEntry("var:pxrUsdInSession"))
- if isinstance(sessionValues, FnAttribute.GroupAttribute):
- gb.set('session', sessionValues)
-
-
- gb.set('system', graphState.getOpSystemArgs())
- gb.set('processStageWideQueries', FnAttribute.IntAttribute(1))
-
- gb.set('setOpArgsToInfo', FnAttribute.IntAttribute(1))
-
-
- # check for any extra attributes or namespaces set downstream
- # via graph state
- extra = graphState.getDynamicEntry('var:usdExtraAttributesOrNamespaces')
- if extra:
- gb.set('extraAttributesOrNamespaces', extra)
-
- argsOverride = graphState.getDynamicEntry('var:pxrUsdInArgs')
- if isinstance(argsOverride, FnAttribute.GroupAttribute):
- gb.update(argsOverride)
-
- pxrUsdInArgs = gb.build()
-
- return pxrUsdInArgs
-
-nb.setCustomMethod('buildPxrUsdInOpArgsAtGraphState',
- buildPxrUsdInOpArgsAtGraphState)
-
-#-----------------------------------------------------------------------------
-
-kArgsCookTmpKeyToken = 'pxrUsdIn_argsCookTmpKey'
-
-# While it's possible to call buildPxrUsdInOpArgsAtGraphState directly, it's
-# usually more meaningful to call it with a graphState relative to a
-# downstream node as PxrUsdInVariantSelect (and its sibling) contribute to
-# the graphState and resulting opArgs. This wraps up the inconvenience of
-# tracking the graphState by injecting an extra entry into starting graphState
-# which triggers buildOpChain to record its opArgs.
-#
-# NOTE: should a better way of tracking graphState appear in a future version
-# of Katana, the implementation details here are hidden within this
-# method.
-def buildPxrUsdInOpArgsFromDownstreamNode(
- self, downstreamNode, graphState, portIndex=0):
- if not hasattr(self, '_argsCookTmp'):
- self._argsCookTmp = {}
-
- key = (FnAttribute.GroupBuilder()
- .set('graphState', graphState.getOpSystemArgs())
- .set('node', hash(downstreamNode))
- .set('portIndex', portIndex)
- .build().getHash())
-
- # Set a dynamic entry that's not prefixed with "var:" so it won't show up
- # in op system args (or other graph state comparisons other than hash
- # uniqueness)
- useGraphState = graphState.edit().setDynamicEntry(kArgsCookTmpKeyToken,
- FnAttribute.StringAttribute(key)).build()
-
- # trigger a cook with this unique graph state
- Nodes3DAPI.CreateClient(downstreamNode,
- graphState=useGraphState, portIndex=portIndex)
-
- if key in self._argsCookTmp:
- result = self._argsCookTmp[key]
- return result
- else:
- # TODO, exception?
- pass
-
-nb.setCustomMethod('buildPxrUsdInOpArgsFromDownstreamNode',
- buildPxrUsdInOpArgsFromDownstreamNode)
-
-#-----------------------------------------------------------------------------
-
-def flushStage(self, viewNode, graphState, portIndex=0):
- opArgs = self.buildPxrUsdInOpArgsFromDownstreamNode(viewNode, graphState,
- portIndex=portIndex)
-
- if isinstance(opArgs, FnAttribute.GroupAttribute):
- FnGeolibServices.AttributeFunctionUtil.Run("PxrUsdIn.FlushStage",
- opArgs)
-
-nb.setCustomMethod('flushStage', flushStage)
-
-#-----------------------------------------------------------------------------
-
-def buildOpChain(self, interface):
- interface.setMinRequiredInputs(0)
-
- frameTime = interface.getGraphState().getTime()
-
-
- # simpler case for the archive
- if self.getParameter('asArchive').getValue(frameTime):
- sscb = FnGeolibServices.OpArgsBuilders.StaticSceneCreate(True)
- location = self.getScenegraphLocation(frameTime)
- sscb.createEmptyLocation(location, 'usd archive')
-
-
- gb = FnAttribute.GroupBuilder()
-
-
- for name in ('fileName', 'isolatePath'):
- gb.set(name, interface.buildAttrFromParam(
- self.getParameter(name)))
-
- gb.set('currentTime', FnAttribute.DoubleAttribute(frameTime))
-
- attrs = gb.build()
-
- sscb.setAttrAtLocation(location, 'geometry', attrs)
-
- if self.getParameter('includeProxyForArchive').getValue(frameTime):
- sscb.addSubOpAtLocation(location,
- 'PxrUsdIn.AddViewerProxy', attrs)
-
-
- interface.appendOp('StaticSceneCreate', sscb.build())
- return
-
-
- graphState = interface.getGraphState()
- pxrUsdInArgs = self.buildPxrUsdInOpArgsAtGraphState(graphState)
-
- # When buildOpChain is reached as result of a call to
- # buildPxrUsdInOpArgsFromDownstreamNode, an additional entry will be
- # present in the graphState (otherwise not meaningful to the cooked scene).
- # If found, we'll record opArgs at the specified key in a member variable
- # dict.
- argsCookTmpKey = graphState.getDynamicEntry(kArgsCookTmpKeyToken)
- if isinstance(argsCookTmpKey, FnAttribute.StringAttribute):
- self._argsCookTmp[argsCookTmpKey.getValue('', False)] = pxrUsdInArgs
-
-
- # our primary op in the chain that will create the root location
- sscb = FnGeolibServices.OpArgsBuilders.StaticSceneCreate(True)
-
- sscb.addSubOpAtLocation(self.getScenegraphLocation(
- interface.getFrameTime()), 'PxrUsdIn', pxrUsdInArgs)
-
- sscb.setAttrAtLocation('/root', 'info.usdLoader', FnAttribute.StringAttribute('PxrUsdIn'))
-
- interface.appendOp('StaticSceneCreate', sscb.build())
-
-nb.setGetScenegraphLocationFnc(getScenegraphLocation)
-nb.setBuildOpChainFnc(buildOpChain)
-
-
-#-----------------------------------------------------------------------------
-
-# XXX prePopulate exists in some production data with an incorrect default
-# value. Assume all studio uses of it prior to this fix intend for
-# it to be enabled.
-def pxrUsdInUpgradeToVersionTwo(nodeElement):
- prePopulateElement = NodegraphAPI.Xio.Node_getParameter(
- nodeElement, 'prePopulate')
- if prePopulateElement:
- NodegraphAPI.Xio.Parameter_setValue(prePopulateElement, 1)
-
-nb.setNodeTypeVersion(2)
-nb.setNodeTypeVersionUpdateFnc(2, pxrUsdInUpgradeToVersionTwo)
-
-
-
-
-
-
-
-nb.build()
-
-
-#-----------------------------------------------------------------------------
-
-nb = Nodes3DAPI.NodeTypeBuilder('PxrUsdInVariantSelect')
-nb.setInputPortNames(("in",))
-
-nb.setParametersTemplateAttr(FnAttribute.GroupBuilder()
- .set('location', '')
- .set('args.variantSetName', '')
- .set('args.variantSelection', '')
- .set('additionalLocations', FnAttribute.StringAttribute([]))
- .build())
-
-nb.setHintsForParameter('location', {
- 'widget' : 'scenegraphLocation',
-})
-
-nb.setHintsForParameter('additionalLocations', {
- 'widget' : 'scenegraphLocationArray',
-})
-
-nb.setGenericAssignRoots('args', '__variantUI')
-
-def buildOpChain(self, interface):
- interface.setExplicitInputRequestsEnabled(True)
-
- graphState = interface.getGraphState()
-
- frameTime = interface.getFrameTime()
-
- location = self.getParameter("location").getValue(frameTime)
-
- variantSetName = ''
- if self.getParameter("args.variantSetName.enable").getValue(frameTime):
- variantSetName = self.getParameter("args.variantSetName.value").getValue(
- frameTime)
-
-
- variantSelection = None
- if self.getParameter("args.variantSelection.enable").getValue(frameTime):
- variantSelection = self.getParameter(
- "args.variantSelection.value").getValue(frameTime)
-
- if location and variantSetName and variantSelection is not None:
- entryName = FnAttribute.DelimiterEncode(location)
- entryPath = "variants." + entryName + "." + variantSetName
-
- valueAttr = FnAttribute.StringAttribute(variantSelection)
- gb = FnAttribute.GroupBuilder()
- gb.set(entryPath, valueAttr)
-
- for addLocParam in self.getParameter(
- 'additionalLocations').getChildren():
- location = addLocParam.getValue(frameTime)
- if location:
- entryName = FnAttribute.DelimiterEncode(location)
- entryPath = "variants." + entryName + "." + variantSetName
- gb.set(entryPath, valueAttr)
-
-
- existingValue = (
- interface.getGraphState().getDynamicEntry("var:pxrUsdInSession"))
-
- if isinstance(existingValue, FnAttribute.GroupAttribute):
- gb.deepUpdate(existingValue)
-
- graphState = (graphState.edit()
- .setDynamicEntry("var:pxrUsdInSession", gb.build())
- .build())
-
-
- interface.addInputRequest("in", graphState)
-
-nb.setBuildOpChainFnc(buildOpChain)
-
-def getScenegraphLocation(self, frameTime):
- location = self.getParameter('location').getValue(frameTime)
- if not (location == '/root' or location.startswith('/root/')):
- location = '/root'
- return location
-
-nb.setGetScenegraphLocationFnc(getScenegraphLocation)
-
-
-def appendToParametersOpChain(self, interface):
- frameTime = interface.getFrameTime()
-
- location = self.getScenegraphLocation(frameTime)
- variantSetName = ''
- if self.getParameter('args.variantSetName.enable').getValue(frameTime):
- variantSetName = self.getParameter(
- 'args.variantSetName.value').getValue(frameTime)
-
- # This makes use of the attrs recognized by PxrUsdInUtilExtraHintsDap
- # to provide the hinting from incoming attr values.
- uiscript = '''
- local variantSetName = Interface.GetOpArg('user.variantSetName'):getValue()
-
- local variantsGroup = (Interface.GetAttr('info.usd.variants') or
- GroupAttribute())
-
- local variantSetNames = {}
- for i = 0, variantsGroup:getNumberOfChildren() - 1 do
- variantSetNames[#variantSetNames + 1] = variantsGroup:getChildName(i)
- end
-
- Interface.SetAttr("__pxrUsdInExtraHints." ..
- Attribute.DelimiterEncode("__variantUI.variantSetName"),
- GroupBuilder()
- :set('widget', StringAttribute('popup'))
- :set('options', StringAttribute(variantSetNames))
- :set('editable', IntAttribute(1))
- :build())
-
- local variantOptions = {}
-
- if variantSetName ~= '' then
- local variantOptionsAttr =
- variantsGroup:getChildByName(variantSetName)
- if Attribute.IsString(variantOptionsAttr) then
- variantOptions = variantOptionsAttr:getNearestSample(0.0)
- end
- end
-
- Interface.SetAttr("__pxrUsdInExtraHints." ..
- Attribute.DelimiterEncode("__variantUI.variantSelection"),
- GroupBuilder()
- :set('widget', StringAttribute('popup'))
- :set('options', StringAttribute(variantOptions))
- :set('editable', IntAttribute(1))
- :build())
- '''
-
- sscb = FnGeolibServices.OpArgsBuilders.StaticSceneCreate(True)
-
- sscb.addSubOpAtLocation(location, 'OpScript.Lua',
- FnAttribute.GroupBuilder()
- .set('script', uiscript)
- .set('user.variantSetName', variantSetName)
- .build())
-
- interface.appendOp('StaticSceneCreate', sscb.build())
-
-
-nb.setAppendToParametersOpChainFnc(appendToParametersOpChain)
-
-nb.build()
-
-#-----------------------------------------------------------------------------
-
-nb = Nodes3DAPI.NodeTypeBuilder('PxrUsdInDefaultMotionSamples')
-nb.setInputPortNames(("in",))
-
-nb.setParametersTemplateAttr(FnAttribute.GroupBuilder()
- .set('locations', '')
- .build(),
- forceArrayNames=('locations',))
-
-nb.setHintsForParameter('locations', {
- 'widget' : 'scenegraphLocationArray',
- 'help' : 'Hierarchy root location paths for which to use default motion sample times.'
-})
-
-def buildOpChain(self, interface):
- interface.setExplicitInputRequestsEnabled(True)
-
- graphState = interface.getGraphState()
- frameTime = interface.getFrameTime()
- locations = self.getParameter("locations")
-
- if locations:
- gb = FnAttribute.GroupBuilder()
-
- for loc in locations.getChildren():
- gb.set("overrides." + FnAttribute.DelimiterEncode(
- loc.getValue(frameTime)) + ".motionSampleTimes",
- FnAttribute.IntAttribute(1))
-
- existingValue = (
- interface.getGraphState().getDynamicEntry("var:pxrUsdInSession"))
-
- if isinstance(existingValue, FnAttribute.GroupAttribute):
- gb.deepUpdate(existingValue)
-
- graphState = (graphState.edit()
- .setDynamicEntry("var:pxrUsdInSession", gb.build())
- .build())
-
- interface.addInputRequest("in", graphState)
-
-nb.setBuildOpChainFnc(buildOpChain)
-
-nb.build()
-
-#-----------------------------------------------------------------------------
-
-nb = Nodes3DAPI.NodeTypeBuilder('PxrUsdInMotionOverrides')
-nb.setInputPortNames(('in',))
-
-nb.setParametersTemplateAttr(FnAttribute.GroupBuilder()
- .set('locations', '')
- .set('overrides.motionSampleTimes', '')
- .set('overrides.currentTime', '')
- .set('overrides.shutterOpen', '')
- .set('overrides.shutterClose', '')
- .build(),
- forceArrayNames=('locations',))
-
-nb.setHintsForParameter('locations', {
- 'widget': 'scenegraphLocationArray',
- 'help': 'Hierarchy root location paths for which overrides will be applied.'
-})
-
-nb.setHintsForParameter('overrides', {
- 'help': 'Any non-empty overrides will be used for motion calculations.',
- 'open': True,
-})
-
-def buildOpChain(self, interface):
- interface.setExplicitInputRequestsEnabled(True)
-
- graphState = interface.getGraphState()
- frameTime = interface.getFrameTime()
-
- locations = self.getParameter('locations')
- overrides = self.getParameter('overrides')
-
- if locations.getNumChildren() > 0:
-
- # Build overrides as a child group
- gb1 = FnAttribute.GroupBuilder()
-
- motionSampleTimes = overrides.getChild('motionSampleTimes').getValue(frameTime)
- currentTime = overrides.getChild('currentTime').getValue(frameTime)
- shutterOpen = overrides.getChild('shutterOpen').getValue(frameTime)
- shutterClose = overrides.getChild('shutterClose').getValue(frameTime)
-
- if motionSampleTimes:
- floatTimes = [float(t) for t in motionSampleTimes.split(' ')]
- gb1.set('motionSampleTimes', FnAttribute.FloatAttribute(floatTimes))
-
- if currentTime:
- gb1.set('currentTime', FnAttribute.FloatAttribute(float(currentTime)))
-
- if shutterOpen:
- gb1.set('shutterOpen', FnAttribute.FloatAttribute(float(shutterOpen)))
-
- if shutterClose:
- gb1.set('shutterClose', FnAttribute.FloatAttribute(float(shutterClose)))
-
- overridesAttr = gb1.build()
-
- if overridesAttr.getNumberOfChildren() > 0:
-
- # Encode per-location overrides in the graph state
- gb2 = FnAttribute.GroupBuilder()
-
- for loc in locations.getChildren():
- encodedLoc = FnAttribute.DelimiterEncode(loc.getValue(frameTime))
- if encodedLoc:
- gb2.set('overrides.' + encodedLoc, overridesAttr)
-
- existingValue = (
- interface.getGraphState().getDynamicEntry('var:pxrUsdInSession'))
- if isinstance(existingValue, FnAttribute.GroupAttribute):
- gb2.deepUpdate(existingValue)
-
- graphState = (graphState.edit()
- .setDynamicEntry('var:pxrUsdInSession', gb2.build())
- .build())
-
- interface.addInputRequest('in', graphState)
-
-nb.setBuildOpChainFnc(buildOpChain)
-
-nb.build()
-
-#-----------------------------------------------------------------------------
-
-nb = Nodes3DAPI.NodeTypeBuilder('PxrUsdInActivationSet')
-nb.setInputPortNames(("in",))
-
-nb.setParametersTemplateAttr(FnAttribute.GroupBuilder()
- .set('locations', '')
- .set('active', 0)
- .build(),
- forceArrayNames=('locations',))
-
-nb.setHintsForParameter('locations', {
- 'widget' : 'scenegraphLocationArray',
- 'help' : 'locations to activate or deactivate.'
-})
-
-nb.setHintsForParameter('active', {
- 'widget' : 'boolean',
-})
-
-def buildOpChain(self, interface):
- interface.setExplicitInputRequestsEnabled(True)
-
- graphState = interface.getGraphState()
- frameTime = interface.getFrameTime()
- locations = self.getParameter("locations")
-
- if locations:
- state = FnAttribute.IntAttribute(
- bool(self.getParameter("active").getValue(frameTime)))
-
- gb = FnAttribute.GroupBuilder()
-
- for loc in locations.getChildren():
- gb.set("activations." + FnAttribute.DelimiterEncode(
- loc.getValue(frameTime)), state)
-
- existingValue = (
- interface.getGraphState().getDynamicEntry("var:pxrUsdInSession"))
-
- if isinstance(existingValue, FnAttribute.GroupAttribute):
- gb.deepUpdate(existingValue)
-
- graphState = (graphState.edit()
- .setDynamicEntry("var:pxrUsdInSession", gb.build())
- .build())
-
- interface.addInputRequest("in", graphState)
-
-nb.setBuildOpChainFnc(buildOpChain)
-
-nb.build()
-
-
-#-----------------------------------------------------------------------------
-
-nb = Nodes3DAPI.NodeTypeBuilder('PxrUsdInAttributeSet')
-
-nb.setInputPortNames(("in",))
-
-nb.setParametersTemplateAttr(FnAttribute.GroupBuilder()
- .set('locations', '')
- .set('attrName', 'attr')
- .set('type', 'float')
-
- .set('asMetadata', 0)
- .set('listOpType', 'explicit')
-
- .set('numberValue', 1.0)
- .set('stringValue', '')
-
- .set('forceArrayForSingleValue', 0)
-
- .build(),
- forceArrayNames=(
- 'locations',
- 'numberValue',
- 'stringValue'))
-
-nb.setHintsForParameter('locations', {
- 'widget' : 'scenegraphLocationArray',
- 'help' : 'locations on which to set.'
-})
-
-nb.setHintsForParameter('type', {
- 'widget' : 'popup',
- 'options' : ['int', 'float', 'double', 'string', 'listOp',],
-})
-
-nb.setHintsForParameter('asMetadata', {
- 'widget' : 'boolean',
-})
-
-nb.setHintsForParameter('forceArrayForSingleValue', {
- 'widget' : 'boolean',
-})
-
-nb.setHintsForParameter('listOpType', {
- 'widget' : 'popup',
- 'options' : [
- 'explicit',
- 'added',
- 'deleted',
- 'ordered',
- 'prepended',
- 'appended'],
- 'conditionalVisOp' : 'equalTo',
- 'conditionalVisPath' : '../type',
- 'conditionalVisValue' : 'listOp',
-})
-
-nb.setHintsForParameter('numberValue', {
- 'widget' : 'sortableArray',
- 'conditionalVisOp' : 'notEqualTo',
- 'conditionalVisPath' : '../type',
- 'conditionalVisValue' : 'string',
-})
-
-nb.setHintsForParameter('stringValue', {
- 'widget' : 'sortableArray',
- 'conditionalVisOp' : 'equalTo',
- 'conditionalVisPath' : '../type',
- 'conditionalVisValue' : 'string',
-})
-
-__numberAttrTypes = {
- 'int' : FnAttribute.IntAttribute,
- 'float' : FnAttribute.FloatAttribute,
- 'double': FnAttribute.DoubleAttribute,
- 'listOp': FnAttribute.IntAttribute,
-}
-
-def buildOpChain(self, interface):
- interface.setExplicitInputRequestsEnabled(True)
-
- graphState = interface.getGraphState()
- frameTime = interface.getFrameTime()
- locationsParam = self.getParameter("locations")
-
- attrName = self.getParameter('attrName').getValue(
- frameTime).replace('.', ':')
-
- locations = [y for y in
- (x.getValue(frameTime) for x in locationsParam.getChildren()) if y]
-
- if attrName and locations:
- typeValue = self.getParameter('type').getValue(frameTime)
- if typeValue == 'string':
- valueAttr = interface.buildAttrFromParam(
- self.getParameter('stringValue'))
- else:
- valueAttr = interface.buildAttrFromParam(
- self.getParameter('numberValue'),
- numberType=__numberAttrTypes.get(typeValue,
- FnAttribute.FloatAttribute))
-
-
-
-
- if typeValue == 'listOp':
- entryGb = FnAttribute.GroupBuilder()
- entryGb.set('type', 'SdfInt64ListOp')
- entryGb.set('listOp.%s' % self.getParameter(
- 'listOpType').getValue(frameTime), valueAttr)
-
- entryGroup = entryGb.build()
- else:
- entryGb = FnAttribute.GroupBuilder()
- entryGb.set('value', valueAttr)
-
- if valueAttr.getNumberOfValues() == 1:
- if self.getParameter('forceArrayForSingleValue'
- ).getValue(frameTime):
- entryGb.set('forceArray', 1)
-
- entryGroup = entryGb.build()
-
- gb = FnAttribute.GroupBuilder()
-
- asMetadata = (typeValue == 'listOp'
- or self.getParameter('asMetadata').getValue(frameTime) != 0)
-
- for loc in locations:
-
- if asMetadata:
-
- if typeValue == 'listOp':
- gb.set("metadata.%s.prim.%s" % (
- FnAttribute.DelimiterEncode(loc), attrName,),
- entryGroup)
-
-
- # TODO, only listOps are supported at the moment.
-
- else:
- gb.set("attrs.%s.%s" % (
- FnAttribute.DelimiterEncode(loc), attrName,),
- entryGroup)
-
- existingValue = (
- interface.getGraphState().getDynamicEntry("var:pxrUsdInSession"))
-
- if isinstance(existingValue, FnAttribute.GroupAttribute):
- gb.deepUpdate(existingValue)
-
- graphState = (graphState.edit()
- .setDynamicEntry("var:pxrUsdInSession", gb.build())
- .build())
-
- interface.addInputRequest("in", graphState)
-
-nb.setBuildOpChainFnc(buildOpChain)
-
-nb.build()
-
-#-----------------------------------------------------------------------------
-
-nb = Nodes3DAPI.NodeTypeBuilder('PxrUsdInIsolate')
-
-nb.setInputPortNames(("in",))
-
-
-nb.setParametersTemplateAttr(FnAttribute.GroupBuilder()
- .set('locations', '')
- .set('mode', 'append')
- .build(),
- forceArrayNames=(
- 'locations',
- ))
-
-nb.setHintsForParameter('locations', {
- 'widget' : 'scenegraphLocationArray',
-})
-
-nb.setHintsForParameter('mode', {
- 'widget' : 'popup',
- 'options' : ['append', 'replace'],
-})
-
-
-def buildOpChain(self, interface):
- interface.setExplicitInputRequestsEnabled(True)
-
- graphState = interface.getGraphState()
- frameTime = interface.getFrameTime()
- locationsParam = self.getParameter("locations")
-
- locations = [y for y in
- (x.getValue(frameTime) for x in locationsParam.getChildren()) if y]
-
- if locations:
- existingValue = (
- graphState.getDynamicEntry("var:pxrUsdInSession")
- or FnAttribute.GroupAttribute())
-
- # later nodes set to 'replace' win out
- maskIsFinal = existingValue.getChildByName('maskIsFinal')
- if not maskIsFinal:
-
- gb = FnAttribute.GroupBuilder()
-
- gb.update(existingValue)
-
- mode = self.getParameter('mode').getValue(frameTime)
-
- if mode == 'replace':
- gb.set('mask', FnAttribute.StringAttribute(locations))
- gb.set('maskIsFinal', 1)
- else:
- existingLocationsAttr = existingValue.getChildByName('mask')
- if isinstance(existingLocationsAttr, FnAttribute.StringAttribute):
- locations.extend(existingLocationsAttr.getNearestSample(0))
-
- gb.set('mask', FnAttribute.StringAttribute(locations))
-
- graphState = (graphState.edit()
- .setDynamicEntry("var:pxrUsdInSession", gb.build())
- .build())
-
- interface.addInputRequest("in", graphState)
-
-nb.setBuildOpChainFnc(buildOpChain)
-
-nb.build()
-
-#-----------------------------------------------------------------------------
-
-nb = Nodes3DAPI.NodeTypeBuilder('PxrUsdInResolveMaterialBindings')
-
-nb.setInputPortNames(("in",))
-
-nb.setParametersTemplateAttr(FnAttribute.GroupBuilder()
- .set('purpose', '')
- .set('omitIfParentValueMatches', 0)
- .build())
-
-nb.setHintsForParameter('purpose', {
- 'help' : """
- The name of the purpose from which to tranfer material bindings to the
- "materialAssign" attribute. An empty value is treated as "allPurpose". The
- sources of these values are within the "usd.materialBindings.*" attribute
- -- which will be present if "usePurposeBasedMaterialBinding" is enabled
- on the upstream PxrUsdIn.
- """,
-})
-
-nb.setHintsForParameter('omitIfParentValueMatches', {
- 'widget' : 'boolean',
- 'help' : """If enabled, bindings will be omitted if they are identical
- to that of their parent. This is useful because collection-based bindings
- in USD default to apply to all prims at and under the specified paths"
- """,
-})
-
-def buildOpChain(self, interface):
- interface.appendOp("PxrUsdInResolveMaterialBindings",
- FnAttribute.GroupBuilder()
- .set("purpose", interface.buildAttrFromParam(
- self.getParameter('purpose')))
- .set("omitIfParentValueMatches", interface.buildAttrFromParam(
- self.getParameter('omitIfParentValueMatches'),
- numberType=FnAttribute.IntAttribute))
- .build())
-
-nb.setBuildOpChainFnc(buildOpChain)
-nb.build()
diff --git a/third_party/katana/usdKatana/CMakeLists.txt b/third_party/katana/usdKatana/CMakeLists.txt
deleted file mode 100644
index baf74979a4..0000000000
--- a/third_party/katana/usdKatana/CMakeLists.txt
+++ /dev/null
@@ -1,84 +0,0 @@
-set(PXR_PACKAGE usdKatana)
-
-set(vtKatana_LIBRARY "")
-if (NOT ${KATANA_API_VERSION} VERSION_LESS "3.0.0")
- set(vtKatana_LIBRARY "vtKatana")
-endif()
-
-pxr_shared_library(${PXR_PACKAGE}
- LIBRARIES
- plug
- gf
- tf
- trace
- vt
- ar
- sdf
- usd
- usdHydra
- usdImaging
- usdImagingGL
- usdShade
- usdSkel
- usdGeom
- usdLux
- usdRi
- usdUI
- usdUtils
- cameraUtil
- hio
- glf
- katanaAttrfncApi
- ${vtKatana_LIBRARY}
- ${Boost_THREAD_LIBRARY}
-
- PUBLIC_CLASSES
- attrMap
- baseMaterialHelpers
- blindDataObject
- cache
- debugCodes
- locks
- tokens
- lookAPI
- utils
-
- usdInArgs
- usdInPrivateData
- usdInPluginRegistry
-
- readBasisCurves
- readBlindData
- readCamera
- readConstraintTarget
- readGprim
- readGeomSubset
- readLight
- readLightFilter
- readMaterial
- readMesh
- readModel
- readNurbsPatch
- readPointInstancer
- readPoints
- readPrim
- readXformable
-
- PUBLIC_HEADERS
- api.h
-
- PYMODULE_CPPFILES
- wrapBlindDataObject.cpp
- wrapCache.cpp
- wrapLookAPI.cpp
- module.cpp
-
- PYMODULE_FILES
- __init__.py
-
- RESOURCE_FILES
- plugInfo.json
- generatedSchema.usda
- schema.usda:usdKatana/schema.usda
-)
-
diff --git a/third_party/katana/usdKatana/__init__.py b/third_party/katana/usdKatana/__init__.py
deleted file mode 100644
index 40a8bd0e3c..0000000000
--- a/third_party/katana/usdKatana/__init__.py
+++ /dev/null
@@ -1,43 +0,0 @@
-#
-# Copyright 2016 Pixar
-#
-# Licensed under the Apache License, Version 2.0 (the "Apache License")
-# with the following modification; you may not use this file except in
-# compliance with the Apache License and the following modification to it:
-# Section 6. Trademarks. is deleted and replaced with:
-#
-# 6. Trademarks. This License does not grant permission to use the trade
-# names, trademarks, service marks, or product names of the Licensor
-# and its affiliates, except as required to comply with Section 4(c) of
-# the License and to reproduce the content of the NOTICE file.
-#
-# You may obtain a copy of the Apache License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the Apache License with the above modification is
-# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the Apache License for the specific
-# language governing permissions and limitations under the Apache License.
-#
-
-import _usdKatana
-from pxr import Tf
-Tf.PrepareModule(_usdKatana, locals())
-del Tf
-
-#Tf.PrepareModule(_usdKatana, locals())
-#Tf.PrepareModule(_usdKatana, locals())
-#del Tf
-
-# from tokens import TokensClass
-# Tokens = TokensClass()
-# del tokens, TokensClass
-
-try:
- import __DOC
- __DOC.Execute(locals())
- del __DOC
-except Exception:
- pass
diff --git a/third_party/katana/usdKatana/api.h b/third_party/katana/usdKatana/api.h
deleted file mode 100644
index 8ee25a4b96..0000000000
--- a/third_party/katana/usdKatana/api.h
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-// Copyright 2017 Pixar
-//
-// Licensed under the Apache License, Version 2.0 (the "Apache License")
-// with the following modification; you may not use this file except in
-// compliance with the Apache License and the following modification to it:
-// Section 6. Trademarks. is deleted and replaced with:
-//
-// 6. Trademarks. This License does not grant permission to use the trade
-// names, trademarks, service marks, or product names of the Licensor
-// and its affiliates, except as required to comply with Section 4(c) of
-// the License and to reproduce the content of the NOTICE file.
-//
-// You may obtain a copy of the Apache License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the Apache License with the above modification is
-// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the Apache License for the specific
-// language governing permissions and limitations under the Apache License.
-//
-#ifndef USDKATANA_API_H
-#define USDKATANA_API_H
-
-#include "pxr/base/arch/export.h"
-
-#if defined(PXR_STATIC)
-# define USDKATANA_API
-# define USDKATANA_API_TEMPLATE_CLASS(...)
-# define USDKATANA_API_TEMPLATE_STRUCT(...)
-# define USDKATANA_LOCAL
-#else
-# if defined(USDKATANA_EXPORTS)
-# define USDKATANA_API ARCH_EXPORT
-# define USDKATANA_API_TEMPLATE_CLASS(...) ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__)
-# define USDKATANA_API_TEMPLATE_STRUCT(...) ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__)
-# else
-# define USDKATANA_API ARCH_IMPORT
-# define USDKATANA_API_TEMPLATE_CLASS(...) ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__)
-# define USDKATANA_API_TEMPLATE_STRUCT(...) ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__)
-# endif
-# define USDKATANA_LOCAL ARCH_HIDDEN
-#endif
-
-#endif
diff --git a/third_party/katana/usdKatana/attrMap.cpp b/third_party/katana/usdKatana/attrMap.cpp
deleted file mode 100644
index f4a14e31d6..0000000000
--- a/third_party/katana/usdKatana/attrMap.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-//
-// Copyright 2016 Pixar
-//
-// Licensed under the Apache License, Version 2.0 (the "Apache License")
-// with the following modification; you may not use this file except in
-// compliance with the Apache License and the following modification to it:
-// Section 6. Trademarks. is deleted and replaced with:
-//
-// 6. Trademarks. This License does not grant permission to use the trade
-// names, trademarks, service marks, or product names of the Licensor
-// and its affiliates, except as required to comply with Section 4(c) of
-// the License and to reproduce the content of the NOTICE file.
-//
-// You may obtain a copy of the Apache License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the Apache License with the above modification is
-// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the Apache License for the specific
-// language governing permissions and limitations under the Apache License.
-//
-#include "pxr/pxr.h"
-#include "usdKatana/attrMap.h"
-#include "usdKatana/utils.h"
-
-PXR_NAMESPACE_OPEN_SCOPE
-
-
-void
-PxrUsdKatanaAttrMap::set(
- const std::string& path,
- const Foundry::Katana::Attribute& attr)
-{
- // on mutation, seed the groupBuilder with the lastBuild value and clear
- if (_lastBuilt.isValid())
- {
- _groupBuilder.update(_lastBuilt);
- _lastBuilt = Foundry::Katana::GroupAttribute();
- }
-
- _groupBuilder.set(path, attr);
-}
-
-PxrUsdKatanaAttrMap&
-PxrUsdKatanaAttrMap::Set(
- const std::string& path,
- const UsdAttribute& attr)
-{
- VtValue val;
- if (attr.HasAuthoredValue() && attr.Get(&val, _usdTimeCode)) {
- FnKat::Attribute kat_attr =
- PxrUsdKatanaUtils::ConvertVtValueToKatAttr(val);
- _groupBuilder.set(path, kat_attr);
- }
- return *this;
-}
-
-void
-PxrUsdKatanaAttrMap::del(const std::string& path)
-{
- // on mutation, seed the groupBuilder with the lastBuild value and clear
- if (_lastBuilt.isValid())
- {
- _groupBuilder.update(_lastBuilt);
- _lastBuilt = Foundry::Katana::GroupAttribute();
- }
-
- _groupBuilder.del(path);
-}
-
-FnAttribute::GroupAttribute
-PxrUsdKatanaAttrMap::build()
-{
- if (_lastBuilt.isValid())
- {
- return _lastBuilt;
- }
-
- _lastBuilt = _groupBuilder.build();
- return _lastBuilt;
-}
-
-void
-PxrUsdKatanaAttrMap::toInterface(FnKat::GeolibCookInterface& interface)
-{
- FnAttribute::GroupAttribute groupAttr = build();
- size_t numChildren = groupAttr.getNumberOfChildren();
- for (size_t i = 0; i < numChildren; i++)
- {
- const std::string childName = groupAttr.getChildName(i);
- const FnKat::Attribute childAttr = groupAttr.getChildByIndex(i);
-
- if (childAttr.getType() == kFnKatAttributeTypeGroup)
- {
- FnAttribute::GroupAttribute existingAttr = interface.getOutputAttr(childName);
- if (existingAttr.isValid())
- {
- // If we are setting a group attribute and an existing
- // group attribute exists, merge them.
- interface.setAttr(childName,
- FnAttribute::GroupBuilder()
- .update(existingAttr)
- .deepUpdate(childAttr)
- .build());
- }
- else
- {
- interface.setAttr(childName, childAttr);
- }
- }
- else
- {
- interface.setAttr(childName, childAttr);
- }
- }
-}
-
-bool PxrUsdKatanaAttrMap::isBuilt()
-{
- return _lastBuilt.isValid();
-}
-
-PXR_NAMESPACE_CLOSE_SCOPE
-
diff --git a/third_party/katana/usdKatana/attrMap.h b/third_party/katana/usdKatana/attrMap.h
deleted file mode 100644
index 1bea571d31..0000000000
--- a/third_party/katana/usdKatana/attrMap.h
+++ /dev/null
@@ -1,100 +0,0 @@
-//
-// Copyright 2016 Pixar
-//
-// Licensed under the Apache License, Version 2.0 (the "Apache License")
-// with the following modification; you may not use this file except in
-// compliance with the Apache License and the following modification to it:
-// Section 6. Trademarks. is deleted and replaced with:
-//
-// 6. Trademarks. This License does not grant permission to use the trade
-// names, trademarks, service marks, or product names of the Licensor
-// and its affiliates, except as required to comply with Section 4(c) of
-// the License and to reproduce the content of the NOTICE file.
-//
-// You may obtain a copy of the Apache License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the Apache License with the above modification is
-// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the Apache License for the specific
-// language governing permissions and limitations under the Apache License.
-//
-#ifndef USD_KATANA_ATTR_MAP_H
-#define USD_KATANA_ATTR_MAP_H
-
-#include "pxr/pxr.h"
-#include
-#include
-#include "pxr/usd/usd/attribute.h"
-
-#include
-
-PXR_NAMESPACE_OPEN_SCOPE
-
-
-/// \brief An object to store attributes. The current implementation uses
-/// a Foundry::Katana::GroupBuilder behind the scenes, but the dependence on
-/// that thus far is somewhat minimal and not all of the behavior of
-/// GroupBuilder has been exposed.
-///
-/// This class is here in case we need to have different behavior than the
-/// GroupBuilder.
-class PxrUsdKatanaAttrMap
-{
-public:
- /// Configure this object to evaluate USD attributes at the given time.
- void SetUSDTimeCode(UsdTimeCode timeCode) {
- _usdTimeCode = timeCode;
- }
-
- /// Set the katana attribute \p path by evaluating the given
- /// USD attribute \p attr at the time configured in SetUSDTime().
- /// Returns this object by reference so these calls can be chained.
- PxrUsdKatanaAttrMap& Set(const std::string& path, const UsdAttribute& attr);
-
- /// \brief set \p attr at \p path.
- void set(const std::string& path, const Foundry::Katana::Attribute& attr);
-
- /// \brief delete attribute at \p path
- void del(const std::string& path);
-
- /// \brief build a group attribute
- FnAttribute::GroupAttribute build();
-
- /// \brief sets attrs in \p attrs onto the \p interface.
- void toInterface(Foundry::Katana::GeolibCookInterface& interface);
-
-
- /// \brief returns true if a call to build has been made prior to any
- /// subsequent calls to set or del.
- bool isBuilt();
-
-
- typedef boost::upgrade_mutex Mutex;
- /// \brief while no locking occurs internal to this class, calling code
- /// may wish to manage read/write locks per-instance.
- Mutex & getInstanceMutex() { return m_mutex; }
-
-private:
-
- Foundry::Katana::GroupBuilder _groupBuilder;
-
- // Cache the last call to _groupBuilder.build() so that instances can be
- // reused (as GroupBuilder clears itself by default)
- Foundry::Katana::GroupAttribute _lastBuilt;
-
-
- // Timecode to use when reading USD samples
- UsdTimeCode _usdTimeCode;
-
- // per-instance mutex available for external use.
- Mutex m_mutex;
-
-};
-
-
-PXR_NAMESPACE_CLOSE_SCOPE
-
-#endif // USD_KATANA_ATTR_MAP_H
diff --git a/third_party/katana/usdKatana/baseMaterialHelpers.cpp b/third_party/katana/usdKatana/baseMaterialHelpers.cpp
deleted file mode 100644
index 39ec2499d3..0000000000
--- a/third_party/katana/usdKatana/baseMaterialHelpers.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-//
-// Copyright 2016 Pixar
-//
-// Licensed under the Apache License, Version 2.0 (the "Apache License")
-// with the following modification; you may not use this file except in
-// compliance with the Apache License and the following modification to it:
-// Section 6. Trademarks. is deleted and replaced with:
-//
-// 6. Trademarks. This License does not grant permission to use the trade
-// names, trademarks, service marks, or product names of the Licensor
-// and its affiliates, except as required to comply with Section 4(c) of
-// the License and to reproduce the content of the NOTICE file.
-//
-// You may obtain a copy of the Apache License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the Apache License with the above modification is
-// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the Apache License for the specific
-// language governing permissions and limitations under the Apache License.
-//
-#include "pxr/pxr.h"
-#include "usdKatana/baseMaterialHelpers.h"
-#include "pxr/usd/pcp/layerStack.h"
-#include "pxr/usd/pcp/node.h"
-#include "pxr/usd/pcp/primIndex.h"
-#include "pxr/usd/usd/prim.h"
-#include "pxr/usd/usd/attribute.h"
-#include "pxr/usd/usd/relationship.h"
-#include "pxr/usd/sdf/relationshipSpec.h"
-
-PXR_NAMESPACE_OPEN_SCOPE
-
-
-static bool
-_NodeRepresentsDirectReference(const PcpNodeRef &node)
-{
- for (PcpNodeRef n = node;
- n; // 0, or false, means we are at the root node
- n = n.GetParentNode()) {
- if (n.GetArcType() == PcpArcTypeReference) {
- if (! n.IsDueToAncestor()) {
- // direct reference!
- return true;
- }
- }
- }
- return false;
-}
-
-
-// This tests if a given node represents a "live" base material,
-// i.e. once that hasn't been "flattened out" due to being
-// pulled across a reference to a library.
-static bool
-_NodeRepresentsLiveBaseMaterial(const PcpNodeRef &node)
-{
- bool isLiveBaseMaterial = false;
- for (PcpNodeRef n = node;
- n; // 0, or false, means we are at the root node
- n = n.GetOriginNode()) {
- switch(n.GetArcType()) {
- case PcpArcTypeSpecialize:
- isLiveBaseMaterial = true;
- break;
- // dakrunch: specializes across references are actually still valid.
- //
- // case PcpArcTypeReference:
- // if (isLiveBaseMaterial) {
- // // Node is within a base material, but that is in turn
- // // across a reference. That means this is a library
- // // material, so it is not live and we should flatten it
- // // out. Continue iterating, however, since this
- // // might be referenced into some other live base material
- // // downstream.
- // isLiveBaseMaterial = false;
- // }
- // break;
- default:
- break;
- }
- }
- return isLiveBaseMaterial;
-}
-
-
-bool
-PxrUsdKatana_IsAttrValFromDirectReference(const UsdAttribute &attr)
-{
- return _NodeRepresentsDirectReference( attr.GetResolveInfo().GetNode() );
-}
-
-
-bool
-PxrUsdKatana_IsAttrValFromBaseMaterial(const UsdAttribute &attr)
-{
- return _NodeRepresentsLiveBaseMaterial( attr.GetResolveInfo().GetNode() );
-}
-
-bool
-PxrUsdKatana_IsPrimDefFromBaseMaterial(const UsdPrim &prim)
-{
- for(const PcpNodeRef &n: prim.GetPrimIndex().GetNodeRange()) {
- for (const SdfLayerRefPtr &l: n.GetLayerStack()->GetLayers()) {
- if (SdfPrimSpecHandle p = l->GetPrimAtPath(n.GetPath())) {
- if (SdfIsDefiningSpecifier(p->GetSpecifier())) {
- return _NodeRepresentsLiveBaseMaterial(n);
- }
- }
- }
- }
- return false;
-}
-
-bool
-PxrUsdKatana_AreRelTargetsFromBaseMaterial(const UsdRelationship &rel)
-{
- // Find the strongest opinion about the relationship targets.
- SdfRelationshipSpecHandle strongestRelSpec;
- SdfPropertySpecHandleVector propStack = rel.GetPropertyStack();
- for (const SdfPropertySpecHandle &prop: propStack) {
- if (SdfRelationshipSpecHandle relSpec =
- TfDynamic_cast(prop)) {
- if (relSpec->HasTargetPathList()) {
- strongestRelSpec = relSpec;
- break;
- }
- }
- }
- // Find which prim node introduced that opinion.
- if (strongestRelSpec) {
- for(const PcpNodeRef &node:
- rel.GetPrim().GetPrimIndex().GetNodeRange()) {
- if (node.GetPath() == strongestRelSpec->GetPath().GetPrimPath() &&
- node.GetLayerStack()->HasLayer(strongestRelSpec->GetLayer())) {
- return _NodeRepresentsLiveBaseMaterial(node);
- }
- }
- }
- return false;
-}
-
-PXR_NAMESPACE_CLOSE_SCOPE
-
diff --git a/third_party/katana/usdKatana/baseMaterialHelpers.h b/third_party/katana/usdKatana/baseMaterialHelpers.h
deleted file mode 100644
index 1b0e9110c2..0000000000
--- a/third_party/katana/usdKatana/baseMaterialHelpers.h
+++ /dev/null
@@ -1,69 +0,0 @@
-//
-// Copyright 2016 Pixar
-//
-// Licensed under the Apache License, Version 2.0 (the "Apache License")
-// with the following modification; you may not use this file except in
-// compliance with the Apache License and the following modification to it:
-// Section 6. Trademarks. is deleted and replaced with:
-//
-// 6. Trademarks. This License does not grant permission to use the trade
-// names, trademarks, service marks, or product names of the Licensor
-// and its affiliates, except as required to comply with Section 4(c) of
-// the License and to reproduce the content of the NOTICE file.
-//
-// You may obtain a copy of the Apache License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the Apache License with the above modification is
-// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the Apache License for the specific
-// language governing permissions and limitations under the Apache License.
-//
-#ifndef USD_KATANA_BASE_MATERIAL_HELPERS_H
-#define USD_KATANA_BASE_MATERIAL_HELPERS_H
-
-#include "pxr/pxr.h"
-
-PXR_NAMESPACE_OPEN_SCOPE
-
-class UsdAttribute;
-class UsdPrim;
-class UsdRelationship;
-
-// Methods for analyzing base/derived material structure
-//
-// XXX What we're trying to do here has been described as "partial
-// composition" -- in the sense that we are trying to resolve
-// attributes and relationships in a way that temporarily
-// mutes any contributions from specialized classes, so that
-// we can represent the specializes hierarchy in a way that
-// exercises katana's namespace-style inheritance.
-//
-// It seems likely that with more time/experience, we may
-// want to move some of this either into UsdShade API, or
-// directly into Usd in some form. Consider this a first
-// step to demonstrate that we have the functional pieces
-// of a solution, leaving open the question of ideal API
-// for this sort of thing.
-
-// Check if this attribute resolves from across a direct reference arc.
-bool PxrUsdKatana_IsAttrValFromDirectReference(const UsdAttribute &attr);
-
-// Check if this attribute resolves from across a specializes arc.
-bool PxrUsdKatana_IsAttrValFromBaseMaterial(const UsdAttribute &attr);
-
-// Check if this prim is defined across a specializes arc.
-bool PxrUsdKatana_IsPrimDefFromBaseMaterial(const UsdPrim &prim);
-
-// Check if this relationship has targets provided across a specializes arc.
-// (Usd doesn't provide a UsdResolveInfo style API for asking where
-// relationship targets are authored, so we do it here ourselves.)
-bool PxrUsdKatana_AreRelTargetsFromBaseMaterial(const UsdRelationship &rel);
-
-
-PXR_NAMESPACE_CLOSE_SCOPE
-
-#endif
-
diff --git a/third_party/katana/usdKatana/blindDataObject.cpp b/third_party/katana/usdKatana/blindDataObject.cpp
deleted file mode 100644
index c9034c1c86..0000000000
--- a/third_party/katana/usdKatana/blindDataObject.cpp
+++ /dev/null
@@ -1,325 +0,0 @@
-//
-// Copyright 2016 Pixar
-//
-// Licensed under the Apache License, Version 2.0 (the "Apache License")
-// with the following modification; you may not use this file except in
-// compliance with the Apache License and the following modification to it:
-// Section 6. Trademarks. is deleted and replaced with:
-//
-// 6. Trademarks. This License does not grant permission to use the trade
-// names, trademarks, service marks, or product names of the Licensor
-// and its affiliates, except as required to comply with Section 4(c) of
-// the License and to reproduce the content of the NOTICE file.
-//
-// You may obtain a copy of the Apache License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the Apache License with the above modification is
-// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the Apache License for the specific
-// language governing permissions and limitations under the Apache License.
-//
-#include "usdKatana/blindDataObject.h"
-#include "pxr/usd/usd/schemaRegistry.h"
-#include "pxr/usd/usd/typed.h"
-
-#include "pxr/usd/sdf/types.h"
-#include "pxr/usd/sdf/assetPath.h"
-
-PXR_NAMESPACE_OPEN_SCOPE
-
-// Register the schema with the TfType system.
-TF_REGISTRY_FUNCTION(TfType)
-{
- TfType::Define >();
-
- // Register the usd prim typename as an alias under UsdSchemaBase. This
- // enables one to call
- // TfType::Find().FindDerivedByName("BlindDataObject")
- // to find TfType, which is how IsA queries are
- // answered.
- TfType::AddAlias("BlindDataObject");
-}
-
-/* virtual */
-UsdKatanaBlindDataObject::~UsdKatanaBlindDataObject()
-{
-}
-
-/* static */
-UsdKatanaBlindDataObject
-UsdKatanaBlindDataObject::Get(const UsdStagePtr &stage, const SdfPath &path)
-{
- if (!stage) {
- TF_CODING_ERROR("Invalid stage");
- return UsdKatanaBlindDataObject();
- }
- return UsdKatanaBlindDataObject(stage->GetPrimAtPath(path));
-}
-
-/* static */
-UsdKatanaBlindDataObject
-UsdKatanaBlindDataObject::Define(
- const UsdStagePtr &stage, const SdfPath &path)
-{
- static TfToken usdPrimTypeName("BlindDataObject");
- if (!stage) {
- TF_CODING_ERROR("Invalid stage");
- return UsdKatanaBlindDataObject();
- }
- return UsdKatanaBlindDataObject(
- stage->DefinePrim(path, usdPrimTypeName));
-}
-
-/* virtual */
-UsdSchemaType UsdKatanaBlindDataObject::_GetSchemaType() const {
- return UsdKatanaBlindDataObject::schemaType;
-}
-
-/* static */
-const TfType &
-UsdKatanaBlindDataObject::_GetStaticTfType()
-{
- static TfType tfType = TfType::Find();
- return tfType;
-}
-
-/* static */
-bool
-UsdKatanaBlindDataObject::_IsTypedSchema()
-{
- static bool isTyped = _GetStaticTfType().IsA();
- return isTyped;
-}
-
-/* virtual */
-const TfType &
-UsdKatanaBlindDataObject::_GetTfType() const
-{
- return _GetStaticTfType();
-}
-
-UsdAttribute
-UsdKatanaBlindDataObject::GetTypeAttr() const
-{
- return GetPrim().GetAttribute(UsdKatanaTokens->katanaType);
-}
-
-UsdAttribute
-UsdKatanaBlindDataObject::CreateTypeAttr(VtValue const &defaultValue, bool writeSparsely) const
-{
- return UsdSchemaBase::_CreateAttr(UsdKatanaTokens->katanaType,
- SdfValueTypeNames->String,
- /* custom = */ false,
- SdfVariabilityVarying,
- defaultValue,
- writeSparsely);
-}
-
-UsdAttribute
-UsdKatanaBlindDataObject::GetVisibleAttr() const
-{
- return GetPrim().GetAttribute(UsdKatanaTokens->katanaVisible);
-}
-
-UsdAttribute
-UsdKatanaBlindDataObject::CreateVisibleAttr(VtValue const &defaultValue, bool writeSparsely) const
-{
- return UsdSchemaBase::_CreateAttr(UsdKatanaTokens->katanaVisible,
- SdfValueTypeNames->Bool,
- /* custom = */ false,
- SdfVariabilityVarying,
- defaultValue,
- writeSparsely);
-}
-
-UsdAttribute
-UsdKatanaBlindDataObject::GetSuppressGroupToAssemblyPromotionAttr() const
-{
- return GetPrim().GetAttribute(UsdKatanaTokens->katanaSuppressGroupToAssemblyPromotion);
-}
-
-UsdAttribute
-UsdKatanaBlindDataObject::CreateSuppressGroupToAssemblyPromotionAttr(VtValue const &defaultValue, bool writeSparsely) const
-{
- return UsdSchemaBase::_CreateAttr(UsdKatanaTokens->katanaSuppressGroupToAssemblyPromotion,
- SdfValueTypeNames->Bool,
- /* custom = */ false,
- SdfVariabilityVarying,
- defaultValue,
- writeSparsely);
-}
-
-namespace {
-static inline TfTokenVector
-_ConcatenateAttributeNames(const TfTokenVector& left,const TfTokenVector& right)
-{
- TfTokenVector result;
- result.reserve(left.size() + right.size());
- result.insert(result.end(), left.begin(), left.end());
- result.insert(result.end(), right.begin(), right.end());
- return result;
-}
-}
-
-/*static*/
-const TfTokenVector&
-UsdKatanaBlindDataObject::GetSchemaAttributeNames(bool includeInherited)
-{
- static TfTokenVector localNames = {
- UsdKatanaTokens->katanaType,
- UsdKatanaTokens->katanaVisible,
- UsdKatanaTokens->katanaSuppressGroupToAssemblyPromotion,
- };
- static TfTokenVector allNames =
- _ConcatenateAttributeNames(
- UsdTyped::GetSchemaAttributeNames(true),
- localNames);
-
- if (includeInherited)
- return allNames;
- else
- return localNames;
-}
-
-PXR_NAMESPACE_CLOSE_SCOPE
-
-// ===================================================================== //
-// Feel free to add custom code below this line. It will be preserved by
-// the code generator.
-//
-// Just remember to wrap code in the appropriate delimiters:
-// 'PXR_NAMESPACE_OPEN_SCOPE', 'PXR_NAMESPACE_CLOSE_SCOPE'.
-// ===================================================================== //
-// --(BEGIN CUSTOM CODE)--
-
-using std::string;
-
-PXR_NAMESPACE_OPEN_SCOPE
-
-TF_DEFINE_PRIVATE_TOKENS(
- _tokens,
-
- // If you update this, you may need to update _KATANA_NAMESPACE_INDEX
- ((kbdNamespace, "katana:fromKlf"))
-);
-
-// This value should be set such that:
-// ['katana', 'fromKlf', katanaNameSpace, 'attrName']
-// katanaNamespace = prop.SplitName()[_KATANA_NAMESPACE_INDEX];
-static const size_t _KATANA_NAMESPACE_INDEX = 2;
-
-TfToken UsdKatanaBlindDataObject::GetKbdAttributeNameSpace(const UsdProperty &prop)
-{
- std::vector names = prop.SplitName();
- if (names.size() < _KATANA_NAMESPACE_INDEX + 2) {
- return TfToken("");
- }
- return TfToken(names[_KATANA_NAMESPACE_INDEX]);
-}
-
-std::string
-UsdKatanaBlindDataObject::GetGroupBuilderKeyForProperty(
- const UsdProperty& prop)
-{
- std::vector nameParts = prop.SplitName();
- if (nameParts.size() < _KATANA_NAMESPACE_INDEX + 2) {
- return "";
- }
-
- // unsanitize -- we do this inplace
- TF_FOR_ALL(namePartsIter, nameParts) {
- std::string& nameToken = *namePartsIter;
- if (nameToken.empty()) {
- nameToken = "ERROR_EMPTY_TOKEN";
- }
- else {
- if (nameToken[0] == '_' and nameToken.size() > 1 and
- isdigit(nameToken[1])) {
- nameToken = nameToken.substr(1);
- }
- }
- }
-
- // we're getting the name after the katanaNamespace.
- return TfStringJoin(
- nameParts.begin()+_KATANA_NAMESPACE_INDEX+1,
- nameParts.end(), ".");
-}
-
-static std::string
-_MakeKbdAttrName(const string &katanaAttrName)
-{
- // katana doesn't require everything to be valid identifiers like Sdf does.
- // This function sanitizes and GetGroupBuilderKeyForProperty un-sanitizes
- std::vector nameTokens = TfStringSplit(katanaAttrName, ".");
-
- TF_FOR_ALL(nameTokenIter, nameTokens) {
- std::string& nameToken = *nameTokenIter;
- if (nameToken.empty()) {
- nameToken = "ERROR_EMPTY_TOKEN";
- }
- else {
- if (isdigit(nameToken[0])) {
- nameToken = "_" + nameToken;
- }
- }
- }
-
- return _tokens->kbdNamespace.GetString() + ":" + TfStringJoin(
- nameTokens, ":");
-}
-
-UsdAttribute
-UsdKatanaBlindDataObject::CreateKbdAttribute(
- const std::string& katanaAttrName,
- const SdfValueTypeName &usdType)
-{
- std::string fullName = _MakeKbdAttrName(katanaAttrName);
- UsdAttribute attr = GetPrim().CreateAttribute(TfToken(fullName), usdType,
- /* custom = */ false);
- if (!TF_VERIFY(attr)) {
- return UsdAttribute();
- }
- return attr;
-}
-
-std::vector
-UsdKatanaBlindDataObject::GetKbdAttributes(
- const string &nameSpace) const
-{
- std::vector props =
- GetPrim().GetPropertiesInNamespace(_tokens->kbdNamespace);
-
- std::vector validProps;
- bool requestedNameSpace = (nameSpace != "");
- TfToken nameSpaceToken(nameSpace);
-
- TF_FOR_ALL(propItr, props){
- UsdProperty prop = *propItr;
- if (requestedNameSpace and GetKbdAttributeNameSpace(prop) != nameSpaceToken) {
- continue;
- }
- validProps.push_back(prop);
- }
- return validProps;
-}
-
-UsdAttribute
-UsdKatanaBlindDataObject::GetKbdAttribute(
- const std::string& katanaAttrName)
-{
- std::string fullName = _MakeKbdAttrName(katanaAttrName);
- return GetPrim().GetAttribute(TfToken(fullName));
-}
-
-bool
-UsdKatanaBlindDataObject::IsKbdAttribute(const UsdProperty &attr)
-{
- return TfStringStartsWith(attr.GetName(), _tokens->kbdNamespace);
-}
-
-PXR_NAMESPACE_CLOSE_SCOPE
diff --git a/third_party/katana/usdKatana/blindDataObject.h b/third_party/katana/usdKatana/blindDataObject.h
deleted file mode 100644
index 50ae68f676..0000000000
--- a/third_party/katana/usdKatana/blindDataObject.h
+++ /dev/null
@@ -1,302 +0,0 @@
-//
-// Copyright 2016 Pixar
-//
-// Licensed under the Apache License, Version 2.0 (the "Apache License")
-// with the following modification; you may not use this file except in
-// compliance with the Apache License and the following modification to it:
-// Section 6. Trademarks. is deleted and replaced with:
-//
-// 6. Trademarks. This License does not grant permission to use the trade
-// names, trademarks, service marks, or product names of the Licensor
-// and its affiliates, except as required to comply with Section 4(c) of
-// the License and to reproduce the content of the NOTICE file.
-//
-// You may obtain a copy of the Apache License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the Apache License with the above modification is
-// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the Apache License for the specific
-// language governing permissions and limitations under the Apache License.
-//
-#ifndef USDKATANA_GENERATED_BLINDDATAOBJECT_H
-#define USDKATANA_GENERATED_BLINDDATAOBJECT_H
-
-/// \file usdKatana/blindDataObject.h
-
-#include "pxr/pxr.h"
-#include "usdKatana/api.h"
-#include "pxr/usd/usd/typed.h"
-#include "pxr/usd/usd/prim.h"
-#include "pxr/usd/usd/stage.h"
-#include "usdKatana/tokens.h"
-
-#include "pxr/base/vt/value.h"
-
-#include "pxr/base/gf/vec3d.h"
-#include "pxr/base/gf/vec3f.h"
-#include "pxr/base/gf/matrix4d.h"
-
-#include "pxr/base/tf/token.h"
-#include "pxr/base/tf/type.h"
-
-PXR_NAMESPACE_OPEN_SCOPE
-
-class SdfAssetPath;
-
-// -------------------------------------------------------------------------- //
-// BLINDDATAOBJECT //
-// -------------------------------------------------------------------------- //
-
-/// \class UsdKatanaBlindDataObject
-///
-/// Container namespace schema for katana blind data from the klf file
-///
-class UsdKatanaBlindDataObject : public UsdTyped
-{
-public:
- /// Compile time constant representing what kind of schema this class is.
- ///
- /// \sa UsdSchemaType
- static const UsdSchemaType schemaType = UsdSchemaType::ConcreteTyped;
-
- /// Construct a UsdKatanaBlindDataObject on UsdPrim \p prim .
- /// Equivalent to UsdKatanaBlindDataObject::Get(prim.GetStage(), prim.GetPath())
- /// for a \em valid \p prim, but will not immediately throw an error for
- /// an invalid \p prim
- explicit UsdKatanaBlindDataObject(const UsdPrim& prim=UsdPrim())
- : UsdTyped(prim)
- {
- }
-
- /// Construct a UsdKatanaBlindDataObject on the prim held by \p schemaObj .
- /// Should be preferred over UsdKatanaBlindDataObject(schemaObj.GetPrim()),
- /// as it preserves SchemaBase state.
- explicit UsdKatanaBlindDataObject(const UsdSchemaBase& schemaObj)
- : UsdTyped(schemaObj)
- {
- }
-
- /// Destructor.
- USDKATANA_API
- virtual ~UsdKatanaBlindDataObject();
-
- /// Return a vector of names of all pre-declared attributes for this schema
- /// class and all its ancestor classes. Does not include attributes that
- /// may be authored by custom/extended methods of the schemas involved.
- USDKATANA_API
- static const TfTokenVector &
- GetSchemaAttributeNames(bool includeInherited=true);
-
- /// Return a UsdKatanaBlindDataObject holding the prim adhering to this
- /// schema at \p path on \p stage. If no prim exists at \p path on
- /// \p stage, or if the prim at that path does not adhere to this schema,
- /// return an invalid schema object. This is shorthand for the following:
- ///
- /// \code
- /// UsdKatanaBlindDataObject(stage->GetPrimAtPath(path));
- /// \endcode
- ///
- USDKATANA_API
- static UsdKatanaBlindDataObject
- Get(const UsdStagePtr &stage, const SdfPath &path);
-
- /// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
- /// is defined (according to UsdPrim::IsDefined()) on this stage.
- ///
- /// If a prim adhering to this schema at \p path is already defined on this
- /// stage, return that prim. Otherwise author an \a SdfPrimSpec with
- /// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
- /// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
- /// with \p specifier == \a SdfSpecifierDef and empty typeName at the
- /// current EditTarget for any nonexistent, or existing but not \a Defined
- /// ancestors.
- ///
- /// The given \a path must be an absolute prim path that does not contain
- /// any variant selections.
- ///
- /// If it is impossible to author any of the necessary PrimSpecs, (for
- /// example, in case \a path cannot map to the current UsdEditTarget's
- /// namespace) issue an error and return an invalid \a UsdPrim.
- ///
- /// Note that this method may return a defined prim whose typeName does not
- /// specify this schema class, in case a stronger typeName opinion overrides
- /// the opinion at the current EditTarget.
- ///
- USDKATANA_API
- static UsdKatanaBlindDataObject
- Define(const UsdStagePtr &stage, const SdfPath &path);
-
-protected:
- /// Returns the type of schema this class belongs to.
- ///
- /// \sa UsdSchemaType
- USDKATANA_API
- UsdSchemaType _GetSchemaType() const override;
-
-private:
- // needs to invoke _GetStaticTfType.
- friend class UsdSchemaRegistry;
- USDKATANA_API
- static const TfType &_GetStaticTfType();
-
- static bool _IsTypedSchema();
-
- // override SchemaBase virtuals.
- USDKATANA_API
- const TfType &_GetTfType() const override;
-
-public:
- // --------------------------------------------------------------------- //
- // TYPE
- // --------------------------------------------------------------------- //
- ///
- ///
- /// | ||
- /// | -- | -- |
- /// | Declaration | `string katana:type` |
- /// | C++ Type | std::string |
- /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->String |
- USDKATANA_API
- UsdAttribute GetTypeAttr() const;
-
- /// See GetTypeAttr(), and also
- /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
- /// If specified, author \p defaultValue as the attribute's default,
- /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
- /// the default for \p writeSparsely is \c false.
- USDKATANA_API
- UsdAttribute CreateTypeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
-
-public:
- // --------------------------------------------------------------------- //
- // VISIBLE
- // --------------------------------------------------------------------- //
- ///
- ///
- /// | ||
- /// | -- | -- |
- /// | Declaration | `bool katana:visible` |
- /// | C++ Type | bool |
- /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool |
- USDKATANA_API
- UsdAttribute GetVisibleAttr() const;
-
- /// See GetVisibleAttr(), and also
- /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
- /// If specified, author \p defaultValue as the attribute's default,
- /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
- /// the default for \p writeSparsely is \c false.
- USDKATANA_API
- UsdAttribute CreateVisibleAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
-
-public:
- // --------------------------------------------------------------------- //
- // SUPPRESSGROUPTOASSEMBLYPROMOTION
- // --------------------------------------------------------------------- //
- /// If true don't promote a group to an assembly.
- ///
- /// | ||
- /// | -- | -- |
- /// | Declaration | `bool katana:suppressGroupToAssemblyPromotion` |
- /// | C++ Type | bool |
- /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool |
- USDKATANA_API
- UsdAttribute GetSuppressGroupToAssemblyPromotionAttr() const;
-
- /// See GetSuppressGroupToAssemblyPromotionAttr(), and also
- /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
- /// If specified, author \p defaultValue as the attribute's default,
- /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
- /// the default for \p writeSparsely is \c false.
- USDKATANA_API
- UsdAttribute CreateSuppressGroupToAssemblyPromotionAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
-
-public:
- // ===================================================================== //
- // Feel free to add custom code below this line, it will be preserved by
- // the code generator.
- //
- // Just remember to:
- // - Close the class declaration with };
- // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
- // - Close the include guard with #endif
- // ===================================================================== //
- // --(BEGIN CUSTOM CODE)--
-
- // --------------------------------------------------------------------- //
- // CreateKbdAttribute
- // --------------------------------------------------------------------- //
- /// \brief Create an attribute on the prim to which this schema is attached.
- ///
- /// This will be a blind representation of a Katana attribute from Klf file.
- /// \p katanaFullName should be the full attribute name from katana, i.e.
- /// "materials.interface.foo". \p usdType is the typename for the
- /// attribute and will be passed directly to \p UsdPrim::CreateAttribute().
- UsdAttribute
- CreateKbdAttribute(
- const std::string &katanaFullName,
- const SdfValueTypeName &usdType);
-
- // --------------------------------------------------------------------- //
- // GetKbdAttributes
- // --------------------------------------------------------------------- //
- /// Return all rib attributes on this prim, or under a specific
- /// namespace (e.g. "user")
- ///
- /// As noed above, rib attributes can be either UsdAttribute or
- /// UsdRelationship, and like all UsdProperties, need not have a defined
- /// value.
- std::vector
- GetKbdAttributes(const std::string &nameSpace = "") const;
-
- // --------------------------------------------------------------------- //
- // GetKbdAttribute
- // --------------------------------------------------------------------- //
- /// Return a specific KBD attribute
- UsdAttribute
- GetKbdAttribute(const std::string &katanaFullName);
-
- // --------------------------------------------------------------------- //
- // GetKbdAttributeNameSpace
- // --------------------------------------------------------------------- //
- /// Return the containing namespace of the katana attribute (e.g.
- /// "geometry" or "materials"). Can be used with
- /// GetGroupBuilderKeyForProperty()
- ///
- static TfToken GetKbdAttributeNameSpace(const UsdProperty &prop);
-
- // --------------------------------------------------------------------- //
- // GetGroupBuilderKeyForProperty
- // --------------------------------------------------------------------- //
- /// Return a string that is the attribute name that can be used with a
- /// group builder. For example, when constructing the GroupAttribute for
- /// the top-level group "geometry", this should be used as follows:
- ///
- /// FnKat::GroupBuilder gb;
- /// props = UsdKatanaBlindDataObject(prim).GetKbdAttribute("geometry");
- /// gb.set(UsdKatanaBlindDataObject::GetGroupBuilderKeyForProperty(props[0]), ...)
- /// return gb.build();
- ///
- /// For the attribute:
- /// custom int katana:fromKlf:materials:interface:foo = 0
- ///
- /// this returns
- /// "interface.foo"
- ///
- /// To get "materials", use GetKbdAttributeNameSpace()
- static std::string GetGroupBuilderKeyForProperty(const UsdProperty& prop);
-
- // --------------------------------------------------------------------- //
- // IsKbdAttribute
- // --------------------------------------------------------------------- //
- /// Return true if the property is in the "ri:attributes" namespace.
- ///
- static bool IsKbdAttribute(const UsdProperty &prop);
-};
-
-PXR_NAMESPACE_CLOSE_SCOPE
-
-#endif
diff --git a/third_party/katana/usdKatana/cache.cpp b/third_party/katana/usdKatana/cache.cpp
deleted file mode 100644
index 5c7e62e676..0000000000
--- a/third_party/katana/usdKatana/cache.cpp
+++ /dev/null
@@ -1,917 +0,0 @@
-//
-// Copyright 2016 Pixar
-//
-// Licensed under the Apache License, Version 2.0 (the "Apache License")
-// with the following modification; you may not use this file except in
-// compliance with the Apache License and the following modification to it:
-// Section 6. Trademarks. is deleted and replaced with:
-//
-// 6. Trademarks. This License does not grant permission to use the trade
-// names, trademarks, service marks, or product names of the Licensor
-// and its affiliates, except as required to comply with Section 4(c) of
-// the License and to reproduce the content of the NOTICE file.
-//
-// You may obtain a copy of the Apache License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the Apache License with the above modification is
-// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the Apache License for the specific
-// language governing permissions and limitations under the Apache License.
-//
-#include "pxr/pxr.h"
-#include "usdKatana/cache.h"
-#include "usdKatana/locks.h"
-#include "usdKatana/debugCodes.h"
-
-#include "pxr/usd/ar/resolver.h"
-
-#include "pxr/usdImaging/usdImagingGL/engine.h"
-
-#include "pxr/usd/usdUtils/stageCache.h"
-#include "pxr/usd/sdf/layer.h"
-#include "pxr/usd/sdf/path.h"
-#include "pxr/usd/sdf/attributeSpec.h"
-#include "pxr/base/trace/trace.h"
-#include "pxr/usd/usd/prim.h"
-#include "pxr/usd/usd/stageCacheContext.h"
-
-#include "pxr/base/arch/systemInfo.h"
-#include "pxr/base/tf/instantiateSingleton.h"
-
-#include
-#include
-
-#include
-
-PXR_NAMESPACE_OPEN_SCOPE
-
-
-TF_INSTANTIATE_SINGLETON(UsdKatanaCache);
-
-
-namespace
-{
- template
- bool AddSimpleTypedSdfAttribute(SdfPrimSpecHandle prim,
- const std::string & attrName, const fnAttrT & valueAttr,
- const FnAttribute::IntAttribute & forceArrayAttr,
- SdfValueTypeName scalarType)
- {
- if (!prim)
- {
- return false;
- }
-
- if (!valueAttr.isValid())
- {
- return false;
- }
-
- bool isArray;
- if (forceArrayAttr.isValid()) {
- isArray = forceArrayAttr.getValue();
- }
- else {
- isArray = valueAttr.getNumberOfValues() != 1;
- }
- auto sdfAttr = SdfAttributeSpec::New(prim, attrName,
- isArray ? scalarType.GetArrayType() : scalarType);
-
- if (!sdfAttr)
- {
- return false;
- }
-
- if (isArray)
- {
- VtArray vtArray;
-
- auto sample = valueAttr.getNearestSample(0.0f);
- vtArray.assign(&sample[0],
- &sample[0] + valueAttr.getNumberOfValues());
-
- sdfAttr->SetDefaultValue(VtValue(vtArray));
- }
- else
- {
- sdfAttr->SetDefaultValue(
- VtValue(valueAttr.getValue(typename fnAttrT::value_type(),
- false)));
- }
- return true;
- }
-}
-
-SdfLayerRefPtr&
-UsdKatanaCache::_FindOrCreateSessionLayer(
- FnAttribute::GroupAttribute sessionAttr,
- const std::string& rootLocation) {
- // Grab a reader lock for reading the _sessionKeyCache
- boost::upgrade_lock
- readerLock(UsdKatanaGetSessionCacheLock());
-
-
- std::string cacheKey = _ComputeCacheKey(sessionAttr, rootLocation);
-
- // Open the usd stage
- SdfLayerRefPtr sessionLayer;
-
- if (_sessionKeyCache.find(cacheKey) == _sessionKeyCache.end())
- {
- boost::upgrade_to_unique_lock
- writerLock(readerLock);
- sessionLayer = SdfLayer::CreateAnonymous();
- _sessionKeyCache[cacheKey] = sessionLayer;
-
-
- std::string rootLocationPlusSlash = rootLocation + "/";
-
-
- FnAttribute::GroupAttribute variantsAttr =
- sessionAttr.getChildByName("variants");
- for (int64_t i = 0, e = variantsAttr.getNumberOfChildren(); i != e;
- ++i)
- {
- std::string entryName = FnAttribute::DelimiterDecode(
- variantsAttr.getChildName(i));
-
- FnAttribute::GroupAttribute entryVariantSets =
- variantsAttr.getChildByIndex(i);
-
- if (entryVariantSets.getNumberOfChildren() == 0)
- {
- continue;
- }
-
- if (!pystring::startswith(entryName, rootLocationPlusSlash))
- {
- continue;
- }
-
-
- std::string primPath = pystring::slice(entryName,
- rootLocation.size());
-
- for (int64_t i = 0, e = entryVariantSets.getNumberOfChildren();
- i != e; ++i)
- {
- std::string variantSetName = entryVariantSets.getChildName(i);
-
- FnAttribute::StringAttribute variantValueAttr =
- entryVariantSets.getChildByIndex(i);
- if (!variantValueAttr.isValid())
- {
- continue;
- }
-
- std::string variantSetSelection =
- variantValueAttr.getValue("", false);
-
- SdfPath varSelPath(primPath);
-
-
- SdfPrimSpecHandle spec = SdfCreatePrimInLayer(
- sessionLayer, varSelPath.GetPrimPath());
- if (spec)
- {
- std::pair sel =
- varSelPath.GetVariantSelection();
- spec->SetVariantSelection(variantSetName,
- variantSetSelection);
- }
- }
- }
-
-
- FnAttribute::GroupAttribute activationsAttr =
- sessionAttr.getChildByName("activations");
- for (int64_t i = 0, e = activationsAttr.getNumberOfChildren(); i != e;
- ++i)
- {
- std::string entryName = FnAttribute::DelimiterDecode(
- activationsAttr.getChildName(i));
-
- FnAttribute::IntAttribute stateAttr =
- activationsAttr.getChildByIndex(i);
-
- if (stateAttr.getNumberOfValues() != 1)
- {
- continue;
- }
-
- if (!pystring::startswith(entryName, rootLocationPlusSlash))
- {
- continue;
- }
-
- std::string primPath = pystring::slice(entryName,
- rootLocation.size());
-
- SdfPath varSelPath(primPath);
-
- SdfPrimSpecHandle spec = SdfCreatePrimInLayer(
- sessionLayer, varSelPath.GetPrimPath());
- spec->SetActive(stateAttr.getValue());
- }
-
- FnAttribute::GroupAttribute attrsAttr =
- sessionAttr.getChildByName("attrs");
-
- for (int64_t i = 0, e = attrsAttr.getNumberOfChildren(); i != e;
- ++i)
- {
- std::string entryName = FnAttribute::DelimiterDecode(
- attrsAttr.getChildName(i));
-
- FnAttribute::GroupAttribute entryAttr =
- attrsAttr.getChildByIndex(i);
-
- if (!pystring::startswith(entryName, rootLocationPlusSlash))
- {
- continue;
- }
-
- std::string primPath = pystring::slice(entryName,
- rootLocation.size());
-
- SdfPath varSelPath(primPath);
-
- SdfPrimSpecHandle spec = SdfCreatePrimInLayer(
- sessionLayer, varSelPath.GetPrimPath());
-
- if (!spec)
- {
- continue;
- }
-
- for (int64_t i = 0, e = entryAttr.getNumberOfChildren(); i != e;
- ++i)
- {
- std::string attrName = entryAttr.getChildName(i);
- FnAttribute::GroupAttribute attrDef =
- entryAttr.getChildByIndex(i);
-
- FnAttribute::IntAttribute forceArrayAttr =
- attrDef.getChildByName("forceArray");
-
-
- FnAttribute::DataAttribute valueAttr =
- attrDef.getChildByName("value");
- if (!valueAttr.isValid())
- {
- continue;
- }
-
- // TODO, additional SdfValueTypes, blocking, metadata
-
- switch (valueAttr.getType())
- {
- case kFnKatAttributeTypeInt:
- {
- AddSimpleTypedSdfAttribute<
- FnAttribute::IntAttribute, int>(
- spec, attrName, valueAttr, forceArrayAttr,
- SdfValueTypeNames->Int);
-
- break;
- }
- case kFnKatAttributeTypeFloat:
- {
- AddSimpleTypedSdfAttribute<
- FnAttribute::FloatAttribute, float>(
- spec, attrName, valueAttr, forceArrayAttr,
- SdfValueTypeNames->Float);
-
- break;
- }
- case kFnKatAttributeTypeDouble:
- {
- AddSimpleTypedSdfAttribute<
- FnAttribute::DoubleAttribute, double>(
- spec, attrName, valueAttr, forceArrayAttr,
- SdfValueTypeNames->Double);
- break;
- }
- case kFnKatAttributeTypeString:
- {
- AddSimpleTypedSdfAttribute<
- FnAttribute::StringAttribute, std::string>(
- spec, attrName, valueAttr, forceArrayAttr,
- SdfValueTypeNames->String);
-
- break;
- }
- default:
- break;
- };
- }
- }
-
-
-
- FnAttribute::GroupAttribute metadataAttr =
- sessionAttr.getChildByName("metadata");
- for (int64_t i = 0, e = metadataAttr.getNumberOfChildren(); i != e;
- ++i)
- {
- std::string entryName = FnAttribute::DelimiterDecode(
- metadataAttr.getChildName(i));
-
- FnAttribute::GroupAttribute entryAttr =
- metadataAttr.getChildByIndex(i);
-
- if (!pystring::startswith(entryName, rootLocationPlusSlash))
- {
- continue;
- }
-
- std::string primPath = pystring::slice(entryName,
- rootLocation.size());
-
- SdfPath varSelPath(primPath);
-
- SdfPrimSpecHandle spec = SdfCreatePrimInLayer(
- sessionLayer, varSelPath.GetPrimPath());
-
- if (!spec)
- {
- continue;
- }
-
-
- // Currently support only metadata at the prim level
- FnAttribute::GroupAttribute primEntries =
- entryAttr.getChildByName("prim");
- for (int64_t i = 0, e = primEntries.getNumberOfChildren(); i < e; ++i)
- {
- FnAttribute::GroupAttribute attrDefGrp =
- primEntries.getChildByIndex(i);
- std::string attrName = primEntries.getChildName(i);
-
- std::string typeName = FnAttribute::StringAttribute(
- attrDefGrp.getChildByName("type")).getValue("", false);
- if (typeName == "SdfInt64ListOp")
- {
- FnAttribute::IntAttribute valueAttr;
-
- SdfInt64ListOp listOp;
- std::vector itemList;
-
- auto convertFnc = [](
- FnAttribute::IntAttribute intAttr,
- std::vector & outputItemList)
- {
- outputItemList.clear();
- if (intAttr.getNumberOfValues() == 0)
- {
- return;
- }
-
- auto sample = intAttr.getNearestSample(0);
- outputItemList.reserve(sample.size());
- outputItemList.insert(outputItemList.end(),
- sample.begin(), sample.end());
- };
-
- valueAttr = attrDefGrp.getChildByName("listOp.explicit");
- if (valueAttr.isValid())
- {
- convertFnc(valueAttr, itemList);
- listOp.SetExplicitItems(itemList);
- }
-
- valueAttr = attrDefGrp.getChildByName("listOp.added");
- if (valueAttr.isValid())
- {
- convertFnc(valueAttr, itemList);
- listOp.SetAddedItems(itemList);
- }
-
- valueAttr = attrDefGrp.getChildByName("listOp.deleted");
- if (valueAttr.isValid())
- {
- convertFnc(valueAttr, itemList);
- listOp.SetDeletedItems(itemList);
- }
-
- valueAttr = attrDefGrp.getChildByName("listOp.ordered");
- if (valueAttr.isValid())
- {
- convertFnc(valueAttr, itemList);
- listOp.SetOrderedItems(itemList);
- }
-
- valueAttr = attrDefGrp.getChildByName("listOp.prepended");
- if (valueAttr.isValid())
- {
- convertFnc(valueAttr, itemList);
- listOp.SetPrependedItems(itemList);
- }
-
- valueAttr = attrDefGrp.getChildByName("listOp.appended");
- if (valueAttr.isValid())
- {
- convertFnc(valueAttr, itemList);
- listOp.SetAppendedItems(itemList);
- }
-
- spec->SetInfo(TfToken(attrName), VtValue(listOp));
- }
- }
- }
-
- FnAttribute::StringAttribute dynamicSublayersAttr =
- sessionAttr.getChildByName("subLayers");
-
- if (dynamicSublayersAttr.getNumberOfValues() > 0){
-
- FnAttribute::StringAttribute::array_type dynamicSublayers = dynamicSublayersAttr.getNearestSample(0);
- if (dynamicSublayersAttr.getTupleSize() != 2 ||
- dynamicSublayers.size() % 2 != 0){
- TF_CODING_ERROR("sublayers must contain a list of two-tuples [(rootLocation, sublayerIdentifier)]");
- }
-
- std::set subLayersSet;
- std::vector subLayers;
- for (size_t i = 0; i 0){
- if (subLayersSet.find(dynamicSublayers[i+1]) == subLayersSet.end()){
- subLayers.push_back(dynamicSublayers[i+1]);
- subLayersSet.insert(dynamicSublayers[i+1]);
- }
- else
- TF_CODING_ERROR("Cannot add same sublayer twice.");
- }
- }
- sessionLayer->SetSubLayerPaths(subLayers);
- }
- }
-
- return _sessionKeyCache[cacheKey];
-
-}
-
-
-/* static */
-void
-UsdKatanaCache::_SetMutedLayers(
- const UsdStageRefPtr &stage, const std::string &layerRegex)
-{
- // Trace this function to track its performance
- TRACE_FUNCTION();
-
- // Unmute layers that are currently muted, but not requested to be muted
- SdfLayerHandleVector stageLayers = stage->GetUsedLayers();
-
- bool regexIsEmpty = layerRegex == "" || layerRegex == "^$";
-
- // use a better regex library?
- regex_t regex;
- if (regcomp(®ex, layerRegex.c_str(), REG_EXTENDED))
- {
- TF_WARN("UsdKatanaCache: Invalid ignoreLayerRegex value: %s",
- layerRegex.c_str());
- regexIsEmpty = true;
- }
-
-
- regmatch_t* rmatch = 0;
-
- TF_FOR_ALL(stageLayer, stageLayers)
- {
- SdfLayerHandle layer = *stageLayer;
- if (!layer) {
- continue;
- }
- std::string layerPath = layer->GetRepositoryPath();
- const std::string layerIdentifier = layer->GetIdentifier();
-
- bool match = false;
-
- if (!regexIsEmpty)
- {
- if (layer && !regexec(
- ®ex,
- layerIdentifier.c_str(),
- 0, rmatch, 0))
- {
- match = true;
- }
- }
-
- if (!match && stage->IsLayerMuted(layerIdentifier)) {
- TF_DEBUG(USDKATANA_CACHE_RENDERER).Msg("{USD RENDER CACHE} "
- "Unmuting Layer: '%s'\n",
- layerIdentifier.c_str());
- stage->UnmuteLayer(layerIdentifier);
- }
-
- if (match && !stage->IsLayerMuted(layerIdentifier)) {
- TF_DEBUG(USDKATANA_CACHE_RENDERER).Msg("{USD RENDER CACHE} "
- "Muting Layer: '%s'\n",
- layerIdentifier.c_str());
- stage->MuteLayer(layerIdentifier);
- }
- }
- regfree(®ex);
-}
-
-UsdKatanaCache::UsdKatanaCache()
-{
-}
-
-void
-UsdKatanaCache::Flush()
-{
- // Flushing is writing, grab writer locks for the caches.
- boost::unique_lock
- rendererWriterLock(UsdKatanaGetRendererCacheLock());
- boost::unique_lock
- sessionWriterLock(UsdKatanaGetSessionCacheLock());
-
- UsdUtilsStageCache::Get().Clear();
- _sessionKeyCache.clear();
- _rendererCache.clear();
-}
-
-
-static std::string
-_ResolvePath(const std::string& path)
-{
- return ArGetResolver().Resolve(path);
-}
-
-// UsdStage::OpenMasked doesn't participate with the active UsdStageCache.
-// Use of a UsdStageCacheRequest subclass lets work with the cache for masked
-// stages without having to manually lock.
-//
-// The assumption is that external consumers of the UsdStageCache which don't
-// go through UsdKatanaCache will take the first otherwise matching stage
-// independent of masking or session layer. Those consumers are not typically
-// active in the katanaBin process but may be in the render. While the
-// interactive process can result in multiple session or mask specific copies
-// of the same stage (via interactive edits), that's not likely to be relevant
-// to the renderboot process.
-//
-// NOTE: This does not own the reference to the provided mask so its lifetime
-// must be externally managed.
-//
-// Additionally, UsdStagePopulationMask::All() should be sent in for an
-// empty mask. That's only relevant internal to this file as this class
-// is not exposed.
-class PxrUsdIn_StageOpenRequest : public UsdStageCacheRequest
-{
-public:
-
- PxrUsdIn_StageOpenRequest(UsdStage::InitialLoadSet load,
- SdfLayerHandle const &rootLayer,
- SdfLayerHandle const &sessionLayer,
- ArResolverContext const &pathResolverContext,
- const UsdStagePopulationMask & mask
- )
- : _rootLayer(rootLayer)
- , _sessionLayer(sessionLayer)
- , _pathResolverContext(pathResolverContext)
- , _initialLoadSet(load)
- , _mask(mask)
- {}
-
- virtual ~PxrUsdIn_StageOpenRequest(){};
-
- virtual bool IsSatisfiedBy(UsdStageRefPtr const &stage) const
- {
- // NOTE: no need to compare the mask as the session layer key
- // already incorporates the masks value.
- return _rootLayer == stage->GetRootLayer() &&
- _sessionLayer == stage->GetSessionLayer() &&
- _pathResolverContext == stage->GetPathResolverContext();
- }
-
- virtual bool IsSatisfiedBy(UsdStageCacheRequest const &pending) const
- {
-
- auto req = dynamic_cast(&pending);
- if (!req)
- {
- return false;
- }
-
- return _rootLayer == req->_rootLayer &&
- _sessionLayer == req->_sessionLayer &&
- _pathResolverContext == req->_pathResolverContext;// &&
- // NOTE: no need to compare the mask as the session layer key
- // already incorporates the masks value.
- //_mask == req->_mask;
-
- }
- virtual UsdStageRefPtr Manufacture()
- {
- return UsdStage::OpenMasked(_rootLayer, _sessionLayer,
- _pathResolverContext,
- _mask,
- _initialLoadSet);
- }
-
-private:
- SdfLayerHandle _rootLayer;
- SdfLayerHandle _sessionLayer;
- ArResolverContext _pathResolverContext;
- UsdStage::InitialLoadSet _initialLoadSet;
- const UsdStagePopulationMask & _mask;
-};
-
-
-// While the population mask is not part of the session layer, it's delivered
-// along with the GroupAttribute which describes the session layer so that
-// it's incorporated in the same cache key. Other uses of population masks
-// may want to keep the mask mutable for a given stage, PxrUsdIn ensures that
-// they are unique copies as it's possible (although usually discouraged) to
-// have simultaneous states active at once.
-void FillPopulationMaskFromSessionAttr(
- FnAttribute::GroupAttribute sessionAttr,
- const std::string & sessionRootLocation,
- UsdStagePopulationMask & mask)
-{
- FnAttribute::StringAttribute maskAttr =
- sessionAttr.getChildByName("mask");
-
- if (maskAttr.getNumberOfValues() > 0)
- {
- std::string rootLocationPlusSlash = sessionRootLocation + "/";
-
- auto values = maskAttr.getNearestSample(0.0f);
-
- for (auto i : values)
- {
- if (!pystring::startswith(i, rootLocationPlusSlash))
- {
- continue;
- }
-
- std::string primPath = pystring::slice(i,
- sessionRootLocation.size());
-
- mask.Add(SdfPath(primPath));
- }
- }
-
- if (mask.IsEmpty())
- {
- mask = UsdStagePopulationMask::All();
- }
-}
-
-
-UsdStageRefPtr UsdKatanaCache::GetStage(
- std::string const& fileName,
- FnAttribute::GroupAttribute sessionAttr,
- const std::string & sessionRootLocation,
- std::string const& ignoreLayerRegex,
- bool forcePopulate)
-{
- TF_DEBUG(USDKATANA_CACHE_STAGE).Msg(
- "{USD STAGE CACHE} Creating and caching UsdStage for "
- "given filePath @%s@, which resolves to @%s@\n",
- fileName.c_str(), _ResolvePath(fileName).c_str());
-
- if (SdfLayerRefPtr rootLayer = SdfLayer::FindOrOpen(fileName)) {
- SdfLayerRefPtr& sessionLayer =
- _FindOrCreateSessionLayer(sessionAttr, sessionRootLocation);
-
- UsdStageCache& stageCache = UsdUtilsStageCache::Get();
-
- UsdStagePopulationMask mask;
- FillPopulationMaskFromSessionAttr(
- sessionAttr, sessionRootLocation, mask);
-
- const UsdStage::InitialLoadSet load =
- (forcePopulate ? UsdStage::LoadAll : UsdStage::LoadNone);
-
- auto result = stageCache.RequestStage(
- PxrUsdIn_StageOpenRequest(
- load,
- rootLayer,
- sessionLayer,
- ArGetResolver().GetCurrentContext(),
- mask));
-
- UsdStageRefPtr stage = result.first;
-
- if (result.second)
- {
- TF_DEBUG(USDKATANA_CACHE_STAGE).Msg(
- "{USD STAGE CACHE} Loaded stage "
- "(%s, forcePopulate=%s) "
- "with UsdStage address '%lx'\n"
- "and sessionAttr hash '%s'\n",
- fileName.c_str(),
- forcePopulate?"true":"false",
- (size_t)stage.operator->(),
- sessionAttr.getHash().str().c_str());
-
- }
- else
- {
- TF_DEBUG(USDKATANA_CACHE_STAGE).Msg(
- "{USD STAGE CACHE} Fetching cached stage "
- "(%s, forcePopulate=%s) "
- "with UsdStage address '%lx'\n"
- "and sessionAttr hash '%s'\n",
- fileName.c_str(),
- forcePopulate?"true":"false",
- (size_t)stage.operator->(),
- sessionAttr.getHash().str().c_str());
- }
-
- // Mute layers according to a regex.
- _SetMutedLayers(stage, ignoreLayerRegex);
-
- return stage;
-
- }
-
- static UsdStageRefPtr NULL_STAGE;
- return NULL_STAGE;
-}
-
-
-UsdStageRefPtr
-UsdKatanaCache::GetUncachedStage(std::string const& fileName,
- FnAttribute::GroupAttribute sessionAttr,
- const std::string & sessionRootLocation,
- std::string const& ignoreLayerRegex,
- bool forcePopulate)
-{
- TF_DEBUG(USDKATANA_CACHE_STAGE).Msg(
- "{USD STAGE CACHE} Creating UsdStage for "
- "given filePath @%s@, which resolves to @%s@\n",
- fileName.c_str(), _ResolvePath(fileName).c_str());
-
- if (SdfLayerRefPtr rootLayer = SdfLayer::FindOrOpen(fileName)) {
- SdfLayerRefPtr& sessionLayer =
- _FindOrCreateSessionLayer(sessionAttr, sessionRootLocation);
-
-
- UsdStagePopulationMask mask;
- FillPopulationMaskFromSessionAttr(sessionAttr, sessionRootLocation,
- mask);
-
-
- const UsdStage::InitialLoadSet load =
- (forcePopulate ? UsdStage::LoadAll : UsdStage::LoadNone);
-
- // OpenMasked is always uncached
- UsdStageRefPtr const stage = UsdStage::OpenMasked(rootLayer, sessionLayer,
- ArGetResolver().GetCurrentContext(), mask,
- load);
-
- TF_DEBUG(USDKATANA_CACHE_STAGE).Msg(
- "{USD STAGE CACHE} Loaded uncached stage "
- "(%s, forcePopulate=%s) "
- "with UsdStage address '%lx'\n"
- "and sessionAttr hash '%s'\n",
- fileName.c_str(),
- forcePopulate?"true":"false",
- (size_t)stage.operator->(),
- sessionAttr.getHash().str().c_str());
-
- // Mute layers according to a regex.
- _SetMutedLayers(stage, ignoreLayerRegex);
-
- return stage;
-
- }
-
- return UsdStageRefPtr();
-
-
-}
-
-
-void UsdKatanaCache::FlushStage(const UsdStageRefPtr & stage)
-{
- UsdStageCache& stageCache = UsdUtilsStageCache::Get();
-
- stageCache.Erase(stage);
-}
-
-
-UsdImagingGLEngineSharedPtr const&
-UsdKatanaCache::GetRenderer(UsdStageRefPtr const& stage,
- UsdPrim const& root,
- std::string const& sessionKey)
-{
- // Grab a reader lock for reading the _rendererCache
- boost::upgrade_lock
- readerLock(UsdKatanaGetRendererCacheLock());
-
- // First look for a parent renderer object first.
- std::string const prefix = stage->GetRootLayer()->GetIdentifier()
- + "::" + sessionKey + "::";
-
- std::string key = prefix + root.GetPath().GetString();
- {
- _RendererCache::const_iterator it = _rendererCache.find(key);
- if (it != _rendererCache.end())
- return it->second;
- }
-
- // May 2015: In the future, we might want to look for a renderer
- // cached at the parent prim that we can reuse to render this prim. This
- // would save some time by not creating a new renderer for every prim.
- //
- // UsdImaging does not currently support recycling renderers in this way,
- // so we can't do it yet. It's a non-issue at the moment because we only
- // render proxies at components, not at every prim.
- //
- // For future reference, here is some example code for re-using the renderer
- // from the parent prim:
- //
- // Look for a renderer cached at the parent.
- // std::string parentKey = prefix + root.GetParent().GetPath().GetString();
- // _RendererCache::const_iterator it = _rendererCache.find(parentKey);
- // if (it != _rendererCache.end()) {
- // TF_DEBUG(USDKATANA_CACHE_RENDERER).Msg("{USD RENDER CACHE} "
- // "Inherited renderer '%s' from parent '%s'\n",
- // key.c_str(),
- // parentKey.c_str());
- // // Protect the _rendererCache for write
- // boost::upgrade_to_unique_lock
- // writerLock(readerLock);
-
- // // Chain the child to the parent;
- // _rendererCache.insert(std::make_pair(key, it->second));
- // return it->second;
- // }
-
- TF_DEBUG(USDKATANA_CACHE_RENDERER).Msg("{USD RENDER CACHE} "
- "New renderer created with key '%s'\n",
- key.c_str());
-
- // Protect the _rendererCache for write
- boost::upgrade_to_unique_lock writerLock(readerLock);
-
- // Make a new renderer at the requested path
- SdfPathVector excludedPaths;
- std::pair<_RendererCache::iterator,bool> res =
- _rendererCache.insert(std::make_pair(key,
- UsdImagingGLEngineSharedPtr(new UsdImagingGLEngine(root.GetPath(),
- excludedPaths))));
- return res.first->second;
-}
-
-std::string UsdKatanaCache::_ComputeCacheKey(
- FnAttribute::GroupAttribute sessionAttr,
- const std::string& rootLocation) {
- return FnAttribute::GroupAttribute(
- // replace invalid sessionAttr with empty valid group for consistency
- // with external queries based on "info.usd.outputSession"
- "s", sessionAttr.isValid() ? sessionAttr : FnAttribute::GroupAttribute(true),
- "r", FnAttribute::StringAttribute(rootLocation), true)
- .getHash()
- .str();
-}
-
-SdfLayerRefPtr UsdKatanaCache::FindSessionLayer(
- FnAttribute::GroupAttribute sessionAttr,
- const std::string& rootLocation) {
- std::string cacheKey = _ComputeCacheKey(sessionAttr, rootLocation);
- return FindSessionLayer(cacheKey);
-}
-
-SdfLayerRefPtr UsdKatanaCache::FindSessionLayer(
- const std::string& cacheKey) {
- boost::upgrade_lock
- readerLock(UsdKatanaGetSessionCacheLock());
- const auto& it = _sessionKeyCache.find(cacheKey);
- if (it != _sessionKeyCache.end()) {
- return it->second;
- }
- return NULL;
-}
-
-
-
-SdfLayerRefPtr UsdKatanaCache::FindOrCreateSessionLayer(
- const std::string& sessionAttrXML,
- const std::string& rootLocation)
-{
- FnAttribute::GroupAttribute sessionAttr =
- FnAttribute::Attribute::parseXML(sessionAttrXML.c_str());
-
- if (!sessionAttr.isValid())
- {
- sessionAttr = FnAttribute::GroupAttribute(true);
- }
-
- return _FindOrCreateSessionLayer(sessionAttr, rootLocation);
-}
-
-
-
-PXR_NAMESPACE_CLOSE_SCOPE
-
diff --git a/third_party/katana/usdKatana/cache.h b/third_party/katana/usdKatana/cache.h
deleted file mode 100644
index 3234feb87b..0000000000
--- a/third_party/katana/usdKatana/cache.h
+++ /dev/null
@@ -1,137 +0,0 @@
-//
-// Copyright 2016 Pixar
-//
-// Licensed under the Apache License, Version 2.0 (the "Apache License")
-// with the following modification; you may not use this file except in
-// compliance with the Apache License and the following modification to it:
-// Section 6. Trademarks. is deleted and replaced with:
-//
-// 6. Trademarks. This License does not grant permission to use the trade
-// names, trademarks, service marks, or product names of the Licensor
-// and its affiliates, except as required to comply with Section 4(c) of
-// the License and to reproduce the content of the NOTICE file.
-//
-// You may obtain a copy of the Apache License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the Apache License with the above modification is
-// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the Apache License for the specific
-// language governing permissions and limitations under the Apache License.
-//
-#ifndef USD_KATANA_CACHE_H
-#define USD_KATANA_CACHE_H
-
-#include "pxr/pxr.h"
-#include "pxr/usd/usd/stage.h"
-#include "pxr/usd/sdf/declareHandles.h"
-#include "pxr/usdImaging/usdImagingGL/engine.h"
-#include "pxr/base/tf/singleton.h"
-
-#include
-
-#include