Skip to content

Commit c7f862d

Browse files
committed
Merge pull request #94738 from TokageItLab/blendshape-edit
Fix BlendShapeTrack insertion not working
2 parents 44342c3 + b075eba commit c7f862d

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

editor/animation_track_editor.cpp

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "editor/inspector_dock.h"
4444
#include "editor/plugins/animation_player_editor_plugin.h"
4545
#include "editor/themes/editor_scale.h"
46+
#include "scene/3d/mesh_instance_3d.h"
4647
#include "scene/animation/animation_player.h"
4748
#include "scene/animation/tween.h"
4849
#include "scene/gui/check_box.h"
@@ -5120,16 +5121,7 @@ void AnimationTrackEditor::_new_track_property_selected(const String &p_name) {
51205121
Animation::InterpolationType interp_type = Animation::INTERPOLATION_LINEAR;
51215122
bool loop_wrap = true;
51225123
_fetch_value_track_options(full_path, &update_mode, &interp_type, &loop_wrap);
5123-
if (adding_track_type == Animation::TYPE_VALUE) {
5124-
undo_redo->create_action(TTR("Add Track"));
5125-
undo_redo->add_do_method(animation.ptr(), "add_track", adding_track_type);
5126-
undo_redo->add_do_method(animation.ptr(), "track_set_path", animation->get_track_count(), full_path);
5127-
undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_type", animation->get_track_count(), interp_type);
5128-
undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_loop_wrap", animation->get_track_count(), loop_wrap);
5129-
undo_redo->add_do_method(animation.ptr(), "value_track_set_update_mode", animation->get_track_count(), update_mode);
5130-
undo_redo->add_undo_method(animation.ptr(), "remove_track", animation->get_track_count());
5131-
undo_redo->commit_action();
5132-
} else {
5124+
if (adding_track_type == Animation::TYPE_BEZIER) {
51335125
Vector<String> subindices;
51345126
{
51355127
// Hack.
@@ -5157,6 +5149,24 @@ void AnimationTrackEditor::_new_track_property_selected(const String &p_name) {
51575149
undo_redo->add_undo_method(animation.ptr(), "remove_track", base_track);
51585150
}
51595151
undo_redo->commit_action();
5152+
} else {
5153+
bool is_blend_shape = adding_track_type == Animation::TYPE_BLEND_SHAPE;
5154+
if (is_blend_shape) {
5155+
PackedStringArray split = p_name.split("/");
5156+
if (!split.is_empty()) {
5157+
full_path = String(adding_track_path) + ":" + split[split.size() - 1];
5158+
}
5159+
}
5160+
undo_redo->create_action(TTR("Add Track"));
5161+
undo_redo->add_do_method(animation.ptr(), "add_track", adding_track_type);
5162+
undo_redo->add_do_method(animation.ptr(), "track_set_path", animation->get_track_count(), full_path);
5163+
undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_type", animation->get_track_count(), interp_type);
5164+
undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_loop_wrap", animation->get_track_count(), loop_wrap);
5165+
if (!is_blend_shape) {
5166+
undo_redo->add_do_method(animation.ptr(), "value_track_set_update_mode", animation->get_track_count(), update_mode);
5167+
}
5168+
undo_redo->add_undo_method(animation.ptr(), "remove_track", animation->get_track_count());
5169+
undo_redo->commit_action();
51605170
}
51615171
}
51625172

@@ -5249,7 +5259,16 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) {
52495259

52505260
id.value = base->get_scale();
52515261
} break;
5252-
case Animation::TYPE_BLEND_SHAPE:
5262+
case Animation::TYPE_BLEND_SHAPE: {
5263+
MeshInstance3D *base = Object::cast_to<MeshInstance3D>(node);
5264+
5265+
if (!base) {
5266+
EditorNode::get_singleton()->show_warning(TTR("Track is not of type MeshInstance3D, can't insert key"));
5267+
return;
5268+
}
5269+
5270+
id.value = base->get_blend_shape_value(base->find_blend_shape_by_name(id.path.get_subname(0)));
5271+
} break;
52535272
case Animation::TYPE_VALUE: {
52545273
NodePath bp;
52555274
_find_hint_for_track(p_track, bp, &id.value);

0 commit comments

Comments
 (0)