Merge pull request #72043 from SaracenOne/animation_tree_crashfix

Fix crash when switching to a different node from AnimationTree
This commit is contained in:
Rémi Verschelde 2023-01-26 01:08:35 +01:00
commit 04591379d0
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 12 additions and 8 deletions

View file

@ -1138,7 +1138,7 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co
accent.a *= 0.6;
}
const Ref<Texture2D> icons[6] = {
const Ref<Texture2D> icons[] = {
get_theme_icon(SNAME("TransitionImmediateBig"), SNAME("EditorIcons")),
get_theme_icon(SNAME("TransitionSyncBig"), SNAME("EditorIcons")),
get_theme_icon(SNAME("TransitionEndBig"), SNAME("EditorIcons")),
@ -1146,6 +1146,7 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co
get_theme_icon(SNAME("TransitionSyncAutoBig"), SNAME("EditorIcons")),
get_theme_icon(SNAME("TransitionEndAutoBig"), SNAME("EditorIcons"))
};
const int ICON_COUNT = sizeof(icons) / sizeof(*icons);
if (p_selected) {
state_machine_draw->draw_line(p_from, p_to, accent, 6);
@ -1162,7 +1163,9 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co
fade_linecolor.set_hsv(1.0, fade_linecolor.get_s(), fade_linecolor.get_v());
state_machine_draw->draw_line(p_from, p_from.lerp(p_to, p_fade_ratio), fade_linecolor, 2);
}
Ref<Texture2D> icon = icons[p_mode + (p_auto_advance ? 3 : 0)];
int icon_index = p_mode + (p_auto_advance ? ICON_COUNT / 2 : 0);
ERR_FAIL_COND(icon_index >= ICON_COUNT);
Ref<Texture2D> icon = icons[icon_index];
Transform2D xf;
xf.columns[0] = (p_to - p_from).normalized();

View file

@ -65,13 +65,14 @@ void AnimationTreeEditor::edit(AnimationTree *p_tree) {
tree = p_tree;
Vector<String> path;
if (tree && tree->has_meta("_tree_edit_path")) {
path = tree->get_meta("_tree_edit_path");
} else {
current_root = ObjectID();
if (tree) {
if (tree->has_meta("_tree_edit_path")) {
path = tree->get_meta("_tree_edit_path");
} else {
current_root = ObjectID();
}
edit_path(path);
}
edit_path(path);
}
void AnimationTreeEditor::_node_removed(Node *p_node) {