-
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
MAYA-103697 selection update on new objects #537
MAYA-103697 selection update on new objects #537
Conversation
if (state) { | ||
return state->fullySelected ? kFullySelected : kPartiallySelected; | ||
} | ||
|
||
return state ? kPartiallySelected : kUnselected; | ||
return kUnselected; |
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.
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 |
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.
At the frame creating a proxy shape, we need to update the Hydra selection.
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.
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*>(¬ification); | ||
if (selectionChanged != nullptr) { | ||
if (dynamic_cast<const Ufe::SelectionChanged*>(¬ification) || | ||
dynamic_cast<const Ufe::ObjectAdd*>(¬ification)) { |
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.
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.
@@ -361,11 +362,14 @@ void ProxyRenderDelegate::_InitRenderDelegate(MSubSceneContainer& container) { | |||
|
|||
#if defined(WANT_UFE_BUILD) | |||
if (!_ufeSelectionObserver) { | |||
_ufeSelectionObserver = std::make_shared<UfeSelectionObserver>(*this); |
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.
Feels funny to still have it called selection observer, when it's observing both the selection and the scene... Maybe just plain ufeObserver?
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.
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.
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.
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?
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 am renaming it to just _observer
.
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.
Works for me.
I cannot rename it to _ufeObserver due to a bug in VS compiler that would treat _ufeObserver as a magic id.
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.