Browse Source

Do not allow multiple data connections to the same data input slot, fixes #6357.Improved curve rendering when nodes are close.

Daniel J. Ramirez 8 years ago
parent
commit
707bb96fa8
2 changed files with 11 additions and 1 deletions
  1. 10 0
      modules/visual_script/visual_script_editor.cpp
  2. 1 1
      scene/gui/graph_edit.cpp

+ 10 - 0
modules/visual_script/visual_script_editor.cpp

@@ -2328,6 +2328,16 @@ void VisualScriptEditor::_graph_connected(const String &p_from, int p_from_slot,
 		undo_redo->add_do_method(script.ptr(), "sequence_connect", edited_func, p_from.to_int(), from_port, p_to.to_int());
 		undo_redo->add_undo_method(script.ptr(), "sequence_disconnect", edited_func, p_from.to_int(), from_port, p_to.to_int());
 	} else {
+
+		// disconect current, and connect the new one
+		if (script->is_input_value_port_connected(edited_func, p_to.to_int(), to_port)) {
+			int conn_from;
+			int conn_port;
+			script->get_input_value_port_connection_source(edited_func, p_to.to_int(), to_port, &conn_from, &conn_port);
+			undo_redo->add_do_method(script.ptr(), "data_disconnect", edited_func, conn_from, conn_port, p_to.to_int(), to_port);
+			undo_redo->add_undo_method(script.ptr(), "data_connect", edited_func, conn_from, conn_port, p_to.to_int(), to_port);
+		}
+
 		undo_redo->add_do_method(script.ptr(), "data_connect", edited_func, p_from.to_int(), from_port, p_to.to_int(), to_port);
 		undo_redo->add_undo_method(script.ptr(), "data_disconnect", edited_func, p_from.to_int(), from_port, p_to.to_int(), to_port);
 		//update nodes in sgraph

+ 1 - 1
scene/gui/graph_edit.cpp

@@ -601,7 +601,7 @@ void GraphEdit::_draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const
 	int cp_neg_len = get_constant("bezier_len_neg");
 
 	if (diff > 0) {
-		cp_offset = MAX(cp_len, diff * 0.5);
+		cp_offset = MIN(cp_len, diff * 0.5);
 	} else {
 		cp_offset = MAX(MIN(cp_len - diff, cp_neg_len), -diff * 0.5);
 	}