Skip to content

Commit

Permalink
EMSUSD-190 fix the default parent
Browse files Browse the repository at this point in the history
- No longer send an explicit add notification for the item that was converted from Maya to USD.
- Call the parent function instead of the defaultParent function. We only need to invalidate the scene from the point where the object were edited.
- When calling defaultParent, the entire Maya cene would be invalidated.
- Change the implementation of the proxy shape default parent since it is a Maya node, its default parent must also be a Maya node.
- Fortunately, the old behavior was only used when reparenting and one cannot change the location of the USD virtual root, so the old bahavior was never used in  practice, as far as I can tell.
  • Loading branch information
pierrebai-adsk committed Jul 5, 2023
1 parent c7c40ac commit c954f28
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
14 changes: 2 additions & 12 deletions lib/mayaUsd/fileio/primUpdaterManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1135,13 +1135,8 @@ bool PrimUpdaterManager::mergeToUsd(
auto ufeUsdItem = Ufe::Hierarchy::createItem(pulledPath.pop());
auto hier = Ufe::Hierarchy::hierarchy(ufeUsdItem);
if (TF_VERIFY(hier)) {
scene.notify(Ufe::SubtreeInvalidate(hier->defaultParent()));
scene.notify(Ufe::SubtreeInvalidate(hier->parent()));
}

// We must recreate the UFE item because it has changed data models (Maya -> USD).
if (TF_VERIFY(ufeUsdItem))
scene.notify(Ufe::ObjectAdd(ufeUsdItem));

progressBar.advance();

scopeIt.end();
Expand Down Expand Up @@ -1406,13 +1401,8 @@ bool PrimUpdaterManager::discardPrimEdits(const Ufe::Path& pulledPath)
auto ufeUsdItem = Ufe::Hierarchy::createItem(pulledPath);
auto hier = Ufe::Hierarchy::hierarchy(ufeUsdItem);
if (TF_VERIFY(hier)) {
scene.notify(Ufe::SubtreeInvalidate(hier->defaultParent()));
scene.notify(Ufe::SubtreeInvalidate(hier->parent()));
}

// We must recreate the UFE item because it has changed data models (Maya -> USD).
if (TF_VERIFY(ufeUsdItem))
scene.notify(Ufe::ObjectAdd(ufeUsdItem));

progressBar.advance();

scopeIt.end();
Expand Down
21 changes: 17 additions & 4 deletions lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,23 @@ ProxyShapeHierarchy::reorderCmd(const Ufe::SceneItemList& orderedList) const

Ufe::SceneItem::Ptr ProxyShapeHierarchy::defaultParent() const
{
// The default parent is the root of the USD scene.
// Since the proxy shape corresponds to the USD root prim,
// therefore we implement the default parent as the proxy shape itself.
return UsdSceneItem::create(sceneItem()->path(), getUsdRootPrim());
// The documentation for defaultParent() stipulate that it should return
// where this node should be inserted to be added back. The proxy shape need
// to be inserted under its Maya shape node, which is its default parent,
// so we return that.
//
// It used to return the USD virtual root prim, but that caused problem since
// the UFE path pointed to a Maya node (the proxy shape) and teh default parent
// was a USD object, leading to a contradiction. In particular, it became
// impossible to create a UFE Hiearchy interface from that default parent: its
// path indicated it was in the Maya run-time, yet its scene item claimed to
// be in the USD run-time.
//
// As far as I can tell, the defaultParent function is only used when reparenting
// nodes that lacked a parent, to figure a default location where to insert them.
//
// The PrimUpdaterManager also used to call it, but it no longer does.
return fMayaHierarchy->defaultParent();
}

#endif // UFE_V2_FEATURES_AVAILABLE
Expand Down

0 comments on commit c954f28

Please sign in to comment.