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

move pxrUsdStageNode and pxrUsdPointBasedDeformerNode registration to mayaUsd core #825

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
26 changes: 26 additions & 0 deletions lib/mayaUsd/nodes/proxyShapePlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@
#include <maya/MGlobal.h>
#include <maya/MFnPlugin.h>
#include <maya/MDrawRegistry.h>
#include <maya/MPxNode.h>

#include <pxr/base/tf/envSetting.h>

#include <mayaUsd/nodes/hdImagingShape.h>
#include <mayaUsd/nodes/pointBasedDeformerNode.h>
#include <mayaUsd/nodes/proxyShapeBase.h>
#include <mayaUsd/nodes/stageData.h>
#include <mayaUsd/nodes/stageNode.h>

PXR_NAMESPACE_USING_DIRECTIVE

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);

Expand Down
36 changes: 1 addition & 35 deletions plugin/pxr/maya/lib/usdMaya/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -76,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
Expand All @@ -102,28 +100,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=<PXR_TEST_DIR>/maya_profile
)
set(TEST_INSTALL_PREFIX "${PXR_INSTALL_PREFIX}")

pxr_install_test_dir(
SRC testenv/UsdExportAssemblyTest
Expand Down Expand Up @@ -221,22 +203,6 @@ pxr_register_test(testUsdImportNestedAssemblyAnimation
MAYA_APP_DIR=<PXR_TEST_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=<PXR_TEST_DIR>/maya_profile
)

pxr_register_test(testUsdMayaBlockSceneModificationContext
CUSTOM_PYTHON ${MAYA_PY_EXECUTABLE}
COMMAND "${TEST_INSTALL_PREFIX}/tests/testUsdMayaBlockSceneModificationContext"
Expand Down

This file was deleted.

23 changes: 0 additions & 23 deletions plugin/pxr/maya/plugin/pxrUsd/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@
#include "usdMaya/listShadingModesCommand.h"

#include <mayaUsd/listeners/notice.h>
#include <mayaUsd/nodes/pointBasedDeformerNode.h>
#include "usdMaya/proxyShape.h"
#include "usdMaya/referenceAssembly.h"
#include <mayaUsd/nodes/stageNode.h>
#include <mayaUsd/utils/undoHelperCommand.h>

#include <maya/MFnPlugin.h>
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions test/lib/mayaUsd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
add_subdirectory(nodes)
add_subdirectory(render)
25 changes: 25 additions & 0 deletions test/lib/mayaUsd/nodes/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@
# limitations under the License.
#

import os
import unittest

from pxr import Gf

from maya import OpenMaya as OM
from maya import OpenMayaAnim as OMA
from maya import cmds
from maya import standalone

import fixturesUtils

import os
import unittest


class testPointBasedDeformerNode(unittest.TestCase):

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/lib/usd/pxrUsdPreviewSurface/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions test/lib/usd/translators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand Down Expand Up @@ -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'))
Expand Down