Skip to content

Commit

Permalink
Implement shader generation for groups
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometror committed Nov 18, 2024
1 parent f25f10b commit 809c21e
Show file tree
Hide file tree
Showing 5 changed files with 1,804 additions and 1,326 deletions.
13 changes: 3 additions & 10 deletions editor/plugins/visual_shader_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,6 @@ void VisualShaderGraphPlugin::update_node_deferred(VisualShader::Type p_type, in

void VisualShaderGraphPlugin::update_node(VisualShader::Type p_type, int p_node_id) {
// TODO: Adjust this check to node groups.
print_line("update_node: " + itos(p_node_id) + " has links: " + (links.has(p_node_id) ? "true" : "false"));
// Print all links.
for (const KeyValue<int, Link> &E : links) {
print_line("Link: " + itos(E.key));
}
if (p_type != editor->get_current_shader_type() || !links.has(p_node_id)) {
return;
}
Expand Down Expand Up @@ -704,7 +699,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool
// Add "Edit" button to group node titlebar.
Button *edit_group_btn = memnew(Button);
edit_group_btn->set_text(TTR("Edit"));
edit_group_btn->set_icon(editor->get_theme_icon("Edit", "EditorIcons"));
edit_group_btn->set_button_icon(editor->get_theme_icon("Edit", "EditorIcons"));
edit_group_btn->connect("pressed", callable_mp(editor, &VisualShaderEditor::_edit_group_in_graph).bind(p_id), CONNECT_DEFERRED);
titlebar->add_child(edit_group_btn);

Expand Down Expand Up @@ -1635,7 +1630,7 @@ void VisualShaderEditor::save_external_data(const String &p_str) {

void VisualShaderEditor::validate_script() {
// TODO: Check if this is correct. Probably needs more work.
if (editing_shader_graph != nullptr) {
if (editing_shader_graph.is_valid()) {
_update_nodes();
}
}
Expand Down Expand Up @@ -2565,8 +2560,6 @@ void VisualShaderEditor::_set_mode(int p_which) {
}

void VisualShaderEditor::_edit_group_in_graph(int p_idx) {
print_line("Edit group: " + itos(p_idx));

Ref<VisualShaderNodeGroup> group_node = editing_shader_graph->get_node(p_idx);
ERR_FAIL_COND(group_node.is_null());

Expand Down Expand Up @@ -2725,7 +2718,7 @@ void VisualShaderEditor::_update_parameter_refs(HashSet<String> &p_deleted_names
}

void VisualShaderEditor::_update_graph() {
if (editing_shader_graph == nullptr) {
if (editing_shader_graph.is_null()) {
return;
}

Expand Down
Loading

0 comments on commit 809c21e

Please sign in to comment.