From 14acc4cba5ac7480de7192dbbde982018bf5cc3b Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Fri, 9 Oct 2020 18:25:14 -0700 Subject: [PATCH 1/4] move pxrUsdStageNode and pxrUsdPointBasedDeformerNode registration to mayaUsd core These nodes are created when the "useAsAnimationCache" import arg is used. The import arg is built into the base import command, so the nodes must be registered and de-registered in the core, otherwise imports that use the arg will fail. --- lib/mayaUsd/nodes/proxyShapePlugin.cpp | 26 ++++++++++++++++++++++++ plugin/pxr/maya/plugin/pxrUsd/plugin.cpp | 23 --------------------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/lib/mayaUsd/nodes/proxyShapePlugin.cpp b/lib/mayaUsd/nodes/proxyShapePlugin.cpp index b88875f51a..996adc1b42 100644 --- a/lib/mayaUsd/nodes/proxyShapePlugin.cpp +++ b/lib/mayaUsd/nodes/proxyShapePlugin.cpp @@ -26,12 +26,15 @@ #include #include #include +#include #include #include +#include #include #include +#include PXR_NAMESPACE_USING_DIRECTIVE @@ -81,6 +84,23 @@ MayaUsdProxyShapePlugin::initialize(MFnPlugin& plugin) getProxyShapeClassification()); CHECK_MSTATUS(status); + // Stage and point-based deformer node registration. These nodes are + // created when the "useAsAnimationCache" import argument is used. + status = plugin.registerNode( + UsdMayaStageNode::typeName, + UsdMayaStageNode::typeId, + UsdMayaStageNode::creator, + UsdMayaStageNode::initialize); + CHECK_MSTATUS_AND_RETURN_IT(status); + + status = plugin.registerNode( + UsdMayaPointBasedDeformerNode::typeName, + UsdMayaPointBasedDeformerNode::typeId, + UsdMayaPointBasedDeformerNode::creator, + UsdMayaPointBasedDeformerNode::initialize, + MPxNode::kDeformerNode); + CHECK_MSTATUS_AND_RETURN_IT(status); + // Hybrid Hydra / VP2 rendering uses a draw override to draw the proxy // shape. The Pixar and MayaUsd plugins use the UsdMayaProxyDrawOverride, // so register it here. Native USD VP2 rendering uses a sub-scene override. @@ -176,6 +196,12 @@ MayaUsdProxyShapePlugin::finalize(MFnPlugin& plugin) CHECK_MSTATUS(status); } + status = plugin.deregisterNode(UsdMayaPointBasedDeformerNode::typeId); + CHECK_MSTATUS(status); + + status = plugin.deregisterNode(UsdMayaStageNode::typeId); + CHECK_MSTATUS(status); + status = plugin.deregisterNode(MayaUsdProxyShapeBase::typeId); CHECK_MSTATUS(status); diff --git a/plugin/pxr/maya/plugin/pxrUsd/plugin.cpp b/plugin/pxr/maya/plugin/pxrUsd/plugin.cpp index 9c3ab4dacf..41aa68ab49 100644 --- a/plugin/pxr/maya/plugin/pxrUsd/plugin.cpp +++ b/plugin/pxr/maya/plugin/pxrUsd/plugin.cpp @@ -26,10 +26,8 @@ #include "usdMaya/listShadingModesCommand.h" #include -#include #include "usdMaya/proxyShape.h" #include "usdMaya/referenceAssembly.h" -#include #include #include @@ -70,21 +68,6 @@ initializePlugin(MObject obj) status = MayaUsdProxyShapePlugin::initialize(plugin); CHECK_MSTATUS_AND_RETURN_IT(status); - status = plugin.registerNode( - UsdMayaStageNode::typeName, - UsdMayaStageNode::typeId, - UsdMayaStageNode::creator, - UsdMayaStageNode::initialize); - CHECK_MSTATUS_AND_RETURN_IT(status); - - status = plugin.registerNode( - UsdMayaPointBasedDeformerNode::typeName, - UsdMayaPointBasedDeformerNode::typeId, - UsdMayaPointBasedDeformerNode::creator, - UsdMayaPointBasedDeformerNode::initialize, - MPxNode::kDeformerNode); - CHECK_MSTATUS_AND_RETURN_IT(status); - status = plugin.registerShape( UsdMayaProxyShape::typeName, UsdMayaProxyShape::typeId, @@ -265,12 +248,6 @@ uninitializePlugin(MObject obj) status = plugin.deregisterNode(UsdMayaProxyShape::typeId); CHECK_MSTATUS(status); - status = plugin.deregisterNode(UsdMayaPointBasedDeformerNode::typeId); - CHECK_MSTATUS(status); - - status = plugin.deregisterNode(UsdMayaStageNode::typeId); - CHECK_MSTATUS(status); - status = MayaUsdProxyShapePlugin::finalize(plugin); CHECK_MSTATUS(status); From eba9c800872c13d84ec2a31042ba08dc87018e7f Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Mon, 31 Aug 2020 20:09:01 -0700 Subject: [PATCH 2/4] rename CMake target for pxrUsdPreviewSurface tests This clears the way for a MAYAUSD_NODES_TEST target in test/lib/mayaUsd/nodes. --- test/lib/usd/pxrUsdPreviewSurface/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lib/usd/pxrUsdPreviewSurface/CMakeLists.txt b/test/lib/usd/pxrUsdPreviewSurface/CMakeLists.txt index 9e6d771eb7..277ac37a32 100644 --- a/test/lib/usd/pxrUsdPreviewSurface/CMakeLists.txt +++ b/test/lib/usd/pxrUsdPreviewSurface/CMakeLists.txt @@ -1,4 +1,4 @@ -set(TARGET_NAME MAYAUSD_NODES_TEST) +set(TARGET_NAME MAYAUSD_PXR_USD_PREVIEW_SURFACE_TEST) # Unit test scripts. set(TEST_SCRIPT_FILES From eb8b6fe129d8e4bb368121c3e3268951ad750592 Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Mon, 31 Aug 2020 20:43:45 -0700 Subject: [PATCH 3/4] migrate testPointBasedDeformerNode test from plugin/pxr/... to test/lib/mayaUsd/nodes/... This change moves the unit test for the pxrUsdPointBasedDeformerNode in lib/mayaUsd/nodes from usdMaya in the Pixar plugin area to test/... A new directory was created for these node-specific tests. --- plugin/pxr/maya/lib/usdMaya/CMakeLists.txt | 19 +------------- test/lib/mayaUsd/CMakeLists.txt | 1 + test/lib/mayaUsd/nodes/CMakeLists.txt | 25 +++++++++++++++++++ .../DeformingCube.usda | 0 .../nodes}/testPointBasedDeformerNode.py | 15 +++++------ 5 files changed, 35 insertions(+), 25 deletions(-) create mode 100644 test/lib/mayaUsd/nodes/CMakeLists.txt rename {plugin/pxr/maya/lib/usdMaya/testenv => test/lib/mayaUsd/nodes}/PointBasedDeformerNodeTest/DeformingCube.usda (100%) rename {plugin/pxr/maya/lib/usdMaya/testenv => test/lib/mayaUsd/nodes}/testPointBasedDeformerNode.py (95%) diff --git a/plugin/pxr/maya/lib/usdMaya/CMakeLists.txt b/plugin/pxr/maya/lib/usdMaya/CMakeLists.txt index c564117036..c6b9b133e6 100644 --- a/plugin/pxr/maya/lib/usdMaya/CMakeLists.txt +++ b/plugin/pxr/maya/lib/usdMaya/CMakeLists.txt @@ -65,7 +65,6 @@ pxr_shared_library(${PXR_PACKAGE} ) pxr_test_scripts( - testenv/testPointBasedDeformerNode.py testenv/testUsdExportAssembly.py testenv/testUsdExportAssemblyEdits.py # testUsdExportPackage input file PackageTest.ma has a requirement on @@ -102,28 +101,12 @@ pxr_test_scripts( # B) we don't know the absolute path to the test directory at cmake-compile # time -pxr_install_test_dir( - SRC testenv/PointBasedDeformerNodeTest - DEST testPointBasedDeformerNode -) -set(TEST_INSTALL_PREFIX "${PXR_INSTALL_PREFIX}") - # MAYA-96273 (closed as by design) says that to obtain correct mayapy exit # codes starting with Maya 2018.4, the MAYA_NO_STANDALONE_ATEXIT environment # variable must be defined. Otherwise, mayapy unconditionally exits with 0 # (success), which completely masks test failures. -pxr_register_test(testPointBasedDeformerNode - CUSTOM_PYTHON ${MAYA_PY_EXECUTABLE} - COMMAND "${TEST_INSTALL_PREFIX}/tests/testPointBasedDeformerNode" - TESTENV testPointBasedDeformerNode - ENV - MAYA_PLUG_IN_PATH=${TEST_INSTALL_PREFIX}/maya/plugin - MAYA_SCRIPT_PATH=${TEST_INSTALL_PREFIX}/maya/lib/usd/usdMaya/resources - MAYA_DISABLE_CIP=1 - MAYA_NO_STANDALONE_ATEXIT=1 - MAYA_APP_DIR=/maya_profile -) +set(TEST_INSTALL_PREFIX "${PXR_INSTALL_PREFIX}") pxr_install_test_dir( SRC testenv/UsdExportAssemblyTest diff --git a/test/lib/mayaUsd/CMakeLists.txt b/test/lib/mayaUsd/CMakeLists.txt index 90e88a9928..96ee18759e 100644 --- a/test/lib/mayaUsd/CMakeLists.txt +++ b/test/lib/mayaUsd/CMakeLists.txt @@ -1 +1,2 @@ +add_subdirectory(nodes) add_subdirectory(render) diff --git a/test/lib/mayaUsd/nodes/CMakeLists.txt b/test/lib/mayaUsd/nodes/CMakeLists.txt new file mode 100644 index 0000000000..1e368280ca --- /dev/null +++ b/test/lib/mayaUsd/nodes/CMakeLists.txt @@ -0,0 +1,25 @@ +set(TARGET_NAME MAYAUSD_NODES_TEST) + +set(TEST_SCRIPT_FILES + testPointBasedDeformerNode.py +) + +add_custom_target(${TARGET_NAME} ALL) + +# copy all the resources and Python scripts to build directory +mayaUsd_copyDirectory(${TARGET_NAME} + SOURCE ${CMAKE_CURRENT_SOURCE_DIR} + DESTINATION ${CMAKE_CURRENT_BINARY_DIR} + EXCLUDE "*.txt" +) + +foreach(script ${TEST_SCRIPT_FILES}) + mayaUsd_get_unittest_target(target ${script}) + mayaUsd_add_test(${target} + PYTHON_MODULE ${target} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) + + # Add a ctest label to these tests for easy filtering. + set_property(TEST ${target} APPEND PROPERTY LABELS nodes) +endforeach() diff --git a/plugin/pxr/maya/lib/usdMaya/testenv/PointBasedDeformerNodeTest/DeformingCube.usda b/test/lib/mayaUsd/nodes/PointBasedDeformerNodeTest/DeformingCube.usda similarity index 100% rename from plugin/pxr/maya/lib/usdMaya/testenv/PointBasedDeformerNodeTest/DeformingCube.usda rename to test/lib/mayaUsd/nodes/PointBasedDeformerNodeTest/DeformingCube.usda diff --git a/plugin/pxr/maya/lib/usdMaya/testenv/testPointBasedDeformerNode.py b/test/lib/mayaUsd/nodes/testPointBasedDeformerNode.py similarity index 95% rename from plugin/pxr/maya/lib/usdMaya/testenv/testPointBasedDeformerNode.py rename to test/lib/mayaUsd/nodes/testPointBasedDeformerNode.py index d4a7a4589b..1aba2323ff 100644 --- a/plugin/pxr/maya/lib/usdMaya/testenv/testPointBasedDeformerNode.py +++ b/test/lib/mayaUsd/nodes/testPointBasedDeformerNode.py @@ -15,9 +15,6 @@ # limitations under the License. # -import os -import unittest - from pxr import Gf from maya import OpenMaya as OM @@ -25,6 +22,11 @@ from maya import cmds from maya import standalone +import fixturesUtils + +import os +import unittest + class testPointBasedDeformerNode(unittest.TestCase): @@ -36,11 +38,10 @@ class testPointBasedDeformerNode(unittest.TestCase): @classmethod def setUpClass(cls): - standalone.initialize('usd') - - cmds.loadPlugin('pxrUsd') + inputPath = fixturesUtils.setUpClass(__file__) - cls._deformingCubeUsdFilePath = os.path.abspath('DeformingCube.usda') + cls._deformingCubeUsdFilePath = os.path.join(inputPath, + 'PointBasedDeformerNodeTest', 'DeformingCube.usda') cls._deformingCubePrimPath = '/DeformingCube/Geom/Cube' @classmethod From 1cf4c26dc89148d5b4c4108e8e333c5d811f0116 Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Tue, 1 Sep 2020 00:21:36 -0700 Subject: [PATCH 4/4] migrate testUsdTranslateTypelessDefs test from pxr's usdMaya to test/... as testUsdImportExportTypelessDefs --- plugin/pxr/maya/lib/usdMaya/CMakeLists.txt | 17 ----------- .../ExoticTypeNames.usda | 20 ------------- test/lib/usd/translators/CMakeLists.txt | 1 + .../ExoticTypeNames.usda | 30 +++++++++++++++++++ .../testUsdImportExportTypelessDefs.py | 28 +++++++++-------- 5 files changed, 46 insertions(+), 50 deletions(-) delete mode 100644 plugin/pxr/maya/lib/usdMaya/testenv/UsdTranslateTypelessDefs/ExoticTypeNames.usda create mode 100644 test/lib/usd/translators/UsdImportExportTypelessDefsTest/ExoticTypeNames.usda rename plugin/pxr/maya/lib/usdMaya/testenv/testUsdTranslateTypelessDefs.py => test/lib/usd/translators/testUsdImportExportTypelessDefs.py (88%) diff --git a/plugin/pxr/maya/lib/usdMaya/CMakeLists.txt b/plugin/pxr/maya/lib/usdMaya/CMakeLists.txt index c6b9b133e6..af3dfb58ef 100644 --- a/plugin/pxr/maya/lib/usdMaya/CMakeLists.txt +++ b/plugin/pxr/maya/lib/usdMaya/CMakeLists.txt @@ -75,7 +75,6 @@ pxr_test_scripts( testenv/testUsdExportPointInstancer.py testenv/testUsdImportAsAssemblies.py testenv/testUsdImportNestedAssemblyAnimation.py - testenv/testUsdTranslateTypelessDefs.py testenv/testUsdMayaBlockSceneModificationContext.py testenv/testUsdMayaDiagnosticDelegate.py testenv/testUsdMayaGetVariantSetSelections.py @@ -204,22 +203,6 @@ pxr_register_test(testUsdImportNestedAssemblyAnimation MAYA_APP_DIR=/maya_profile ) -pxr_install_test_dir( - SRC testenv/UsdTranslateTypelessDefs - DEST testUsdTranslateTypelessDefs -) -pxr_register_test(testUsdTranslateTypelessDefs - CUSTOM_PYTHON ${MAYA_PY_EXECUTABLE} - COMMAND "${TEST_INSTALL_PREFIX}/tests/testUsdTranslateTypelessDefs" - TESTENV testUsdTranslateTypelessDefs - ENV - MAYA_PLUG_IN_PATH=${TEST_INSTALL_PREFIX}/maya/plugin - MAYA_SCRIPT_PATH=${TEST_INSTALL_PREFIX}/maya/lib/usd/usdMaya/resources - MAYA_DISABLE_CIP=1 - MAYA_NO_STANDALONE_ATEXIT=1 - MAYA_APP_DIR=/maya_profile -) - pxr_register_test(testUsdMayaBlockSceneModificationContext CUSTOM_PYTHON ${MAYA_PY_EXECUTABLE} COMMAND "${TEST_INSTALL_PREFIX}/tests/testUsdMayaBlockSceneModificationContext" diff --git a/plugin/pxr/maya/lib/usdMaya/testenv/UsdTranslateTypelessDefs/ExoticTypeNames.usda b/plugin/pxr/maya/lib/usdMaya/testenv/UsdTranslateTypelessDefs/ExoticTypeNames.usda deleted file mode 100644 index d10a16eda3..0000000000 --- a/plugin/pxr/maya/lib/usdMaya/testenv/UsdTranslateTypelessDefs/ExoticTypeNames.usda +++ /dev/null @@ -1,20 +0,0 @@ -#usda 1.0 - -def Xform "A" { - def "A_1" { - def "A_1_I" { - } - def Cube "A_1_II" { - } - def Scope "A_1_III" { - } - } - def Scope "A_2" { - } -} - -def "B" { - def Xform "B_1" { - } -} - diff --git a/test/lib/usd/translators/CMakeLists.txt b/test/lib/usd/translators/CMakeLists.txt index 19052d8d58..3434b2467d 100644 --- a/test/lib/usd/translators/CMakeLists.txt +++ b/test/lib/usd/translators/CMakeLists.txt @@ -41,6 +41,7 @@ set(TEST_SCRIPT_FILES testUsdImportCamera.py testUsdImportColorSets.py testUsdImportExportScope.py + testUsdImportExportTypelessDefs.py # To investigate: following test asserts in TDNshapeEditorManager.cpp, but # passes. PPT, 17-Jun-20. testUsdImportFrameRange.py diff --git a/test/lib/usd/translators/UsdImportExportTypelessDefsTest/ExoticTypeNames.usda b/test/lib/usd/translators/UsdImportExportTypelessDefsTest/ExoticTypeNames.usda new file mode 100644 index 0000000000..4911fc9f30 --- /dev/null +++ b/test/lib/usd/translators/UsdImportExportTypelessDefsTest/ExoticTypeNames.usda @@ -0,0 +1,30 @@ +#usda 1.0 + +def Xform "A" +{ + def "A_1" + { + def "A_1_I" + { + } + + def Cube "A_1_II" + { + } + + def Scope "A_1_III" + { + } + } + + def Scope "A_2" + { + } +} + +def "B" +{ + def Xform "B_1" + { + } +} diff --git a/plugin/pxr/maya/lib/usdMaya/testenv/testUsdTranslateTypelessDefs.py b/test/lib/usd/translators/testUsdImportExportTypelessDefs.py similarity index 88% rename from plugin/pxr/maya/lib/usdMaya/testenv/testUsdTranslateTypelessDefs.py rename to test/lib/usd/translators/testUsdImportExportTypelessDefs.py index cbafd49850..5b0d964ba0 100644 --- a/plugin/pxr/maya/lib/usdMaya/testenv/testUsdTranslateTypelessDefs.py +++ b/test/lib/usd/translators/testUsdImportExportTypelessDefs.py @@ -15,25 +15,25 @@ # limitations under the License. # - -import os -import unittest +from pxr import Usd from maya import cmds from maya import standalone -from pxr import Usd +import fixturesUtils +import os +import unittest -class testUsdTranslateTypelessDefs(unittest.TestCase): - USD_FILE = os.path.abspath('ExoticTypeNames.usda') - USD_FILE_OUT = os.path.abspath('ExoticTypeNames.reexported.usda') +class testUsdImportExportTypelessDefs(unittest.TestCase): @classmethod def setUpClass(cls): - standalone.initialize('usd') - cmds.loadPlugin('pxrUsd') + inputPath = fixturesUtils.setUpClass(__file__) + + cls._usdFile = os.path.join(inputPath, + "UsdImportExportTypelessDefsTest", "ExoticTypeNames.usda") @classmethod def tearDownClass(cls): @@ -43,7 +43,7 @@ def setUp(self): cmds.file(new=True, force=True) def testImport(self): - cmds.usdImport(file=self.USD_FILE, primPath='/') + cmds.mayaUSDImport(file=self._usdFile, primPath='/') dagObjects = cmds.ls(long=True, dag=True) self.assertIn('|A', dagObjects) @@ -89,10 +89,12 @@ def testImport(self): self.assertFalse(cmds.getAttr('|B|B_1.tx', lock=True)) def testReexport(self): - cmds.usdImport(file=self.USD_FILE, primPath='/') - cmds.usdExport(file=self.USD_FILE_OUT) + cmds.mayaUSDImport(file=self._usdFile, primPath='/') + + exportedUsdFile = os.path.abspath('ExoticTypeNames.reexported.usda') + cmds.mayaUSDExport(file=exportedUsdFile) - stage = Usd.Stage.Open(self.USD_FILE_OUT) + stage = Usd.Stage.Open(exportedUsdFile) self.assertTrue(stage) self.assertTrue(stage.GetPrimAtPath('/A'))