Fix errors when creating bezier component tracks.

This commit is contained in:
Saracen 2024-09-10 08:33:42 +01:00
parent 21249950da
commit 09515bfc6c
1 changed files with 24 additions and 1 deletions

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;