Autodesk / maya-usd

A common USD (Universal Scene Description) plugin for Autodesk Maya
765 stars 201 forks source link

USD Layer Editor - List layer Edits #2382

Open lucasIllusorium opened 2 years ago

lucasIllusorium commented 2 years ago

Is your feature request related to a problem? Please describe. When using the USD Layer editor, we miss the ability to undo some of the edits in a dirty layer. we might not want to delete all edits and redo the work we really want to keep.

example: if someone is making edits inside a layer, layout.usd, they might edit multiple prims in multiple ways. to keep it simple let's say we change two prim's transform. cube and sphere. The layer will get dirty and if I save I will save both edits. But I might want to undo the cube xform edit to only save the sphere edits.

Right now, I believe the only way to do this is to either revert layer to file, losing both edits and having to redo sphere xform edit. Or save both edits and then open the layout.usd in a text editor and remove the edits we don't want to keep.

Describe the solution you'd like I would suggest adding a new button when right-clicking on a layer from the USD layer editor. This button will work similarly to the List Reference Edits window from the reference editor.

Maybe I'm missing something and there is a way to do this. If not maybe there is a better way to handle this problem. Thanks

Lucas3Dspain commented 1 year ago

any updates on a way to list the edits on a layer?

womanyoyoyo-adsk commented 1 year ago

@Lucas3Dspain We agree that the solution @lucasIllusorium is proposing sounds like one we'd pursue. Currently we are not putting our resources on this unfortunately. That's the update.

BigRoy commented 1 year ago

Purely as a reference for beginners to the USD API I've started a topic on the USD Alliance forums on How to use USD API basics to design a "List Edits" editor.

Potentially it can aid anyone familiar with Maya / Qt but unfamiliar with the USD API to prototype tooling for this particular issue and learn the USD API along the way.

BigRoy commented 1 year ago

Here's a quick prototype I did in Maya 2024 with Maya USD.

image

The code is available here.

It's not optimized, it doesn't filter, it also shows the session layer, etc. but you can go through the edits, multiselect and then click delete to remove the authored opinion in a layer so I guess even though a draft implementation might solve some of @lucasIllusorium issue.


Side question: What would be the most trivial way to get icons matching the Maya Outliner for the USD types?

I tried doing this:

import os
import glob

def get_maya_usd_type_icon_paths():

    icon_by_typename = {}
    prefix = len("out_USD_")
    suffix = len(".png")
    for folder in os.getenv("XBMLANGPATH").split(os.pathsep):
        files = glob.glob(os.path.join(folder, "out_USD_*.png"))
        if not files:
            continue

        for filepath in files:
            basename = os.path.basename(filepath)
            typename = basename[prefix:-suffix]

            if typename.endswith("_200") or typename.endswith("_150"):
                # Ignore different sizes
                continue

            if typename not in icon_by_typename:
                icon_by_typename[typename] = filepath

    return icon_by_typename

print(get_usd_icons())

But it'd basically not get the icons for xform, curves, etc. I assume those are actually taking other internal icons Maya already has but I'm wondering if there's any way to easily find which one should match which USD Prim Type (or if maybe I could get the resource path through Ufe API?)

BigRoy commented 1 year ago

Just wanted to ping back in regarding this question:

Side question: What would be the most trivial way to get icons matching the Maya Outliner for the USD types?


Aside of that @Lucas3Dspain @lucasIllusorium any chance the prototype has been of use for you already? Just curious to hear if you might have any notes/feedback in the meantime.

Lucas3Dspain commented 1 year ago

Hi @BigRoy!

I had some time to use the tool in non-production data. So far this looks really powerful ! I only had the chance to use the tool outside of Maya, so I'm running the tool standalone.

This is what I found:

I want to explore what kind of filters can/make sense to be implemented. Some ideas:

seando-adsk commented 1 year ago

Side question: What would be the most trivial way to get icons matching the Maya Outliner for the USD types?

The Outliner first looks for an icon matching the nodeType of the prim: outUSD.png. If not found then we loop thru all the Ufe::SceneItem::ancestoryNodeTypes() looking for one that matches: outUSD.png

Sean

BigRoy commented 1 year ago

The Outliner first looks for an icon matching the nodeType of the prim: outUSD.png. If not found then we loop thru all the Ufe::SceneItem::ancestoryNodeTypes() looking for one that matches: outUSD.png

That's great knowledge. For anyone else, here's Python code to get that type list:

import mayaUsd.ufe
import ufe

# Using Ufe
def createUfeSceneItem(dagPath, sdfPath=None):
    ufePath = ufe.PathString.path('{},{}'.format(dagPath,sdfPath) if sdfPath != None else '{}'.format(dagPath))
    ufeItem = ufe.Hierarchy.createItem(ufePath)
    return ufeItem

path = "|stage1|stageShape1,/root/cube"
item = createUfeSceneItem(path)
print(item.ancestorNodeTypes())

# Using just the UsdPrim
def get_types(prim):
    types = []
    for t in schema_type.GetAllAncestorTypes():
        name = Usd.SchemaRegistry.GetConcreteSchemaTypeName(t) or t.typeName
        types.append(name)
    return types

prim = mayaUsd.ufe.ufePathToPrim(path)
print(get_types(prim))
BigRoy commented 1 year ago

@Lucas3Dspain Thanks for the input. Try this version.

It's a bit quick and dirty so might give errors but at least you can test the design, etc.

Note: It does not highlight whether it's animated. ;)


this might be an issue on my end but I couldn't find a way to make permanent changes to the stage.

Could you elaborate on that issue? It should provide live changes to the USD Stage - to persist them I suppose you need to save the USD layer you tweaked?

womanyoyoyo-adsk commented 1 year ago

Thanks for sharing this @BigRoy!

BigRoy commented 1 year ago

Let me know if there's any need to collaborate more on tools for these. Maybe Autodesk team has some UX design ideas/proposals of their own that can be used to prototype some more?

BigRoy commented 11 months ago

I missed this point before:

maybe use color/font like in usdView

That's definitely a good idea to ensure familiarity to some. So just sharing this quick reference here.

BigRoy commented 10 months ago

I've fiddled some more with this prototype and started setting up some more prototype USD Qt tools - here's a demo video that also contains the Prim Spec Editor https://github.com/BigRoy/usd-qtpy/releases/tag/0.0.2 running live in Maya.