diff options
Diffstat (limited to 'source/blender/editors/armature/poselib.c')
-rw-r--r-- | source/blender/editors/armature/poselib.c | 512 |
1 files changed, 256 insertions, 256 deletions
diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index f180f735294..36c15c50809 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -89,9 +89,9 @@ static void action_set_activemarker(void *UNUSED(a), void *UNUSED(b), void *UNUS /* == POSE-LIBRARY TOOL FOR BLENDER == * * Overview: - * This tool allows animators to store a set of frequently used poses to dump into - * the active action to help in "budget" productions to quickly block out new actions. - * It acts as a kind of "glorified clipboard for poses", allowing for naming of poses. + * This tool allows animators to store a set of frequently used poses to dump into + * the active action to help in "budget" productions to quickly block out new actions. + * It acts as a kind of "glorified clipboard for poses", allowing for naming of poses. * * Features: * - PoseLibs are simply normal Actions @@ -108,10 +108,10 @@ static void action_set_activemarker(void *UNUSED(a), void *UNUSED(b), void *UNUS /* gets the first available frame in poselib to store a pose on * - frames start from 1, and a pose should occur on every frame... 0 is error! */ -static int poselib_get_free_index (bAction *act) +static int poselib_get_free_index(bAction *act) { TimeMarker *marker; - int low=0, high=0; + int low = 0, high = 0; short changed = 0; /* sanity checks */ @@ -124,7 +124,7 @@ static int poselib_get_free_index (bAction *act) do { changed = 0; - for (marker= act->markers.first; marker; marker= marker->next) { + for (marker = act->markers.first; marker; marker = marker->next) { /* only increase low if value is 1 greater than low, to find "gaps" where * poses were removed from the poselib */ @@ -135,7 +135,7 @@ static int poselib_get_free_index (bAction *act) /* value replaces high if it is the highest value encountered yet */ if (marker->frame > high) { - high= marker->frame; + high = marker->frame; changed = 1; } } @@ -151,17 +151,17 @@ static int poselib_get_free_index (bAction *act) } /* returns the active pose for a poselib */ -static TimeMarker *poselib_get_active_pose (bAction *act) +static TimeMarker *poselib_get_active_pose(bAction *act) { if ((act) && (act->active_marker)) - return BLI_findlink(&act->markers, act->active_marker-1); + return BLI_findlink(&act->markers, act->active_marker - 1); else return NULL; } /* Get object that Pose Lib should be found on */ - /* XXX C can be zero */ -static Object *get_poselib_object (bContext *C) +/* XXX C can be zero */ +static Object *get_poselib_object(bContext *C) { ScrArea *sa; @@ -178,7 +178,7 @@ static Object *get_poselib_object (bContext *C) } /* Poll callback for operators that require existing PoseLib data (with poses) to work */ -static int has_poselib_pose_data_poll (bContext *C) +static int has_poselib_pose_data_poll(bContext *C) { Object *ob = get_poselib_object(C); return (ob && ob->poselib); @@ -187,7 +187,7 @@ static int has_poselib_pose_data_poll (bContext *C) /* ----------------------------------- */ /* Initialize a new poselib (whether it is needed or not) */ -static bAction *poselib_init_new (Object *ob) +static bAction *poselib_init_new(Object *ob) { /* sanity checks - only for armatures */ if (ELEM(NULL, ob, ob->pose)) @@ -196,13 +196,13 @@ static bAction *poselib_init_new (Object *ob) /* init object's poselib action (unlink old one if there) */ if (ob->poselib) id_us_min(&ob->poselib->id); - ob->poselib= add_empty_action("PoseLib"); + ob->poselib = add_empty_action("PoseLib"); return ob->poselib; } /* Initialize a new poselib (checks if that needs to happen) */ -static bAction *poselib_validate (Object *ob) +static bAction *poselib_validate(Object *ob) { if (ELEM(NULL, ob, ob->pose)) return NULL; @@ -215,7 +215,7 @@ static bAction *poselib_validate (Object *ob) /* ************************************************************* */ /* Pose Lib UI Operators */ -static int poselib_new_exec (bContext *C, wmOperator *UNUSED(op)) +static int poselib_new_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = get_poselib_object(C); @@ -227,7 +227,7 @@ static int poselib_new_exec (bContext *C, wmOperator *UNUSED(op)) poselib_init_new(ob); /* notifier here might evolve? */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); return OPERATOR_FINISHED; } @@ -244,12 +244,12 @@ void POSELIB_OT_new(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ------------------------------------------------ */ -static int poselib_unlink_exec (bContext *C, wmOperator *UNUSED(op)) +static int poselib_unlink_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = get_poselib_object(C); @@ -262,7 +262,7 @@ static int poselib_unlink_exec (bContext *C, wmOperator *UNUSED(op)) ob->poselib = NULL; /* notifier here might evolve? */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); return OPERATOR_FINISHED; } @@ -279,7 +279,7 @@ void POSELIB_OT_unlink(wmOperatorType *ot) ot->poll = has_poselib_pose_data_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************************************************* */ @@ -288,10 +288,10 @@ void POSELIB_OT_unlink(wmOperatorType *ot) /* This tool automagically generates/validates poselib data so that it corresponds to the data * in the action. This is for use in making existing actions usable as poselibs. */ -static int poselib_sanitise_exec (bContext *C, wmOperator *op) +static int poselib_sanitise_exec(bContext *C, wmOperator *op) { Object *ob = get_poselib_object(C); - bAction *act = (ob)? ob->poselib : NULL; + bAction *act = (ob) ? ob->poselib : NULL; DLRBT_Tree keys; ActKeyColumn *ak; TimeMarker *marker, *markern; @@ -304,14 +304,14 @@ static int poselib_sanitise_exec (bContext *C, wmOperator *op) /* determine which frames have keys */ BLI_dlrbTree_init(&keys); - action_to_keylist(NULL, act, &keys, NULL); + action_to_keylist(NULL, act, &keys, NULL); BLI_dlrbTree_linkedlist_sync(&keys); /* for each key, make sure there is a corresponding pose */ - for (ak= keys.first; ak; ak= ak->next) { + for (ak = keys.first; ak; ak = ak->next) { /* check if any pose matches this */ // TODO: don't go looking through the list like this every time... - for (marker= act->markers.first; marker; marker= marker->next) { + for (marker = act->markers.first; marker; marker = marker->next) { if (IS_EQ(marker->frame, (double)ak->cfra)) { marker->flag = -1; break; @@ -321,20 +321,20 @@ static int poselib_sanitise_exec (bContext *C, wmOperator *op) /* add new if none found */ if (marker == NULL) { /* add pose to poselib */ - marker= MEM_callocN(sizeof(TimeMarker), "ActionMarker"); + marker = MEM_callocN(sizeof(TimeMarker), "ActionMarker"); BLI_strncpy(marker->name, "Pose", sizeof(marker->name)); - marker->frame= (int)ak->cfra; - marker->flag= -1; + marker->frame = (int)ak->cfra; + marker->flag = -1; BLI_addtail(&act->markers, marker); } } /* remove all untagged poses (unused), and remove all tags */ - for (marker= act->markers.first; marker; marker= markern) { - markern= marker->next; + for (marker = act->markers.first; marker; marker = markern) { + markern = marker->next; if (marker->flag != -1) BLI_freelinkN(&act->markers, marker); @@ -348,7 +348,7 @@ static int poselib_sanitise_exec (bContext *C, wmOperator *op) /* send notifiers for this - using keyframe editing notifiers, since action * may be being shown in anim editors as active action */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -365,15 +365,15 @@ void POSELIB_OT_action_sanitise(wmOperatorType *ot) ot->poll = has_poselib_pose_data_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ------------------------------------------ */ -static void poselib_add_menu_invoke__replacemenu (bContext *C, uiLayout *layout, void *UNUSED(arg)) +static void poselib_add_menu_invoke__replacemenu(bContext *C, uiLayout *layout, void *UNUSED(arg)) { - Object *ob= get_poselib_object(C); - bAction *act= ob->poselib; /* never NULL */ + Object *ob = get_poselib_object(C); + bAction *act = ob->poselib; /* never NULL */ TimeMarker *marker; wmOperatorType *ot = WM_operatortype_find("POSELIB_OT_pose_add", 1); @@ -384,7 +384,7 @@ static void poselib_add_menu_invoke__replacemenu (bContext *C, uiLayout *layout, uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT); /* add each marker to this menu */ - for (marker= act->markers.first; marker; marker= marker->next) { + for (marker = act->markers.first; marker; marker = marker->next) { PointerRNA props_ptr; props_ptr = uiItemFullO_ptr(layout, ot, @@ -396,11 +396,11 @@ static void poselib_add_menu_invoke__replacemenu (bContext *C, uiLayout *layout, } } -static int poselib_add_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) +static int poselib_add_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) { - Scene *scene= CTX_data_scene(C); - Object *ob= get_poselib_object(C); - bPose *pose= (ob) ? ob->pose : NULL; + Scene *scene = CTX_data_scene(C); + Object *ob = get_poselib_object(C); + bPose *pose = (ob) ? ob->pose : NULL; uiPopupMenu *pup; uiLayout *layout; @@ -409,8 +409,8 @@ static int poselib_add_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED return OPERATOR_CANCELLED; /* start building */ - pup= uiPupMenuBegin(C, op->type->name, ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, op->type->name, ICON_NONE); + layout = uiPupMenuLayout(pup); uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT); /* add new (adds to the first unoccupied frame) */ @@ -432,14 +432,14 @@ static int poselib_add_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED } -static int poselib_add_exec (bContext *C, wmOperator *op) +static int poselib_add_exec(bContext *C, wmOperator *op) { - Object *ob= get_poselib_object(C); + Object *ob = get_poselib_object(C); bAction *act = poselib_validate(ob); - bPose *pose= (ob) ? ob->pose : NULL; + bPose *pose = (ob) ? ob->pose : NULL; TimeMarker *marker; - KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_WHOLE_CHARACTER_ID); /* this includes custom props :)*/ - int frame= RNA_int_get(op->ptr, "frame"); + KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_WHOLE_CHARACTER_ID); /* this includes custom props :)*/ + int frame = RNA_int_get(op->ptr, "frame"); char name[64]; /* sanity check (invoke should have checked this anyway) */ @@ -453,17 +453,17 @@ static int poselib_add_exec (bContext *C, wmOperator *op) * - for the 'replace' option, this should end up finding the appropriate marker, * so no new one will be added */ - for (marker= act->markers.first; marker; marker= marker->next) { + for (marker = act->markers.first; marker; marker = marker->next) { if (marker->frame == frame) { BLI_strncpy(marker->name, name, sizeof(marker->name)); break; } } if (marker == NULL) { - marker= MEM_callocN(sizeof(TimeMarker), "ActionMarker"); + marker = MEM_callocN(sizeof(TimeMarker), "ActionMarker"); BLI_strncpy(marker->name, name, sizeof(marker->name)); - marker->frame= frame; + marker->frame = frame; BLI_addtail(&act->markers, marker); } @@ -477,7 +477,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_countlist(&act->markers); /* done */ return OPERATOR_FINISHED; @@ -496,7 +496,7 @@ void POSELIB_OT_pose_add(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_int(ot->srna, "frame", 1, 0, INT_MAX, "Frame", "Frame to store pose on", 0, INT_MAX); @@ -511,9 +511,9 @@ static EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA *UNUS Object *ob = get_poselib_object(C); bAction *act = (ob) ? ob->poselib : NULL; TimeMarker *marker; - EnumPropertyItem *item= NULL, item_tmp= {0}; - int totitem= 0; - int i= 0; + EnumPropertyItem *item = NULL, item_tmp = {0}; + int totitem = 0; + int i = 0; if (C == NULL) { return DummyRNA_NULL_items; @@ -522,24 +522,24 @@ static EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA *UNUS /* check that the action exists */ if (act) { /* add each marker to the list */ - for (marker=act->markers.first, i=0; marker; marker= marker->next, i++) { - item_tmp.identifier= item_tmp.name= marker->name; - item_tmp.icon= ICON_ARMATURE_DATA; - item_tmp.value= i; + for (marker = act->markers.first, i = 0; marker; marker = marker->next, i++) { + item_tmp.identifier = item_tmp.name = marker->name; + item_tmp.icon = ICON_ARMATURE_DATA; + item_tmp.value = i; RNA_enum_item_add(&item, &totitem, &item_tmp); } } RNA_enum_item_end(&item, &totitem); - *free= 1; + *free = 1; return item; } -static int poselib_remove_exec (bContext *C, wmOperator *op) +static int poselib_remove_exec(bContext *C, wmOperator *op) { - Object *ob= get_poselib_object(C); - bAction *act= (ob) ? ob->poselib : NULL; + Object *ob = get_poselib_object(C); + bAction *act = (ob) ? ob->poselib : NULL; TimeMarker *marker; int marker_index; FCurve *fcu; @@ -567,12 +567,12 @@ static int poselib_remove_exec (bContext *C, wmOperator *op) } /* remove relevant keyframes */ - for (fcu= act->curves.first; fcu; fcu= fcu->next) { + for (fcu = act->curves.first; fcu; fcu = fcu->next) { BezTriple *bezt; unsigned int i; if (fcu->bezt) { - for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { + for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { /* check if remove */ if (IS_EQ(bezt->vec[1][0], marker->frame)) { delete_fcurve_key(fcu, i, 1); @@ -586,12 +586,12 @@ static int poselib_remove_exec (bContext *C, wmOperator *op) BLI_freelinkN(&act->markers, marker); /* fix active pose number */ - act->active_marker= 0; + act->active_marker = 0; /* send notifiers for this - using keyframe editing notifiers, since action * may be being shown in anim editors as active action */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -612,7 +612,7 @@ void POSELIB_OT_pose_remove(wmOperatorType *ot) ot->poll = has_poselib_pose_data_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ prop = RNA_def_enum(ot->srna, "pose", DummyRNA_NULL_items, 0, "Pose", "The pose to remove"); @@ -620,10 +620,10 @@ void POSELIB_OT_pose_remove(wmOperatorType *ot) ot->prop = prop; } -static int poselib_rename_invoke (bContext *C, wmOperator *op, wmEvent *evt) +static int poselib_rename_invoke(bContext *C, wmOperator *op, wmEvent *evt) { - Object *ob= get_poselib_object(C); - bAction *act= (ob) ? ob->poselib : NULL; + Object *ob = get_poselib_object(C); + bAction *act = (ob) ? ob->poselib : NULL; TimeMarker *marker; /* check if valid poselib */ @@ -633,14 +633,14 @@ static int poselib_rename_invoke (bContext *C, wmOperator *op, wmEvent *evt) } /* get index (and pointer) of pose to remove */ - marker= BLI_findlink(&act->markers, act->active_marker-1); + marker = BLI_findlink(&act->markers, act->active_marker - 1); if (marker == NULL) { BKE_report(op->reports, RPT_ERROR, "Invalid index for Pose"); return OPERATOR_CANCELLED; } else { /* use the existing name of the marker as the name, and use the active marker as the one to rename */ - RNA_enum_set(op->ptr, "pose", act->active_marker-1); + RNA_enum_set(op->ptr, "pose", act->active_marker - 1); RNA_string_set(op->ptr, "name", marker->name); } @@ -648,10 +648,10 @@ static int poselib_rename_invoke (bContext *C, wmOperator *op, wmEvent *evt) return WM_operator_props_popup(C, op, evt); } -static int poselib_rename_exec (bContext *C, wmOperator *op) +static int poselib_rename_exec(bContext *C, wmOperator *op) { - Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); - bAction *act= (ob) ? ob->poselib : NULL; + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + bAction *act = (ob) ? ob->poselib : NULL; TimeMarker *marker; char newname[64]; @@ -662,7 +662,7 @@ static int poselib_rename_exec (bContext *C, wmOperator *op) } /* get index (and pointer) of pose to remove */ - marker= BLI_findlink(&act->markers, RNA_int_get(op->ptr, "pose")); + marker = BLI_findlink(&act->markers, RNA_int_get(op->ptr, "pose")); if (marker == NULL) { BKE_report(op->reports, RPT_ERROR, "Invalid index for Pose"); return OPERATOR_CANCELLED; @@ -678,7 +678,7 @@ static int poselib_rename_exec (bContext *C, wmOperator *op) /* send notifiers for this - using keyframe editing notifiers, since action * may be being shown in anim editors as active action */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -702,13 +702,13 @@ void POSELIB_OT_pose_rename(wmOperatorType *ot) ot->poll = has_poselib_pose_data_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - /* NOTE: name not pose is the operator's "main" property, so that it will get activated in the popup for easy renaming */ + /* NOTE: name not pose is the operator's "main" property, so that it will get activated in the popup for easy renaming */ ot->prop = RNA_def_string(ot->srna, "name", "RenamedPose", 64, "New Pose Name", "New name for pose"); - prop= RNA_def_enum(ot->srna, "pose", prop_poses_dummy_types, 0, "Pose", "The pose to rename"); - RNA_def_enum_funcs(prop, poselib_stored_pose_itemf); + prop = RNA_def_enum(ot->srna, "pose", prop_poses_dummy_types, 0, "Pose", "The pose to rename"); + RNA_def_enum_funcs(prop, poselib_stored_pose_itemf); } /* ************************************************************* */ @@ -716,31 +716,31 @@ void POSELIB_OT_pose_rename(wmOperatorType *ot) /* Simple struct for storing settings/data for use during PoseLib preview */ typedef struct tPoseLib_PreviewData { - ListBase backups; /* tPoseLib_Backup structs for restoring poses */ - ListBase searchp; /* LinkData structs storing list of poses which match the current search-string */ - - Scene *scene; /* active scene */ - ScrArea *sa; /* active area */ + ListBase backups; /* tPoseLib_Backup structs for restoring poses */ + ListBase searchp; /* LinkData structs storing list of poses which match the current search-string */ - PointerRNA rna_ptr; /* RNA-Pointer to Object 'ob' */ - Object *ob; /* object to work on */ - bArmature *arm; /* object's armature data */ - bPose *pose; /* object's pose */ - bAction *act; /* poselib to use */ - TimeMarker *marker; /* 'active' pose */ + Scene *scene; /* active scene */ + ScrArea *sa; /* active area */ - int selcount; /* number of selected elements to work on */ - int totcount; /* total number of elements to work on */ - - short state; /* state of main loop */ - short redraw; /* redraw/update settings during main loop */ - short flag; /* flags for various settings */ - - short search_cursor; /* position of cursor in searchstr (cursor occurs before the item at the nominated index) */ - char searchstr[64]; /* (Part of) Name to search for to filter poses that get shown */ - char searchold[64]; /* Previously set searchstr (from last loop run), so that we can detected when to rebuild searchp */ + PointerRNA rna_ptr; /* RNA-Pointer to Object 'ob' */ + Object *ob; /* object to work on */ + bArmature *arm; /* object's armature data */ + bPose *pose; /* object's pose */ + bAction *act; /* poselib to use */ + TimeMarker *marker; /* 'active' pose */ + + int selcount; /* number of selected elements to work on */ + int totcount; /* total number of elements to work on */ + + short state; /* state of main loop */ + short redraw; /* redraw/update settings during main loop */ + short flag; /* flags for various settings */ + + short search_cursor; /* position of cursor in searchstr (cursor occurs before the item at the nominated index) */ + char searchstr[64]; /* (Part of) Name to search for to filter poses that get shown */ + char searchold[64]; /* Previously set searchstr (from last loop run), so that we can detected when to rebuild searchp */ - char headerstr[200]; /* Info-text to print in header */ + char headerstr[200]; /* Info-text to print in header */ } tPoseLib_PreviewData; /* defines for tPoseLib_PreviewData->state values */ @@ -761,8 +761,8 @@ enum { /* defines for tPoseLib_PreviewData->flag values */ enum { - PL_PREVIEW_FIRSTTIME = (1<<0), - PL_PREVIEW_SHOWORIGINAL = (1<<1) + PL_PREVIEW_FIRSTTIME = (1 << 0), + PL_PREVIEW_SHOWORIGINAL = (1 << 1) }; /* ---------------------------- */ @@ -771,35 +771,35 @@ enum { typedef struct tPoseLib_Backup { struct tPoseLib_Backup *next, *prev; - bPoseChannel *pchan; /* pose channel backups are for */ + bPoseChannel *pchan; /* pose channel backups are for */ - bPoseChannel olddata; /* copy of pose channel's old data (at start) */ - IDProperty *oldprops; /* copy (needs freeing) of pose channel's properties (at start) */ + bPoseChannel olddata; /* copy of pose channel's old data (at start) */ + IDProperty *oldprops; /* copy (needs freeing) of pose channel's properties (at start) */ } tPoseLib_Backup; /* Makes a copy of the current pose for restoration purposes - doesn't do constraints currently */ -static void poselib_backup_posecopy (tPoseLib_PreviewData *pld) +static void poselib_backup_posecopy(tPoseLib_PreviewData *pld) { bActionGroup *agrp; bPoseChannel *pchan; /* for each posechannel that has an actionchannel in */ - for (agrp= pld->act->groups.first; agrp; agrp= agrp->next) { + for (agrp = pld->act->groups.first; agrp; agrp = agrp->next) { /* try to find posechannel */ - pchan= BKE_pose_channel_find_name(pld->pose, agrp->name); + pchan = BKE_pose_channel_find_name(pld->pose, agrp->name); /* backup data if available */ if (pchan) { tPoseLib_Backup *plb; /* store backup */ - plb= MEM_callocN(sizeof(tPoseLib_Backup), "tPoseLib_Backup"); + plb = MEM_callocN(sizeof(tPoseLib_Backup), "tPoseLib_Backup"); - plb->pchan= pchan; + plb->pchan = pchan; memcpy(&plb->olddata, plb->pchan, sizeof(bPoseChannel)); if (pchan->prop) - plb->oldprops= IDP_CopyProperty(pchan->prop); + plb->oldprops = IDP_CopyProperty(pchan->prop); BLI_addtail(&pld->backups, plb); @@ -812,11 +812,11 @@ static void poselib_backup_posecopy (tPoseLib_PreviewData *pld) } /* Restores original pose */ -static void poselib_backup_restore (tPoseLib_PreviewData *pld) +static void poselib_backup_restore(tPoseLib_PreviewData *pld) { tPoseLib_Backup *plb; - for (plb= pld->backups.first; plb; plb= plb->next) { + for (plb = pld->backups.first; plb; plb = plb->next) { /* copy most of data straight back */ memcpy(plb->pchan, &plb->olddata, sizeof(bPoseChannel)); @@ -829,12 +829,12 @@ static void poselib_backup_restore (tPoseLib_PreviewData *pld) } /* Free list of backups, including any side data it may use */ -static void poselib_backup_free_data (tPoseLib_PreviewData *pld) +static void poselib_backup_free_data(tPoseLib_PreviewData *pld) { tPoseLib_Backup *plb, *plbn; - for (plb= pld->backups.first; plb; plb= plbn) { - plbn= plb->next; + for (plb = pld->backups.first; plb; plb = plbn) { + plbn = plb->next; /* free custom data */ if (plb->oldprops) { @@ -852,48 +852,48 @@ static void poselib_backup_free_data (tPoseLib_PreviewData *pld) /* Applies the appropriate stored pose from the pose-library to the current pose * - assumes that a valid object, with a poselib has been supplied * - gets the string to print in the header - * - this code is based on the code for extract_pose_from_action in blenkernel/action.c + * - this code is based on the code for extract_pose_from_action in blenkernel/action.c */ -static void poselib_apply_pose (tPoseLib_PreviewData *pld) +static void poselib_apply_pose(tPoseLib_PreviewData *pld) { - PointerRNA *ptr= &pld->rna_ptr; - bArmature *arm= pld->arm; - bPose *pose= pld->pose; + PointerRNA *ptr = &pld->rna_ptr; + bArmature *arm = pld->arm; + bPose *pose = pld->pose; bPoseChannel *pchan; - bAction *act= pld->act; + bAction *act = pld->act; bActionGroup *agrp; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc group_ok_cb; - int frame= 1; + int frame = 1; /* get the frame */ if (pld->marker) - frame= pld->marker->frame; + frame = pld->marker->frame; else return; /* init settings for testing groups for keyframes */ - group_ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); - ked.f1= ((float)frame) - 0.5f; - ked.f2= ((float)frame) + 0.5f; + group_ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); + ked.f1 = ((float)frame) - 0.5f; + ked.f2 = ((float)frame) + 0.5f; /* start applying - only those channels which have a key at this point in time! */ - for (agrp= act->groups.first; agrp; agrp= agrp->next) { + for (agrp = act->groups.first; agrp; agrp = agrp->next) { /* check if group has any keyframes */ if (ANIM_animchanneldata_keyframes_loop(&ked, NULL, agrp, ALE_GROUP, NULL, group_ok_cb, NULL)) { /* has keyframe on this frame, so try to get a PoseChannel with this name */ - pchan= BKE_pose_channel_find_name(pose, agrp->name); + pchan = BKE_pose_channel_find_name(pose, agrp->name); if (pchan) { - short ok= 0; + short ok = 0; /* check if this bone should get any animation applied */ if (pld->selcount == 0) { /* if no bones are selected, then any bone is ok */ - ok= 1; + ok = 1; } else if (pchan->bone) { /* only ok if bone is visible and selected */ @@ -913,11 +913,11 @@ static void poselib_apply_pose (tPoseLib_PreviewData *pld) } /* Auto-keys/tags bones affected by the pose used from the poselib */ -static void poselib_keytag_pose (bContext *C, Scene *scene, tPoseLib_PreviewData *pld) +static void poselib_keytag_pose(bContext *C, Scene *scene, tPoseLib_PreviewData *pld) { - bPose *pose= pld->pose; + bPose *pose = pld->pose; bPoseChannel *pchan; - bAction *act= pld->act; + bAction *act = pld->act; bActionGroup *agrp; KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID); @@ -925,9 +925,9 @@ static void poselib_keytag_pose (bContext *C, Scene *scene, tPoseLib_PreviewData short autokey = autokeyframe_cfra_can_key(scene, &pld->ob->id); /* start tagging/keying */ - for (agrp= act->groups.first; agrp; agrp= agrp->next) { + for (agrp = act->groups.first; agrp; agrp = agrp->next) { /* only for selected bones unless there aren't any selected, in which case all are included */ - pchan= BKE_pose_channel_find_name(pose, agrp->name); + pchan = BKE_pose_channel_find_name(pose, agrp->name); if (pchan) { if ( (pld->selcount == 0) || ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) ) { @@ -956,35 +956,35 @@ static void poselib_keytag_pose (bContext *C, Scene *scene, tPoseLib_PreviewData } /* send notifiers for this */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } /* Apply the relevant changes to the pose */ -static void poselib_preview_apply (bContext *C, wmOperator *op) +static void poselib_preview_apply(bContext *C, wmOperator *op) { - tPoseLib_PreviewData *pld= (tPoseLib_PreviewData *)op->customdata; + tPoseLib_PreviewData *pld = (tPoseLib_PreviewData *)op->customdata; /* only recalc pose (and its dependencies) if pose has changed */ if (pld->redraw == PL_PREVIEW_REDRAWALL) { /* don't clear pose if firsttime */ - if ((pld->flag & PL_PREVIEW_FIRSTTIME)==0) + if ((pld->flag & PL_PREVIEW_FIRSTTIME) == 0) poselib_backup_restore(pld); else pld->flag &= ~PL_PREVIEW_FIRSTTIME; /* pose should be the right one to draw (unless we're temporarily not showing it) */ - if ((pld->flag & PL_PREVIEW_SHOWORIGINAL)==0) { + if ((pld->flag & PL_PREVIEW_SHOWORIGINAL) == 0) { RNA_int_set(op->ptr, "pose_index", BLI_findindex(&pld->act->markers, pld->marker)); poselib_apply_pose(pld); } else - RNA_int_set(op->ptr, "pose_index", -2); /* -2 means don't apply any pose */ + RNA_int_set(op->ptr, "pose_index", -2); /* -2 means don't apply any pose */ /* old optimize trick... this enforces to bypass the depgraph * - note: code copied from transform_generics.c -> recalcData() */ // FIXME: shouldn't this use the builtin stuff? - if ((pld->arm->flag & ARM_DELAYDEFORM)==0) + if ((pld->arm->flag & ARM_DELAYDEFORM) == 0) DAG_id_tag_update(&pld->ob->id, OB_RECALC_DATA); /* sets recalc flags */ else BKE_pose_where_is(pld->scene, pld->ob); @@ -1004,12 +1004,12 @@ static void poselib_preview_apply (bContext *C, wmOperator *op) short index; /* get search-string */ - index= pld->search_cursor; + index = pld->search_cursor; if (index >= 0 && index <= sizeof(tempstr) - 1) { memcpy(&tempstr[0], &pld->searchstr[0], index); - tempstr[index]= '|'; - memcpy(&tempstr[index+1], &pld->searchstr[index], (sizeof(tempstr) - 1) - index); + tempstr[index] = '|'; + memcpy(&tempstr[index + 1], &pld->searchstr[index], (sizeof(tempstr) - 1) - index); } else { BLI_strncpy(tempstr, pld->searchstr, sizeof(tempstr)); @@ -1035,8 +1035,8 @@ static void poselib_preview_apply (bContext *C, wmOperator *op) } /* request drawing of view + clear redraw flag */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, pld->ob); - pld->redraw= PL_PREVIEW_NOREDRAW; + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, pld->ob); + pld->redraw = PL_PREVIEW_NOREDRAW; } /* ---------------------------- */ @@ -1044,7 +1044,7 @@ static void poselib_preview_apply (bContext *C, wmOperator *op) /* This helper function is called during poselib_preview_poses to find the * pose to preview next (after a change event) */ -static void poselib_preview_get_next (tPoseLib_PreviewData *pld, int step) +static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step) { /* stop if not going anywhere, as we assume that there is a direction to move in */ if (step == 0) @@ -1061,91 +1061,91 @@ static void poselib_preview_get_next (tPoseLib_PreviewData *pld, int step) BLI_freelistN(&pld->searchp); /* generate a new list of search matches */ - for (marker= pld->act->markers.first; marker; marker= marker->next) { + for (marker = pld->act->markers.first; marker; marker = marker->next) { /* does the name partially match? - * - don't worry about case, to make it easier for users to quickly input a name (or + * - don't worry about case, to make it easier for users to quickly input a name (or * part of one), which is the whole point of this feature */ if (BLI_strcasestr(marker->name, pld->searchstr)) { /* make link-data to store reference to it */ - ld= MEM_callocN(sizeof(LinkData), "PoseMatch"); - ld->data= marker; + ld = MEM_callocN(sizeof(LinkData), "PoseMatch"); + ld->data = marker; BLI_addtail(&pld->searchp, ld); } } /* set current marker to NULL (so that we start from first) */ - pld->marker= NULL; + pld->marker = NULL; } /* check if any matches */ if (pld->searchp.first == NULL) { - pld->marker= NULL; + pld->marker = NULL; return; } /* find first match */ - for (ldc= pld->searchp.first; ldc; ldc= ldc->next) { + for (ldc = pld->searchp.first; ldc; ldc = ldc->next) { if (ldc->data == pld->marker) break; } if (ldc == NULL) - ldc= pld->searchp.first; + ldc = pld->searchp.first; /* Loop through the matches in a cyclic fashion, incrementing/decrementing step as appropriate * until step == 0. At this point, marker should be the correct marker. */ if (step > 0) { - for (ld=ldc; ld && step; ld=ldn, step--) - ldn= (ld->next) ? ld->next : pld->searchp.first; + for (ld = ldc; ld && step; ld = ldn, step--) + ldn = (ld->next) ? ld->next : pld->searchp.first; } else { - for (ld=ldc; ld && step; ld=ldn, step++) - ldn= (ld->prev) ? ld->prev : pld->searchp.last; + for (ld = ldc; ld && step; ld = ldn, step++) + ldn = (ld->prev) ? ld->prev : pld->searchp.last; } /* set marker */ if (ld) - pld->marker= ld->data; + pld->marker = ld->data; } else { TimeMarker *marker, *next; /* if no marker, because we just ended searching, then set that to the start of the list */ if (pld->marker == NULL) - pld->marker= pld->act->markers.first; + pld->marker = pld->act->markers.first; /* Loop through the markers in a cyclic fashion, incrementing/decrementing step as appropriate * until step == 0. At this point, marker should be the correct marker. */ if (step > 0) { - for (marker=pld->marker; marker && step; marker=next, step--) - next= (marker->next) ? marker->next : pld->act->markers.first; + for (marker = pld->marker; marker && step; marker = next, step--) + next = (marker->next) ? marker->next : pld->act->markers.first; } else { - for (marker=pld->marker; marker && step; marker=next, step++) - next= (marker->prev) ? marker->prev : pld->act->markers.last; + for (marker = pld->marker; marker && step; marker = next, step++) + next = (marker->prev) ? marker->prev : pld->act->markers.last; } /* it should be fairly impossible for marker to be NULL */ if (marker) - pld->marker= marker; + pld->marker = marker; } } /* specially handle events for searching */ -static void poselib_preview_handle_search (tPoseLib_PreviewData *pld, unsigned short event, char ascii) +static void poselib_preview_handle_search(tPoseLib_PreviewData *pld, unsigned short event, char ascii) { /* try doing some form of string manipulation first */ switch (event) { case BACKSPACEKEY: if (pld->searchstr[0] && pld->search_cursor) { - short len= strlen(pld->searchstr); - short index= pld->search_cursor; + short len = strlen(pld->searchstr); + short index = pld->search_cursor; short i; for (i = index; i <= len; i++) - pld->searchstr[i-1] = pld->searchstr[i]; + pld->searchstr[i - 1] = pld->searchstr[i]; pld->search_cursor--; @@ -1157,13 +1157,13 @@ static void poselib_preview_handle_search (tPoseLib_PreviewData *pld, unsigned s case DELKEY: if (pld->searchstr[0] && pld->searchstr[1]) { - short len= strlen(pld->searchstr); - short index= pld->search_cursor; + short len = strlen(pld->searchstr); + short index = pld->search_cursor; int i; if (index < len) { for (i = index; i < len; i++) - pld->searchstr[i] = pld->searchstr[i+1]; + pld->searchstr[i] = pld->searchstr[i + 1]; poselib_preview_get_next(pld, 1); pld->redraw = PL_PREVIEW_REDRAWALL; @@ -1175,18 +1175,18 @@ static void poselib_preview_handle_search (tPoseLib_PreviewData *pld, unsigned s if (ascii) { /* character to add to the string */ - short index= pld->search_cursor; - short len= (pld->searchstr[0]) ? strlen(pld->searchstr) : 0; + short index = pld->search_cursor; + short len = (pld->searchstr[0]) ? strlen(pld->searchstr) : 0; short i; if (len) { for (i = len; i > index; i--) - pld->searchstr[i]= pld->searchstr[i-1]; + pld->searchstr[i] = pld->searchstr[i - 1]; } else - pld->searchstr[1]= 0; + pld->searchstr[1] = 0; - pld->searchstr[index]= ascii; + pld->searchstr[index] = ascii; pld->search_cursor++; poselib_preview_get_next(pld, 1); @@ -1195,9 +1195,9 @@ static void poselib_preview_handle_search (tPoseLib_PreviewData *pld, unsigned s } /* handle events for poselib_preview_poses */ -static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wmEvent *event) +static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, wmEvent *event) { - tPoseLib_PreviewData *pld= op->customdata; + tPoseLib_PreviewData *pld = op->customdata; int ret = OPERATOR_RUNNING_MODAL; /* only accept 'press' event, and ignore 'release', so that we don't get double actions */ @@ -1217,7 +1217,7 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm /* exit - cancel */ case ESCKEY: case RIGHTMOUSE: - pld->state= PL_PREVIEW_CANCEL; + pld->state = PL_PREVIEW_CANCEL; break; /* exit - confirm */ @@ -1225,7 +1225,7 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm case RETKEY: case PADENTER: case SPACEKEY: - pld->state= PL_PREVIEW_CONFIRM; + pld->state = PL_PREVIEW_CONFIRM; break; /* view manipulation */ @@ -1243,7 +1243,7 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm /* quicky compare to original */ case TABKEY: pld->flag &= ~PL_PREVIEW_SHOWORIGINAL; - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; break; } @@ -1257,7 +1257,7 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm /* exit - cancel */ case ESCKEY: case RIGHTMOUSE: - pld->state= PL_PREVIEW_CANCEL; + pld->state = PL_PREVIEW_CANCEL; break; /* exit - confirm */ @@ -1265,39 +1265,39 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm case RETKEY: case PADENTER: case SPACEKEY: - pld->state= PL_PREVIEW_CONFIRM; + pld->state = PL_PREVIEW_CONFIRM; break; /* toggle between original pose and poselib pose*/ case TABKEY: pld->flag |= PL_PREVIEW_SHOWORIGINAL; - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; break; /* change to previous pose (cyclic) */ case PAGEUPKEY: case WHEELUPMOUSE: poselib_preview_get_next(pld, -1); - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; break; /* change to next pose (cyclic) */ case PAGEDOWNKEY: case WHEELDOWNMOUSE: poselib_preview_get_next(pld, 1); - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; break; /* jump 5 poses (cyclic, back) */ case DOWNARROWKEY: poselib_preview_get_next(pld, -5); - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; break; /* jump 5 poses (cyclic, forward) */ case UPARROWKEY: poselib_preview_get_next(pld, 5); - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; break; /* change to next pose or searching cursor control */ @@ -1306,12 +1306,12 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm /* move text-cursor to the right */ if (pld->search_cursor < strlen(pld->searchstr)) pld->search_cursor++; - pld->redraw= PL_PREVIEW_REDRAWHEADER; + pld->redraw = PL_PREVIEW_REDRAWHEADER; } else { /* change to next pose (cyclic) */ poselib_preview_get_next(pld, 1); - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; } break; @@ -1321,42 +1321,42 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm /* move text-cursor to the left */ if (pld->search_cursor) pld->search_cursor--; - pld->redraw= PL_PREVIEW_REDRAWHEADER; + pld->redraw = PL_PREVIEW_REDRAWHEADER; } else { /* change to previous pose (cyclic) */ poselib_preview_get_next(pld, -1); - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; } break; /* change to first pose or start of searching string */ case HOMEKEY: if (pld->searchstr[0]) { - pld->search_cursor= 0; - pld->redraw= PL_PREVIEW_REDRAWHEADER; + pld->search_cursor = 0; + pld->redraw = PL_PREVIEW_REDRAWHEADER; } else { /* change to first pose */ - pld->marker= pld->act->markers.first; - pld->act->active_marker= 1; + pld->marker = pld->act->markers.first; + pld->act->active_marker = 1; - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; } break; /* change to last pose or start of searching string */ case ENDKEY: if (pld->searchstr[0]) { - pld->search_cursor= strlen(pld->searchstr); - pld->redraw= PL_PREVIEW_REDRAWHEADER; + pld->search_cursor = strlen(pld->searchstr); + pld->redraw = PL_PREVIEW_REDRAWHEADER; } else { /* change to last pose */ - pld->marker= pld->act->markers.last; - pld->act->active_marker= BLI_countlist(&pld->act->markers); + pld->marker = pld->act->markers.last; + pld->act->active_marker = BLI_countlist(&pld->act->markers); - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; } break; @@ -1396,53 +1396,53 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm /* ---------------------------- */ /* Init PoseLib Previewing data */ -static void poselib_preview_init_data (bContext *C, wmOperator *op) +static void poselib_preview_init_data(bContext *C, wmOperator *op) { tPoseLib_PreviewData *pld; - Object *ob= get_poselib_object(C); + Object *ob = get_poselib_object(C); int pose_index = RNA_int_get(op->ptr, "pose_index"); /* set up preview state info */ - op->customdata= pld= MEM_callocN(sizeof(tPoseLib_PreviewData), "PoseLib Preview Data"); + op->customdata = pld = MEM_callocN(sizeof(tPoseLib_PreviewData), "PoseLib Preview Data"); /* get basic data */ - pld->ob= ob; - pld->arm= (ob) ? (ob->data) : NULL; - pld->pose= (ob) ? (ob->pose) : NULL; - pld->act= (ob) ? (ob->poselib) : NULL; + pld->ob = ob; + pld->arm = (ob) ? (ob->data) : NULL; + pld->pose = (ob) ? (ob->pose) : NULL; + pld->act = (ob) ? (ob->poselib) : NULL; - pld->scene= CTX_data_scene(C); - pld->sa= CTX_wm_area(C); + pld->scene = CTX_data_scene(C); + pld->sa = CTX_wm_area(C); /* get starting pose based on RNA-props for this operator */ if (pose_index == -1) - pld->marker= poselib_get_active_pose(pld->act); + pld->marker = poselib_get_active_pose(pld->act); else if (pose_index == -2) pld->flag |= PL_PREVIEW_SHOWORIGINAL; else - pld->marker= (pld->act) ? BLI_findlink(&pld->act->markers, pose_index) : NULL; + pld->marker = (pld->act) ? BLI_findlink(&pld->act->markers, pose_index) : NULL; /* check if valid poselib */ if (ELEM3(NULL, pld->ob, pld->pose, pld->arm)) { BKE_report(op->reports, RPT_ERROR, "PoseLib is only for Armatures in PoseMode"); - pld->state= PL_PREVIEW_ERROR; + pld->state = PL_PREVIEW_ERROR; return; } if (pld->act == NULL) { BKE_report(op->reports, RPT_ERROR, "Object doesn't have a valid PoseLib"); - pld->state= PL_PREVIEW_ERROR; + pld->state = PL_PREVIEW_ERROR; return; } if (pld->marker == NULL) { if (pld->act->markers.first) { /* just use first one then... */ - pld->marker= pld->act->markers.first; + pld->marker = pld->act->markers.first; if (pose_index > -2) BKE_report(op->reports, RPT_WARNING, "PoseLib had no active pose"); } else { BKE_report(op->reports, RPT_ERROR, "PoseLib has no poses to preview/apply"); - pld->state= PL_PREVIEW_ERROR; + pld->state = PL_PREVIEW_ERROR; return; } } @@ -1454,30 +1454,30 @@ static void poselib_preview_init_data (bContext *C, wmOperator *op) poselib_backup_posecopy(pld); /* set flags for running */ - pld->state= PL_PREVIEW_RUNNING; - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->state = PL_PREVIEW_RUNNING; + pld->redraw = PL_PREVIEW_REDRAWALL; pld->flag |= PL_PREVIEW_FIRSTTIME; /* set depsgraph flags */ - /* make sure the lock is set OK, unlock can be accidentally saved? */ + /* make sure the lock is set OK, unlock can be accidentally saved? */ pld->pose->flag |= POSE_LOCKED; pld->pose->flag &= ~POSE_DO_UNLOCK; /* clear strings + search */ - pld->headerstr[0]= pld->searchstr[0]= pld->searchold[0]= '\0'; - pld->search_cursor= 0; + pld->headerstr[0] = pld->searchstr[0] = pld->searchold[0] = '\0'; + pld->search_cursor = 0; } /* After previewing poses */ -static void poselib_preview_cleanup (bContext *C, wmOperator *op) +static void poselib_preview_cleanup(bContext *C, wmOperator *op) { - tPoseLib_PreviewData *pld= (tPoseLib_PreviewData *)op->customdata; - Scene *scene= pld->scene; - Object *ob= pld->ob; - bPose *pose= pld->pose; - bArmature *arm= pld->arm; - bAction *act= pld->act; - TimeMarker *marker= pld->marker; + tPoseLib_PreviewData *pld = (tPoseLib_PreviewData *)op->customdata; + Scene *scene = pld->scene; + Object *ob = pld->ob; + bPose *pose = pld->pose; + bArmature *arm = pld->arm; + bAction *act = pld->act; + TimeMarker *marker = pld->marker; /* redraw the header so that it doesn't show any of our stuff anymore */ ED_area_headerprint(pld->sa, NULL); @@ -1492,7 +1492,7 @@ static void poselib_preview_cleanup (bContext *C, wmOperator *op) /* old optimize trick... this enforces to bypass the depgraph * - note: code copied from transform_generics.c -> recalcData() */ - if ((arm->flag & ARM_DELAYDEFORM)==0) + if ((arm->flag & ARM_DELAYDEFORM) == 0) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */ else BKE_pose_where_is(scene, ob); @@ -1503,7 +1503,7 @@ static void poselib_preview_cleanup (bContext *C, wmOperator *op) poselib_keytag_pose(C, scene, pld); /* change active pose setting */ - act->active_marker= BLI_findindex(&act->markers, marker) + 1; + act->active_marker = BLI_findindex(&act->markers, marker) + 1; action_set_activemarker(act, marker, NULL); /* Update event for pose and deformation children */ @@ -1523,13 +1523,13 @@ static void poselib_preview_cleanup (bContext *C, wmOperator *op) /* free temp data for operator */ MEM_freeN(pld); - op->customdata= NULL; + op->customdata = NULL; } /* End previewing operation */ -static int poselib_preview_exit (bContext *C, wmOperator *op) +static int poselib_preview_exit(bContext *C, wmOperator *op) { - tPoseLib_PreviewData *pld= op->customdata; + tPoseLib_PreviewData *pld = op->customdata; int exit_state = pld->state; /* finish up */ @@ -1542,16 +1542,16 @@ static int poselib_preview_exit (bContext *C, wmOperator *op) } /* Cancel previewing operation (called when exiting Blender) */ -static int poselib_preview_cancel (bContext *C, wmOperator *op) +static int poselib_preview_cancel(bContext *C, wmOperator *op) { poselib_preview_exit(C, op); return OPERATOR_CANCELLED; } /* main modal status check */ -static int poselib_preview_modal (bContext *C, wmOperator *op, wmEvent *event) +static int poselib_preview_modal(bContext *C, wmOperator *op, wmEvent *event) { - tPoseLib_PreviewData *pld= op->customdata; + tPoseLib_PreviewData *pld = op->customdata; int ret; /* 1) check state to see if we're still running */ @@ -1559,7 +1559,7 @@ static int poselib_preview_modal (bContext *C, wmOperator *op, wmEvent *event) return poselib_preview_exit(C, op); /* 2) handle events */ - ret= poselib_preview_handle_event(C, op, event); + ret = poselib_preview_handle_event(C, op, event); /* 3) apply changes and redraw, otherwise, confirming goes wrong */ if (pld->redraw) @@ -1575,7 +1575,7 @@ static int poselib_preview_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(e /* check if everything is ok, and init settings for modal operator */ poselib_preview_init_data(C, op); - pld= (tPoseLib_PreviewData *)op->customdata; + pld = (tPoseLib_PreviewData *)op->customdata; if (pld->state == PL_PREVIEW_ERROR) { /* an error occurred, so free temp mem used */ @@ -1593,13 +1593,13 @@ static int poselib_preview_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(e } /* Repeat operator */ -static int poselib_preview_exec (bContext *C, wmOperator *op) +static int poselib_preview_exec(bContext *C, wmOperator *op) { tPoseLib_PreviewData *pld; /* check if everything is ok, and init settings for modal operator */ poselib_preview_init_data(C, op); - pld= (tPoseLib_PreviewData *)op->customdata; + pld = (tPoseLib_PreviewData *)op->customdata; if (pld->state == PL_PREVIEW_ERROR) { /* an error occurred, so free temp mem used */ @@ -1637,10 +1637,10 @@ void POSELIB_OT_browse_interactive(wmOperatorType *ot) ot->poll = has_poselib_pose_data_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* properties */ - // TODO: make the pose_index into a proper enum instead of a cryptic int... + // TODO: make the pose_index into a proper enum instead of a cryptic int... ot->prop = RNA_def_int(ot->srna, "pose_index", -1, -2, INT_MAX, "Pose", "Index of the pose to apply (-2 for no change to pose, -1 for poselib active pose)", 0, INT_MAX); // XXX: percentage vs factor? @@ -1660,9 +1660,9 @@ void POSELIB_OT_apply_pose(wmOperatorType *ot) ot->poll = has_poselib_pose_data_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - // TODO: make the pose_index into a proper enum instead of a cryptic int... + // TODO: make the pose_index into a proper enum instead of a cryptic int... ot->prop = RNA_def_int(ot->srna, "pose_index", -1, -2, INT_MAX, "Pose", "Index of the pose to apply (-2 for no change to pose, -1 for poselib active pose)", 0, INT_MAX); } |