EMSUSD-3563: Add new reference workflow implementation#4591
EMSUSD-3563: Add new reference workflow implementation#4591antonkhelou wants to merge 2 commits into
Conversation
|
|
||
| // Derive the new prim name from the referenced filename stem. | ||
| std::string stem = path; | ||
| const size_t slash = stem.find_last_of("/\\"); |
There was a problem hiding this comment.
should that cover \ and /. , maybe use the filesystem util maya-usd uses?
| if (dot != std::string::npos) | ||
| stem = stem.substr(0, dot); | ||
| std::string newPrimName = TfMakeValidIdentifier(stem); | ||
| if (newPrimName.empty()) |
There was a problem hiding this comment.
Is that even possible? TfMakeValidIdentifier can return an empty string? probably not
| std::string newPrimName = TfMakeValidIdentifier(stem); | ||
| if (newPrimName.empty()) | ||
| newPrimName = "Reference"; | ||
|
|
There was a problem hiding this comment.
Dont you need to check for name conflicts?
| SdfPrimSpecHandle primSpec | ||
| = layer->GetPrimAtPath(SdfPath("/" + defaultPrimName)); | ||
| if (primSpec) | ||
| newPrimType = primSpec->GetTypeName().GetString(); |
There was a problem hiding this comment.
and if there's no default prim in there what happens, it explodes?
| if (_newPrimType == "Class") { | ||
| newPrim = stage->CreateClassPrim(childPath); | ||
| } else { | ||
| TfToken typeToken = _newPrimType.empty() ? TfToken() : TfToken(_newPrimType); |
There was a problem hiding this comment.
i dont htink empty type is a good default
|
|
||
| UsdPrim newPrim; | ||
| if (_newPrimType == "Class") { | ||
| newPrim = stage->CreateClassPrim(childPath); |
There was a problem hiding this comment.
is that a real workflow, to reference a class prim into a new class prim? seems weird. Having a default class prim seems weird as well, dunno what that means
| return; | ||
| } | ||
|
|
||
| const SdfPath refPrimPath = _primPath.empty() ? SdfPath() : SdfPath(_primPath); |
There was a problem hiding this comment.
I assume below here is like the add reference command? Would it not be simpler to just have a composite command and reuse the add reference command we already have?
| : public UsdUndoableCommand<Ufe::UndoableCommand> | ||
| { | ||
| public: | ||
| UsdUndoAddReferenceToNewPrimCommand( |
There was a problem hiding this comment.
the other add ref command is exposed to python
maya-usd/lib/usdUfe/python/wrapCommands.cpp
Line 147 in 139c895
There was a problem hiding this comment.
useful if only for tests :
Changes the existing "Add..." to "Add to Prim...", and adds a new "Add..." menu option under Reference which creates a new prim using the type of the referenced usd file's default prim type, and adds the "reference" arc there.