-
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
Hide orphaned pulled nodes on ancestor structure change. #2576
Changes from 2 commits
ca70462
3d79000
ef78fdd
4b6b920
1f49cea
4da800c
aa8b425
890c0b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,24 +38,26 @@ namespace MAYAUSD_NS_DEF { | |
|
||
OrphanedNodesManager::Memento::Memento(Ufe::Trie<PullVariantInfo>&& pulledPrims) | ||
: _pulledPrims(std::move(pulledPrims)) | ||
{ } | ||
{ | ||
} | ||
|
||
OrphanedNodesManager::Memento::Memento() | ||
: _pulledPrims() | ||
{ } | ||
{ | ||
} | ||
|
||
OrphanedNodesManager::Memento::Memento(Memento&& rhs) | ||
: _pulledPrims(std::move(rhs._pulledPrims)) | ||
{ } | ||
{ | ||
} | ||
|
||
OrphanedNodesManager::Memento& OrphanedNodesManager::Memento::operator=(Memento&& rhs) | ||
{ | ||
_pulledPrims = std::move(rhs._pulledPrims); | ||
return *this; | ||
} | ||
|
||
Ufe::Trie<OrphanedNodesManager::PullVariantInfo> | ||
OrphanedNodesManager::Memento::release() | ||
Ufe::Trie<OrphanedNodesManager::PullVariantInfo> OrphanedNodesManager::Memento::release() | ||
{ | ||
return std::move(_pulledPrims); | ||
} | ||
|
@@ -64,12 +66,12 @@ OrphanedNodesManager::Memento::release() | |
// Class OrphanedNodesManager | ||
//------------------------------------------------------------------------------ | ||
|
||
OrphanedNodesManager::OrphanedNodesManager() : _pulledPrims() { } | ||
OrphanedNodesManager::OrphanedNodesManager() | ||
: _pulledPrims() | ||
{ | ||
} | ||
|
||
void OrphanedNodesManager::add( | ||
const Ufe::Path& pulledPath, | ||
const MDagPath& pullParentPath | ||
) | ||
void OrphanedNodesManager::add(const Ufe::Path& pulledPath, const MDagPath& pullParentPath) | ||
{ | ||
// Add the pull parent to our pulled prims prefix tree. Also add the full | ||
// configuration of variant set selections for each ancestor, up to the USD | ||
|
@@ -110,14 +112,31 @@ void OrphanedNodesManager::operator()(const Ufe::Notification& n) | |
} | ||
} | ||
} else if (pulledPrims().containsDescendant(changedPath)) { | ||
#ifdef UFE_V4_FEATURES_AVAILABLE | ||
// Use UFE v4 notification to op conversion. | ||
handleOp(sceneNotification); | ||
#else | ||
// UFE v3: convert to op ourselves. Only convert supported | ||
// notifications. | ||
if (auto objAdd = dynamic_cast<const Ufe::ObjectAdd*>(&sceneNotification)) { | ||
handleOp(Ufe::SceneCompositeNotification::Op( | ||
Ufe::SceneCompositeNotification::ObjectAdd, objAdd->item())); | ||
} else if (auto objDel = dynamic_cast<const Ufe::ObjectDelete*>(&sceneNotification)) { | ||
handleOp(Ufe::SceneCompositeNotification::Op( | ||
Ufe::SceneCompositeNotification::ObjectDelete, objDel->path())); | ||
} else if ( | ||
auto subtrInv = dynamic_cast<const Ufe::SubtreeInvalidate*>(&sceneNotification)) { | ||
handleOp(Ufe::SceneCompositeNotification::Op( | ||
Ufe::SceneCompositeNotification::SubtreeInvalidate, subtrInv->root())); | ||
} | ||
#endif | ||
} | ||
} | ||
|
||
void OrphanedNodesManager::handleOp(const Ufe::SceneCompositeNotification::Op& op) | ||
{ | ||
switch (op.opType) { | ||
case Ufe::SceneChanged::ObjectAdd: { | ||
case Ufe::SceneCompositeNotification::ObjectAdd: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In UFE v3 the enumerant was in the SceneCompositeNotification derived class, in UFE v4 it's move to the base class, but the derived class scope still works, so using the derived class is UFE v3/v4 compatible, a requirement for 2023 compatibility. |
||
// Restoring a previously-deleted scene item may restore an orphaned | ||
// node. Traverse the trie, and show hidden pull parents that are | ||
// descendants of the argument path. The trie node that corresponds to | ||
|
@@ -127,7 +146,7 @@ void OrphanedNodesManager::handleOp(const Ufe::SceneCompositeNotification::Op& o | |
TF_VERIFY(ancestorNode); | ||
recursiveSetVisibility(ancestorNode, true); | ||
} break; | ||
case Ufe::SceneChanged::ObjectDelete: { | ||
case Ufe::SceneCompositeNotification::ObjectDelete: { | ||
// The following cases will generate object delete: | ||
// - Inactivate of ancestor USD prim sends object post delete. The | ||
// inactive object has no children. | ||
|
@@ -146,7 +165,7 @@ void OrphanedNodesManager::handleOp(const Ufe::SceneCompositeNotification::Op& o | |
TF_VERIFY(ancestorNode); | ||
recursiveSetVisibility(ancestorNode, false); | ||
} break; | ||
case Ufe::SceneChanged::SubtreeInvalidate: { | ||
case Ufe::SceneCompositeNotification::SubtreeInvalidate: { | ||
// On subtree invalidate, the scene item itself has not had a structure | ||
// change, but its children have changed. There are two cases: | ||
// - the node has children: from a variant switch, or from a payload | ||
|
@@ -217,35 +236,28 @@ void OrphanedNodesManager::handleOp(const Ufe::SceneCompositeNotification::Op& o | |
} | ||
} | ||
} break; | ||
default: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. UNIX (Linux, macOS) warning as error fix. |
||
// ObjectPathChange (reparent, rename): to be implemented (MAYA-125039). | ||
// SceneCompositeNotification: already expanded in operator(). | ||
} | ||
} | ||
} | ||
|
||
Ufe::Trie<OrphanedNodesManager::PullVariantInfo>& | ||
OrphanedNodesManager::pulledPrims() | ||
Ufe::Trie<OrphanedNodesManager::PullVariantInfo>& OrphanedNodesManager::pulledPrims() | ||
{ | ||
return _pulledPrims; | ||
} | ||
|
||
const Ufe::Trie<OrphanedNodesManager::PullVariantInfo>& | ||
OrphanedNodesManager::pulledPrims() const | ||
const Ufe::Trie<OrphanedNodesManager::PullVariantInfo>& OrphanedNodesManager::pulledPrims() const | ||
{ | ||
return _pulledPrims; | ||
} | ||
|
||
void OrphanedNodesManager::clear() | ||
{ | ||
pulledPrims().clear(); | ||
} | ||
void OrphanedNodesManager::clear() { pulledPrims().clear(); } | ||
|
||
bool OrphanedNodesManager::empty() const | ||
{ | ||
return pulledPrims().root()->empty(); | ||
} | ||
bool OrphanedNodesManager::empty() const { return pulledPrims().root()->empty(); } | ||
|
||
void OrphanedNodesManager::restore(Memento&& previous) | ||
{ | ||
_pulledPrims = std::move(previous.release()); | ||
} | ||
void OrphanedNodesManager::restore(Memento&& previous) { _pulledPrims = previous.release(); } | ||
|
||
/* static */ | ||
bool OrphanedNodesManager::setVisibilityPlug( | ||
|
@@ -345,9 +357,8 @@ OrphanedNodesManager::variantSetDescriptors(const Ufe::Path& p) | |
} | ||
|
||
/* static */ | ||
Ufe::Trie<OrphanedNodesManager::PullVariantInfo> OrphanedNodesManager::deepCopy( | ||
const Ufe::Trie<PullVariantInfo>& src | ||
) | ||
Ufe::Trie<OrphanedNodesManager::PullVariantInfo> | ||
OrphanedNodesManager::deepCopy(const Ufe::Trie<PullVariantInfo>& src) | ||
{ | ||
Ufe::Trie<PullVariantInfo> dst; | ||
deepCopy(src.root(), dst.root()); | ||
|
@@ -357,12 +368,11 @@ Ufe::Trie<OrphanedNodesManager::PullVariantInfo> OrphanedNodesManager::deepCopy( | |
/* static */ | ||
void OrphanedNodesManager::deepCopy( | ||
const Ufe::TrieNode<PullVariantInfo>::Ptr& src, | ||
const Ufe::TrieNode<PullVariantInfo>::Ptr& dst | ||
) | ||
const Ufe::TrieNode<PullVariantInfo>::Ptr& dst) | ||
{ | ||
for (const auto& c : src->childrenComponents()) { | ||
const auto& srcChild = (*src)[c]; | ||
auto dstChild = std::make_shared<Ufe::TrieNode<PullVariantInfo>>(c); | ||
auto dstChild = std::make_shared<Ufe::TrieNode<PullVariantInfo>>(c); | ||
dst->add(dstChild); | ||
if (srcChild->hasData()) { | ||
dstChild->setData(srcChild->data()); | ||
|
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.
Maya 2023 UFE v3 did not have nice notification to notification op conversion.