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

MAYA-106780 - Editing USD should mark scene as dirty #1061

Merged

Conversation

seando-adsk
Copy link
Collaborator

MAYA-106780 - Editing USD should mark scene as dirty

  • Added catch-all condition in response to USD stage changes. If no UFE notif is sent, but we were given paths, send a UFE subtreeInvalidate notif.

* Added catch-all condition in response to USD stage
  changes. If no UFE notif is sent, but we were given
  paths, send a UFE subtreeInvalidate notif.
@seando-adsk seando-adsk added bug Something isn't working ufe-usd Related to UFE-USD plugin in Maya-Usd labels Jan 11, 2021
}

auto sceneItem = Ufe::Hierarchy::createItem(ufePath);
Ufe::Scene::instance().notify(Ufe::SubtreeInvalidate(sceneItem));
Copy link
Collaborator

Choose a reason for hiding this comment

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

This feels very awkward. SubtreeInvalidate is meant to imply a structural change to the hierarchy, but you're adding info-only changes to it. I don't think we should be doing that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We discussed this internally and since we have no other UFE notif to send this was the only thing we could do. One idea was the creation of a new UFE notif (such as SceneDirty) but we decided against that. @kxl-adsk Can you provide more info?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree that the catch-all UFE notification for structural change (i.e. ResyncedPaths) should be SubtreeInvalidate --- but isn't that the case already?

For info-only changes, we should be able to extract an attribute out of the notice, and shouldn't need SubtreeInvalidate --- no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay I reworked it as we discussed to send Ufe attribute changed notif for the ChangedInfoOnlyPaths. I also incorporated the upcoming UFE changes (.36) to change the notif() method.

I also added the special case when both resync and changed only paths are empty.

lib/mayaUsd/ufe/StagesSubject.cpp Outdated Show resolved Hide resolved
Comment on lines 315 to 338
#ifdef UFE_V2_FEATURES_AVAILABLE
// If we get here and didn't send any UFE notif, but yet have paths
// then we'll send a catch-all subtree invalidate notification.
if (!anyUfeV2NotifSent) {
SdfPathVector allPaths = (SdfPathVector)notice.GetResyncedPaths();
allPaths.insert(
allPaths.end(),
notice.GetChangedInfoOnlyPaths().begin(),
notice.GetChangedInfoOnlyPaths().end());
SdfPath::RemoveDescendentPaths(&allPaths);
for (const auto& changedPath : allPaths) {
Ufe::Path ufePath;
if (changedPath == SdfPath::AbsoluteRootPath()) {
ufePath = stagePath(sender);
} else {
const std::string& usdPrimPathStr = changedPath.GetPrimPath().GetString();
ufePath = stagePath(sender) + Ufe::PathSegment(usdPrimPathStr, g_USDRtid, '/');
}

auto sceneItem = Ufe::Hierarchy::createItem(ufePath);
Ufe::Scene::instance().notify(Ufe::SubtreeInvalidate(sceneItem));
}
}
#endif
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The bulk of the change is here. I added a new boolean flag to know if any UFE notif is sent above. If not, then we merge the ResyncedPaths and ChangedInfoOnlyPaths and only keep the highest common ancestor paths. Then send a UFE subtree invalidate for each remaining 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.

As an example if you add an anonymous layer (via the Layer Editor) this stageChanged() method is called with a few ChangedInfoOnlyPaths (no ResyncPaths). Nothing is done with these notifs as they don't meet any of our specific conditions. So they will now be caught in this new block and send a subtree invalidate notif. This is used to refresh and and set dirty the Maya scene.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ufe::SubtreeInvalidate is v2 only, thus all this code is ifdef protected (including the new bool).

lib/mayaUsd/ufe/StagesSubject.cpp Outdated Show resolved Hide resolved
}

auto sceneItem = Ufe::Hierarchy::createItem(ufePath);
Ufe::Scene::instance().notify(Ufe::SubtreeInvalidate(sceneItem));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We discussed this internally and since we have no other UFE notif to send this was the only thing we could do. One idea was the creation of a new UFE notif (such as SceneDirty) but we decided against that. @kxl-adsk Can you provide more info?

* Reworked to send ufe attribute value changed for the
  ChangedInfoOnlyPaths (instead of subtreeInvalidate).
@seando-adsk
Copy link
Collaborator Author

@ppt-adsk Oops sorry I forgot to commit the change to the test.

* Fixed mistake in test for older UFE version.
Comment on lines +37 to +42
if(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') >= '2036'):
if isinstance(notification, ufe.AttributeValueChanged):
self._notifications += 1
else:
if isinstance(notification, ufe.AttributeChanged):
self._notifications += 1
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops sorry. Of course the test passed locally for me because I had UFE 0.2.36. I forgot to account for older UFE versions.

@seando-adsk seando-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Jan 13, 2021
@seando-adsk
Copy link
Collaborator Author

@kxl-adsk I had a random test timeout on master Windows python3 only.
The following tests FAILED:
116 - testUsdImportXforms (Timeout)

Please merge. In the meantime, I'll re-run the preflight just to verify that it was indeed random.

@kxl-adsk kxl-adsk merged commit 4e83afd into dev Jan 13, 2021
@kxl-adsk kxl-adsk deleted the donnels/MAYA-106780/editing_usd_should_mark_scene_as_dirty branch January 13, 2021 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready-for-merge Development process is finished, PR is ready for merge ufe-usd Related to UFE-USD plugin in Maya-Usd
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants