Skip to content

Commit

Permalink
Merge pull request #43115 from RandomShaper/reset_track
Browse files Browse the repository at this point in the history
Add animation reset track feature
  • Loading branch information
akien-mga authored Dec 20, 2020
2 parents e9d12f9 + b7367ac commit bc2ac0b
Show file tree
Hide file tree
Showing 13 changed files with 310 additions and 90 deletions.
25 changes: 13 additions & 12 deletions core/object/undo_redo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "undo_redo.h"

#include "core/io/resource.h"
#include "core/os/os.h"

void UndoRedo::_discard_redo() {
Expand Down Expand Up @@ -104,8 +105,8 @@ void UndoRedo::add_do_method(Object *p_object, const StringName &p_method, VARIA
ERR_FAIL_COND((current_action + 1) >= actions.size());
Operation do_op;
do_op.object = p_object->get_instance_id();
if (Object::cast_to<Resource>(p_object)) {
do_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
if (Object::cast_to<Reference>(p_object)) {
do_op.ref = Ref<Reference>(Object::cast_to<Reference>(p_object));
}

do_op.type = Operation::TYPE_METHOD;
Expand All @@ -130,8 +131,8 @@ void UndoRedo::add_undo_method(Object *p_object, const StringName &p_method, VAR

Operation undo_op;
undo_op.object = p_object->get_instance_id();
if (Object::cast_to<Resource>(p_object)) {
undo_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
if (Object::cast_to<Reference>(p_object)) {
undo_op.ref = Ref<Reference>(Object::cast_to<Reference>(p_object));
}

undo_op.type = Operation::TYPE_METHOD;
Expand All @@ -149,8 +150,8 @@ void UndoRedo::add_do_property(Object *p_object, const StringName &p_property, c
ERR_FAIL_COND((current_action + 1) >= actions.size());
Operation do_op;
do_op.object = p_object->get_instance_id();
if (Object::cast_to<Resource>(p_object)) {
do_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
if (Object::cast_to<Reference>(p_object)) {
do_op.ref = Ref<Reference>(Object::cast_to<Reference>(p_object));
}

do_op.type = Operation::TYPE_PROPERTY;
Expand All @@ -171,8 +172,8 @@ void UndoRedo::add_undo_property(Object *p_object, const StringName &p_property,

Operation undo_op;
undo_op.object = p_object->get_instance_id();
if (Object::cast_to<Resource>(p_object)) {
undo_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
if (Object::cast_to<Reference>(p_object)) {
undo_op.ref = Ref<Reference>(Object::cast_to<Reference>(p_object));
}

undo_op.type = Operation::TYPE_PROPERTY;
Expand All @@ -187,8 +188,8 @@ void UndoRedo::add_do_reference(Object *p_object) {
ERR_FAIL_COND((current_action + 1) >= actions.size());
Operation do_op;
do_op.object = p_object->get_instance_id();
if (Object::cast_to<Resource>(p_object)) {
do_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
if (Object::cast_to<Reference>(p_object)) {
do_op.ref = Ref<Reference>(Object::cast_to<Reference>(p_object));
}

do_op.type = Operation::TYPE_REFERENCE;
Expand All @@ -207,8 +208,8 @@ void UndoRedo::add_undo_reference(Object *p_object) {

Operation undo_op;
undo_op.object = p_object->get_instance_id();
if (Object::cast_to<Resource>(p_object)) {
undo_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
if (Object::cast_to<Reference>(p_object)) {
undo_op.ref = Ref<Reference>(Object::cast_to<Reference>(p_object));
}

undo_op.type = Operation::TYPE_REFERENCE;
Expand Down
4 changes: 2 additions & 2 deletions core/object/undo_redo.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
#ifndef UNDO_REDO_H
#define UNDO_REDO_H

#include "core/io/resource.h"
#include "core/object/class_db.h"
#include "core/object/reference.h"

class UndoRedo : public Object {
GDCLASS(UndoRedo, Object);
Expand Down Expand Up @@ -61,7 +61,7 @@ class UndoRedo : public Object {
};

Type type;
Ref<Resource> resref;
Ref<Reference> ref;
ObjectID object;
StringName name;
Variant args[VARIANT_ARG_MAX];
Expand Down
4 changes: 4 additions & 0 deletions doc/classes/AnimationPlayer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@
<member name="playback_speed" type="float" setter="set_speed_scale" getter="get_speed_scale" default="1.0">
The speed scaling ratio. For instance, if this value is 1, then the animation plays at normal speed. If it's 0.5, then it plays at half speed. If it's 2, then it plays at double speed.
</member>
<member name="reset_on_save" type="bool" setter="set_reset_on_save_enabled" getter="is_reset_on_save_enabled" default="true">
This is used by the editor. If set to [code]true[/code], the scene will be saved with the effects of the reset animation applied (as if it had been seeked to time 0), then reverted after saving.
In other words, the saved scene file will contain the "default pose", as defined by the reset animation, if any, with the editor keeping the values that the nodes had before saving.
</member>
<member name="root_node" type="NodePath" setter="set_root" getter="get_root" default="NodePath(&quot;..&quot;)">
The node from which node path references will travel.
</member>
Expand Down
Loading

0 comments on commit bc2ac0b

Please sign in to comment.