diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-03-06 13:32:38 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-03-06 13:36:59 +0300 |
commit | d8491cb7c6745f7c8335843470c7c0a9e2708a87 (patch) | |
tree | a2e0f6fd602eac36dd8dbb6bd9983eec6835df56 | |
parent | 17e1fef85aa45f95d2e7c872901ca1c6140fad73 (diff) |
Cleanup: Animation, renamed and clarified 'success' variable
The `ANIM_apply_keyingset()` returns a value that indicates the number of
changed channels (if nonnegative) or an error state (negative). In the
places where the return value was actually used, this value was stored in
a badly named variable.
-rw-r--r-- | source/blender/editors/animation/keyframing.c | 24 | ||||
-rw-r--r-- | source/blender/editors/animation/keyingsets.c | 31 |
2 files changed, 28 insertions, 27 deletions
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index c80cfd77cf4..1c60dcfbd52 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1814,7 +1814,7 @@ static int insert_key_exec(bContext *C, wmOperator *op) bool ob_edit_mode = false; float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap - int success; + int num_channels; KeyingSet *ks = keyingset_get_from_op_with_error(op, op->type->prop, scene); if (ks == NULL) { @@ -1830,13 +1830,13 @@ static int insert_key_exec(bContext *C, wmOperator *op) } /* try to insert keyframes for the channels specified by KeyingSet */ - success = ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); + num_channels = ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); if (G.debug & G_DEBUG) { BKE_reportf(op->reports, RPT_INFO, "Keying set '%s' - successfully added %d keyframes", ks->name, - success); + num_channels); } /* restore the edit mode if necessary */ @@ -1845,17 +1845,17 @@ static int insert_key_exec(bContext *C, wmOperator *op) } /* report failure or do updates? */ - if (success == MODIFYKEY_INVALID_CONTEXT) { + if (num_channels == MODIFYKEY_INVALID_CONTEXT) { BKE_report(op->reports, RPT_ERROR, "No suitable context info for active keying set"); return OPERATOR_CANCELLED; } - else if (success) { + else if (num_channels) { /* if the appropriate properties have been set, make a note that we've inserted something */ if (RNA_boolean_get(op->ptr, "confirm_success")) { BKE_reportf(op->reports, RPT_INFO, "Successfully added %d keyframes for keying set '%s'", - success, + num_channels, ks->name); } @@ -2018,7 +2018,7 @@ static int delete_key_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap - int success; + int num_channels; KeyingSet *ks = keyingset_get_from_op_with_error(op, op->type->prop, scene); if (ks == NULL) { @@ -2055,23 +2055,23 @@ static int delete_key_exec(bContext *C, wmOperator *op) } /* try to delete keyframes for the channels specified by KeyingSet */ - success = ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_DELETE, cfra); + num_channels = ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_DELETE, cfra); if (G.debug & G_DEBUG) { - printf("KeyingSet '%s' - Successfully removed %d Keyframes\n", ks->name, success); + printf("KeyingSet '%s' - Successfully removed %d Keyframes\n", ks->name, num_channels); } /* report failure or do updates? */ - if (success == MODIFYKEY_INVALID_CONTEXT) { + if (num_channels == MODIFYKEY_INVALID_CONTEXT) { BKE_report(op->reports, RPT_ERROR, "No suitable context info for active keying set"); return OPERATOR_CANCELLED; } - else if (success) { + else if (num_channels) { /* if the appropriate properties have been set, make a note that we've inserted something */ if (RNA_boolean_get(op->ptr, "confirm_success")) { BKE_reportf(op->reports, RPT_INFO, "Successfully removed %d keyframes for keying set '%s'", - success, + num_channels, ks->name); } diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index d2e542772c2..721953f41c8 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -1030,7 +1030,7 @@ static eInsertKeyFlags keyingset_apply_keying_flags(const eInsertKeyFlags base_f * This takes into account many of the different combinations of using KeyingSets. * * \returns the number of channels that key-frames were added or - * #eModifyKey_Returns (a negative number). + * an #eModifyKey_Returns value (always a negative number). */ int ANIM_apply_keyingset( bContext *C, ListBase *dsources, bAction *act, KeyingSet *ks, short mode, float cfra) @@ -1043,7 +1043,7 @@ int ANIM_apply_keyingset( const eInsertKeyFlags base_kflags = ANIM_get_keyframing_flags(scene, true); const char *groupname = NULL; eInsertKeyFlags kflag = 0; - int success = 0; + int num_channels = 0; char keytype = scene->toolsettings->keyframe_type; /* sanity checks */ @@ -1131,20 +1131,20 @@ int ANIM_apply_keyingset( for (; i < arraylen; i++) { /* action to take depends on mode */ if (mode == MODIFYKEY_MODE_INSERT) { - success += insert_keyframe(bmain, - reports, - ksp->id, - act, - groupname, - ksp->rna_path, - i, - cfra, - keytype, - &nla_cache, - kflag2); + num_channels += insert_keyframe(bmain, + reports, + ksp->id, + act, + groupname, + ksp->rna_path, + i, + cfra, + keytype, + &nla_cache, + kflag2); } else if (mode == MODIFYKEY_MODE_DELETE) { - success += delete_keyframe(bmain, reports, ksp->id, act, ksp->rna_path, i, cfra); + num_channels += delete_keyframe(bmain, reports, ksp->id, act, ksp->rna_path, i, cfra); } } @@ -1170,7 +1170,8 @@ int ANIM_apply_keyingset( BKE_animsys_free_nla_keyframing_context_cache(&nla_cache); /* return the number of channels successfully affected */ - return success; + BLI_assert(num_channels >= 0); + return num_channels; } /* ************************************************** */ |