Skip to content

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

Merged
merged 8 commits into from
Nov 12, 2024

Conversation

adamgerhant
Copy link
Collaborator

@adamgerhant adamgerhant commented Nov 7, 2024

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.

Copy link
Member

@0HyperCube 0HyperCube left a 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
Copy link
Member

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?

Copy link
Collaborator Author

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 => {
Copy link
Member

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.);
Copy link
Member

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?

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 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.

@Keavon Keavon force-pushed the user-created-nodes branch from 4828171 to d96e57f Compare November 12, 2024 22:06
@Keavon Keavon changed the title Improved support for user created nodes Add merging nodes into a subgraph with Ctrl+M and basic subgraph signature customization Nov 12, 2024
@Keavon Keavon merged commit 4250f29 into master Nov 12, 2024
4 checks passed
@Keavon Keavon deleted the user-created-nodes branch November 12, 2024 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow users to escape from node implementations Improved node graph support for user created nodes
3 participants