diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2015-09-24 18:24:20 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2015-09-24 18:24:20 +0300 |
commit | 27b3ea622f8bd313a8e2827dfec752bf2125566c (patch) | |
tree | f212e49d224ce8e1cfc3b17a64ae524711494391 /source/blender/editors/armature/pose_lib.c | |
parent | 372dff8d1dc7e24d4b2cd37de245588ecfce8bfa (diff) | |
parent | de80e687689032cb85179a1f7e89750573631d5d (diff) |
Merge remote-tracking branch 'origin/master' into cycles_camera_nodescycles_camera_nodes
Note: the branch currently crashes in blender_camera_nodes.cpp:
BL::NodeTree b_ntree = b_data.node_groups[nodes_tree_name];
The crash was introduced in:
cb7cf523e5c000609f32a382e2c0fcc57f635a42
Conflicts:
intern/cycles/SConscript
intern/cycles/blender/addon/__init__.py
intern/cycles/blender/addon/properties.py
intern/cycles/blender/blender_camera.cpp
intern/cycles/kernel/kernel_types.h
intern/cycles/kernel/svm/svm.h
intern/cycles/kernel/svm/svm_types.h
intern/cycles/render/camera.cpp
intern/cycles/render/camera.h
Diffstat (limited to 'source/blender/editors/armature/pose_lib.c')
-rw-r--r-- | source/blender/editors/armature/pose_lib.c | 56 |
1 files changed, 42 insertions, 14 deletions
diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c index 0609fcc29e8..a984e5d1ccd 100644 --- a/source/blender/editors/armature/pose_lib.c +++ b/source/blender/editors/armature/pose_lib.c @@ -35,7 +35,7 @@ #include "BLI_blenlib.h" #include "BLI_dlrbTree.h" -#include "BLF_translation.h" +#include "BLT_translation.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" @@ -177,6 +177,15 @@ static int has_poselib_pose_data_poll(bContext *C) return (ob && ob->poselib); } +/* Poll callback for operators that require existing PoseLib data (with poses) + * as they need to do some editing work on those poses (i.e. not on lib-linked actions) + */ +static int has_poselib_pose_data_for_editing_poll(bContext *C) +{ + Object *ob = get_poselib_object(C); + return (ob && ob->poselib && !ob->poselib->id.lib); +} + /* ----------------------------------- */ /* Initialize a new poselib (whether it is needed or not) */ @@ -357,7 +366,7 @@ void POSELIB_OT_action_sanitize(wmOperatorType *ot) /* callbacks */ ot->exec = poselib_sanitize_exec; - ot->poll = has_poselib_pose_data_poll; + ot->poll = has_poselib_pose_data_for_editing_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -365,6 +374,25 @@ void POSELIB_OT_action_sanitize(wmOperatorType *ot) /* ------------------------------------------ */ +/* Poll callback for adding poses to a PoseLib */ +static int poselib_add_poll(bContext *C) +{ + /* There are 2 cases we need to be careful with: + * 1) When this operator is invoked from a hotkey, there may be no PoseLib yet + * 2) If a PoseLib already exists, we can't edit the action if it is a lib-linked + * actions, as data will be lost when saving the file + */ + if (ED_operator_posemode(C)) { + Object *ob = get_poselib_object(C); + if (ob) { + if ((ob->poselib == NULL) || (ob->poselib->id.lib == 0)) { + return true; + } + } + } + return false; +} + static void poselib_add_menu_invoke__replacemenu(bContext *C, uiLayout *layout, void *UNUSED(arg)) { Object *ob = get_poselib_object(C); @@ -404,8 +432,8 @@ static int poselib_add_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U return OPERATOR_CANCELLED; /* start building */ - pup = uiPupMenuBegin(C, op->type->name, ICON_NONE); - layout = uiPupMenuLayout(pup); + pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE); + layout = UI_popup_menu_layout(pup); uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT); /* add new (adds to the first unoccupied frame) */ @@ -420,10 +448,10 @@ static int poselib_add_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U uiItemMenuF(layout, IFACE_("Replace Existing..."), 0, poselib_add_menu_invoke__replacemenu, NULL); } - uiPupMenuEnd(C, pup); + UI_popup_menu_end(C, pup); /* this operator is only for a menu, not used further */ - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } @@ -472,7 +500,7 @@ static int poselib_add_exec(bContext *C, wmOperator *op) ANIM_apply_keyingset(C, NULL, act, ks, MODIFYKEY_MODE_INSERT, (float)frame); /* store new 'active' pose number */ - act->active_marker = BLI_countlist(&act->markers); + act->active_marker = BLI_listbase_count(&act->markers); /* done */ return OPERATOR_FINISHED; @@ -488,7 +516,7 @@ void POSELIB_OT_pose_add(wmOperatorType *ot) /* api callbacks */ ot->invoke = poselib_add_menu_invoke; ot->exec = poselib_add_exec; - ot->poll = ED_operator_posemode; + ot->poll = poselib_add_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -604,7 +632,7 @@ void POSELIB_OT_pose_remove(wmOperatorType *ot) /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = poselib_remove_exec; - ot->poll = has_poselib_pose_data_poll; + ot->poll = has_poselib_pose_data_for_editing_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -692,7 +720,7 @@ void POSELIB_OT_pose_rename(wmOperatorType *ot) /* api callbacks */ ot->invoke = poselib_rename_invoke; ot->exec = poselib_rename_exec; - ot->poll = has_poselib_pose_data_poll; + ot->poll = has_poselib_pose_data_for_editing_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -916,7 +944,7 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, tPoseLib_PreviewData KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID); ListBase dsources = {NULL, NULL}; - short autokey = autokeyframe_cfra_can_key(scene, &pld->ob->id); + bool autokey = autokeyframe_cfra_can_key(scene, &pld->ob->id); /* start tagging/keying */ for (agrp = act->groups.first; agrp; agrp = agrp->next) { @@ -1050,7 +1078,7 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step) LinkData *ld, *ldn, *ldc; /* free and rebuild if needed (i.e. if search-str changed) */ - if (strcmp(pld->searchstr, pld->searchold)) { + if (!STREQ(pld->searchstr, pld->searchold)) { /* free list of temporary search matches */ BLI_freelistN(&pld->searchp); @@ -1196,7 +1224,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con /* only accept 'press' event, and ignore 'release', so that we don't get double actions */ if (ELEM(event->val, KM_PRESS, KM_NOTHING) == 0) { - //printf("PoseLib: skipping event with type '%s' and val %d\n", WM_key_event_string(event->type), event->val); + //printf("PoseLib: skipping event with type '%s' and val %d\n", WM_key_event_string(event->type, false), event->val); return ret; } @@ -1348,7 +1376,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con else { /* change to last pose */ pld->marker = pld->act->markers.last; - pld->act->active_marker = BLI_countlist(&pld->act->markers); + pld->act->active_marker = BLI_listbase_count(&pld->act->markers); pld->redraw = PL_PREVIEW_REDRAWALL; } |