|
@@ -540,6 +540,11 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
|
|
|
List<StringName> sname;
|
|
|
player->get_animation_list(&sname);
|
|
|
|
|
|
+ Ref<Animation> reset_anim;
|
|
|
+ bool has_reset_anim = player->has_animation("RESET");
|
|
|
+ if (has_reset_anim) {
|
|
|
+ reset_anim = player->get_animation("RESET");
|
|
|
+ }
|
|
|
for (const StringName &E : sname) {
|
|
|
Ref<Animation> anim = player->get_animation(E);
|
|
|
for (int i = 0; i < anim->get_track_count(); i++) {
|
|
@@ -593,6 +598,12 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
|
|
|
|
|
|
track = track_value;
|
|
|
|
|
|
+ if (has_reset_anim) {
|
|
|
+ int rt = reset_anim->find_track(path, track_type);
|
|
|
+ if (rt >= 0 && reset_anim->track_get_key_count(rt) > 0) {
|
|
|
+ track_value->init_value = reset_anim->track_get_key_value(rt, 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
} break;
|
|
|
case Animation::TYPE_POSITION_3D:
|
|
|
case Animation::TYPE_ROTATION_3D:
|
|
@@ -645,6 +656,25 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (has_reset_anim) {
|
|
|
+ int rt = reset_anim->find_track(path, track_type);
|
|
|
+ if (rt >= 0 && reset_anim->track_get_key_count(rt) > 0) {
|
|
|
+ switch (track_type) {
|
|
|
+ case Animation::TYPE_POSITION_3D: {
|
|
|
+ track_xform->init_loc = reset_anim->track_get_key_value(rt, 0);
|
|
|
+ } break;
|
|
|
+ case Animation::TYPE_ROTATION_3D: {
|
|
|
+ track_xform->ref_rot = reset_anim->track_get_key_value(rt, 0);
|
|
|
+ track_xform->init_rot = track_xform->ref_rot.log();
|
|
|
+ } break;
|
|
|
+ case Animation::TYPE_SCALE_3D: {
|
|
|
+ track_xform->init_scale = reset_anim->track_get_key_value(rt, 0);
|
|
|
+ } break;
|
|
|
+ default: {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
#endif // _3D_DISABLED
|
|
|
} break;
|
|
|
case Animation::TYPE_BLEND_SHAPE: {
|
|
@@ -675,6 +705,13 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
|
|
|
track_bshape->object = mesh_3d;
|
|
|
track_bshape->object_id = mesh_3d->get_instance_id();
|
|
|
track = track_bshape;
|
|
|
+
|
|
|
+ if (has_reset_anim) {
|
|
|
+ int rt = reset_anim->find_track(path, track_type);
|
|
|
+ if (rt >= 0 && reset_anim->track_get_key_count(rt) > 0) {
|
|
|
+ track_bshape->init_value = reset_anim->track_get_key_value(rt, 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
#endif
|
|
|
} break;
|
|
|
case Animation::TYPE_METHOD: {
|
|
@@ -704,6 +741,13 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
|
|
|
track_bezier->object_id = track_bezier->object->get_instance_id();
|
|
|
|
|
|
track = track_bezier;
|
|
|
+
|
|
|
+ if (has_reset_anim) {
|
|
|
+ int rt = reset_anim->find_track(path, track_type);
|
|
|
+ if (rt >= 0 && reset_anim->track_get_key_count(rt) > 0) {
|
|
|
+ track_bezier->init_value = reset_anim->track_get_key_value(rt, 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
} break;
|
|
|
case Animation::TYPE_AUDIO: {
|
|
|
TrackCacheAudio *track_audio = memnew(TrackCacheAudio);
|
|
@@ -1244,7 +1288,7 @@ void AnimationTree::_process_graph(double p_delta) {
|
|
|
|
|
|
if (t->process_pass != process_pass) {
|
|
|
t->process_pass = process_pass;
|
|
|
- t->value = 0;
|
|
|
+ t->value = t->init_value;
|
|
|
}
|
|
|
|
|
|
float value;
|
|
@@ -1256,7 +1300,7 @@ void AnimationTree::_process_graph(double p_delta) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- t->value += value * blend;
|
|
|
+ t->value += (value - t->init_value) * blend;
|
|
|
#endif // _3D_DISABLED
|
|
|
} break;
|
|
|
case Animation::TYPE_VALUE: {
|
|
@@ -1274,10 +1318,15 @@ void AnimationTree::_process_graph(double p_delta) {
|
|
|
|
|
|
if (t->process_pass != process_pass) {
|
|
|
t->process_pass = process_pass;
|
|
|
- t->value = value;
|
|
|
- t->value.zero();
|
|
|
+ if (!t->init_value) {
|
|
|
+ t->init_value = value;
|
|
|
+ t->init_value.zero();
|
|
|
+ } else {
|
|
|
+ t->value = t->init_value;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ Variant::sub(value, t->init_value, value);
|
|
|
Variant::blend(t->value, value, blend, t->value);
|
|
|
} else {
|
|
|
if (blend < CMP_EPSILON) {
|
|
@@ -1321,10 +1370,10 @@ void AnimationTree::_process_graph(double p_delta) {
|
|
|
|
|
|
if (t->process_pass != process_pass) {
|
|
|
t->process_pass = process_pass;
|
|
|
- t->value = 0;
|
|
|
+ t->value = t->init_value;
|
|
|
}
|
|
|
|
|
|
- t->value += bezier * blend;
|
|
|
+ t->value += (bezier - t->init_value) * blend;
|
|
|
} break;
|
|
|
case Animation::TYPE_AUDIO: {
|
|
|
if (blend < CMP_EPSILON) {
|