-
-
Notifications
You must be signed in to change notification settings - Fork 578
Add merging nodes into a subgraph with Ctrl+M and basic subgraph signature customization #2097
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
Conversation
9297b83
to
3bfc82a
Compare
8b65941
to
4828171
Compare
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 work on this. Works robustly when I've tested it.
@@ -64,6 +64,23 @@ static DOCUMENT_NODE_TYPES: once_cell::sync::Lazy<Vec<DocumentNodeDefinition>> = | |||
/// The [`DocumentNode`] is the instance while these [`DocumentNodeDefinition`]s are the "classes" or "blueprints" from which the instances are built. | |||
fn static_nodes() -> Vec<DocumentNodeDefinition> { | |||
let mut custom = vec![ | |||
// TODO: Auto-generate this from its proto node macro |
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.
There are no protonodes here?
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.
Yes, that should be deleted, as well as all other comments for network implementation node definitions.
@@ -345,6 +349,171 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphHandlerData<'a>> for NodeGrap | |||
} => { | |||
network_interface.insert_node_between(&node_id, &input_connector, insert_node_input_index, selection_network_path); | |||
} | |||
NodeGraphMessage::MergeSelectedNodes => { |
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.
Would it be easier to understand if you split this into separate functions?
e.g:
- checking if the nodes are discontinuous in a line of dependencies
- Collecting the existing inputs and exports (and targets)
- Crafting the new node and reconnecting.
let bounding_box_top_right = DVec2::new((all_nodes_bounding_box[1].x / 24. + 0.5).floor() * 24., (all_nodes_bounding_box[0].y / 24. + 0.5).floor() * 24.) + offset_from_top_right; | ||
let export_top_right = DVec2::new(viewport_top_right.x.max(bounding_box_top_right.x), viewport_top_right.y.min(bounding_box_top_right.y)); | ||
let add_export_center = export_top_right + DVec2::new(0., network.exports.len() as f64 * 24.); | ||
let add_export = ClickTarget::new(Subpath::new_ellipse(add_export_center - DVec2::new(8., 8.), add_export_center + DVec2::new(8., 8.)), 0.); |
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.
Would it be possible to avoid hardcoding the size & shape of the buttons here as well as in the frontend?
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.
The frontend button in the UI is purely visual. The click targets are currently incorrect, since they are spherical while the button is a rounded square. I also need to add it to the alt+C debug overlay. But they do need to be hardcoded in Rust.
4828171
to
d96e57f
Compare
Closes #2043, closes #2099
Adds UI elements in order to access the various functions provided by the network interface to add/remove/rename exports.
Adds a "Merge Selected Nodes" macro to automatically group a set of nodes into a subnetwork.