maya-usd icon indicating copy to clipboard operation
maya-usd copied to clipboard

[EMSUSD-1091] Non local edit target layer cannot be saved and restored

Open csyshing opened this issue 11 months ago • 3 comments

Describe the bug

Hi,

When saving Maya scene with the edit target layer being set to a non local layer, the edit target layer info is lost and cannot be restored after reopening.

The example USD file is extracted and simplified from a production scene.

Steps to reproduce Steps to reproduce the behavior:

  1. Launch Maya and run following code snippet to prepare the stage with edit target:
import pxr
from maya import cmds
import mayaUsd.ufe

usdFile = '/path/to/example/root_layer.usda'   # See attached zip file

# Prepare the stage
proxyShapeNode = cmds.createNode('mayaUsdProxyShape')
cmds.setAttr(proxyShapeNode + '.filePath', usdFile, type='string')
stage = mayaUsd.ufe.getStage('|world|mayaUsdProxy1|mayaUsdProxyShape1')

prim = stage.GetPrimAtPath("/root/group/sphere/group/sphere")
assert(prim.IsValid())

# Find the pcp node for the prim
primNode = prim.GetPrimIndex().rootNode.children[0].children[0].children[0]
assert(primNode)
# For this particular case, the layer should be the deepest "geo.usda" layer
targetLayer = primNode.layerStack.identifier.rootLayer
assert(targetLayer)
# Verify target layer that it is **not** in stage layer stack
assert(targetLayer not in stage.GetLayerStack())
# Verify current edit target layer is not the target layer
assert(stage.GetEditTarget().GetLayer() != targetLayer)
# Change edit target layer
stage.SetEditTarget(pxr.Usd.EditTarget(targetLayer, primNode))
# Verify edit target layer
assert(stage.GetEditTarget().GetLayer() == targetLayer)
  1. Save Maya scene
  2. Reopen the Maya scene, inspect the edit target layer, it is pointing to the root layer (unexpected)

Expected behavior

Non local edit target layer can be saved and restored as expected.

Attachments

Example USD files for the repro steps: non_local_edit_target_layer.zip

Specs (if applicable):

  • OS & version [e.g. Windows 10] CentOS 7.8
  • Compiler & version: GCC 9.3
  • Maya version: Maya-2023.3
  • Maya USD commit SHA: Official v0.27.0
  • Pixar USD commit SHA: Official USD-22.05 & 23.02

csyshing avatar Feb 27 '24 11:02 csyshing

As a team we have been discussing workflows around targeting non local layers. At the time we are looking mainly into using Edit Routing for workflows around targeting non local layers. But if you think we need to have a UX around this that is exposed more to the artist, we would love to hear your thoughts in a new discussion thread.

Our hesitation at the time is around the complexity of doing these kinds of edits when the user is unaware of the consequences in a pipeline. Local layers themselves offer a lot of opportunities for artists to make mistakes, and when you expose even more avenues to editing the data in external files arbitrarily it creates some dangers. Most studios we've talked to so far are OK with edit routing as a solution, which is why that is currently how we are looking at it. But we would love to hear all sides.

wallworm avatar Feb 29 '24 15:02 wallworm

Hi @wallworm , there are mainly two user cases in our studio:

  1. Artists start the scene with edit target being set to session layer, whenever they make the changes via our proprietary toolset, our toolset will switch the edit target to a non-local layer, save the changes, and switch back to session layer
  • Different operations/attribute changes would be targeted in in different edit layers, for example the visibility changes will be stored in a 'visibility layer' (non-local), the xfroms changes will be stored in a 'xfrom layer' (non-local), other types of changes might just stored in default edit target layer (session layer), etc.
  • The switching happens automatically depends on what kind of changes would be, artistes do not manually choose which edit target layer (nor having the ability to change the edit target layer). This 'auto switching' is on purpose, transparent for artists, and interim during the operation
  • For this use case, edit routing will be super useful and we would love to move our implementation from proprietary toolset to be edit routing, so that artists will be free to make edits without needing to pay extra attention to keep making changes via proprietary toolset, i.e. right click on the prim in Maya outliner to toggle visibility, and the changes can still be stored in custom non-local edit target layer as expected.
  • Currently ADSK plugin does not serialize and deserialize non-local dirty layers thus causing problem when reopening Maya scene
  1. Artists start the scene with edit target being set to a specific layer (via custom stage opening function in our proprietary toolset) - non-local, and it's workflow dependent, all the changes go to this non-local layer by default, similar as point 1 above, some of the edits might still trigger a 'auto edit target switching' to be stored in another layer depends on the operations/attributes
  • The non-local edit target layer setting is persistent, edit routing doesn't seem to be useful for this case
  • Artists expect to restore the edit target after reopening Maya scene
  • Currently ADSK plugin does not have the ability to maintain non-local edit target layer nor able to restore non-local edit target layer after reopening

I realized that I was talking about two problems (1. saving and restoring non-local dirty layers, 2. saving and restoring non-local edit target layer), and this issue #3637 is mainly for the second problem.

Let me know if that's clear!

csyshing avatar Mar 06 '24 20:03 csyshing

@csyshing Thanks for the details. We are actively exploring this.

wallworm avatar Mar 07 '24 17:03 wallworm