From 91d2485c526b98e368d78bb132a906ac11c899a1 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 10 Oct 2014 15:04:33 +0200 Subject: Fix T42163: Outliner: recursive visibility toggle: autokeyframe only works for ancestor, not children Ancestor's autokeyframing is handled through UI/buttons code, but children completely skipped this, so we have to do it explicitely here... --- .../blender/editors/space_outliner/outliner_draw.c | 38 +++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 7eb90953df4..e033f781f62 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -29,6 +29,7 @@ * \ingroup spoutliner */ +#include "DNA_anim_types.h" #include "DNA_armature_types.h" #include "DNA_group_types.h" #include "DNA_lamp_types.h" @@ -46,6 +47,7 @@ #include "BKE_context.h" #include "BKE_deform.h" #include "BKE_depsgraph.h" +#include "BKE_fcurve.h" #include "BKE_global.h" #include "BKE_library.h" #include "BKE_main.h" @@ -55,6 +57,7 @@ #include "BKE_object.h" #include "ED_armature.h" +#include "ED_keyframing.h" #include "ED_object.h" #include "ED_screen.h" @@ -168,7 +171,7 @@ static void restrictbutton_recursive_bone(bContext *C, bArmature *arm, Bone *bon } static void restrictbutton_recursive_child(bContext *C, Scene *scene, Object *ob_parent, char flag, - bool state, bool deselect) + bool state, bool deselect, const char *rnapropname) { Main *bmain = CTX_data_main(C); Object *ob; @@ -183,6 +186,33 @@ static void restrictbutton_recursive_child(bContext *C, Scene *scene, Object *ob else { ob->restrictflag &= ~flag; } + + if (rnapropname) { + PointerRNA ptr; + PropertyRNA *prop; + ID *id; + bAction *action; + FCurve *fcu; + bool driven; + + RNA_id_pointer_create(&ob->id, &ptr); + prop = RNA_struct_find_property(&ptr, rnapropname); + fcu = rna_get_fcurve_context_ui(C, &ptr, prop, 0, &action, &driven); + + if (fcu && !driven) { + id = ptr.id.data; + if (autokeyframe_cfra_can_key(scene, id)) { + ReportList *reports = CTX_wm_reports(C); + short flag = ANIM_get_keyframing_flags(scene, 1); + + fcu->flag &= ~FCURVE_SELECTED; + insert_keyframe(reports, id, action, ((fcu->grp) ? (fcu->grp->name) : (NULL)), + fcu->rna_path, fcu->array_index, CFRA, flag); + /* Assuming this is not necessary here, since 'ancestor' object button will do it anyway. */ + /* WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); */ + } + } + } } } } @@ -203,7 +233,7 @@ static void restrictbutton_view_cb(bContext *C, void *poin, void *poin2) if (CTX_wm_window(C)->eventstate->ctrl) { restrictbutton_recursive_child(C, scene, ob, OB_RESTRICT_VIEW, - (ob->restrictflag & OB_RESTRICT_VIEW) != 0, true); + (ob->restrictflag & OB_RESTRICT_VIEW) != 0, true, "hide"); } WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); @@ -226,7 +256,7 @@ static void restrictbutton_sel_cb(bContext *C, void *poin, void *poin2) if (CTX_wm_window(C)->eventstate->ctrl) { restrictbutton_recursive_child(C, scene, ob, OB_RESTRICT_SELECT, - (ob->restrictflag & OB_RESTRICT_SELECT) != 0, true); + (ob->restrictflag & OB_RESTRICT_SELECT) != 0, true, NULL); } WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); @@ -239,7 +269,7 @@ static void restrictbutton_rend_cb(bContext *C, void *poin, void *poin2) if (CTX_wm_window(C)->eventstate->ctrl) { restrictbutton_recursive_child(C, (Scene *)poin, ob, OB_RESTRICT_RENDER, - (ob->restrictflag & OB_RESTRICT_RENDER) != 0, false); + (ob->restrictflag & OB_RESTRICT_RENDER) != 0, false, "hide_render"); } WM_event_add_notifier(C, NC_SCENE | ND_OB_RENDER, poin); -- cgit v1.2.3