You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Make the dragging connections more user-friendly in visual shaders
This commit is contained in:
@@ -3083,6 +3083,9 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, Stri
|
||||
if (!is_native) {
|
||||
vsnode->set_script(add_options[p_idx].script);
|
||||
}
|
||||
VisualShaderNodeCustom *custom_node = Object::cast_to<VisualShaderNodeCustom>(vsn);
|
||||
ERR_FAIL_COND(!custom_node);
|
||||
custom_node->update_ports();
|
||||
}
|
||||
|
||||
bool is_texture2d = (Object::cast_to<VisualShaderNodeTexture>(vsnode.ptr()) != nullptr);
|
||||
@@ -3211,16 +3214,26 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, Stri
|
||||
undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_slot, _to_node, _to_slot);
|
||||
undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_slot, _to_node, _to_slot);
|
||||
} else {
|
||||
// Attempting to connect to the first correct port.
|
||||
int _to_slot = -1;
|
||||
|
||||
// Attempting to connect to the default input port or to the first correct port (if it's not found).
|
||||
for (int i = 0; i < vsnode->get_input_port_count(); i++) {
|
||||
if (visual_shader->is_port_types_compatible(output_port_type, vsnode->get_input_port_type(i))) {
|
||||
undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_slot, _to_node, i);
|
||||
undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, from_node, from_slot, _to_node, i);
|
||||
undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_slot, _to_node, i);
|
||||
undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_slot, _to_node, i);
|
||||
break;
|
||||
if (i == vsnode->get_default_input_port(output_port_type)) {
|
||||
_to_slot = i;
|
||||
break;
|
||||
} else if (_to_slot == -1) {
|
||||
_to_slot = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_to_slot >= 0) {
|
||||
undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_slot, _to_node, _to_slot);
|
||||
undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, from_node, from_slot, _to_node, _to_slot);
|
||||
undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_slot, _to_node, _to_slot);
|
||||
undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_slot, _to_node, _to_slot);
|
||||
}
|
||||
}
|
||||
|
||||
if (output_port_type == VisualShaderNode::PORT_TYPE_SAMPLER) {
|
||||
|
||||
Reference in New Issue
Block a user