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

MAYA-125991 - Unable to switch variants when Session Layer is targeted #2698

Merged
merged 3 commits into from
Nov 3, 2022
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
14 changes: 12 additions & 2 deletions lib/mayaUsd/ufe/private/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,20 @@ bool allowedInStrongerLayer(

// If allowed, verify if the target layer is stronger than any existing layer with an opinion.
auto stage = prim.GetStage();
auto rootLayer = stage->GetRootLayer();
auto targetLayer = stage->GetEditTarget().GetLayer();
auto topLayer = primStack.front()->GetLayer();
return getStrongerLayer(rootLayer, targetLayer, topLayer) == targetLayer;

// Session Layer is the strongest in the stage, so check its hierarchy first
auto strongerLayer = getStrongerLayer(stage->GetSessionLayer(), targetLayer, topLayer);
if (strongerLayer == targetLayer) {
return true;
} else if (strongerLayer == topLayer) {
return false;
}

// If none of the two layers was found in the Session Layer hierarchy,
// then proceed to the stage's general layer hierarchy
return getStrongerLayer(stage->GetRootLayer(), targetLayer, topLayer) == targetLayer;
}

} // namespace
Expand Down
14 changes: 11 additions & 3 deletions test/lib/ufe/testContextOps.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ def testGetItems(self):
if c.checked:
self.assertEqual(c.item, 'Ball_8')

def testSwitchVariantInWeakerLayer(self):
def testSwitchVariantInLayer(self):
"""
Test that switching variant in a weaker layer is restricted.
Test switching variant in layers: stronger, weaker, session.
"""
contextItems = self.contextOps.getItems([])

Expand Down Expand Up @@ -200,7 +200,15 @@ def shadingVariantOnPrim():
# Verify the variant has not switched.
self.assertEqual(shadingVariant(), 'Cue')
self.assertEqual(shadingVariantOnPrim(), 'Cue')


# Verify we can switch variant in Session Layer.
stage.SetEditTarget(stage.GetSessionLayer())
cmd = self.contextOps.doOpCmd(
['Variant Sets', 'shadingVariant', 'Ball_8'])
self.assertIsNotNone(cmd)
ufeCmd.execute(cmd)
self.assertEqual(shadingVariant(), 'Ball_8')
self.assertEqual(shadingVariantOnPrim(), 'Ball_8')

def testDoOp(self):
# Change visibility, undo / redo.
Expand Down