Skip to content

Commit 8f87e60

Browse files
authored
Merge pull request #107241 from TokageItLab/fix-anim-insert-type
Fix animation track inserted path and key type
2 parents 9e02194 + 19f342e commit 8f87e60

File tree

1 file changed

+5
-35
lines changed

1 file changed

+5
-35
lines changed

editor/animation_track_editor.cpp

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4463,17 +4463,8 @@ void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_p
44634463
String path = root->get_path_to(p_node, true);
44644464

44654465
// Get the value from the subpath.
4466-
Variant value = p_node;
4467-
Vector<String> property_path = p_property.split(":");
4468-
for (const String &E : property_path) {
4469-
if (value.get_type() == Variant::OBJECT) {
4470-
Object *obj = value;
4471-
value = obj->get(E);
4472-
} else {
4473-
value = Variant();
4474-
break;
4475-
}
4476-
}
4466+
Vector<StringName> subpath = NodePath(p_property).get_as_property_path().get_subnames();
4467+
Variant value = p_node->get_indexed(subpath);
44774468

44784469
if (Object::cast_to<AnimationPlayer>(p_node) && p_property == "current_animation") {
44794470
if (p_node == AnimationPlayerEditor::get_singleton()->get_player()) {
@@ -4710,30 +4701,6 @@ PropertyInfo AnimationTrackEditor::_find_hint_for_track(int p_idx, NodePath &r_b
47104701
}
47114702
}
47124703

4713-
for (int i = 0; i < leftover_path.size() - 1; i++) {
4714-
bool valid;
4715-
property_info_base = property_info_base.get_named(leftover_path[i], valid);
4716-
}
4717-
4718-
// Hack for the fact that bezier tracks leftover paths can reference
4719-
// the individual components for types like vectors.
4720-
if (property_info_base.is_null()) {
4721-
if (res.is_valid()) {
4722-
property_info_base = res;
4723-
} else if (node) {
4724-
property_info_base = node;
4725-
}
4726-
4727-
if (leftover_path.size()) {
4728-
leftover_path.remove_at(leftover_path.size() - 1);
4729-
}
4730-
4731-
for (int i = 0; i < leftover_path.size() - 1; i++) {
4732-
bool valid;
4733-
property_info_base = property_info_base.get_named(leftover_path[i], valid);
4734-
}
4735-
}
4736-
47374704
if (property_info_base.is_null()) {
47384705
WARN_PRINT(vformat("Could not determine track hint for '%s:%s' because its base property is null.",
47394706
String(path.get_concatenated_names()), String(path.get_concatenated_subnames())));
@@ -4791,6 +4758,9 @@ static Vector<String> _get_bezier_subindices_for_type(Variant::Type p_type, bool
47914758
subindices.push_back(":z");
47924759
subindices.push_back(":d");
47934760
} break;
4761+
case Variant::NIL: {
4762+
subindices.push_back(""); // Hack: it is probably float since non-numeric types are filtered in the selection window.
4763+
} break;
47944764
default: {
47954765
if (r_valid) {
47964766
*r_valid = false;

0 commit comments

Comments
 (0)