Browse Source

Merge pull request #83892 from Geometror/fix-gn-slot-index

Fix GraphNode slot index inconsistency.
Rémi Verschelde 1 year ago
parent
commit
3f9af43e73
2 changed files with 8 additions and 8 deletions
  1. 6 6
      scene/gui/graph_edit.cpp
  2. 2 2
      scene/gui/graph_node.cpp

+ 6 - 6
scene/gui/graph_edit.cpp

@@ -598,7 +598,7 @@ bool GraphEdit::_filter_input(const Point2 &p_point) {
 
 
 			// Determine slot height.
 			// Determine slot height.
 			int slot_index = graph_node->get_input_port_slot(j);
 			int slot_index = graph_node->get_input_port_slot(j);
-			Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index));
+			Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index, false));
 
 
 			port_size.height = MAX(port_size.height, child ? child->get_size().y : 0);
 			port_size.height = MAX(port_size.height, child ? child->get_size().y : 0);
 
 
@@ -612,7 +612,7 @@ bool GraphEdit::_filter_input(const Point2 &p_point) {
 
 
 			// Determine slot height.
 			// Determine slot height.
 			int slot_index = graph_node->get_output_port_slot(j);
 			int slot_index = graph_node->get_output_port_slot(j);
-			Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index));
+			Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index, false));
 			port_size.height = MAX(port_size.height, child ? child->get_size().y : 0);
 			port_size.height = MAX(port_size.height, child ? child->get_size().y : 0);
 
 
 			if (is_in_output_hotzone(graph_node, j, p_point / zoom, port_size)) {
 			if (is_in_output_hotzone(graph_node, j, p_point / zoom, port_size)) {
@@ -643,7 +643,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
 
 
 				// Determine slot height.
 				// Determine slot height.
 				int slot_index = graph_node->get_output_port_slot(j);
 				int slot_index = graph_node->get_output_port_slot(j);
-				Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index));
+				Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index, false));
 				port_size.height = MAX(port_size.height, child ? child->get_size().y : 0);
 				port_size.height = MAX(port_size.height, child ? child->get_size().y : 0);
 
 
 				if (is_in_output_hotzone(graph_node, j, click_pos, port_size)) {
 				if (is_in_output_hotzone(graph_node, j, click_pos, port_size)) {
@@ -700,7 +700,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
 
 
 				// Determine slot height.
 				// Determine slot height.
 				int slot_index = graph_node->get_input_port_slot(j);
 				int slot_index = graph_node->get_input_port_slot(j);
-				Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index));
+				Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index, false));
 				port_size.height = MAX(port_size.height, child ? child->get_size().y : 0);
 				port_size.height = MAX(port_size.height, child ? child->get_size().y : 0);
 
 
 				if (is_in_input_hotzone(graph_node, j, click_pos, port_size)) {
 				if (is_in_input_hotzone(graph_node, j, click_pos, port_size)) {
@@ -777,7 +777,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
 
 
 						// Determine slot height.
 						// Determine slot height.
 						int slot_index = graph_node->get_output_port_slot(j);
 						int slot_index = graph_node->get_output_port_slot(j);
-						Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index));
+						Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index, false));
 						port_size.height = MAX(port_size.height, child ? child->get_size().y : 0);
 						port_size.height = MAX(port_size.height, child ? child->get_size().y : 0);
 
 
 						int type = graph_node->get_output_port_type(j);
 						int type = graph_node->get_output_port_type(j);
@@ -801,7 +801,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
 
 
 						// Determine slot height.
 						// Determine slot height.
 						int slot_index = graph_node->get_input_port_slot(j);
 						int slot_index = graph_node->get_input_port_slot(j);
-						Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index));
+						Control *child = Object::cast_to<Control>(graph_node->get_child(slot_index, false));
 						port_size.height = MAX(port_size.height, child ? child->get_size().y : 0);
 						port_size.height = MAX(port_size.height, child ? child->get_size().y : 0);
 
 
 						int type = graph_node->get_input_port_type(j);
 						int type = graph_node->get_input_port_type(j);

+ 2 - 2
scene/gui/graph_node.cpp

@@ -620,7 +620,7 @@ void GraphNode::_port_pos_update() {
 				port_cache.pos = Point2i(edgeofs, vertical_ofs + size.height / 2);
 				port_cache.pos = Point2i(edgeofs, vertical_ofs + size.height / 2);
 				port_cache.type = slot_table[i].type_left;
 				port_cache.type = slot_table[i].type_left;
 				port_cache.color = slot_table[i].color_left;
 				port_cache.color = slot_table[i].color_left;
-				port_cache.slot_index = child->get_index(); // Index with internal nodes included.
+				port_cache.slot_index = child->get_index(false);
 				left_port_cache.push_back(port_cache);
 				left_port_cache.push_back(port_cache);
 			}
 			}
 			if (slot_table[i].enable_right) {
 			if (slot_table[i].enable_right) {
@@ -628,7 +628,7 @@ void GraphNode::_port_pos_update() {
 				port_cache.pos = Point2i(get_size().width - edgeofs, vertical_ofs + size.height / 2);
 				port_cache.pos = Point2i(get_size().width - edgeofs, vertical_ofs + size.height / 2);
 				port_cache.type = slot_table[i].type_right;
 				port_cache.type = slot_table[i].type_right;
 				port_cache.color = slot_table[i].color_right;
 				port_cache.color = slot_table[i].color_right;
-				port_cache.slot_index = child->get_index(); // Index with internal nodes included.
+				port_cache.slot_index = child->get_index(false);
 				right_port_cache.push_back(port_cache);
 				right_port_cache.push_back(port_cache);
 			}
 			}
 		}
 		}