Merge pull request #96789 from SaracenOne/bezier_fixes

Fix errors when creating bezier component tracks.
This commit is contained in:
Rémi Verschelde 2024-09-12 09:17:54 +02:00
commit 18cdfb8101
No known key found for this signature in database
GPG Key ID: C3336907360768E1

View File

@ -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);
}
// 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()) {
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())));
@ -4472,7 +4491,11 @@ AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertD
} break;
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) {
Array arr = animation->track_get_key_value(p_id.track_idx, existing);
arr[0] = p_id.value;