-
Notifications
You must be signed in to change notification settings - Fork 201
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
Disable edit as Maya for materials. #2631
Merged
seando-adsk
merged 1 commit into
dev
from
tremblp/MAYA-123848/prevent_usdShade_editAsMaya
Sep 28, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// Copyright 2022 Autodesk | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
#include "materialUpdater.h" | ||
|
||
#include "shadingTokens.h" | ||
|
||
#include <mayaUsd/fileio/primUpdaterRegistry.h> | ||
|
||
#include <pxr/pxr.h> | ||
#include <pxr/usd/usdShade/material.h> | ||
|
||
#include <basePxrUsdPreviewSurface/usdPreviewSurface.h> | ||
|
||
PXR_NAMESPACE_OPEN_SCOPE | ||
|
||
PXRUSDMAYA_REGISTER_UPDATER( | ||
UsdShadeMaterial, | ||
usdPreviewSurface, | ||
MaterialUpdater, | ||
UsdMayaPrimUpdater::Supports::Invalid); | ||
|
||
MaterialUpdater::MaterialUpdater( | ||
const UsdMayaPrimUpdaterContext& context, | ||
const MFnDependencyNode& depNodeFn, | ||
const Ufe::Path& path) | ||
: UsdMayaPrimUpdater(context, depNodeFn, path) | ||
{ | ||
} | ||
|
||
/* virtual */ | ||
bool MaterialUpdater::canEditAsMaya() const { return false; } | ||
|
||
PXR_NAMESPACE_CLOSE_SCOPE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// Copyright 2022 Autodesk | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
#pragma once | ||
|
||
#include <mayaUsd/fileio/primUpdater.h> | ||
|
||
PXR_NAMESPACE_OPEN_SCOPE | ||
|
||
class MaterialUpdater : public UsdMayaPrimUpdater | ||
{ | ||
public: | ||
MAYAUSD_CORE_PUBLIC | ||
MaterialUpdater( | ||
const UsdMayaPrimUpdaterContext& context, | ||
const MFnDependencyNode& depNodeFn, | ||
const Ufe::Path& path); | ||
|
||
/// As of 16-Sep-2022, prims of type Material cannot be pulled by | ||
/// themselves, so this method returns false. Materials can only be edited | ||
/// as Maya when associated with pulled Dag nodes. This may change in | ||
/// future versions of maya-usd. | ||
MAYAUSD_CORE_PUBLIC | ||
bool canEditAsMaya() const override; | ||
}; | ||
|
||
PXR_NAMESPACE_CLOSE_SCOPE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ | |
import fixturesUtils | ||
|
||
from usdUtils import createSimpleXformScene | ||
from ufeUtils import ufeFeatureSetVersion | ||
|
||
from maya import OpenMaya as OM | ||
from maya import OpenMayaAnim as OMA | ||
|
@@ -65,7 +64,6 @@ def tearDownClass(cls): | |
def setUp(self): | ||
cmds.file(new=True, force=True) | ||
|
||
@unittest.skipUnless(ufeFeatureSetVersion() >= 3, 'Test only available in UFE v3 or greater.') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The CMakeLists.txt file explicitly adds this test file only for UFE v3, so further checking in the test is redundant. |
||
def testCannotEditAsMayaAnAncestor(self): | ||
'''Test that trying to edit an ancestor is not allowed.''' | ||
|
||
|
@@ -82,7 +80,6 @@ def testCannotEditAsMayaAnAncestor(self): | |
self.assertFalse(mayaUsd.lib.PrimUpdaterManager.canEditAsMaya(aUsdUfePathStr)) | ||
self.assertFalse(mayaUsd.lib.PrimUpdaterManager.editAsMaya(aUsdUfePathStr)) | ||
|
||
@unittest.skipUnless(ufeFeatureSetVersion() >= 3, 'Test only available in UFE v3 or greater.') | ||
def testEditAsMayaPreserveTimeline(self): | ||
'''Test that edit does not change the timeline start and end.''' | ||
|
||
|
@@ -114,7 +111,6 @@ def verifyTimeline(): | |
|
||
verifyTimeline() | ||
|
||
@unittest.skipUnless(ufeFeatureSetVersion() >= 3, 'Test only available in UFE v3 or greater.') | ||
def testTransformEditAsMaya(self): | ||
'''Edit a USD transform as a Maya object.''' | ||
|
||
|
@@ -164,7 +160,6 @@ def testTransformEditAsMaya(self): | |
|
||
assertVectorAlmostEqual(self, mayaValues, usdValues) | ||
|
||
@unittest.skipUnless(ufeFeatureSetVersion() >= 3, 'Test only available in UFE v3 or greater.') | ||
def testEditAsMayaUndoRedo(self): | ||
'''Edit a USD transform as a Maya object and apply undo and redo.''' | ||
|
||
|
@@ -286,7 +281,6 @@ def testEditAsMayaUIInfo(self): | |
self.assertEqual('', icon.baseIcon) | ||
self.assertEqual(ufe.UIInfoHandler.Disabled, icon.mode) | ||
|
||
@unittest.skipUnless(ufeFeatureSetVersion() >= 3, 'Test only available in UFE v3 or greater.') | ||
def testIllegalEditAsMaya(self): | ||
'''Trying to edit as Maya on object that doesn't support it.''' | ||
|
||
|
@@ -296,6 +290,8 @@ def testIllegalEditAsMaya(self): | |
stage = mayaUsd.lib.GetPrim(proxyShapePathStr).GetStage() | ||
blendShape = stage.DefinePrim('/BlendShape1', 'BlendShape') | ||
scope = stage.DefinePrim('/Scope1', 'Scope') | ||
scope = stage.DefinePrim('/Mesh1', 'Mesh') | ||
scope = stage.DefinePrim('/Material1', 'Material') | ||
|
||
blendShapePathStr = proxyShapePathStr + ',/BlendShape1' | ||
scopePathStr = proxyShapePathStr + ',/Scope1' | ||
|
@@ -312,8 +308,14 @@ def testIllegalEditAsMaya(self): | |
# with mayaUsd.lib.OpUndoItemList(): | ||
# self.assertFalse(mayaUsd.lib.PrimUpdaterManager.canEditAsMaya(scopePathStr)) | ||
# self.assertFalse(mayaUsd.lib.PrimUpdaterManager.editAsMaya(scopePathStr)) | ||
|
||
# Mesh can be edited as Maya. | ||
self.assertTrue(mayaUsd.lib.PrimUpdaterManager.canEditAsMaya(proxyShapePathStr + ',/Mesh1')) | ||
|
||
# Material cannot be edited as Maya: it explicitly disables this | ||
# capability. | ||
self.assertFalse(mayaUsd.lib.PrimUpdaterManager.canEditAsMaya(proxyShapePathStr + ',/Material1')) | ||
|
||
@unittest.skipUnless(ufeFeatureSetVersion() >= 3, 'Test only available in UFE v3 or greater.') | ||
def testSessionLayer(self): | ||
'''Verify that the edit gets on the sessionLayer instead of the editTarget layer.''' | ||
|
||
|
@@ -345,8 +347,6 @@ def testSessionLayer(self): | |
|
||
self.assertEqual(prim.GetCustomDataByKey(kPullPrimMetadataKey), None) | ||
|
||
|
||
@unittest.skipUnless(ufeFeatureSetVersion() >= 3, 'Test only available in UFE v3 or greater.') | ||
def testTargetLayer(self): | ||
'''Verify that the target layer is not moved after Edit As Maya.''' | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the single important line of this pull request: disabling edit as Maya for materials, as per design's request. Perhaps we will find a workflow that will allow this in the future, but for now edit as Maya on a material does nothing and produces a warning.