Skip to content

Commit

Permalink
Wrapping PcpLayerStack::GetMutedLayers to python
Browse files Browse the repository at this point in the history
See #1782

(Internal change: 2241610)
  • Loading branch information
pixar-oss committed Jul 21, 2022
1 parent 2a38a1e commit 6f085de
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pxr/usd/pcp/testenv/testPcpLayerMuting.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ def test_MutingSublayers(self):
[layer.GetPrimAtPath('/Root'),
sublayer.GetPrimAtPath('/Root'),
anonymousSublayer.GetPrimAtPath('/Root')])
self.assertEqual(pi.rootNode.layerStack.mutedLayers, [])

(pi2, err2) = pcp2.ComputePrimIndex('/Root')
self.assertTrue(not err2)
self.assertEqual(pi2.primStack,
[layer.GetPrimAtPath('/Root'),
sublayer.GetPrimAtPath('/Root'),
anonymousSublayer.GetPrimAtPath('/Root')])
self.assertEqual(pi2.rootNode.layerStack.mutedLayers, [])

# Muting the cache's root layer is explicitly disallowed.
with self.assertRaises(Tf.ErrorException):
Expand All @@ -77,13 +79,16 @@ def test_MutingSublayers(self):
self.assertEqual(pi.primStack,
[layer.GetPrimAtPath('/Root'),
anonymousSublayer.GetPrimAtPath('/Root')])
self.assertEqual(pi.rootNode.layerStack.mutedLayers,
[sublayer.identifier])

(pi2, err2) = pcp2.ComputePrimIndex('/Root')
self.assertTrue(not err2)
self.assertEqual(pi2.primStack,
[layer.GetPrimAtPath('/Root'),
sublayer.GetPrimAtPath('/Root'),
anonymousSublayer.GetPrimAtPath('/Root')])
self.assertEqual(pi2.rootNode.layerStack.mutedLayers, [])

# Unmute sublayer and verify that it comes back into /Root's
# prim stack.
Expand All @@ -94,13 +99,15 @@ def test_MutingSublayers(self):
[layer.GetPrimAtPath('/Root'),
sublayer.GetPrimAtPath('/Root'),
anonymousSublayer.GetPrimAtPath('/Root')])
self.assertEqual(pi.rootNode.layerStack.mutedLayers, [])

(pi2, err2) = pcp2.ComputePrimIndex('/Root')
self.assertTrue(not err2)
self.assertEqual(pi2.primStack,
[layer.GetPrimAtPath('/Root'),
sublayer.GetPrimAtPath('/Root'),
anonymousSublayer.GetPrimAtPath('/Root')])
self.assertEqual(pi2.rootNode.layerStack.mutedLayers, [])

# Mute sublayer and verify that change processing has occurred
# and that it no longer appears in /Root's prim stack.
Expand All @@ -111,13 +118,16 @@ def test_MutingSublayers(self):
[layer.GetPrimAtPath('/Root'),
sublayer.GetPrimAtPath('/Root')])
self.assertTrue(anonymousSublayer)
self.assertEqual(pi.rootNode.layerStack.mutedLayers,
[anonymousSublayer.identifier])

(pi2, err2) = pcp2.ComputePrimIndex('/Root')
self.assertTrue(not err2)
self.assertEqual(pi2.primStack,
[layer.GetPrimAtPath('/Root'),
sublayer.GetPrimAtPath('/Root'),
anonymousSublayer.GetPrimAtPath('/Root')])
self.assertEqual(pi2.rootNode.layerStack.mutedLayers, [])

# Unmute sublayer and verify that it comes back into /Root's
# prim stack.
Expand All @@ -128,13 +138,15 @@ def test_MutingSublayers(self):
[layer.GetPrimAtPath('/Root'),
sublayer.GetPrimAtPath('/Root'),
anonymousSublayer.GetPrimAtPath('/Root')])
self.assertEqual(pi.rootNode.layerStack.mutedLayers, [])

(pi2, err2) = pcp2.ComputePrimIndex('/Root')
self.assertTrue(not err2)
self.assertEqual(pi2.primStack,
[layer.GetPrimAtPath('/Root'),
sublayer.GetPrimAtPath('/Root'),
anonymousSublayer.GetPrimAtPath('/Root')])
self.assertEqual(pi2.rootNode.layerStack.mutedLayers, [])

def test_MutingSessionLayer(self):
"""Tests ability to mute a cache's session layer."""
Expand All @@ -149,13 +161,16 @@ def test_MutingSessionLayer(self):
self.assertEqual(pi.primStack,
[sessionLayer.GetPrimAtPath('/Root'),
layer.GetPrimAtPath('/Root')])
self.assertEqual(pi.rootNode.layerStack.mutedLayers, [])

pcp.RequestLayerMuting([sessionLayer.identifier], [])

(pi, err) = pcp.ComputePrimIndex('/Root')
self.assertTrue(not err)
self.assertEqual(pi.primStack,
[layer.GetPrimAtPath('/Root')])
self.assertEqual(pi.rootNode.layerStack.mutedLayers,
[sessionLayer.identifier])

pcp.RequestLayerMuting([], [sessionLayer.identifier])

Expand All @@ -164,6 +179,7 @@ def test_MutingSessionLayer(self):
self.assertEqual(pi.primStack,
[sessionLayer.GetPrimAtPath('/Root'),
layer.GetPrimAtPath('/Root')])
self.assertEqual(pi.rootNode.layerStack.mutedLayers, [])

def test_MutingReferencedLayers(self):
"""Tests behavior when muting and unmuting the root layer of
Expand Down
3 changes: 3 additions & 0 deletions pxr/usd/pcp/wrapLayerStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ void wrapLayerStack()
.add_property("layerTree",
make_function(&PcpLayerStack::GetLayerTree,
return_value_policy<return_by_value>()))
.add_property("mutedLayers",
make_function(&PcpLayerStack::GetMutedLayers,
return_value_policy<TfPySequenceToList>()))
.add_property("relocatesSourceToTarget",
make_function(&PcpLayerStack::GetRelocatesSourceToTarget,
return_value_policy<return_by_value>()))
Expand Down

0 comments on commit 6f085de

Please sign in to comment.