2
0
Эх сурвалжийг харах

Merge pull request #96789 from SaracenOne/bezier_fixes

Fix errors when creating bezier component tracks.
Rémi Verschelde 1 жил өмнө
parent
commit
18cdfb8101

+ 24 - 1
editor/animation_track_editor.cpp

@@ -4345,6 +4345,25 @@ PropertyInfo AnimationTrackEditor::_find_hint_for_track(int p_idx, NodePath &r_b
 		property_info_base = property_info_base.get_named(leftover_path[i], valid);
 		property_info_base = property_info_base.get_named(leftover_path[i], valid);
 	}
 	}
 
 
+	// Hack for the fact that bezier tracks leftover paths can reference
+	// the individual components for types like vectors.
+	if (property_info_base.is_null()) {
+		if (res.is_valid()) {
+			property_info_base = res;
+		} else if (node) {
+			property_info_base = node;
+		}
+
+		if (leftover_path.size()) {
+			leftover_path.remove_at(leftover_path.size() - 1);
+		}
+
+		for (int i = 0; i < leftover_path.size() - 1; i++) {
+			bool valid;
+			property_info_base = property_info_base.get_named(leftover_path[i], valid);
+		}
+	}
+
 	if (property_info_base.is_null()) {
 	if (property_info_base.is_null()) {
 		WARN_PRINT(vformat("Could not determine track hint for '%s:%s' because its base property is null.",
 		WARN_PRINT(vformat("Could not determine track hint for '%s:%s' because its base property is null.",
 				String(path.get_concatenated_names()), String(path.get_concatenated_subnames())));
 				String(path.get_concatenated_names()), String(path.get_concatenated_subnames())));
@@ -4472,7 +4491,11 @@ AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertD
 
 
 		} break;
 		} break;
 		case Animation::TYPE_BEZIER: {
 		case Animation::TYPE_BEZIER: {
-			int existing = animation->track_find_key(p_id.track_idx, time, Animation::FIND_MODE_APPROX);
+			int existing = -1;
+			if (p_id.track_idx < animation->get_track_count()) {
+				existing = animation->track_find_key(p_id.track_idx, time, Animation::FIND_MODE_APPROX);
+			}
+
 			if (existing != -1) {
 			if (existing != -1) {
 				Array arr = animation->track_get_key_value(p_id.track_idx, existing);
 				Array arr = animation->track_get_key_value(p_id.track_idx, existing);
 				arr[0] = p_id.value;
 				arr[0] = p_id.value;