3131#include " animation_blend_space_1d_editor.h"
3232
3333#include " core/os/keyboard.h"
34+ #include " editor/docks/inspector_dock.h"
3435#include " editor/editor_node.h"
3536#include " editor/editor_string_names.h"
3637#include " editor/editor_undo_redo_manager.h"
@@ -133,9 +134,9 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
133134 for (int i = 0 ; i < points.size (); i++) {
134135 if (Math::abs (float (points[i] - mb->get_position ().x )) < 10 * EDSCALE) {
135136 selected_point = i;
136-
137137 Ref<AnimationNode> node = blend_space->get_blend_point_node (i);
138- EditorNode::get_singleton ()->push_item (node.ptr (), " " , true );
138+ current_blend_point_editor->setup (blend_space, selected_point, node);
139+ InspectorDock::get_inspector_singleton ()->edit (current_blend_point_editor.ptr ());
139140 dragging_selected_attempt = true ;
140141 drag_from = mb->get_position ();
141142 _update_tool_erase ();
@@ -336,6 +337,8 @@ void AnimationNodeBlendSpace1DEditor::_update_space() {
336337
337338 sync->set_pressed (blend_space->is_using_sync ());
338339 interpolation->select (blend_space->get_blend_mode ());
340+ use_velocity_limit->set_pressed (blend_space->get_use_velocity_limit ());
341+ default_velocity_limit->set_value (blend_space->get_velocity_limit ());
339342
340343 label_value->set_text (blend_space->get_value_label ());
341344
@@ -364,6 +367,11 @@ void AnimationNodeBlendSpace1DEditor::_config_changed(double) {
364367 undo_redo->add_undo_method (blend_space.ptr (), " set_use_sync" , blend_space->is_using_sync ());
365368 undo_redo->add_do_method (blend_space.ptr (), " set_blend_mode" , interpolation->get_selected ());
366369 undo_redo->add_undo_method (blend_space.ptr (), " set_blend_mode" , blend_space->get_blend_mode ());
370+ blending_hb->set_visible (sync->is_pressed ());
371+ undo_redo->add_do_method (blend_space.ptr (), " set_use_velocity_limit" , use_velocity_limit->is_pressed ());
372+ undo_redo->add_undo_method (blend_space.ptr (), " set_use_velocity_limit" , blend_space->get_use_velocity_limit ());
373+ undo_redo->add_do_method (blend_space.ptr (), " set_velocity_limit" , default_velocity_limit->get_value ());
374+ undo_redo->add_undo_method (blend_space.ptr (), " set_velocity_limit" , blend_space->get_velocity_limit ());
367375 undo_redo->add_do_method (this , " _update_space" );
368376 undo_redo->add_undo_method (this , " _update_space" );
369377 undo_redo->commit_action ();
@@ -571,6 +579,7 @@ void AnimationNodeBlendSpace1DEditor::_open_editor() {
571579
572580void AnimationNodeBlendSpace1DEditor::_notification (int p_what) {
573581 switch (p_what) {
582+ case NOTIFICATION_ENTER_TREE:
574583 case NOTIFICATION_THEME_CHANGED: {
575584 error_panel->add_theme_style_override (SceneStringName (panel), get_theme_stylebox (SceneStringName (panel), SNAME (" Tree" )));
576585 error_label->add_theme_color_override (SceneStringName (font_color), get_theme_color (SNAME (" error_color" ), EditorStringName (Editor)));
@@ -616,6 +625,82 @@ void AnimationNodeBlendSpace1DEditor::_notification(int p_what) {
616625 } break ;
617626 }
618627}
628+ void BlendPointEditor1D::setup (Ref<AnimationNodeBlendSpace1D> p_blend_space, int p_idx, Ref<AnimationNode> p_anim_node) {
629+ blend_space = p_blend_space;
630+ selected_point = p_idx;
631+ anim_node = p_anim_node;
632+ }
633+
634+ void BlendPointEditor1D::set_velocity_limit (float p_value) {
635+ if (blend_space.is_valid ()) {
636+ if (updating) {
637+ return ;
638+ }
639+ updating = true ;
640+ EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton ();
641+ undo_redo->create_action (TTR (" Change Node Velocity Limit" ));
642+ undo_redo->add_do_method (blend_space.ptr (), " set_blend_point_vl" , selected_point, p_value);
643+ undo_redo->add_undo_method (blend_space.ptr (), " set_blend_point_vl" , selected_point, blend_space->get_blend_point_vl (selected_point));
644+ undo_redo->commit_action ();
645+ updating = false ;
646+ }
647+ }
648+ double BlendPointEditor1D::get_velocity_limit () const {
649+ return (blend_space.is_valid ()) ? blend_space->get_blend_point_vl (selected_point) : 0.0 ;
650+ }
651+
652+ Ref<AnimationNode> BlendPointEditor1D::get_anim_node () const {
653+ return anim_node;
654+ }
655+ void BlendPointEditor1D::set_velocity_limit_ease (float const p_ease) {
656+ if (blend_space.is_valid ()) {
657+ updating = true ;
658+ EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton ();
659+ undo_redo->create_action (TTR (" Change Blendspace Velocity Limit Ease" ));
660+ undo_redo->add_do_method (blend_space.ptr (), " set_velocity_limit_ease" , p_ease);
661+ undo_redo->add_undo_method (blend_space.ptr (), " set_velocity_limit_ease" , blend_space->get_velocity_limit_ease ());
662+ undo_redo->commit_action ();
663+ updating = false ;
664+ }
665+ }
666+ float BlendPointEditor1D::get_velocity_limit_ease () const {
667+ return (blend_space.is_valid ()) ? blend_space->get_velocity_limit_ease () : 1.0 ;
668+ }
669+
670+ void BlendPointEditor1D::set_override_velocity_limit (bool const p_ovl) {
671+ if (blend_space.is_valid ()) {
672+ updating = true ;
673+ EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton ();
674+ undo_redo->create_action (TTR (" Change Node Override Velocity Limit" ));
675+ undo_redo->add_do_method (blend_space.ptr (), " set_blend_point_ovl" , selected_point, p_ovl);
676+ undo_redo->add_undo_method (blend_space.ptr (), " set_blend_point_ovl" , selected_point, blend_space->get_blend_point_ovl (selected_point));
677+ undo_redo->commit_action ();
678+ updating = false ;
679+ }
680+ }
681+ bool BlendPointEditor1D::get_override_velocity_limit () const {
682+ return (blend_space.is_valid ()) ? blend_space->get_blend_point_ovl (selected_point) : false ;
683+ }
684+
685+ void BlendPointEditor1D::_bind_methods () {
686+ ClassDB::bind_method (D_METHOD (" set_velocity_limit" , " value" ), &BlendPointEditor1D::set_velocity_limit);
687+ ClassDB::bind_method (D_METHOD (" get_velocity_limit" ), &BlendPointEditor1D::get_velocity_limit);
688+ ClassDB::bind_method (D_METHOD (" _dont_undo_redo" ), &BlendPointEditor1D::_dont_undo_redo);
689+ ClassDB::bind_method (D_METHOD (" _hide_script_from_inspector" ), &BlendPointEditor1D::_hide_script_from_inspector);
690+ ClassDB::bind_method (D_METHOD (" _hide_metadata_from_inspector" ), &BlendPointEditor1D::_hide_metadata_from_inspector);
691+
692+ ClassDB::bind_method (D_METHOD (" get_velocity_limit_ease" ), &BlendPointEditor1D::get_velocity_limit_ease);
693+ ClassDB::bind_method (D_METHOD (" set_velocity_limit_ease" ), &BlendPointEditor1D::set_velocity_limit_ease);
694+
695+ ClassDB::bind_method (D_METHOD (" set_override_velocity_limit" ), &BlendPointEditor1D::set_override_velocity_limit);
696+ ClassDB::bind_method (D_METHOD (" get_override_velocity_limit" ), &BlendPointEditor1D::get_override_velocity_limit);
697+
698+ ClassDB::bind_method (D_METHOD (" get_anim_node" ), &BlendPointEditor1D::get_anim_node);
699+ ADD_PROPERTY (PropertyInfo (Variant::FLOAT, " velocity_limit_ease" , PROPERTY_HINT_EXP_EASING), " set_velocity_limit_ease" , " get_velocity_limit_ease" );
700+ ADD_PROPERTY (PropertyInfo (Variant::BOOL, " override_velocity_limit" , PROPERTY_HINT_NONE), " set_override_velocity_limit" , " get_override_velocity_limit" );
701+ ADD_PROPERTY (PropertyInfo (Variant::FLOAT, " velocity_limit" , PROPERTY_HINT_NONE, " 0,60,0.01,or_greater,suffix:/s" ), " set_velocity_limit" , " get_velocity_limit" );
702+ ADD_PROPERTY (PropertyInfo (Variant::OBJECT, " animation_node" , PROPERTY_HINT_RESOURCE_TYPE, " AnimationNode" ), " " , " get_anim_node" );
703+ }
619704
620705void AnimationNodeBlendSpace1DEditor::_bind_methods () {
621706 ClassDB::bind_method (" _update_space" , &AnimationNodeBlendSpace1DEditor::_update_space);
@@ -645,6 +730,8 @@ void AnimationNodeBlendSpace1DEditor::edit(const Ref<AnimationNode> &p_node) {
645730 min_value->set_editable (!read_only);
646731 max_value->set_editable (!read_only);
647732 sync->set_disabled (read_only);
733+ default_velocity_limit->set_editable (!read_only);
734+ use_velocity_limit->set_disabled (read_only);
648735 interpolation->set_disabled (read_only);
649736}
650737
@@ -666,6 +753,7 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
666753 top_hb->add_child (tool_blend);
667754 tool_blend->set_pressed (true );
668755 tool_blend->set_tooltip_text (TTR (" Set the blending position within the space" ));
756+ tool_blend->set_accessibility_name (TTRC (" Set Blending Position" ));
669757 tool_blend->connect (SceneStringName (pressed), callable_mp (this , &AnimationNodeBlendSpace1DEditor::_tool_switch).bind (3 ));
670758
671759 tool_select = memnew (Button);
@@ -674,6 +762,7 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
674762 tool_select->set_button_group (bg);
675763 top_hb->add_child (tool_select);
676764 tool_select->set_tooltip_text (TTR (" Select and move points, create points with RMB." ));
765+ tool_select->set_accessibility_name (TTRC (" Edit Points" ));
677766 tool_select->connect (SceneStringName (pressed), callable_mp (this , &AnimationNodeBlendSpace1DEditor::_tool_switch).bind (0 ));
678767
679768 tool_create = memnew (Button);
@@ -682,6 +771,7 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
682771 tool_create->set_button_group (bg);
683772 top_hb->add_child (tool_create);
684773 tool_create->set_tooltip_text (TTR (" Create points." ));
774+ tool_create->set_accessibility_name (TTRC (" Create Points" ));
685775 tool_create->connect (SceneStringName (pressed), callable_mp (this , &AnimationNodeBlendSpace1DEditor::_tool_switch).bind (1 ));
686776
687777 tool_erase_sep = memnew (VSeparator);
@@ -690,6 +780,7 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
690780 tool_erase->set_theme_type_variation (SceneStringName (FlatButton));
691781 top_hb->add_child (tool_erase);
692782 tool_erase->set_tooltip_text (TTR (" Erase points." ));
783+ tool_erase->set_accessibility_name (TTRC (" Erase Points" ));
693784 tool_erase->connect (SceneStringName (pressed), callable_mp (this , &AnimationNodeBlendSpace1DEditor::_erase_selected));
694785
695786 top_hb->add_child (memnew (VSeparator));
@@ -700,6 +791,7 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
700791 top_hb->add_child (snap);
701792 snap->set_pressed (true );
702793 snap->set_tooltip_text (TTR (" Enable snap and show grid." ));
794+ snap->set_accessibility_name (TTRC (" Snap to Grid" ));
703795 snap->connect (SceneStringName (pressed), callable_mp (this , &AnimationNodeBlendSpace1DEditor::_snap_toggled));
704796
705797 snap_value = memnew (SpinBox);
@@ -722,6 +814,26 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
722814 top_hb->add_child (interpolation);
723815 interpolation->connect (SceneStringName (item_selected), callable_mp (this , &AnimationNodeBlendSpace1DEditor::_config_changed));
724816
817+ blending_hb = memnew (HBoxContainer);
818+ top_hb->add_child (blending_hb);
819+ blending_hb->add_child (memnew (VSeparator));
820+
821+ blending_hb->add_child (memnew (Label (TTR (" Use Velocity Limit:" ))));
822+ use_velocity_limit = memnew (CheckBox);
823+ blending_hb->add_child (use_velocity_limit);
824+ use_velocity_limit->connect (SceneStringName (toggled), callable_mp (this , &AnimationNodeBlendSpace1DEditor::_config_changed));
825+
826+ blending_hb->add_child (memnew (Label (TTR (" Default Velocity limit:" ))));
827+ default_velocity_limit = memnew (SpinBox);
828+ blending_hb->add_child (default_velocity_limit);
829+ default_velocity_limit->set_min (0.0 );
830+ default_velocity_limit->set_step (0.01 );
831+ default_velocity_limit->set_max (60.0 );
832+ default_velocity_limit->set_suffix (" /s" );
833+ default_velocity_limit->connect (SceneStringName (value_changed), callable_mp (this , &AnimationNodeBlendSpace1DEditor::_config_changed));
834+
835+ current_blend_point_editor.instantiate ();
836+
725837 edit_hb = memnew (HBoxContainer);
726838 top_hb->add_child (edit_hb);
727839 edit_hb->add_child (memnew (VSeparator));
0 commit comments