mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-10 21:09:38 +01:00
Create reset tracks with the right update mode
(cherry picked from commit b46a2aaa4bb4ed89be2e8fb8cdde9258f72172c8)
This commit is contained in:
parent
fc7038b073
commit
1e7c186b9a
@ -3579,7 +3579,7 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationTrackEditor::_insert_delay(bool p_create_reset, bool p_create_beziers) {
|
void AnimationTrackEditor::_insert_delay(bool p_reset_wanted, bool p_create_beziers) {
|
||||||
if (insert_query) {
|
if (insert_query) {
|
||||||
//discard since it's entered into query mode
|
//discard since it's entered into query mode
|
||||||
insert_queue = false;
|
insert_queue = false;
|
||||||
@ -3589,7 +3589,7 @@ void AnimationTrackEditor::_insert_delay(bool p_create_reset, bool p_create_bezi
|
|||||||
undo_redo->create_action(TTR("Anim Insert"));
|
undo_redo->create_action(TTR("Anim Insert"));
|
||||||
|
|
||||||
Ref<Animation> reset_anim;
|
Ref<Animation> reset_anim;
|
||||||
if (p_create_reset) {
|
if (p_reset_wanted) {
|
||||||
reset_anim = _create_and_get_reset_animation();
|
reset_anim = _create_and_get_reset_animation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3599,7 +3599,7 @@ void AnimationTrackEditor::_insert_delay(bool p_create_reset, bool p_create_bezi
|
|||||||
if (insert_data.front()->get().advance) {
|
if (insert_data.front()->get().advance) {
|
||||||
advance = true;
|
advance = true;
|
||||||
}
|
}
|
||||||
next_tracks = _confirm_insert(insert_data.front()->get(), next_tracks, p_create_reset, reset_anim, p_create_beziers);
|
next_tracks = _confirm_insert(insert_data.front()->get(), next_tracks, p_reset_wanted, reset_anim, p_create_beziers);
|
||||||
insert_data.pop_front();
|
insert_data.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4062,9 +4062,42 @@ static Vector<String> _get_bezier_subindices_for_type(Variant::Type p_type, bool
|
|||||||
return subindices;
|
return subindices;
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertData p_id, TrackIndices p_next_tracks, bool p_create_reset, Ref<Animation> p_reset_anim, bool p_create_beziers) {
|
AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertData p_id, TrackIndices p_next_tracks, bool p_reset_wanted, Ref<Animation> p_reset_anim, bool p_create_beziers) {
|
||||||
bool created = false;
|
bool created = false;
|
||||||
if (p_id.track_idx < 0) {
|
|
||||||
|
bool create_normal_track = p_id.track_idx < 0;
|
||||||
|
bool create_reset_track = p_reset_wanted && track_type_is_resettable(p_id.type);
|
||||||
|
|
||||||
|
Animation::UpdateMode update_mode = Animation::UPDATE_DISCRETE;
|
||||||
|
if (create_normal_track || create_reset_track) {
|
||||||
|
if (p_id.type == Animation::TYPE_VALUE || p_id.type == Animation::TYPE_BEZIER) {
|
||||||
|
// Hack.
|
||||||
|
NodePath np;
|
||||||
|
animation->add_track(p_id.type);
|
||||||
|
animation->track_set_path(animation->get_track_count() - 1, p_id.path);
|
||||||
|
PropertyInfo h = _find_hint_for_track(animation->get_track_count() - 1, np);
|
||||||
|
animation->remove_track(animation->get_track_count() - 1); // Hack.
|
||||||
|
|
||||||
|
if (h.type == Variant::REAL ||
|
||||||
|
h.type == Variant::VECTOR2 ||
|
||||||
|
h.type == Variant::RECT2 ||
|
||||||
|
h.type == Variant::VECTOR3 ||
|
||||||
|
h.type == Variant::AABB ||
|
||||||
|
h.type == Variant::QUATERNION ||
|
||||||
|
h.type == Variant::COLOR ||
|
||||||
|
h.type == Variant::PLANE ||
|
||||||
|
h.type == Variant::TRANSFORM2D ||
|
||||||
|
h.type == Variant::TRANSFORM) {
|
||||||
|
update_mode = Animation::UPDATE_CONTINUOUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (h.usage & PROPERTY_USAGE_ANIMATE_AS_TRIGGER) {
|
||||||
|
update_mode = Animation::UPDATE_TRIGGER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (create_normal_track) {
|
||||||
if (p_create_beziers) {
|
if (p_create_beziers) {
|
||||||
bool valid;
|
bool valid;
|
||||||
Vector<String> subindices = _get_bezier_subindices_for_type(p_id.value.get_type(), &valid);
|
Vector<String> subindices = _get_bezier_subindices_for_type(p_id.value.get_type(), &valid);
|
||||||
@ -4074,7 +4107,7 @@ AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertD
|
|||||||
id.type = Animation::TYPE_BEZIER;
|
id.type = Animation::TYPE_BEZIER;
|
||||||
id.value = p_id.value.get(subindices[i].substr(1, subindices[i].length()));
|
id.value = p_id.value.get(subindices[i].substr(1, subindices[i].length()));
|
||||||
id.path = String(p_id.path) + subindices[i];
|
id.path = String(p_id.path) + subindices[i];
|
||||||
p_next_tracks = _confirm_insert(id, p_next_tracks, p_create_reset, p_reset_anim, false);
|
p_next_tracks = _confirm_insert(id, p_next_tracks, p_reset_wanted, p_reset_anim, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return p_next_tracks;
|
return p_next_tracks;
|
||||||
@ -4082,37 +4115,6 @@ AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertD
|
|||||||
}
|
}
|
||||||
created = true;
|
created = true;
|
||||||
undo_redo->create_action(TTR("Anim Insert Track & Key"));
|
undo_redo->create_action(TTR("Anim Insert Track & Key"));
|
||||||
Animation::UpdateMode update_mode = Animation::UPDATE_DISCRETE;
|
|
||||||
|
|
||||||
if (p_id.type == Animation::TYPE_VALUE || p_id.type == Animation::TYPE_BEZIER) {
|
|
||||||
// Wants a new track.
|
|
||||||
|
|
||||||
{
|
|
||||||
// Hack.
|
|
||||||
NodePath np;
|
|
||||||
animation->add_track(p_id.type);
|
|
||||||
animation->track_set_path(animation->get_track_count() - 1, p_id.path);
|
|
||||||
PropertyInfo h = _find_hint_for_track(animation->get_track_count() - 1, np);
|
|
||||||
animation->remove_track(animation->get_track_count() - 1); //hack
|
|
||||||
|
|
||||||
if (h.type == Variant::REAL ||
|
|
||||||
h.type == Variant::VECTOR2 ||
|
|
||||||
h.type == Variant::RECT2 ||
|
|
||||||
h.type == Variant::VECTOR3 ||
|
|
||||||
h.type == Variant::AABB ||
|
|
||||||
h.type == Variant::QUATERNION ||
|
|
||||||
h.type == Variant::COLOR ||
|
|
||||||
h.type == Variant::PLANE ||
|
|
||||||
h.type == Variant::TRANSFORM2D ||
|
|
||||||
h.type == Variant::TRANSFORM) {
|
|
||||||
update_mode = Animation::UPDATE_CONTINUOUS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (h.usage & PROPERTY_USAGE_ANIMATE_AS_TRIGGER) {
|
|
||||||
update_mode = Animation::UPDATE_TRIGGER;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p_id.track_idx = p_next_tracks.normal;
|
p_id.track_idx = p_next_tracks.normal;
|
||||||
|
|
||||||
@ -4175,8 +4177,7 @@ AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_create_reset && track_type_is_resettable(p_id.type)) {
|
if (create_reset_track) {
|
||||||
bool create_reset_track = true;
|
|
||||||
Animation *reset_anim = p_reset_anim.ptr();
|
Animation *reset_anim = p_reset_anim.ptr();
|
||||||
for (int i = 0; i < reset_anim->get_track_count(); i++) {
|
for (int i = 0; i < reset_anim->get_track_count(); i++) {
|
||||||
if (reset_anim->track_get_path(i) == p_id.path) {
|
if (reset_anim->track_get_path(i) == p_id.path) {
|
||||||
@ -4187,6 +4188,9 @@ AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertD
|
|||||||
if (create_reset_track) {
|
if (create_reset_track) {
|
||||||
undo_redo->add_do_method(reset_anim, "add_track", p_id.type);
|
undo_redo->add_do_method(reset_anim, "add_track", p_id.type);
|
||||||
undo_redo->add_do_method(reset_anim, "track_set_path", p_next_tracks.reset, p_id.path);
|
undo_redo->add_do_method(reset_anim, "track_set_path", p_next_tracks.reset, p_id.path);
|
||||||
|
if (p_id.type == Animation::TYPE_VALUE) {
|
||||||
|
undo_redo->add_do_method(reset_anim, "value_track_set_update_mode", p_next_tracks.reset, update_mode);
|
||||||
|
}
|
||||||
undo_redo->add_do_method(reset_anim, "track_insert_key", p_next_tracks.reset, 0.0f, value);
|
undo_redo->add_do_method(reset_anim, "track_insert_key", p_next_tracks.reset, 0.0f, value);
|
||||||
undo_redo->add_undo_method(reset_anim, "remove_track", reset_anim->get_track_count());
|
undo_redo->add_undo_method(reset_anim, "remove_track", reset_anim->get_track_count());
|
||||||
p_next_tracks.reset++;
|
p_next_tracks.reset++;
|
||||||
|
@ -401,8 +401,8 @@ class AnimationTrackEditor : public VBoxContainer {
|
|||||||
reset = p_reset_anim ? p_reset_anim->get_track_count() : 0;
|
reset = p_reset_anim ? p_reset_anim->get_track_count() : 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
TrackIndices _confirm_insert(InsertData p_id, TrackIndices p_next_tracks, bool p_create_reset, Ref<Animation> p_reset_anim, bool p_create_beziers);
|
TrackIndices _confirm_insert(InsertData p_id, TrackIndices p_next_tracks, bool p_reset_wanted, Ref<Animation> p_reset_anim, bool p_create_beziers);
|
||||||
void _insert_delay(bool p_create_reset, bool p_create_beziers);
|
void _insert_delay(bool p_reset_wanted, bool p_create_beziers);
|
||||||
|
|
||||||
void _root_removed();
|
void _root_removed();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user