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-103697 selection update on new objects #537

Merged
merged 3 commits into from
Jun 1, 2020

Conversation

huidong-chen
Copy link

When a prim switches modeling variant, the children of the prim can probably be changed to a different set of prims, with different hierarchy and paths. Thus the UFE selection observer will need to also listen to Ufe::ObjectAdd notification for Hydra selection update.

The other part of the commit will update the Hydra selection with respect to the UFE global selection when creating a new stage or a new prim.

@huidong-chen huidong-chen requested review from kxl-adsk and ppt-adsk May 29, 2020 13:29
Comment on lines +886 to +890
if (state) {
return state->fullySelected ? kFullySelected : kPartiallySelected;
}

return state ? kPartiallySelected : kUnselected;
return kUnselected;
Copy link
Author

Choose a reason for hiding this comment

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

Tiny refactoring change here for better looking and logical order.

@@ -186,7 +186,7 @@ class ProxyRenderDelegate : public MHWRender::MPxSubSceneOverride
std::unique_ptr<UsdImagingDelegate> _sceneDelegate; //!< USD scene delegate

bool _isPopulated{ false }; //!< If false, scene delegate wasn't populated yet within render index
bool _selectionChanged{ false }; //!< Whether there is any selection change or not
bool _selectionChanged{ true }; //!< Whether there is any selection change or not
Copy link
Author

Choose a reason for hiding this comment

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

At the frame creating a proxy shape, we need to update the Hydra selection.

Copy link
Author

Choose a reason for hiding this comment

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

Because the script to create the stage will select the proxy shape, this change means the new stage will be highlighted, which is what we want (MAYA-102103).

dynamic_cast<const Ufe::SelectionChanged*>(&notification);
if (selectionChanged != nullptr) {
if (dynamic_cast<const Ufe::SelectionChanged*>(&notification) ||
dynamic_cast<const Ufe::ObjectAdd*>(&notification)) {
Copy link
Author

Choose a reason for hiding this comment

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

So we listen to ObjectAdd for Hydra selection update. This will then make sure a new prim or a variant switched prim to be highlighted if it or any of its ancestor is selected.

@huidong-chen huidong-chen requested a review from williamkrick May 29, 2020 13:35
@@ -361,11 +362,14 @@ void ProxyRenderDelegate::_InitRenderDelegate(MSubSceneContainer& container) {

#if defined(WANT_UFE_BUILD)
if (!_ufeSelectionObserver) {
_ufeSelectionObserver = std::make_shared<UfeSelectionObserver>(*this);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Feels funny to still have it called selection observer, when it's observing both the selection and the scene... Maybe just plain ufeObserver?

Copy link
Author

Choose a reason for hiding this comment

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

Good point. I was thinking about the same but somehow gave up probably I thought its purpose is for selection update. But yes, I can rename it.

Copy link
Author

@huidong-chen huidong-chen May 29, 2020

Choose a reason for hiding this comment

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

Unluckily if I rename it to _ufeObserver, I hit a VS compiler bug that would produce an error:

d:\git\maya\worktrees\main\maya\src\components\usd\maya-usd\lib\mayausd\render\vp2renderdelegate\proxyRenderDelegate.h(201): error C2208: 'std::shared_ptr<Ufe_v0::Observer>': no members defined using this type

And I am not the only one hitting the issue:

https://stackoverflow.com/questions/23914815/what-is-the-error-in-my-shared-ptr-declaration

I will have to rename it to _ufeChangeObserver. Or if you have better suggestions?

Copy link
Author

Choose a reason for hiding this comment

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

I am renaming it to just _observer.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Works for me.

I cannot rename it to _ufeObserver due to a bug in VS compiler that would treat _ufeObserver as a magic id.
@huidong-chen huidong-chen added bug Something isn't working vp2renderdelegate Related to VP2RenderDelegate labels May 29, 2020
@huidong-chen huidong-chen requested a review from kxl-adsk June 1, 2020 15:39
@kxl-adsk kxl-adsk merged commit 8801a3d into dev Jun 1, 2020
@kxl-adsk kxl-adsk deleted the chenh/MAYA-103697/selection-update-on-new-objects branch June 1, 2020 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vp2renderdelegate Related to VP2RenderDelegate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants