-
Notifications
You must be signed in to change notification settings - Fork 358
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
Add Shift + C hotkey to create a nodegraph from selected nodes #2048
base: main
Are you sure you want to change the base?
Add Shift + C hotkey to create a nodegraph from selected nodes #2048
Conversation
@WaffleBoyTom This looks like a great start, and to resolve the EasyCLA issue, I'd recommend following up through the support link that the Linux Foundation provides: https://jira.linuxfoundation.org/servicedesk/customer/portal/4 |
In parallel with the CLA process, I'm CC'ing @lfl-eholthouser for her thoughts on the implementation of the feature. |
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.
- Great to see this worked out.
- I've left some comments about adding some more conditional checking and code cleanup. Thanks.
I wanted to follow up on this proposal, @WaffleBoyTom, to see if you might have the bandwidth to address the requests above. Let us know either way! |
Yes ! Sorry about the radio silence. I was planning on finishing this up this weekend hopefully ! |
This looks very promising, thanks @WaffleBoyTom! Make sure to resolve the EasyCLA issue above, following the link provided by the Linux Foundation, so that we can merge your work once it's approved by the MaterialX team. |
Hey ! I followed the link and signed the CLA so I think that should be okay ? I might be missing something |
@WaffleBoyTom It looks like the EasyCLA system still needs approvals for some of the commits above, so perhaps you can follow up by clicking their support link?
|
sounds good, let me do that :) |
9f29709
to
0f61933
Compare
I think we did it :o |
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.
Thanks for the updates @WaffleBoyTom . Looks good.
I just have one small addition item which is to clear the copy "buffer" after the action so that it's not accidently pasted erroneously at some later time.
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.
Thanks for the cleanup @WaffleBoyTom. Looks good to go!
Signed-off-by: Jonathan Stone <jstone@lucasfilm.com>
Signed-off-by: Jonathan Stone <jstone@lucasfilm.com>
Signed-off-by: Jonathan Stone <jstone@lucasfilm.com>
Signed-off-by: Jonathan Stone <jstone@lucasfilm.com>
@WaffleBoyTom I've been giving this new feature a try in my local build, but so far it's not behaving as I would expect, though I may be misunderstanding the intended design. I'm clearing the contents of the Graph Editor, creating a small number of nodes at root scope, then selecting them all, as seen in the following screenshot: I then hit the
Just to make sure I didn't accidentally break anything with my own merges and formatting fixes, I tried the same process again with the codebase at the time of your most recent commit, but I get the same results. What might I be missing? |
Hey Jonathan ! |
@WaffleBoyTom, @jstone-lucasfilm : I'll take a quick look. The current logic does need some changes. It should be:
|
Thank you, I should be able to make these changes this weekend |
This is what I've found that works: bool isNodeGraph = _isNodeGraph; // Check if we're already inside a nodegraph
if (_currUiNode)
{
// Check if current node is a nodegraph (also caught below but a faster "early out"
isNodeGraph |= (_currUiNode->getCategory() == mx::NodeGraph::CATEGORY);
}
if (!isNodeGraph)
{
for (ed::NodeId selected : selectedNodes)
{
int pos = findNode((int)selected.Get());
if (pos >= 0)
{
UiNodePtr node = _graphNodes[pos];
// Check if the selected node is a nodegraph
isNodeGraph |= (node->getCategory() == mx::NodeGraph::CATEGORY);
if (isNodeGraph)
{
// Skip all nodes if one of the nodes is a nodegraph
break;
}
_copiedNodes.insert(
std::pair<UiNodePtr, UiNodePtr>(_graphNodes[pos], nullptr));
}
}
} I checked if you dive in to a node which has a nodegraph implementation that this code isn't even reached since I assume any hot key is prevented from triggering. You probably want to hammer on this a bit more though :). |
Thanks ! |
for (std::map<UiNodePtr, UiNodePtr>::iterator iter = _copiedNodes.begin(); iter != _copiedNodes.end(); iter++) | ||
{ | ||
UiNodePtr node = iter->first; | ||
deleteNode(node); |
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.
This seems to break the links between nodes so even though they are copied the links are not copied over?
Tried moving this later after the paste but it crashes with some shared ptr de-refencing error. Even with this as is, I've seen hang in refresh if you try and select the surfaceshader in the default marble graph and try this operation then try and go back to the parent.
@lfl-eholthouser pinging you as you know this code much better than I. If you don't delete then a nodegraph is created properly with linked nodes and have not experienced any side-effects.
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 found a fix for the linking. Remove this code and add in a new flag to know that a graph has been built. I called this isBuildGraph
and set it here::
// Paste
for (std::map<UiNodePtr, UiNodePtr>::iterator iter = _copiedNodes.begin(); iter != _copiedNodes.end(); iter++)
{
copyUiNode(iter->first);
}
_addNewNode = true;
isBuildGraph = true;
Test this flag later on and go up back to the parent and perform a proper "cut".
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_RootWindow))
{
if (isBuildGraph)
{
upNodeGraph();
_isCut = true;
isBuildGraph = false;
}
if (ImGui::IsKeyReleased(ImGuiKey_Delete) || _isCut)
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 can add this to my code, thank you !!
Addresses #2018.
Shift + C will create nodegraph containing selected nodes.
Connections are not preserved.