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

Tremblp/maya 103815/ufe parenting usd 01 #545

Merged
merged 4 commits into from
Jun 3, 2020

Conversation

ppt-adsk
Copy link
Collaborator

@ppt-adsk ppt-adsk commented Jun 1, 2020

Improve parenting so that parenting between different layers will work. There is an ongoing discussion with Will Telford about restrictions which should be enforced in the parenting workflows, but these can be implemented later. Will this pull request, behaviors that users expect will work, and grouping will work reliably.

logfile.write(l)
# Avoid "UnicodeEncodeError: 'ascii' codec can't encode
# character" errors by serializing utf8 byte strings.
logfile.write(l.encode("utf8"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @ppt-adsk .

logfile.write(l)
# Avoid "UnicodeEncodeError: 'ascii' codec can't encode
# character" errors by serializing utf8 byte strings.
logfile.write(l.encode("utf8"))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is to fix the build.py errors reported by a few people. Completely orthogonal to the rest of the pull request, but I ran into the problem while developing, so I fixed it.

fLayer = MayaUsdUtils::defPrimSpecLayer(childPrim);
if (!fLayer) {
std::string err = TfStringPrintf("No prim found at %s", childPrim.GetPath().GetString().c_str());
fChildLayer = MayaUsdUtils::defPrimSpecLayer(childPrim);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problems when parenting from prims defined in one layer to prims defined in another were because SdfCopySpec was being called with only one layer, the child layer. Fixed to use both the child and parent layer.

auto parentPrim = parent->prim();
// If parent prim is the pseudo-root, no def primSpec will be found, so
// just use the edit target layer.
fParentLayer = parentPrim.IsPseudoRoot() ?
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is expected, but I didn't know about it until I ran into the issue during testing.

@@ -82,13 +106,18 @@ UsdUndoInsertChildCommand::Ptr UsdUndoInsertChildCommand::create(
const UsdSceneItem::Ptr& pos
)
{
return std::make_shared<UsdUndoInsertChildCommand>(parent, child, pos);
// Error if requested parent is currently a child of requested child.
if (parent->path().startsWith(child->path())) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple fix to prevent parenting to existing descendant.

if (parent->path().startsWith(child->path())) {
return nullptr;
}
return std::make_shared<MakeSharedEnabler<UsdUndoInsertChildCommand>>(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made constructor protected, so need intermediate class to return a shared_ptr.

protected:
//! Construct a UsdUndoInsertChildCommand. Note that as of 4-May-2020 the
//! pos argument is ignored, and only append is supported.
UsdUndoInsertChildCommand(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made protected to force callers to go through create().

@@ -35,6 +35,18 @@ def matrixToList(m):
mList = mList + i
return mList

class OpenFileCtx(object):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File open / close convenience context.

def testParentToProxyShape(self):

# Load a file with a USD hierarchy at least 2-levels deep.
filePath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "test-samples", "parentCmd", "simpleHierarchy.ma" )
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No real change, just using the convenience file open / close context.

@ppt-adsk
Copy link
Collaborator Author

ppt-adsk commented Jun 1, 2020

Hi Pilar, I'm hopeful you will have time to provide feedback on this PR, which deals with parenting.

@pilarmolinalopez
Copy link
Contributor

Will do!

@cfmoore007
Copy link

cfmoore007 commented Jun 1, 2020

Looks good here ( from a usability pov ) :
PR545_Results

@kxl-adsk kxl-adsk added ufe-usd Related to UFE-USD plugin in Maya-Usd workflows Related to in-context workflows labels Jun 2, 2020
@kxl-adsk kxl-adsk assigned kxl-adsk and unassigned kxl-adsk Jun 2, 2020
Copy link
Contributor

@pilarmolinalopez pilarmolinalopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me! thanks for this!

@ppt-adsk
Copy link
Collaborator Author

ppt-adsk commented Jun 3, 2020

Successful internal ADSK preflight build number 137.

@kxl-adsk kxl-adsk merged commit 2f58325 into dev Jun 3, 2020
@kxl-adsk kxl-adsk deleted the tremblp/MAYA-103815/ufe_parenting_usd_01 branch June 3, 2020 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ufe-usd Related to UFE-USD plugin in Maya-Usd workflows Related to in-context workflows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants