-
Notifications
You must be signed in to change notification settings - Fork 202
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
Conversation
logfile.write(l) | ||
# Avoid "UnicodeEncodeError: 'ascii' codec can't encode | ||
# character" errors by serializing utf8 byte strings. | ||
logfile.write(l.encode("utf8")) |
There was a problem hiding this comment.
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")) |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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() ? |
There was a problem hiding this comment.
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())) { |
There was a problem hiding this comment.
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>>( |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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" ) |
There was a problem hiding this comment.
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.
Hi Pilar, I'm hopeful you will have time to provide feedback on this PR, which deals with parenting. |
Will do! |
There was a problem hiding this 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!
Successful internal ADSK preflight build number 137. |
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.