From 698487baf23d4b12bd545aea68488bf43ba018c7 Mon Sep 17 00:00:00 2001 From: Alessandro Senese Date: Thu, 12 Oct 2023 08:51:48 +0100 Subject: [PATCH] trying fix offset --- .../animations/bouncing_exits/bounce_out.gd | 22 ++-- addons/anima/core/anima_node.gd | 28 ++--- addons/anima/core/tween.gd | 2 +- .../ui/AnimationPicker/AnimationPicker.gd | 22 +++- .../ui/AnimationPicker/AnimationPicker.tscn | 109 ++++++++++++++---- addons/anima/utils/node_properties.gd | 13 ++- addons/anima/utils/tween_utils.gd | 26 +++-- 7 files changed, 161 insertions(+), 61 deletions(-) diff --git a/addons/anima/animations/bouncing_exits/bounce_out.gd b/addons/anima/animations/bouncing_exits/bounce_out.gd index dfb0557f..6fad1a1f 100644 --- a/addons/anima/animations/bouncing_exits/bounce_out.gd +++ b/addons/anima/animations/bouncing_exits/bounce_out.gd @@ -1,13 +1,13 @@ var KEYFRAMES := { - 20: { - scale = Vector3(0.9, 0.9, 0.9) - }, - [50, 55]: { - opacity = 1, - scale = Vector3(1.1, 1.1, 1.1) - }, - 100: { - opacity = 0, - scale = Vector3(0.3, 0.3, 0.3) - } + 20: { + scale = Vector3(0.9, 0.9, 0.9) + }, + [50, 55]: { + opacity = 1, + scale = Vector3(1.1, 1.1, 1.1) + }, + 100: { + opacity = 0, + scale = Vector3(0.3, 0.3, 0.3) + }, } diff --git a/addons/anima/core/anima_node.gd b/addons/anima/core/anima_node.gd index f5ff5c80..0aad6533 100644 --- a/addons/anima/core/anima_node.gd +++ b/addons/anima/core/anima_node.gd @@ -225,23 +225,25 @@ func reset(): nodes_to_reset.push_front(node) for node in nodes_to_reset: - if not node.has_meta(ANIMA._INITIAL_STATE_META_KEY): - continue + if node.has_meta(ANIMA._INITIAL_STATE_META_KEY): + var meta_value: Dictionary = node.get_meta(ANIMA._INITIAL_STATE_META_KEY) - var meta_value: Dictionary = node.get_meta(ANIMA._INITIAL_STATE_META_KEY) + for key in meta_value: + var value = meta_value[key] + var initial_value = value._initial_value - for key in meta_value: - var value = meta_value[key] - var initial_value = value._initial_value + if value.has("subkey"): + node[value.property][value.key][value.subkey] = initial_value + elif value.has("key"): + node[value.property][value.key] = initial_value + elif value.has("property"): + node[value.property] = initial_value - if value.has("key"): - node[value.property][value.key] = initial_value - elif value.has("subkey"): - node[value.property][value.key][value.subkey] = initial_value - elif value.has("property"): - node[value.property] = initial_value + node.remove_meta(ANIMA._INITIAL_STATE_META_KEY) - node.remove_meta(ANIMA._INITIAL_STATE_META_KEY) + for meta_key in node.get_meta_list(): + if meta_key.begins_with("__anima_"): + node.remove_meta(meta_key) func reset_and_clear() -> void: reset() diff --git a/addons/anima/core/tween.gd b/addons/anima/core/tween.gd index 705fee8d..d879a395 100644 --- a/addons/anima/core/tween.gd +++ b/addons/anima/core/tween.gd @@ -5,7 +5,7 @@ extends Node signal animation_completed -const VISIBILITY_STRATEGY_META_KEY = "__visibility_strategy" +const VISIBILITY_STRATEGY_META_KEY = "__anima_visibility_strategy" var PROPERTIES_TO_ATTENUATE = ["rotate", "rotation", "rotation:y", "rotate:y", "y", "position:y", "x"] diff --git a/addons/anima/ui/AnimationPicker/AnimationPicker.gd b/addons/anima/ui/AnimationPicker/AnimationPicker.gd index e1e01c1a..eed0e0ae 100644 --- a/addons/anima/ui/AnimationPicker/AnimationPicker.gd +++ b/addons/anima/ui/AnimationPicker/AnimationPicker.gd @@ -5,9 +5,12 @@ const HEADER_BUTTON = preload("res://addons/anima/ui/AnimationPicker/HeaderButto const ANIMATION_BUTTON = preload("res://addons/anima/ui/AnimationPicker/AnimationButton.tscn") @onready var List: VBoxContainer = find_child("ListContainer") -@onready var DemoControl: Control = find_child("DemoControl") +@onready var LabelDemo: Control = find_child("LabelDemo") +@onready var SpriteDemo: Sprite2D = find_child("SpriteDemo") @onready var AnimationSpeed: LineEdit = find_child("AnimationSpeed") +var ActiveDemoNode: Node + signal animation_selected(name: String) signal close_pressed @@ -42,7 +45,12 @@ func _ready(): is_first_header = false - _anima = Anima.begin(DemoControl) + _anima = Anima.begin(self) + _on_item_rect_changed() + + ActiveDemoNode = SpriteDemo + ActiveDemoNode.show() +# LabelDemo.modulate.a = 0 func _create_new_header(animation: String) -> Button: var button: Button = HEADER_BUTTON.instantiate() @@ -80,7 +88,7 @@ func _on_animation_button_pressed(animation_name: String): _anima.reset_and_clear() var anima := _anima.then( - Anima.Node(DemoControl).anima_animation(animation_name, AnimationSpeed.get_text().to_float()) + Anima.Node(ActiveDemoNode).anima_animation(animation_name, AnimationSpeed.get_text().to_float()) ).play() await anima.animation_completed @@ -90,3 +98,11 @@ func _on_use_animation_pressed(): func _on_close_button_pressed(): close_pressed.emit() + +func _on_animation_speed_text_submitted(new_text): + _on_animation_button_pressed(_animation_name) + +func _on_item_rect_changed(): + if SpriteDemo: + SpriteDemo.position = LabelDemo.position + SpriteDemo.offset = (SpriteDemo.get_rect().size / 2) - (SpriteDemo.get_rect().size - LabelDemo.get_rect().size) / 2 diff --git a/addons/anima/ui/AnimationPicker/AnimationPicker.tscn b/addons/anima/ui/AnimationPicker/AnimationPicker.tscn index 7f54ae1b..1827d3c8 100644 --- a/addons/anima/ui/AnimationPicker/AnimationPicker.tscn +++ b/addons/anima/ui/AnimationPicker/AnimationPicker.tscn @@ -1,10 +1,25 @@ -[gd_scene load_steps=9 format=3 uid="uid://brxnmcufd6edq"] +[gd_scene load_steps=13 format=3 uid="uid://brxnmcufd6edq"] [ext_resource type="Script" path="res://addons/anima/ui/AnimationPicker/AnimationPicker.gd" id="1_cyqje"] [ext_resource type="PackedScene" uid="uid://hrxmgulob80r" path="res://addons/anima/ui/AnimationPicker/CTAPrimaryButton.tscn" id="2_6r4ts"] [ext_resource type="Texture2D" uid="uid://bxufb8w78e7ja" path="res://addons/anima/resources/anima-preview.png" id="2_pk6n6"] [ext_resource type="PackedScene" uid="uid://0luo7c2dwb4l" path="res://addons/anima/ui/AnimationPicker/CTASecondaryButton.tscn" id="3_qvnfb"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_4yg3m"] +content_margin_left = 12.0 +content_margin_right = 12.0 +bg_color = Color(0.164706, 0.615686, 0.560784, 1) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_0tlf5"] +content_margin_left = 12.0 +content_margin_right = 12.0 +bg_color = Color(0.913725, 0.768627, 0.415686, 1) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_5ixaa"] +content_margin_left = 12.0 +content_margin_right = 12.0 +bg_color = Color(0.14902, 0.27451, 0.32549, 1) + [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_0ikkc"] bg_color = Color(1, 1, 1, 1) @@ -14,6 +29,14 @@ corner_radius_bottom_right = 8 corner_radius_bottom_left = 8 shadow_size = 2 +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_uodjx"] +bg_color = Color(0.913725, 0.768627, 0.415686, 1) +corner_radius_top_left = 8 +corner_radius_top_right = 8 +corner_radius_bottom_right = 8 +corner_radius_bottom_left = 8 +shadow_size = 2 + [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_kcx2w"] bg_color = Color(0.8, 0.8, 0.811765, 1) @@ -30,6 +53,11 @@ script = ExtResource("1_cyqje") [node name="TabContainer" type="TabContainer" parent="."] layout_mode = 2 size_flags_vertical = 3 +theme_override_colors/font_hovered_color = Color(0, 0, 0, 1) +theme_override_font_sizes/font_size = 18 +theme_override_styles/tab_selected = SubResource("StyleBoxFlat_4yg3m") +theme_override_styles/tab_hovered = SubResource("StyleBoxFlat_0tlf5") +theme_override_styles/tab_unselected = SubResource("StyleBoxFlat_5ixaa") theme_override_styles/panel = SubResource("StyleBoxFlat_0ikkc") [node name="Animations" type="HBoxContainer" parent="TabContainer"] @@ -57,14 +85,13 @@ grow_vertical = 2 size_flags_horizontal = 3 size_flags_vertical = 3 -[node name="DemoControl" type="Label" parent="TabContainer/Animations/Control/ControlContainer"] +[node name="LabelDemo" type="Label" parent="TabContainer/Animations/Control/ControlContainer"] layout_mode = 2 theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_font_sizes/font_size = 92 text = "Anima" [node name="SpriteDemo" type="Sprite2D" parent="TabContainer/Animations/Control/ControlContainer"] -visible = false modulate = Color(0, 0, 0, 1) position = Vector2(152.5, 66) texture = ExtResource("2_pk6n6") @@ -90,13 +117,47 @@ layout_mode = 2 [node name="Label" type="Label" parent="TabContainer/Animations/Control/Panel/MarginContainer/HBoxContainer"] layout_mode = 2 -text = "Animation speed (s):" +text = "Animation duration (s):" [node name="AnimationSpeed" type="LineEdit" parent="TabContainer/Animations/Control/Panel/MarginContainer/HBoxContainer"] layout_mode = 2 -text = "0.3" +text = "0.7" alignment = 2 +[node name="ControlWarning" type="MarginContainer" parent="TabContainer/Animations/Control"] +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -101.5 +offset_top = -42.0 +offset_right = 101.5 +grow_horizontal = 2 +grow_vertical = 0 +theme_override_constants/margin_bottom = 12 + +[node name="Panel" type="PanelContainer" parent="TabContainer/Animations/Control/ControlWarning"] +layout_mode = 2 +size_flags_vertical = 8 +theme_override_styles/panel = SubResource("StyleBoxFlat_uodjx") + +[node name="MarginContainer" type="MarginContainer" parent="TabContainer/Animations/Control/ControlWarning/Panel"] +layout_mode = 2 +theme_override_constants/margin_left = 12 +theme_override_constants/margin_top = 8 +theme_override_constants/margin_right = 12 +theme_override_constants/margin_bottom = 8 + +[node name="HBoxContainer" type="HBoxContainer" parent="TabContainer/Animations/Control/ControlWarning/Panel/MarginContainer"] +layout_mode = 2 + +[node name="Label" type="Label" parent="TabContainer/Animations/Control/ControlWarning/Panel/MarginContainer/HBoxContainer"] +layout_mode = 2 +theme_override_colors/font_color = Color(0, 0, 0, 1) +text = "Skew animations do not work with a \"Control\" node" + [node name="PanelContainer" type="PanelContainer" parent="TabContainer/Animations"] custom_minimum_size = Vector2(1, 0) layout_mode = 2 @@ -105,6 +166,7 @@ theme_override_styles/panel = SubResource("StyleBoxFlat_kcx2w") [node name="VBoxContainer" type="VBoxContainer" parent="TabContainer/Animations"] custom_minimum_size = Vector2(320, 0) layout_mode = 2 +theme_override_constants/separation = 0 [node name="ScrollContainer" type="ScrollContainer" parent="TabContainer/Animations/VBoxContainer"] layout_mode = 2 @@ -114,7 +176,6 @@ theme_override_styles/panel = SubResource("StyleBoxFlat_6myxi") [node name="ListContainer" type="VBoxContainer" parent="TabContainer/Animations/VBoxContainer/ScrollContainer"] layout_mode = 2 size_flags_horizontal = 3 -size_flags_vertical = 3 theme_override_constants/separation = 0 [node name="MarginContainer" type="MarginContainer" parent="TabContainer/Animations/VBoxContainer"] @@ -150,21 +211,27 @@ layout_mode = 2 size_flags_horizontal = 3 text = "Close" +[node name="Key Frames" type="HBoxContainer" parent="TabContainer"] +visible = false +layout_mode = 2 + +[connection signal="item_rect_changed" from="." to="." method="_on_item_rect_changed"] +[connection signal="text_submitted" from="TabContainer/Animations/Control/Panel/MarginContainer/HBoxContainer/AnimationSpeed" to="." method="_on_animation_speed_text_submitted"] [connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/HeaderButton" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/HeaderButton" method="_on_toggled" flags=18] -[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33286" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33286" method="_on_toggled" flags=18] -[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33291" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33291" method="_on_toggled" flags=18] -[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33296" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33296" method="_on_toggled" flags=18] -[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33302" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33302" method="_on_toggled" flags=18] -[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33308" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33308" method="_on_toggled" flags=18] -[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33323" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33323" method="_on_toggled" flags=18] -[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33337" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33337" method="_on_toggled" flags=18] -[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33342" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33342" method="_on_toggled" flags=18] -[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33348" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33348" method="_on_toggled" flags=18] -[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33354" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33354" method="_on_toggled" flags=18] -[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33359" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33359" method="_on_toggled" flags=18] -[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33364" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33364" method="_on_toggled" flags=18] -[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33369" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33369" method="_on_toggled" flags=18] -[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33371" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33371" method="_on_toggled" flags=18] -[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33381" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@33381" method="_on_toggled" flags=18] +[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22194" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22194" method="_on_toggled" flags=18] +[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22199" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22199" method="_on_toggled" flags=18] +[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22204" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22204" method="_on_toggled" flags=18] +[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22210" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22210" method="_on_toggled" flags=18] +[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22216" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22216" method="_on_toggled" flags=18] +[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22231" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22231" method="_on_toggled" flags=18] +[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22245" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22245" method="_on_toggled" flags=18] +[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22250" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22250" method="_on_toggled" flags=18] +[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22256" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22256" method="_on_toggled" flags=18] +[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22262" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22262" method="_on_toggled" flags=18] +[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22267" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22267" method="_on_toggled" flags=18] +[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22272" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22272" method="_on_toggled" flags=18] +[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22277" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22277" method="_on_toggled" flags=18] +[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22279" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22279" method="_on_toggled" flags=18] +[connection signal="toggled" from="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22289" to="TabContainer/Animations/VBoxContainer/ScrollContainer/ListContainer/@Button@22289" method="_on_toggled" flags=18] [connection signal="pressed" from="TabContainer/Animations/VBoxContainer/MarginContainer/HBoxContainer/UseAnimation" to="." method="_on_use_animation_pressed"] [connection signal="pressed" from="TabContainer/Animations/VBoxContainer/MarginContainer/HBoxContainer/CloseButton" to="." method="_on_close_button_pressed"] diff --git a/addons/anima/utils/node_properties.gd b/addons/anima/utils/node_properties.gd index 052747b4..a4a75256 100644 --- a/addons/anima/utils/node_properties.gd +++ b/addons/anima/utils/node_properties.gd @@ -10,6 +10,8 @@ # class_name AnimaNodesProperties +const ANIMA_PIVOT_APPLIED_META = "__anima_pivot_applied" + static func get_position(node: Node): if node is Control or node is Window: return node.position @@ -41,8 +43,10 @@ static func get_rotation(node: Node): static func set_2D_pivot(node: Node, pivot: int) -> void: var size: Vector2 = get_size(node) - if node is Window: - pass + if node is Window or node.has_meta(ANIMA_PIVOT_APPLIED_META): + return + + node.set_meta(ANIMA_PIVOT_APPLIED_META, true) match pivot: ANIMA.PIVOT.TOP_CENTER: @@ -64,6 +68,11 @@ static func set_2D_pivot(node: Node, pivot: int) -> void: ANIMA.PIVOT.CENTER: if node is Control: node.set_pivot_offset(size / 2) + else: + var position = node.position + + node.offset = Vector2(size.x / 2, size.y / 2) + node.position = position - node.offset ANIMA.PIVOT.BOTTOM_CENTER: if node is Control: node.set_pivot_offset(Vector2(size.x / 2, size.y / 2)) diff --git a/addons/anima/utils/tween_utils.gd b/addons/anima/utils/tween_utils.gd index 31163027..8b18b250 100644 --- a/addons/anima/utils/tween_utils.gd +++ b/addons/anima/utils/tween_utils.gd @@ -1,5 +1,13 @@ class_name AnimaTweenUtils +static func get_initial_and_relative_meta_keys(property: String) -> Dictionary: + var property_name_for_meta = property.replace(":", "_") + + return { + initial = "__anima_initial_relative_value_" + property_name_for_meta, + relative = "__anima_last_relative_value_" + property_name_for_meta, + } + static func calculate_from_and_to(animation_data: Dictionary) -> Dictionary: var node: Node = animation_data.node var from @@ -14,11 +22,9 @@ static func calculate_from_and_to(animation_data: Dictionary) -> Dictionary: animation_data.erase('to') # - # Godot4 doesn't like a meta_key containing the symbol : + # Godot4 doesn't like a meta_keys.initial containing the symbol : # - var property_name_for_meta = animation_data.property.replace(":", "_") - var meta_key = "_initial_relative_value_" + property_name_for_meta - var meta_key_last_relative_position = "_last_relative_value_" + property_name_for_meta + var meta_keys = get_initial_and_relative_meta_keys(animation_data.property) var calculated_from = null @@ -28,13 +34,13 @@ static func calculate_from_and_to(animation_data: Dictionary) -> Dictionary: from = current_value if relative: - if not node.has_meta(meta_key_last_relative_position): - node.set_meta(meta_key, current_value) + if not node.has_meta(meta_keys.relative): + node.set_meta(meta_keys.initial, current_value) if calculated_from: from += calculated_from else: - var previous_end_position = node.get_meta(meta_key_last_relative_position) + var previous_end_position = node.get_meta(meta_keys.relative) from = previous_end_position elif calculated_from != null: @@ -49,8 +55,8 @@ static func calculate_from_and_to(animation_data: Dictionary) -> Dictionary: # Because keyframes-translations are relative to the node initial position, # while anima_position_relative are relative to the previous "position" # - if relative and animation_data.has("_is_translation") and node.has_meta(meta_key): - start = node.get_meta(meta_key) + if relative and animation_data.has("_is_translation") and node.has_meta(meta_keys.initial): + start = node.get_meta(meta_keys.initial) to = calculate_dynamic_value(animation_data.to, animation_data) to = _maybe_calculate_relative_value(relative, to, start) @@ -58,7 +64,7 @@ static func calculate_from_and_to(animation_data: Dictionary) -> Dictionary: to = current_value if relative: - node.set_meta(meta_key_last_relative_position, to) + node.set_meta(meta_keys.relative, to) var pivot = animation_data.pivot if animation_data.has("pivot") else ANIMA.PIVOT.CENTER if not node is Node3D and not node is CanvasModulate: