Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix onion skinning #29109

Merged
merged 3 commits into from May 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion editor/plugins/animation_player_editor_plugin.cpp
Expand Up @@ -1431,6 +1431,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
new_state["show_rulers"] = false;
new_state["show_guides"] = false;
new_state["show_helpers"] = false;
new_state["show_zoom_control"] = false;
// TODO: Save/restore only affected entries
CanvasItemEditor::get_singleton()->set_state(new_state);
}
Expand Down Expand Up @@ -1483,7 +1484,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
if (valid) {
player->seek(pos, true);
get_tree()->flush_transform_notifications(); // Needed for transforms of Spatials
values_backup.update_skeletons(); // Needed for Skeletons
values_backup.update_skeletons(); // Needed for Skeletons (2D & 3D)

VS::get_singleton()->viewport_set_active(onion.captures[cidx], true);
VS::get_singleton()->viewport_set_parent_viewport(root_vp, onion.captures[cidx]);
Expand Down
14 changes: 13 additions & 1 deletion editor/plugins/canvas_item_editor_plugin.cpp
Expand Up @@ -4009,6 +4009,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
show_rulers = !show_rulers;
int idx = view_menu->get_popup()->get_item_index(SHOW_RULERS);
view_menu->get_popup()->set_item_checked(idx, show_rulers);
_update_scrollbars();
viewport->update();
} break;
case SHOW_GUIDES: {
Expand Down Expand Up @@ -4514,6 +4515,7 @@ Dictionary CanvasItemEditor::get_state() const {
state["show_rulers"] = show_rulers;
state["show_guides"] = show_guides;
state["show_helpers"] = show_helpers;
state["show_zoom_control"] = zoom_hb->is_visible();
state["show_edit_locks"] = show_edit_locks;
state["snap_rotation"] = snap_rotation;
state["snap_relative"] = snap_relative;
Expand All @@ -4524,6 +4526,7 @@ Dictionary CanvasItemEditor::get_state() const {

void CanvasItemEditor::set_state(const Dictionary &p_state) {

bool update_scrollbars = false;
Dictionary state = p_state;
if (state.has("zoom")) {
zoom = p_state["zoom"];
Expand All @@ -4532,7 +4535,7 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) {
if (state.has("ofs")) {
view_offset = p_state["ofs"];
previous_update_view_offset = view_offset;
_update_scrollbars();
update_scrollbars = true;
}

if (state.has("grid_offset")) {
Expand Down Expand Up @@ -4620,6 +4623,7 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) {
show_rulers = state["show_rulers"];
int idx = view_menu->get_popup()->get_item_index(SHOW_RULERS);
view_menu->get_popup()->set_item_checked(idx, show_rulers);
update_scrollbars = true;
}

if (state.has("show_guides")) {
Expand All @@ -4640,6 +4644,11 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) {
view_menu->get_popup()->set_item_checked(idx, show_edit_locks);
}

if (state.has("show_zoom_control")) {
// This one is not user-controllable, but instrumentable
zoom_hb->set_visible(state["show_zoom_control"]);
}

if (state.has("snap_rotation")) {
snap_rotation = state["snap_rotation"];
int idx = snap_config_menu->get_popup()->get_item_index(SNAP_USE_ROTATION);
Expand All @@ -4664,6 +4673,9 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) {
skeleton_menu->get_popup()->set_item_checked(idx, skeleton_show_bones);
}

if (update_scrollbars) {
_update_scrollbars();
}
viewport->update();
}

Expand Down
6 changes: 6 additions & 0 deletions scene/2d/skeleton_2d.h
Expand Up @@ -39,6 +39,9 @@ class Bone2D : public Node2D {
GDCLASS(Bone2D, Node2D)

friend class Skeleton2D;
#ifdef TOOLS_ENABLED
friend class AnimatedValuesBackup;
#endif

Bone2D *parent_bone;
Skeleton2D *skeleton;
Expand Down Expand Up @@ -71,6 +74,9 @@ class Skeleton2D : public Node2D {
GDCLASS(Skeleton2D, Node2D);

friend class Bone2D;
#ifdef TOOLS_ENABLED
friend class AnimatedValuesBackup;
#endif

struct Bone {
bool operator<(const Bone &p_bone) const {
Expand Down
8 changes: 8 additions & 0 deletions scene/animation/animation_player.cpp
Expand Up @@ -37,12 +37,20 @@

#ifdef TOOLS_ENABLED
#include "editor/editor_settings.h"
#include "scene/2d/skeleton_2d.h"

void AnimatedValuesBackup::update_skeletons() {

for (int i = 0; i < entries.size(); i++) {
if (entries[i].bone_idx != -1) {
// 3D bone
Object::cast_to<Skeleton>(entries[i].object)->notification(Skeleton::NOTIFICATION_UPDATE_SKELETON);
} else {
Bone2D *bone = Object::cast_to<Bone2D>(entries[i].object);
if (bone && bone->skeleton) {
// 2D bone
bone->skeleton->_update_transform();
}
}
}
}
Expand Down