Skip to content

Commit

Permalink
Merge pull request #944 from Autodesk/donnels/proxy_shape_ae_template…
Browse files Browse the repository at this point in the history
…_part_2

Proxy Shape AE Template - Part 2
  • Loading branch information
Krystian Ligenza authored Nov 30, 2020
2 parents e3438c2 + fd9a6e8 commit 192ef72
Show file tree
Hide file tree
Showing 27 changed files with 156 additions and 99 deletions.
7 changes: 7 additions & 0 deletions lib/mayaUsd/nodes/proxyShapeBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@

#if defined(WANT_UFE_BUILD)
#include <ufe/path.h>
#ifdef UFE_V2_FEATURES_AVAILABLE
#include <ufe/pathString.h>
#endif
#endif

using namespace MAYAUSD_NS_DEF;
Expand Down Expand Up @@ -1219,10 +1222,14 @@ Ufe::Path MayaUsdProxyShapeBase::ufePath() const
MDagPath thisPath;
MDagPath::getAPathTo(thisMObject(), thisPath);

#ifdef UFE_V2_FEATURES_AVAILABLE
return Ufe::PathString::path(thisPath.fullPathName().asChar());
#else
// MDagPath does not include |world to its full path name
MString fullpath = "|world" + thisPath.fullPathName();

return Ufe::Path(Ufe::PathSegment(fullpath.asChar(), MAYA_UFE_RUNTIME_ID, MAYA_UFE_SEPARATOR));
#endif
}
#endif

Expand Down
9 changes: 7 additions & 2 deletions lib/mayaUsd/ufe/StagesSubject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,13 @@ void StagesSubject::onStageInvalidate(const MayaUsdProxyStageInvalidateNotice& n
afterOpen();

#ifdef UFE_V2_FEATURES_AVAILABLE
Ufe::SceneItem::Ptr sceneItem = Ufe::Hierarchy::createItem(notice.GetProxyShape().ufePath());
Ufe::Scene::instance().notify(Ufe::SubtreeInvalidate(sceneItem));
auto p = notice.GetProxyShape().ufePath();
if (!p.empty()) {
Ufe::SceneItem::Ptr sceneItem = Ufe::Hierarchy::createItem(p);
if (sceneItem) {
Ufe::Scene::instance().notify(Ufe::SubtreeInvalidate(sceneItem));
}
}
#endif
}

Expand Down
7 changes: 7 additions & 0 deletions lib/mayaUsd/ufe/wrapUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

#include <ufe/rtid.h>
#include <ufe/runTimeMgr.h>
#ifdef UFE_V2_FEATURES_AVAILABLE
#include <ufe/pathString.h>
#endif

#include <boost/python.hpp>

Expand Down Expand Up @@ -61,10 +64,14 @@ std::string getNodeTypeFromRawItem(uint64_t rawItem)

UsdStageWeakPtr getStage(const std::string& ufePathString)
{
#ifdef UFE_V2_FEATURES_AVAILABLE
return ufe::getStage(Ufe::PathString::path(ufePathString));
#else
// This function works on a single-segment path, i.e. the Maya Dag path
// segment to the proxy shape. We know the Maya run-time ID is 1,
// separator is '|'.
return ufe::getStage(Ufe::Path(Ufe::PathSegment(ufePathString, 1, '|')));
#endif
}

std::string stagePath(UsdStageWeakPtr stage)
Expand Down
24 changes: 24 additions & 0 deletions plugin/adsk/scripts/AETemplateHelpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import ufe
import mayaUsd.ufe

def GetDefaultPrimName(proxyShape):
try:
proxyStage = mayaUsd.ufe.getStage(proxyShape)
if proxyStage:
defPrim = proxyStage.GetDefaultPrim()
if defPrim:
return defPrim.GetName()
except:
pass
return ''

def GetRootLayerName(proxyShape):
try:
proxyStage = mayaUsd.ufe.getStage(proxyShape)
if proxyStage:
rootLayer = proxyStage.GetRootLayer()
if rootLayer:
return rootLayer.GetDisplayName() if rootLayer.anonymous else rootLayer.realPath
except:
pass
return ''
77 changes: 59 additions & 18 deletions plugin/adsk/scripts/AEmayaUsdProxyShapeTemplate.mel
Original file line number Diff line number Diff line change
@@ -1,7 +1,66 @@
global proc AEmayaUsdProxyShapeInfoNew(string $input)
{
textFieldGrp -label "Root Layer" -editable 0
-ann "Identifies the root layer of a stage. If a file path is shown in this field, the root layer is a file on disk. If a layerName is shown in this field, the root layer is an anonymous layer."
mayaUsdProxyShapeRootLayer;

textFieldGrp -label "Default Prim" -editable 0
-ann "As part of its metadata, each stage can identify a default prim. This is the primitive that is referenced in if you reference in a file."
mayaUsdProxyShapeDefaultPrim;

AEmayaUsdProxyShapeInfoReplace($input);
}

global proc AEmayaUsdProxyShapeInfoReplace(string $input)
{
// From the input attribute we simply want the node name.
string $nodeName = plugNode($input);
string $res[] = `ls -l $nodeName`;
string $fullNodeName = $res[0];

// Call python helpers to get the info we want to display.
string $rootLayer = `python("import AETemplateHelpers; AETemplateHelpers.GetRootLayerName('" + $fullNodeName + "')")`;
string $defaultPrim = `python("import AETemplateHelpers; AETemplateHelpers.GetDefaultPrimName('" + $fullNodeName + "')")`;

textFieldGrp -edit -text $rootLayer mayaUsdProxyShapeRootLayer;
textFieldGrp -edit -text $defaultPrim mayaUsdProxyShapeDefaultPrim;
}

global proc AEmayaUsdProxyShapeTemplate( string $nodeName )
{
editorTemplate -beginScrollLayout;

//
// Proxy Shape specific attributes
//
editorTemplate -suppress "complexity";
editorTemplate -suppress "inStageData";
editorTemplate -suppress "stageCacheId";
editorTemplate -suppress "outStageCacheId";

editorTemplate -beginLayout "Stage" -collapse 0;
// We aren't displaying the "inStageData" attribute in the ProxyShapeInfo. We simply
// pass it in order to get the current nodename. Cannot use the input one here as it
// changes based on which proxy shape the AE is viewing.
editorTemplate -callCustom "AEmayaUsdProxyShapeInfoNew" "AEmayaUsdProxyShapeInfoReplace" inStageData;
editorTemplate -addControl "loadPayloads";
editorTemplate -endLayout;

editorTemplate -beginLayout "Stage Source" -collapse 0;
editorTemplate -addControl "filePath";
editorTemplate -endLayout;

editorTemplate -beginLayout "Stage Display" -collapse 0;
editorTemplate -ann "Edits the current time value of a stage, which corresponds to the animation frame drawn in the viewport. By default, this value connects to Maya's global time node."
-addControl "time";
editorTemplate -addControl "drawGuidePurpose";
editorTemplate -addControl "drawProxyPurpose";
editorTemplate -addControl "drawRenderPurpose";
editorTemplate -addControl "primPath";
editorTemplate -addControl "excludePrimPaths";
editorTemplate -endLayout;


// Object Display (from AEdagNodeCommon.mel):
editorTemplate -beginLayout (uiRes("m_AEshapeTemplate.kObjectDisplay"));
editorTemplate -beginNoOptimize;
Expand Down Expand Up @@ -31,24 +90,6 @@ global proc AEmayaUsdProxyShapeTemplate( string $nodeName )
editorTemplate -callCustom "AEdependNodeUUIDNew" "AEdependNodeUUIDReplace" "nodeState";
editorTemplate -endLayout;

// Proxy Shape specific attributes
editorTemplate -beginLayout "Stage" -collapse 0;
editorTemplate -beginNoOptimize;
editorTemplate -suppress "complexity";
editorTemplate -suppress "inStageData";
editorTemplate -addControl "filePath";
editorTemplate -addControl "primPath";
editorTemplate -addControl "excludePrimPaths";
editorTemplate -addControl "loadPayloads";
editorTemplate -addControl "time";
editorTemplate -addControl "stageCacheId";
editorTemplate -addControl "drawRenderPurpose";
editorTemplate -addControl "drawProxyPurpose";
editorTemplate -addControl "drawGuidePurpose";
editorTemplate -addControl "outStageCacheId";
editorTemplate -endNoOptimize;
editorTemplate -endLayout;

// Displacement Map (completely remove):
editorTemplate -suppress "featureDisplacement";
editorTemplate -suppress "initialSampleRate";
Expand Down
1 change: 1 addition & 0 deletions plugin/adsk/scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ list(APPEND scripts_src
mayaUsdTranslatorImport.mel
mayaUsdTranslatorExport.mel
AEmayaUsdProxyShapeTemplate.mel
AETemplateHelpers.py
mayaUsdMenu.mel
mayaUsd_createStageFromFile.mel
mayaUsd_createStageWithNewLayer.py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ void ProxyDrawOverride::draw(const MHWRender::MDrawContext& context, const MUser
SdfPathVector ufePaths;
auto ufeSelList = Ufe::GlobalSelection::get();

Ufe::PathSegment proxyUfePath = ptr->m_shape->ufePathSegment();
Ufe::PathSegment proxyUfePath = ptr->m_shape->ufePath().getSegments()[0];
for (const auto& sceneItem : *ufeSelList) {
if (sceneItem->runTimeId() == USD_UFE_RUNTIME_ID) {
const Ufe::Path& itemPath = sceneItem->path();
Expand Down
17 changes: 0 additions & 17 deletions plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1905,23 +1905,6 @@ MSelectionMask ProxyShape::getShapeSelectionMask() const
return MSelectionMask(selType);
}

#if defined(WANT_UFE_BUILD)
//----------------------------------------------------------------------------------------------------------------------
Ufe::PathSegment ProxyShape::ufePathSegment() const
{
// Build a path segment to proxyShape
MDagPath thisPath;
MDagPath::getAPathTo(thisMObject(), thisPath);

// MDagPath does not include |world to its full path naem
MString fullpath = "|world" + thisPath.fullPathName();

return Ufe::PathSegment(fullpath.asChar(), MAYA_UFE_RUNTIME_ID, MAYA_UFE_SEPARATOR);
}

Ufe::Path ProxyShape::ufePath() const { return Ufe::Path(ProxyShape::ufePathSegment()); }
#endif

//----------------------------------------------------------------------------------------------------------------------
} // namespace nodes
} // namespace usdmaya
Expand Down
12 changes: 0 additions & 12 deletions plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -833,18 +833,6 @@ class ProxyShape
AL_USDMAYA_PUBLIC
SdfPathVector getPrimPathsFromCommaJoinedString(const MString& paths) const;

#if defined(WANT_UFE_BUILD)
/// \brief Get the UFE path of the maya proxy shape
/// \return An UFE path containing the path to the proxy shape
AL_USDMAYA_PUBLIC
Ufe::Path ufePath() const;

/// \brief Get the UFE path segment of the maya proxy shape
/// \return An UFE path segment containing the maya path to the proxy shape
AL_USDMAYA_PUBLIC
Ufe::PathSegment ufePathSegment() const;
#endif

/// \brief Returns the selection mask of the shape
AL_USDMAYA_PUBLIC
MSelectionMask getShapeSelectionMask() const override;
Expand Down
4 changes: 2 additions & 2 deletions test/lib/ufe/testAttribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def runTestAttribute(self, path, attrName, ufeAttrClass, ufeAttrType):

# Get a UFE scene item the input path in the scene.
itemPath = ufe.Path([
mayaUtils.createUfePathSegment("|world|transform1|proxyShape1"),
mayaUtils.createUfePathSegment("|transform1|proxyShape1"),
usdUtils.createUfePathSegment(path)])
ufeItem = ufe.Hierarchy.createItem(itemPath)

Expand Down Expand Up @@ -420,7 +420,7 @@ def testObservation(self):
# Create three observers, one for global attribute observation, and two
# on different UFE items.
proxyShapePathSegment = mayaUtils.createUfePathSegment(
"|world|transform1|proxyShape1")
"|transform1|proxyShape1")
path = ufe.Path([
proxyShapePathSegment,
usdUtils.createUfePathSegment('/Room_set/Props/Ball_34')])
Expand Down
2 changes: 1 addition & 1 deletion test/lib/ufe/testAttributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def testAttributes(self):

# Get a UFE scene item for one of the balls in the scene.
ball35Path = ufe.Path([
mayaUtils.createUfePathSegment("|world|transform1|proxyShape1"),
mayaUtils.createUfePathSegment("|transform1|proxyShape1"),
usdUtils.createUfePathSegment("/Room_set/Props/Ball_35")])
ball35Item = ufe.Hierarchy.createItem(ball35Path)

Expand Down
2 changes: 1 addition & 1 deletion test/lib/ufe/testComboCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def testComboUSD(self):

# Select Ball_35 to move, rotate, and scale it.
ball35Path = ufe.Path([
mayaUtils.createUfePathSegment("|world|transform1|proxyShape1"),
mayaUtils.createUfePathSegment("|transform1|proxyShape1"),
usdUtils.createUfePathSegment("/Room_set/Props/Ball_35")])
ball35Item = ufe.Hierarchy.createItem(ball35Path)

Expand Down
8 changes: 4 additions & 4 deletions test/lib/ufe/testContextOps.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def setUp(self):

# Select Ball_35.
ball35Path = ufe.Path([
mayaUtils.createUfePathSegment("|world|transform1|proxyShape1"),
mayaUtils.createUfePathSegment("|transform1|proxyShape1"),
usdUtils.createUfePathSegment("/Room_set/Props/Ball_35")])
self.ball35Item = ufe.Hierarchy.createItem(ball35Path)
self.ball35Prim = usdUtils.getPrimFromSceneItem(self.ball35Item)
Expand Down Expand Up @@ -218,7 +218,7 @@ def testAddNewPrim(self):
ufe.Scene.addObserver(ufeObs)

# Create a ContextOps interface for the proxy shape.
proxyShapePath = ufe.Path([mayaUtils.createUfePathSegment("|world|stage1|stageShape1")])
proxyShapePath = ufe.Path([mayaUtils.createUfePathSegment("|stage1|stageShape1")])
proxyShapeItem = ufe.Hierarchy.createItem(proxyShapePath)
contextOps = ufe.ContextOps.contextOps(proxyShapeItem)

Expand Down Expand Up @@ -319,7 +319,7 @@ def testAddNewPrimWithDelete(self):
mayaUsd_createStageWithNewLayer.createStageWithNewLayer()

# Create a ContextOps interface for the proxy shape.
proxyShapePath = ufe.Path([mayaUtils.createUfePathSegment("|world|stage1|stageShape1")])
proxyShapePath = ufe.Path([mayaUtils.createUfePathSegment("|stage1|stageShape1")])
proxyShapeItem = ufe.Hierarchy.createItem(proxyShapePath)
contextOps = ufe.ContextOps.contextOps(proxyShapeItem)

Expand Down Expand Up @@ -358,7 +358,7 @@ def testLoadAndUnload(self):
Descendants", and "Unload".
'''
proxyShapePathSegment = mayaUtils.createUfePathSegment(
'|world|transform1|proxyShape1')
'|transform1|proxyShape1')

propsPath = ufe.Path([
proxyShapePathSegment,
Expand Down
4 changes: 2 additions & 2 deletions test/lib/ufe/testDeleteCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def testDelete(self):
sphereShapeItem = ufe.Hierarchy.createItem(sphereShapePath)

mayaSegment = mayaUtils.createUfePathSegment(
"|world|transform1|proxyShape1")
"|transform1|proxyShape1")
ball35Path = ufe.Path(
[mayaSegment,
usdUtils.createUfePathSegment("/Room_set/Props/Ball_35")])
Expand Down Expand Up @@ -210,7 +210,7 @@ def testDeleteArgs(self):
sphereShapeItem = ufe.Hierarchy.createItem(sphereShapePath)

mayaSegment = mayaUtils.createUfePathSegment(
"|world|transform1|proxyShape1")
"|transform1|proxyShape1")
ball35Path = ufe.Path(
[mayaSegment,
usdUtils.createUfePathSegment("/Room_set/Props/Ball_35")])
Expand Down
2 changes: 1 addition & 1 deletion test/lib/ufe/testDuplicateCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def testDuplicate(self):

ball35Path = ufe.Path([
mayaUtils.createUfePathSegment(
"|world|transform1|proxyShape1"),
"|transform1|proxyShape1"),
usdUtils.createUfePathSegment("/Room_set/Props/Ball_35")])
ball35Item = ufe.Hierarchy.createItem(ball35Path)
ball35Hierarchy = ufe.Hierarchy.hierarchy(ball35Item)
Expand Down
2 changes: 1 addition & 1 deletion test/lib/ufe/testGroupCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def testUsdGroup(self):
'''Creation of USD group objects.'''

mayaPathSegment = mayaUtils.createUfePathSegment(
"|world|transform1|proxyShape1")
"|transform1|proxyShape1")

usdSegmentBall5 = usdUtils.createUfePathSegment(
"/Ball_set/Props/Ball_5")
Expand Down
4 changes: 2 additions & 2 deletions test/lib/ufe/testMatrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def testMatrices(self):

# Next, rotate the USD object by another 30 degrees around X. To
# do so, select it first.
mayaPathSegment = mayaUtils.createUfePathSegment('|world|mayaUsdTransform|shape')
mayaPathSegment = mayaUtils.createUfePathSegment('|mayaUsdTransform|shape')
usdPathSegment = usdUtils.createUfePathSegment('/pCylinder1')
cylinderPath = ufe.Path([mayaPathSegment, usdPathSegment])
cylinderItem = ufe.Hierarchy.createItem(cylinderPath)
Expand All @@ -118,7 +118,7 @@ def testMatrices(self):

# Get a Transform3d interface for the proxy shape's transform, and
# get its transforms.
xformPath = ufe.Path(mayaUtils.createUfePathSegment('|world|mayaUsdTransform'))
xformPath = ufe.Path(mayaUtils.createUfePathSegment('|mayaUsdTransform'))
xformItem = ufe.Hierarchy.createItem(xformPath)
t3d = ufe.Transform3d.transform3d(xformItem)

Expand Down
6 changes: 3 additions & 3 deletions test/lib/ufe/testMayaPickwalk.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,14 @@ def test_pickWalk(self):
# Pickwalk on Non-Mixed Maya items is already tested in Maya regression tests
# Pickwalk on Non-Mixed USD items
ufeUtils.selectPath(ufe.Path([ \
mayaUtils.createUfePathSegment("|world|transform1|proxyShape1"), \
mayaUtils.createUfePathSegment("|transform1|proxyShape1"), \
usdUtils.createUfePathSegment("/Room_set/Props/Ball_1") \
]), True)
self.snapShotAndTest(([], ['Ball_1']))


ufeUtils.selectPath(ufe.Path([ \
mayaUtils.createUfePathSegment("|world|transform1|proxyShape1"), \
mayaUtils.createUfePathSegment("|transform1|proxyShape1"), \
usdUtils.createUfePathSegment("/Room_set/Props/Ball_2") \
]))
self.snapShotAndTest(([], ['Ball_1', 'Ball_2']))
Expand All @@ -202,7 +202,7 @@ def test_pickWalk(self):

# Pickwalk on mixed items
ufeUtils.selectPath(ufe.Path([ \
mayaUtils.createUfePathSegment("|world|transform1|proxyShape1"), \
mayaUtils.createUfePathSegment("|transform1|proxyShape1"), \
usdUtils.createUfePathSegment("/Room_set/Props/Ball_1") \
]), True)
self.snapShotAndTest(([], ['Ball_1']))
Expand Down
Loading

0 comments on commit 192ef72

Please sign in to comment.