Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autodesk: Provide enough information to allow matrix33 default values #2554

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pxr/usd/usdMtlx/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,11 @@ ShaderBuilder::AddProperty(
if (converted.valueTypeName) {
type = converted.valueTypeName.GetAsToken();
// Do not use GetAsToken for comparison as recommended in the API
if (converted.valueTypeName == SdfValueTypeNames->Bool) {
if (converted.valueTypeName == SdfValueTypeNames->Bool ||
converted.valueTypeName == SdfValueTypeNames->Matrix3d) {
defaultValue = UsdMtlxGetUsdValue(element, isOutput);
metadata.emplace(SdrPropertyMetadata->SdrUsdDefinitionType,
converted.valueTypeName.GetType().GetTypeName());
converted.valueTypeName.GetAliasesAsTokens().front());
}
}
else {
Expand Down
15 changes: 14 additions & 1 deletion pxr/usd/usdMtlx/testenv/testUsdMtlxDiscovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import os
os.environ['PXR_MTLX_PLUGIN_SEARCH_PATHS'] = os.getcwd()

from pxr import Tf, Ndr, Sdr
from pxr import Ndr, Sdr, Gf
import unittest

class TestDiscovery(unittest.TestCase):
Expand All @@ -42,6 +42,7 @@ def test_NodeDiscovery(self):
['pxr_nd_boolean',
'pxr_nd_float',
'pxr_nd_integer',
'pxr_nd_matrix33',
'pxr_nd_string',
'pxr_nd_vector',
'pxr_nd_vector_2',
Expand All @@ -54,6 +55,7 @@ def test_NodeDiscovery(self):
['pxr_nd_boolean',
'pxr_nd_float',
'pxr_nd_integer',
'pxr_nd_matrix33',
'pxr_nd_string',
'pxr_nd_vector'])

Expand All @@ -68,6 +70,7 @@ def test_NodeDiscovery(self):
['pxr_nd_boolean',
'pxr_nd_float',
'pxr_nd_integer',
'pxr_nd_matrix33',
'pxr_nd_string',
'pxr_nd_vector_2',
'pxr_nd_vector_noversion'])
Expand All @@ -88,6 +91,7 @@ def test_NodeDiscovery(self):
Ndr.Version(),
Ndr.Version(),
Ndr.Version(),
Ndr.Version(),
Ndr.Version(1),
Ndr.Version(2, 0),
Ndr.Version(2, 1),
Expand All @@ -103,6 +107,7 @@ def test_NodeDiscovery(self):
'pxr_nd_booleanDefaults',
'pxr_nd_float',
'pxr_nd_integer',
'pxr_nd_matrix33',
'pxr_nd_string',
'pxr_nd_vector_2',
'pxr_nd_vector_noversion'])
Expand All @@ -114,6 +119,7 @@ def test_NodeDiscovery(self):
Ndr.Version(),
Ndr.Version(),
Ndr.Version(),
Ndr.Version(),
Ndr.Version(2, 0),
Ndr.Version()])

Expand All @@ -127,6 +133,13 @@ def test_NodeDiscovery(self):
self.assertFalse(falseInput.GetDefaultValue())
self.assertFalse(falseInput.GetDefaultValueAsSdfType())

# Check default values of matrix33 inputs:
node = registry.GetNodeByIdentifier("pxr_nd_matrix33")
self.assertTrue(node)
matrixInput = node.GetInput("in")
self.assertEqual(matrixInput.GetDefaultValue(), Gf.Matrix3d(1,2,3,4,5,6,7,8,9))
self.assertEqual(matrixInput.GetDefaultValueAsSdfType(), Gf.Matrix3d(1,2,3,4,5,6,7,8,9))


if __name__ == '__main__':
unittest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
<input name="inFalse" type="boolean" value="false" />
<output name="out" type="boolean" />
</nodedef>
<nodedef name="pxr_nd_matrix33" node="UsdMtlxTestNode">
<input name="in" type="matrix33" value="1.0,2.0,3.0, 4.0,5.0,6.0, 7.0,8.0,9.0" />
<input name="note" type="string" value="" uniform="true" />
<output name="out" type="matrix33" />
</nodedef>
<nodedef name="pxr_nd_integer" node="UsdMtlxTestNode">
<input name="in" type="integer" />
<input name="note" type="string" value="" uniform="true" />
Expand Down Expand Up @@ -41,6 +46,7 @@
</nodedef>
<implementation name="im_boolean" nodedef="pxr_nd_boolean" file="mx_boolean.osl" function="mx_boolean" />
<implementation name="im_booleanDefaults" nodedef="pxr_nd_booleanDefaults" file="mx_boolean.osl" function="mx_booleanDefaults" />
<implementation name="im_matrix33" nodedef="pxr_nd_matrix33" file="mx_matrix33.osl" function="mx_matrix33" />
<implementation name="im_integer" nodedef="pxr_nd_integer" file="mx_integer.osl" function="mx_integer" />
<implementation name="im_float" nodedef="pxr_nd_float" file="mx_float.osl" function="mx_float" />
<implementation name="im_string" nodedef="pxr_nd_string" file="mx_string.osl" function="mx_string" />
Expand Down