add usd-21-05-win64_py37

This commit is contained in:
Sébastien Albert committed 2021-12-07 17:16:25 +01:00
1 parent 41d23e71ba
commit 66bc054336
15675 files changed
+3061008

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
#
# 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.
#
from . import _ar
from pxr import Tf
Tf.PrepareModule(_ar, locals())
del _ar, Tf
try:
from . import __DOC
__DOC.Execute(locals())
del __DOC
except Exception:
pass
Binary file not shown.
Binary file not shown.
+40
View File
@@ -0,0 +1,40 @@
#
# 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.
#
"""
Camera utilities.
"""
from . import _cameraUtil
from pxr import Tf
Tf.PrepareModule(_cameraUtil, locals())
del _cameraUtil, Tf
try:
import __DOC
__DOC.Execute(locals())
del __DOC
except Exception:
pass
Binary file not shown.
Binary file not shown.
+40
View File
@@ -0,0 +1,40 @@
#
# 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.
#
"""
garch
"""
from . import _garch
from pxr import Tf
Tf.PrepareModule(_garch, locals())
del _garch, Tf
try:
from . import __DOC
__DOC.Execute(locals())
del __DOC
except Exception:
pass
Binary file not shown.
Binary file not shown.
+42
View File
@@ -0,0 +1,42 @@
#
# 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.
#
"""
Graphics Foundation
This package defines classes for fundamental graphics types and operations.
"""
import sys
if 'pxr.Gf._gf' not in sys.modules:
from pxr import Tf
from . import _gf
Tf.PrepareModule(_gf, locals())
del _gf, Tf
del sys
try:
from . import __DOC
__DOC.Execute(locals())
del __DOC
except Exception:
pass
Binary file not shown.
Binary file not shown.
+40
View File
@@ -0,0 +1,40 @@
#
# 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.
#
"""
glf
"""
from . import _glf
from pxr import Tf
Tf.PrepareModule(_glf, locals())
del _glf, Tf
try:
from . import __DOC
__DOC.Execute(locals())
del __DOC
except Exception:
pass
Binary file not shown.
Binary file not shown.
+36
View File
@@ -0,0 +1,36 @@
#
# 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.
#
"""Python bindings for libKind"""
from . import _kind
from pxr import Tf
Tf.PrepareModule(_kind, locals())
del _kind, Tf
try:
from . import __DOC
__DOC.Execute(locals())
del __DOC
except Exception:
pass
Binary file not shown.
Binary file not shown.
+37
View File
@@ -0,0 +1,37 @@
#
# Copyright 2018 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.
#
"""Python bindings for libNdr"""
from . import _ndr
from pxr import Tf
Tf.PrepareModule(_ndr, locals())
del _ndr, Tf
try:
from . import __DOC
__DOC.Execute(locals())
del __DOC
except Exception:
pass
Binary file not shown.
Binary file not shown.
+34
View File
@@ -0,0 +1,34 @@
#
# 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.
#
from . import _pcp
from pxr import Tf
Tf.PrepareModule(_pcp, locals())
del _pcp, Tf
try:
import __DOC
__DOC.Execute(locals())
del __DOC
except Exception:
pass
Binary file not shown.
Binary file not shown.
+39
View File
@@ -0,0 +1,39 @@
#
# 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.
#
"""
This package defines facilities for dealing with plugins.
"""
from . import _plug
from pxr import Tf
Tf.PrepareModule(_plug, locals())
del _plug, Tf
try:
from . import __DOC
__DOC.Execute(locals())
del __DOC
except Exception:
pass
Binary file not shown.
Binary file not shown.
+39
View File
@@ -0,0 +1,39 @@
#
# Copyright 2019 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.
#
"""
Pixar OSD implementation.
"""
from . import _pxOsd
from pxr import Tf
Tf.PrepareModule(_pxOsd, locals())
del _pxOsd, Tf
try:
import __DOC
__DOC.Execute(locals())
del __DOC
except Exception:
pass
Binary file not shown.
Binary file not shown.
+90
View File
@@ -0,0 +1,90 @@
#
# 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.
#
from . import _sdf
from pxr import Tf
Tf.PrepareModule(_sdf, locals())
del _sdf, Tf
def Find(layerFileName, scenePath=None):
'''Find(layerFileName, scenePath) -> object
layerFileName: string
scenePath: Path
If given a single string argument, returns the menv layer with
the given filename. If given two arguments (a string and a Path), finds
the menv layer with the given filename and returns the scene object
within it at the given path.'''
layer = Layer.Find(layerFileName)
if (scenePath is None): return layer
return layer.GetObjectAtPath(scenePath)
# Test utilities
def _PathElemsToPrefixes(absolute, elements):
if absolute:
string = "/"
else:
string = ""
lastElemWasDotDot = False
didFirst = False
for elem in elements:
if elem == Path.parentPathElement:
# dotdot
if didFirst:
string = string + "/"
else:
didFirst = True
string = string + elem
lastElemWasDotDot = True
elif elem[0] == ".":
# property
if lastElemWasDotDot:
string = string + "/"
string = string + elem
lastElemWasDotDot = False
elif elem[0] == "[":
# rel attr or sub-attr indices, don't care which
string = string + elem
lastElemWasDotDot = False
else:
if didFirst:
string = string + "/"
else:
didFirst = True
string = string + elem
lastElemWasDotDot = False
if not string:
return []
path = Path(string)
return path.GetPrefixes()
try:
from . import __DOC
__DOC.Execute(locals())
del __DOC
except Exception:
pass
Binary file not shown.
Binary file not shown.
+37
View File
@@ -0,0 +1,37 @@
#
# Copyright 2018 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.
#
"""Python bindings for libSdr"""
from . import _sdr
from pxr import Tf
Tf.PrepareModule(_sdr, locals())
del _sdr, Tf
try:
from . import __DOC
__DOC.Execute(locals())
del __DOC
except Exception:
pass
Binary file not shown.
Binary file not shown.
+611
View File
@@ -0,0 +1,611 @@
#!/pxrpythonsubst
#
# Copyright 2018 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.
"""
Common utilities that shader-based parser plugins can use in their tests.
This is mostly focused on dealing with OSL and Args files. This may need to be
expanded/generalized to accommodate other types in the future.
"""
from __future__ import print_function
from pxr import Ndr
from pxr import Sdr
from pxr.Sdf import ValueTypeNames as SdfTypes
from pxr import Tf
def IsNodeOSL(node):
"""
Determines if the given node has an OSL source type.
"""
return node.GetSourceType() == "OSL"
# XXX Maybe rename this to GetSdfType (as opposed to the Sdr type)
def GetType(property):
"""
Given a property (SdrShaderProperty), return the SdfValueTypeName type.
"""
sdfTypeIndicator = property.GetTypeAsSdfType()
sdfValueTypeName = sdfTypeIndicator[0]
tfType = sdfValueTypeName.type
return tfType
def TestBasicProperties(node):
"""
Test the correctness of the properties on the specified node (only the
non-shading-specific aspects).
"""
isOSL = IsNodeOSL(node)
# Data that varies between OSL/Args
# --------------------------------------------------------------------------
metadata = {
"widget": "number",
"label": "inputA label",
"page": "inputs1",
"help": "inputA help message",
"uncategorized": "1"
}
if not isOSL:
metadata["name"] = "inputA"
metadata["default"] = "0.0"
metadata["type"] = "float"
# --------------------------------------------------------------------------
properties = {
"inputA": node.GetInput("inputA"),
"inputB": node.GetInput("inputB"),
"inputC": node.GetInput("inputC"),
"inputD": node.GetInput("inputD"),
"inputF2": node.GetInput("inputF2"),
"inputStrArray": node.GetInput("inputStrArray"),
"resultF": node.GetOutput("resultF"),
"resultI": node.GetOutput("resultI"),
}
assert properties["inputA"].GetName() == "inputA"
assert properties["inputA"].GetType() == "float"
assert properties["inputA"].GetDefaultValue() == 0.0
assert not properties["inputA"].IsOutput()
assert not properties["inputA"].IsArray()
assert not properties["inputA"].IsDynamicArray()
assert properties["inputA"].GetArraySize() == 0
assert properties["inputA"].GetInfoString() == "inputA (type: 'float'); input"
assert properties["inputA"].IsConnectable()
assert properties["inputA"].CanConnectTo(properties["resultF"])
assert not properties["inputA"].CanConnectTo(properties["resultI"])
assert properties["inputA"].GetMetadata() == metadata
# --------------------------------------------------------------------------
# Check some array variations
# --------------------------------------------------------------------------
assert properties["inputD"].IsDynamicArray()
assert properties["inputD"].GetArraySize() == 1 if isOSL else -1
assert properties["inputD"].IsArray()
assert list(properties["inputD"].GetDefaultValue()) == [1]
assert not properties["inputF2"].IsDynamicArray()
assert properties["inputF2"].GetArraySize() == 2
assert properties["inputF2"].IsArray()
assert not properties["inputF2"].IsConnectable()
assert list(properties["inputF2"].GetDefaultValue()) == [1.0, 2.0]
assert properties["inputStrArray"].GetArraySize() == 4
assert list(properties["inputStrArray"].GetDefaultValue()) == \
["test", "string", "array", "values"]
def TestShadingProperties(node):
"""
Test the correctness of the properties on the specified node (only the
shading-specific aspects).
"""
isOSL = IsNodeOSL(node)
properties = {
"inputA": node.GetShaderInput("inputA"),
"inputB": node.GetShaderInput("inputB"),
"inputC": node.GetShaderInput("inputC"),
"inputD": node.GetShaderInput("inputD"),
"inputF2": node.GetShaderInput("inputF2"),
"inputF3": node.GetShaderInput("inputF3"),
"inputF4": node.GetShaderInput("inputF4"),
"inputF5": node.GetShaderInput("inputF5"),
"inputInterp": node.GetShaderInput("inputInterp"),
"inputOptions": node.GetShaderInput("inputOptions"),
"inputPoint": node.GetShaderInput("inputPoint"),
"inputNormal": node.GetShaderInput("inputNormal"),
"inputStruct": node.GetShaderInput("inputStruct"),
"inputAssetIdentifier": node.GetShaderInput("inputAssetIdentifier"),
"resultF": node.GetShaderOutput("resultF"),
"resultF2": node.GetShaderOutput("resultF2"),
"resultF3": node.GetShaderOutput("resultF3"),
"resultI": node.GetShaderOutput("resultI"),
"vstruct1": node.GetShaderOutput("vstruct1"),
"vstruct1_bump": node.GetShaderOutput("vstruct1_bump"),
"outputPoint": node.GetShaderOutput("outputPoint"),
"outputNormal": node.GetShaderOutput("outputNormal"),
"outputColor": node.GetShaderOutput("outputColor"),
"outputVector": node.GetShaderOutput("outputVector"),
}
assert properties["inputA"].GetLabel() == "inputA label"
assert properties["inputA"].GetHelp() == "inputA help message"
assert properties["inputA"].GetPage() == "inputs1"
assert properties["inputA"].GetWidget() == "number"
assert properties["inputA"].GetHints() == {
"uncategorized": "1"
}
assert properties["inputA"].GetOptions() == []
assert properties["inputA"].GetVStructMemberOf() == ""
assert properties["inputA"].GetVStructMemberName() == ""
assert not properties["inputA"].IsVStructMember()
assert not properties["inputA"].IsVStruct()
assert properties["inputA"].IsConnectable()
assert properties["inputA"].GetValidConnectionTypes() == []
assert properties["inputA"].CanConnectTo(properties["resultF"])
assert not properties["inputA"].CanConnectTo(properties["resultI"])
# --------------------------------------------------------------------------
# Check correct options parsing
# --------------------------------------------------------------------------
assert set(properties["inputOptions"].GetOptions()) == {
("opt1", "opt1val"),
("opt2", "opt2val")
}
assert set(properties["inputInterp"].GetOptions()) == {
("linear", ""),
("catmull-rom", ""),
("bspline", ""),
("constant", ""),
}
# --------------------------------------------------------------------------
# Check cross-type connection allowances
# --------------------------------------------------------------------------
assert properties["inputPoint"].CanConnectTo(properties["outputNormal"])
assert properties["inputNormal"].CanConnectTo(properties["outputPoint"])
assert properties["inputNormal"].CanConnectTo(properties["outputColor"])
assert properties["inputNormal"].CanConnectTo(properties["outputVector"])
assert properties["inputNormal"].CanConnectTo(properties["resultF3"])
assert properties["inputF2"].CanConnectTo(properties["resultF2"])
assert properties["inputD"].CanConnectTo(properties["resultI"])
assert not properties["inputNormal"].CanConnectTo(properties["resultF2"])
assert not properties["inputF4"].CanConnectTo(properties["resultF2"])
assert not properties["inputF2"].CanConnectTo(properties["resultF3"])
# --------------------------------------------------------------------------
# Check clean and unclean mappings to Sdf types
# --------------------------------------------------------------------------
assert properties["inputB"].GetTypeAsSdfType() == (SdfTypes.Int, "")
assert properties["inputF2"].GetTypeAsSdfType() == (SdfTypes.Float2, "")
assert properties["inputF3"].GetTypeAsSdfType() == (SdfTypes.Float3, "")
assert properties["inputF4"].GetTypeAsSdfType() == (SdfTypes.Float4, "")
assert properties["inputF5"].GetTypeAsSdfType() == (SdfTypes.FloatArray, "")
assert properties["inputStruct"].GetTypeAsSdfType() == \
(SdfTypes.Token, Sdr.PropertyTypes.Struct)
# --------------------------------------------------------------------------
# Ensure asset identifiers are detected correctly
# --------------------------------------------------------------------------
assert properties["inputAssetIdentifier"].IsAssetIdentifier()
assert not properties["inputOptions"].IsAssetIdentifier()
assert properties["inputAssetIdentifier"].GetTypeAsSdfType() == \
(SdfTypes.Asset, "")
# Nested pages and VStructs are only possible in args files
if not isOSL:
# ----------------------------------------------------------------------
# Check nested page correctness
# ----------------------------------------------------------------------
assert properties["vstruct1"].GetPage() == "VStructs.Nested"
assert properties["vstruct1_bump"].GetPage() == "VStructs.Nested.More"
# ----------------------------------------------------------------------
# Check VStruct correctness
# ----------------------------------------------------------------------
assert properties["vstruct1"].IsVStruct()
assert properties["vstruct1"].GetVStructMemberOf() == ""
assert properties["vstruct1"].GetVStructMemberName() == ""
assert not properties["vstruct1"].IsVStructMember()
assert not properties["vstruct1_bump"].IsVStruct()
assert properties["vstruct1_bump"].GetVStructMemberOf() == "vstruct1"
assert properties["vstruct1_bump"].GetVStructMemberName() == "bump"
assert properties["vstruct1_bump"].IsVStructMember()
def TestBasicNode(node, nodeSourceType, nodeDefinitionURI, nodeImplementationURI):
"""
Test basic, non-shader-specific correctness on the specified node.
"""
# Implementation notes:
# ---
# The source type needs to be passed manually in order to ensure the utils
# do not have a dependency on the plugin (where the source type resides).
# The URIs are manually specified because the utils cannot know ahead of
# time where the node originated.
isOSL = IsNodeOSL(node)
nodeContext = "OSL" if isOSL else "pattern"
# Data that varies between OSL/Args
# --------------------------------------------------------------------------
nodeName = "TestNodeOSL" if isOSL else "TestNodeARGS"
numOutputs = 8 if isOSL else 10
outputNames = {
"resultF", "resultF2", "resultF3", "resultI", "outputPoint",
"outputNormal", "outputColor", "outputVector"
}
metadata = {
"category": "testing",
"departments": "testDept",
"help": "This is the test node",
"label": "TestNodeLabel",
"primvars": "primvar1|primvar2|primvar3|$primvarNamingProperty|"
"$invalidPrimvarNamingProperty",
"uncategorizedMetadata": "uncategorized"
}
if not isOSL:
metadata.pop("category")
metadata.pop("label")
metadata.pop("uncategorizedMetadata")
outputNames.add("vstruct1")
outputNames.add("vstruct1_bump")
# --------------------------------------------------------------------------
nodeInputs = {propertyName: node.GetShaderInput(propertyName)
for propertyName in node.GetInputNames()}
nodeOutputs = {propertyName: node.GetShaderOutput(propertyName)
for propertyName in node.GetOutputNames()}
assert node.GetName() == nodeName
assert node.GetContext() == nodeContext
assert node.GetSourceType() == nodeSourceType
assert node.GetFamily() == ""
assert node.GetResolvedDefinitionURI() == nodeDefinitionURI
assert node.GetResolvedImplementationURI() == nodeImplementationURI
assert node.IsValid()
assert len(nodeInputs) == 17
assert len(nodeOutputs) == numOutputs
assert nodeInputs["inputA"] is not None
assert nodeInputs["inputB"] is not None
assert nodeInputs["inputC"] is not None
assert nodeInputs["inputD"] is not None
assert nodeInputs["inputF2"] is not None
assert nodeInputs["inputF3"] is not None
assert nodeInputs["inputF4"] is not None
assert nodeInputs["inputF5"] is not None
assert nodeInputs["inputInterp"] is not None
assert nodeInputs["inputOptions"] is not None
assert nodeInputs["inputPoint"] is not None
assert nodeInputs["inputNormal"] is not None
assert nodeOutputs["resultF2"] is not None
assert nodeOutputs["resultI"] is not None
assert nodeOutputs["outputPoint"] is not None
assert nodeOutputs["outputNormal"] is not None
assert nodeOutputs["outputColor"] is not None
assert nodeOutputs["outputVector"] is not None
print(set(node.GetInputNames()))
assert set(node.GetInputNames()) == {
"inputA", "inputB", "inputC", "inputD", "inputF2", "inputF3", "inputF4",
"inputF5", "inputInterp", "inputOptions", "inputPoint", "inputNormal",
"inputStruct", "inputAssetIdentifier", "primvarNamingProperty",
"invalidPrimvarNamingProperty", "inputStrArray"
}
assert set(node.GetOutputNames()) == outputNames
# There may be additional metadata passed in via the NdrNodeDiscoveryResult.
# So, ensure that the bits we expect to see are there instead of doing
# an equality check.
nodeMetadata = node.GetMetadata()
for i,j in metadata.items():
assert i in nodeMetadata
assert nodeMetadata[i] == metadata[i]
# Test basic property correctness
TestBasicProperties(node)
def TestShaderSpecificNode(node):
"""
Test shader-specific correctness on the specified node.
"""
isOSL = IsNodeOSL(node)
# Data that varies between OSL/Args
# --------------------------------------------------------------------------
numOutputs = 8 if isOSL else 10
label = "TestNodeLabel" if isOSL else ""
category = "testing" if isOSL else ""
vstructNames = [] if isOSL else ["vstruct1"]
pages = {"", "inputs1", "inputs2", "results"} if isOSL else \
{"", "inputs1", "inputs2", "results", "VStructs.Nested",
"VStructs.Nested.More"}
# --------------------------------------------------------------------------
shaderInputs = {propertyName: node.GetShaderInput(propertyName)
for propertyName in node.GetInputNames()}
shaderOutputs = {propertyName: node.GetShaderOutput(propertyName)
for propertyName in node.GetOutputNames()}
assert len(shaderInputs) == 17
assert len(shaderOutputs) == numOutputs
assert shaderInputs["inputA"] is not None
assert shaderInputs["inputB"] is not None
assert shaderInputs["inputC"] is not None
assert shaderInputs["inputD"] is not None
assert shaderInputs["inputF2"] is not None
assert shaderInputs["inputF3"] is not None
assert shaderInputs["inputF4"] is not None
assert shaderInputs["inputF5"] is not None
assert shaderInputs["inputInterp"] is not None
assert shaderInputs["inputOptions"] is not None
assert shaderInputs["inputPoint"] is not None
assert shaderInputs["inputNormal"] is not None
assert shaderOutputs["resultF"] is not None
assert shaderOutputs["resultF2"] is not None
assert shaderOutputs["resultF3"] is not None
assert shaderOutputs["resultI"] is not None
assert shaderOutputs["outputPoint"] is not None
assert shaderOutputs["outputNormal"] is not None
assert shaderOutputs["outputColor"] is not None
assert shaderOutputs["outputVector"] is not None
assert node.GetLabel() == label
assert node.GetCategory() == category
assert node.GetHelp() == "This is the test node"
assert node.GetDepartments() == ["testDept"]
assert set(node.GetPages()) == pages
assert set(node.GetPrimvars()) == {"primvar1", "primvar2", "primvar3"}
assert set(node.GetAdditionalPrimvarProperties()) == {"primvarNamingProperty"}
assert set(node.GetPropertyNamesForPage("results")) == {
"resultF", "resultF2", "resultF3", "resultI"
}
assert set(node.GetPropertyNamesForPage("")) == {
"outputPoint", "outputNormal", "outputColor", "outputVector"
}
assert set(node.GetPropertyNamesForPage("inputs1")) == {"inputA"}
assert set(node.GetPropertyNamesForPage("inputs2")) == {
"inputB", "inputC", "inputD", "inputF2", "inputF3", "inputF4", "inputF5",
"inputInterp", "inputOptions", "inputPoint", "inputNormal",
"inputStruct", "inputAssetIdentifier", "primvarNamingProperty",
"invalidPrimvarNamingProperty", "inputStrArray"
}
assert node.GetAllVstructNames() == vstructNames
# Test shading-specific property correctness
TestShadingProperties(node)
def TestShaderPropertiesNode(node):
"""
Tests property correctness on the specified shader node, which must be
one of the following pre-defined nodes:
* 'TestShaderPropertiesNodeOSL'
* 'TestShaderPropertiesNodeARGS'
* 'TestShaderPropertiesNodeUSD'
These pre-defined nodes have a property of every type that Sdr supports.
Property correctness is defined as:
* The shader property has the expected SdrPropertyType
* The shader property has the expected SdfValueTypeName
* If the shader property has a default value, the default value's type
matches the shader property's type
"""
# This test should only be run on the following allowed node names
# --------------------------------------------------------------------------
allowedNodeNames = ["TestShaderPropertiesNodeOSL",
"TestShaderPropertiesNodeARGS",
"TestShaderPropertiesNodeUSD"]
# If this assertion on the name fails, then this test was called with the
# wrong node.
assert node.GetName() in allowedNodeNames
# If we have the correct node name, double check that the source type is
# also correct
if node.GetName() == "TestShaderPropertiesNodeOSL":
assert node.GetSourceType() == "OSL"
elif node.GetName() == "TestShaderPropertiesNodeARGS":
assert node.GetSourceType() == "RmanCpp"
elif node.GetName() == "TestShaderPropertiesNodeUSD":
assert node.GetSourceType() == "glslfx"
nodeInputs = {propertyName: node.GetShaderInput(propertyName)
for propertyName in node.GetInputNames()}
nodeOutputs = {propertyName: node.GetShaderOutput(propertyName)
for propertyName in node.GetOutputNames()}
# For each property, we test that:
# * The property has the expected SdrPropertyType
# * The property has the expected TfType (from SdfValueTypeName)
# * The property's type and default value's type match
property = nodeInputs["inputInt"]
assert property.GetType() == Sdr.PropertyTypes.Int
assert GetType(property) == Tf.Type.FindByName("int")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputString"]
assert property.GetType() == Sdr.PropertyTypes.String
assert GetType(property) == Tf.Type.FindByName("string")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputFloat"]
assert property.GetType() == Sdr.PropertyTypes.Float
assert GetType(property) == Tf.Type.FindByName("float")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputColor"]
assert property.GetType() == Sdr.PropertyTypes.Color
assert GetType(property) == Tf.Type.FindByName("GfVec3f")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputPoint"]
assert property.GetType() == Sdr.PropertyTypes.Point
assert GetType(property) == Tf.Type.FindByName("GfVec3f")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputNormal"]
assert property.GetType() == Sdr.PropertyTypes.Normal
assert GetType(property) == Tf.Type.FindByName("GfVec3f")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputVector"]
assert property.GetType() == Sdr.PropertyTypes.Vector
assert GetType(property) == Tf.Type.FindByName("GfVec3f")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputMatrix"]
assert property.GetType() == Sdr.PropertyTypes.Matrix
assert GetType(property) == Tf.Type.FindByName("GfMatrix4d")
assert Ndr._ValidateProperty(node, property)
if node.GetName() != "TestShaderPropertiesNodeUSD":
# XXX Note that 'struct' and 'vstruct' types are currently unsupported
# by the UsdShadeShaderDefParserPlugin, which parses shaders defined in
# usd files. Please see UsdShadeShaderDefParserPlugin implementation for
# details.
property = nodeInputs["inputStruct"]
assert property.GetType() == Sdr.PropertyTypes.Struct
assert GetType(property) == Tf.Type.FindByName("TfToken")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputVstruct"]
assert property.GetType() == Sdr.PropertyTypes.Vstruct
assert GetType(property) == Tf.Type.FindByName("TfToken")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputIntArray"]
assert property.GetType() == Sdr.PropertyTypes.Int
assert GetType(property) == Tf.Type.FindByName("VtArray<int>")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputStringArray"]
assert property.GetType() == Sdr.PropertyTypes.String
assert GetType(property) == Tf.Type.FindByName("VtArray<string>")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputFloatArray"]
assert property.GetType() == Sdr.PropertyTypes.Float
assert GetType(property) == Tf.Type.FindByName("VtArray<float>")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputColorArray"]
assert property.GetType() == Sdr.PropertyTypes.Color
assert GetType(property) == Tf.Type.FindByName("VtArray<GfVec3f>")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputPointArray"]
assert property.GetType() == Sdr.PropertyTypes.Point
assert GetType(property) == Tf.Type.FindByName("VtArray<GfVec3f>")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputNormalArray"]
assert property.GetType() == Sdr.PropertyTypes.Normal
assert GetType(property) == Tf.Type.FindByName("VtArray<GfVec3f>")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputVectorArray"]
assert property.GetType() == Sdr.PropertyTypes.Vector
assert GetType(property) == Tf.Type.FindByName("VtArray<GfVec3f>")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputMatrixArray"]
assert property.GetType() == Sdr.PropertyTypes.Matrix
assert GetType(property) == Tf.Type.FindByName("VtArray<GfMatrix4d>")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputFloat2"]
assert property.GetType() == Sdr.PropertyTypes.Float
assert GetType(property) == Tf.Type.FindByName("GfVec2f")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputFloat3"]
assert property.GetType() == Sdr.PropertyTypes.Float
assert GetType(property) == Tf.Type.FindByName("GfVec3f")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputFloat4"]
assert property.GetType() == Sdr.PropertyTypes.Float
assert GetType(property) == Tf.Type.FindByName("GfVec4f")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputAsset"]
assert property.GetType() == Sdr.PropertyTypes.String
assert GetType(property) == Tf.Type.FindByName("SdfAssetPath")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputAssetArray"]
assert property.GetType() == Sdr.PropertyTypes.String
assert GetType(property) == Tf.Type.FindByName("VtArray<SdfAssetPath>")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputColorRoleNone"]
assert property.GetType() == Sdr.PropertyTypes.Float
assert GetType(property) == Tf.Type.FindByName("GfVec3f")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputPointRoleNone"]
assert property.GetType() == Sdr.PropertyTypes.Float
assert GetType(property) == Tf.Type.FindByName("GfVec3f")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputNormalRoleNone"]
assert property.GetType() == Sdr.PropertyTypes.Float
assert GetType(property) == Tf.Type.FindByName("GfVec3f")
assert Ndr._ValidateProperty(node, property)
property = nodeInputs["inputVectorRoleNone"]
assert property.GetType() == Sdr.PropertyTypes.Float
assert GetType(property) == Tf.Type.FindByName("GfVec3f")
assert Ndr._ValidateProperty(node, property)
property = nodeOutputs["outputSurface"]
assert property.GetType() == Sdr.PropertyTypes.Terminal
assert GetType(property) == Tf.Type.FindByName("TfToken")
assert Ndr._ValidateProperty(node, property)
# Specific test of implementationName feature, we can skip type-tests
property = nodeInputs["normal"]
assert property.GetImplementationName() == "aliasedNormalInput"
assert Ndr._ValidateProperty(node, property)
Binary file not shown.
+27
View File
@@ -0,0 +1,27 @@
#
# Copyright 2019 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.
#
# This file makes this module importable from python, which avoids a warning
# when initializing the SdrRegistry.
Binary file not shown.
+178
View File
@@ -0,0 +1,178 @@
#
# 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.
#
"""
Tf -- Tools Foundation
"""
def PrepareModule(module, result):
"""PrepareModule(module, result) -- Prepare an extension module at import
time. Generally, this should only be called by the __init__.py script for a
module upon loading a boost python module (generally '_LibName.so')."""
# inject into result.
ignore = frozenset(['__name__', '__builtins__',
'__doc__', '__file__', '__path__'])
newModuleName = result.get('__name__')
for key, value in module.__dict__.items():
if not key in ignore:
result[key] = value
# Lie about the module from which value came.
if newModuleName and hasattr(value, '__module__'):
try:
setattr(value, '__module__', newModuleName)
except AttributeError as e:
# The __module__ attribute of Boost.Python.function
# objects is not writable, so we get this exception
# a lot. Just ignore it. We're really only concerned
# about the data objects like enum values and such.
#
pass
def GetCodeLocation(framesUp):
"""Returns a tuple (moduleName, functionName, fileName, lineNo).
To trace the current location of python execution, use GetCodeLocation().
By default, the information is returned at the current stack-frame; thus
info = GetCodeLocation()
will return information about the line that GetCodeLocation() was called
from. One can write:
def genericDebugFacility():
info = GetCodeLocation(1)
# print out data
def someCode():
...
if bad:
genericDebugFacility()
and genericDebugFacility() will get information associated with its caller,
i.e. the function someCode()."""
import sys
f_back = sys._getframe(framesUp).f_back
return (f_back.f_globals['__name__'], f_back.f_code.co_name,
f_back.f_code.co_filename, f_back.f_lineno)
# for some strange reason, this errors out when we try to reload it,
# which is odd since _tf is a DSO and can't be reloaded anyway:
import sys
if "pxr.Tf._tf" not in sys.modules:
from . import _tf
PrepareModule(_tf, locals())
del _tf
del sys
# Need to provide an exception type that tf errors will show up as.
class ErrorException(RuntimeError):
def __init__(self, *args):
RuntimeError.__init__(self, *args)
self.__TfException = True
def __str__(self):
return '\n\t' + '\n\t'.join([str(e) for e in self.args])
__SetErrorExceptionClass(ErrorException)
try:
from . import __DOC
__DOC.Execute(locals())
del __DOC
except Exception:
pass
def Warn(msg, template=""):
"""Issue a warning via the TfDiagnostic system.
At this time, template is ignored.
"""
codeInfo = GetCodeLocation(framesUp=1)
_Warn(msg, codeInfo[0], codeInfo[1], codeInfo[2], codeInfo[3])
def Status(msg, verbose=True):
"""Issues a status update to the Tf diagnostic system.
If verbose is True (the default) then information about where in the code
the status update was issued from is included.
"""
if verbose:
codeInfo = GetCodeLocation(framesUp=1)
_Status(msg, codeInfo[0], codeInfo[1], codeInfo[2], codeInfo[3])
else:
_Status(msg, "", "", "", 0)
def RaiseCodingError(msg):
"""Raise a coding error to the Tf Diagnostic system."""
codeInfo = GetCodeLocation(framesUp=1)
_RaiseCodingError(msg, codeInfo[0], codeInfo[1], codeInfo[2], codeInfo[3])
def RaiseRuntimeError(msg):
"""Raise a runtime error to the Tf Diagnostic system."""
codeInfo = GetCodeLocation(framesUp=1)
_RaiseRuntimeError(msg, codeInfo[0], codeInfo[1], codeInfo[2], codeInfo[3])
def Fatal(msg):
"""Raise a fatal error to the Tf Diagnostic system."""
codeInfo = GetCodeLocation(framesUp=1)
_Fatal(msg, codeInfo[0], codeInfo[1], codeInfo[2], codeInfo[3])
class NamedTemporaryFile(object):
"""A named temporary file which keeps the internal file handle closed.
A class which constructs a temporary file(that isn't open) on __enter__,
provides its name as an attribute, and deletes it on __exit__.
Note: The constructor args for this object match those of
python's tempfile.mkstemp() function, and will have the same effect on
the underlying file created."""
def __init__(self, suffix='', prefix='', dir=None, text=False):
# Note that we defer creation until the enter block to
# prevent users from unintentionally creating a bunch of
# temp files that don't get cleaned up.
self._args = (suffix, prefix, dir, text)
def __enter__(self):
from tempfile import mkstemp
from os import close
fd, path = mkstemp(*self._args)
close(fd)
# XXX: We currently only expose the name attribute
# more can be added based on client needs in the future.
self._name = path
return self
def __exit__(self, *args):
import os
os.remove(self.name)
@property
def name(self):
"""The path for the temporary file created."""
return self._name
Binary file not shown.
Binary file not shown.
+24
View File
@@ -0,0 +1,24 @@
#
# 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.
#
Binary file not shown.
@@ -0,0 +1,59 @@
#
# Copyright 2021 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.
#
from pxr import Tf
def _NoArgs():
return "_NoArgs result"
def _ReturnInt():
return 42
def _RepeatStrings(stringList, numRepeats):
return [s * numRepeats for s in stringList]
def _ConcatWithList(arg1, arg2, *args):
return str.join(
" ",
[str(a) for a in
[arg1, arg2]
+ list(args)])
def _ConcatWithKwArgs(arg1, arg2, arg3 = "c", arg4 = "d", **kwargs):
return str.join(
" ",
[str(a) for a in
[arg1, arg2, arg3, arg4]
+ ["%s=%s" % (k, kwargs[k]) for k in sorted(kwargs.keys())]])
def _GetTheeToANonery(arg):
assert arg is None
_globalVar = 88
def _RaiseException():
raise Exception("test exception")
def _RaiseTfError():
Tf.RaiseRuntimeError("test error")
Binary file not shown.
@@ -0,0 +1,28 @@
#
# 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.
#
from pxr import Tf
raise RuntimeError('This module should not get loaded!')
@@ -0,0 +1,27 @@
#
# 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.
#
from pxr import Tf
Tf.ScriptModuleLoader()._LoadModulesForLibrary('DepLoadsAll')
@@ -0,0 +1,30 @@
#
# 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.
#
from pxr import Tf
Tf.ScriptModuleLoader()._LoadModulesForLibrary('LoadsAll')
# Request to load everything. This will be deferred by the TfScriptModuleLoader
# until after the current dependency load is complete.
Tf.ScriptModuleLoader()._LoadModulesForLibrary('')
@@ -0,0 +1,28 @@
#
# 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.
#
from pxr import Tf
Tf.ScriptModuleLoader()._LoadModulesForLibrary('LoadsUnknown')
from . import testTfScriptModuleLoader_Unknown
@@ -0,0 +1,26 @@
#
# 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.
#
from pxr import Tf
Tf.ScriptModuleLoader()._LoadModulesForLibrary('Other')
@@ -0,0 +1,25 @@
#
# 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.
#
pass
@@ -0,0 +1,42 @@
#
# 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.
#
from pxr import Tf
# Register this library with a new, previously unknown dependency. Note, we're
# just using 'sys' as the module to load here, which is a lie. It should really
# be this module, but it doesn't matter, and it's not trivial to come up with a
# robust, correct module name for this module.
Tf.ScriptModuleLoader()._RegisterLibrary('Unknown', 'sys',
['NewDynamicDependency'])
# Register the dependency. In this case we use 'sys' just because it saves us
# from creating a real module called NewDynamicDependency.
Tf.ScriptModuleLoader()._RegisterLibrary('NewDynamicDependency', 'sys', [])
# Load dependencies for this module, which includes the
# NewDynamicDependency. This is a reentrant load that will be handled
# immediately by TfScriptModuleLoader.
Tf.ScriptModuleLoader()._LoadModulesForLibrary('Unknown')
+101
View File
@@ -0,0 +1,101 @@
#
# Copyright 2018 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.
#
"""
Trace -- Utilities for counting and recording events.
"""
from . import _trace
from pxr import Tf
Tf.PrepareModule(_trace, locals())
del _trace, Tf
import contextlib
@contextlib.contextmanager
def TraceScope(label):
"""A context manager that calls BeginEvent on the global collector on enter
and EndEvent on exit."""
try:
collector = Collector()
eventId = collector.BeginEvent(label)
yield
finally:
collector.EndEvent(label)
del contextlib
def TraceFunction(obj):
"""A decorator that enables tracing the function that it decorates.
If you decorate with 'TraceFunction' the function will be traced in the
global collector."""
collector = Collector()
def decorate(func):
import inspect
if inspect.ismethod(func):
callableTypeLabel = 'method'
classLabel = func.__self__.__class__.__name__+'.'
else:
callableTypeLabel = 'func'
classLabel = ''
module = inspect.getmodule(func)
if module is not None:
moduleLabel = module.__name__+'.'
else:
moduleLabel = ''
label = 'Python {0}: {1}{2}{3}'.format(
callableTypeLabel,
moduleLabel,
classLabel,
func.__name__)
def invoke(*args, **kwargs):
with TraceScope(label):
return func(*args, **kwargs)
invoke.__name__ = func.__name__
# Make sure wrapper function gets attributes of wrapped function.
import functools
return functools.update_wrapper(invoke, func)
return decorate(obj)
def TraceMethod(obj):
"""A convenience. Same as TraceFunction but changes the recorded
label to use the term 'method' rather than 'function'."""
return TraceFunction(obj)
# Remove any private stuff, like test classes, if we are not being
# imported from a test.
try:
from . import __DOC
__DOC.Execute(locals())
del __DOC
except Exception:
pass
Binary file not shown.
+78
View File
@@ -0,0 +1,78 @@
#
# Copyright 2018 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.
#
# Execute a script with tracing enabled.
# Usage: python -m pxr.Trace [-o OUTPUT] [-c "command" | FILE]
from __future__ import print_function
import argparse, sys
parser = argparse.ArgumentParser(description='Trace script execution.')
parser.add_argument('-o', dest='output', metavar='OUTPUT',
type=str, default=None,
help='trace output; defaults to stdout')
parser.add_argument('-c', dest='cmd',
type=str,
help='trace <cmd> as a Python script')
parser.add_argument('file', metavar="FILE",
nargs='?',
default=None,
help='script to trace')
args = parser.parse_args()
if not args.cmd and not args.file:
print("Must specify a command or script to trace", file=sys.stderr)
sys.exit(1)
if args.cmd and args.file:
print("Only one of -c or FILE may be specified", file=sys.stderr)
sys.exit(1)
from pxr import Trace
env = {}
# Create a Main function that is traced so we always capture a useful
# top-level scope.
if args.file:
@Trace.TraceFunction
def Main():
exec(compile(open(args.file).read(), args.file, 'exec'), env)
else:
@Trace.TraceFunction
def Main():
exec(args.cmd, env)
try:
Trace.Collector().enabled = True
Main()
finally:
Trace.Collector().enabled = False
if args.output is not None:
Trace.Reporter.globalReporter.Report(args.output)
else:
Trace.Reporter.globalReporter.Report()
Binary file not shown.
Binary file not shown.
+34
View File
@@ -0,0 +1,34 @@
#
# 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.
#
from . import _usd
from pxr import Tf
Tf.PrepareModule(_usd, locals())
del Tf
try:
from . import __DOC
__DOC.Execute(locals())
del __DOC
except Exception:
pass
Binary file not shown.
Binary file not shown.
+42
View File
@@ -0,0 +1,42 @@
#
# Copyright 2019 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.
#
from . import _usdAppUtils
from pxr import Tf
Tf.PrepareModule(_usdAppUtils, locals())
del _usdAppUtils, Tf
try:
from . import __DOC
__DOC.Execute(locals())
del __DOC
except Exception:
pass
from . import cameraArgs
from . import colorArgs
from . import complexityArgs
from . import framesArgs
from . import rendererArgs
Binary file not shown.
Binary file not shown.
+57
View File
@@ -0,0 +1,57 @@
#
# Copyright 2019 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.
#
def AddCmdlineArgs(argsParser, defaultValue=None, altHelpText=''):
"""
Adds camera-related command line arguments to argsParser.
The resulting 'camera' argument will be an Sdf.Path. If no value is given
and defaultValue is not overridden, 'camera' will be a single-element path
containing the primary camera name.
"""
from pxr import Sdf
from pxr import UsdUtils
if defaultValue is None:
defaultValue = UsdUtils.GetPrimaryCameraName()
helpText = altHelpText
if not helpText:
helpText = (
'Which camera to use - may be given as either just the '
'camera\'s prim name (i.e. just the last element in the prim '
'path), or as a full prim path. Note that if only the prim name '
'is used and more than one camera exists with that name, which '
'one is used will effectively be random (default=%(default)s)')
# This avoids an Sdf warning if an empty string is given, which someone
# might do for example with usdview to open the app using the 'Free' camera
# instead of the primary camera.
def _ToSdfPath(inputArg):
if not inputArg:
return Sdf.Path.emptyPath
return Sdf.Path(inputArg)
argsParser.add_argument('--camera', '-cam', action='store',
type=_ToSdfPath, default=defaultValue, help=helpText)
Binary file not shown.
+38
View File
@@ -0,0 +1,38 @@
#
# Copyright 2019 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.
#
def AddCmdlineArgs(argsParser, defaultValue='sRGB', altHelpText=''):
"""
Adds color-related command line arguments to argsParser.
The resulting 'colorCorrectionMode' argument will be a Python string.
"""
helpText = altHelpText
if not helpText:
helpText = (
'the color correction mode to use (default=%(default)s)')
argsParser.add_argument('--colorCorrectionMode', '-color', action='store',
type=str, default=defaultValue,
choices=['disabled', 'sRGB', 'openColorIO'], help=helpText)
Binary file not shown.
@@ -0,0 +1,132 @@
#
# Copyright 2019 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.
#
class RefinementComplexities(object):
"""
An enum-like container of standard complexity settings.
"""
class _RefinementComplexity(object):
"""
Class which represents a level of mesh refinement complexity. Each
level has a string identifier, a display name, and a float complexity
value.
"""
def __init__(self, compId, name, value):
self._id = compId
self._name = name
self._value = value
def __repr__(self):
return self.id
@property
def id(self):
return self._id
@property
def name(self):
return self._name
@property
def value(self):
return self._value
LOW = _RefinementComplexity("low", "Low", 1.0)
MEDIUM = _RefinementComplexity("medium", "Medium", 1.1)
HIGH = _RefinementComplexity("high", "High", 1.2)
VERY_HIGH = _RefinementComplexity("veryhigh", "Very High", 1.3)
_ordered = (LOW, MEDIUM, HIGH, VERY_HIGH)
@classmethod
def ordered(cls):
"""
Get a tuple of all complexity levels in order.
"""
return cls._ordered
@classmethod
def fromId(cls, compId):
"""
Get a complexity from its identifier.
"""
matches = [comp for comp in cls._ordered if comp.id == compId]
if len(matches) == 0:
raise ValueError("No complexity with id '{}'".format(compId))
return matches[0]
@classmethod
def fromName(cls, name):
"""
Get a complexity from its display name.
"""
matches = [comp for comp in cls._ordered if comp.name == name]
if len(matches) == 0:
raise ValueError("No complexity with name '{}'".format(name))
return matches[0]
@classmethod
def next(cls, comp):
"""
Get the next highest level of complexity. If already at the highest
level, return it.
"""
if comp not in cls._ordered:
raise ValueError("Invalid complexity: {}".format(comp))
nextIndex = min(
len(cls._ordered) - 1,
cls._ordered.index(comp) + 1)
return cls._ordered[nextIndex]
@classmethod
def prev(cls, comp):
"""
Get the next lowest level of complexity. If already at the lowest
level, return it.
"""
if comp not in cls._ordered:
raise ValueError("Invalid complexity: {}".format(comp))
prevIndex = max(0, cls._ordered.index(comp) - 1)
return cls._ordered[prevIndex]
def AddCmdlineArgs(argsParser, defaultValue=RefinementComplexities.LOW,
altHelpText=''):
"""
Adds complexity-related command line arguments to argsParser.
The resulting 'complexity' argument will be one of the standard
RefinementComplexities.
"""
helpText = altHelpText
if not helpText:
helpText = ('level of refinement to use (default=%(default)s)')
argsParser.add_argument('--complexity', '-c', action='store',
type=RefinementComplexities.fromId,
default=defaultValue,
choices=[c for c in RefinementComplexities.ordered()],
help=helpText)
Loaded 100 of 15675 files, more files were not shown because too many files have changed in this diff. Show more