Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/animation')
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c263
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c295
-rw-r--r--source/blender/editors/animation/anim_deps.c45
-rw-r--r--source/blender/editors/animation/anim_draw.c51
-rw-r--r--source/blender/editors/animation/anim_filter.c213
-rw-r--r--source/blender/editors/animation/anim_ipo_utils.c39
-rw-r--r--source/blender/editors/animation/anim_markers.c87
-rw-r--r--source/blender/editors/animation/anim_motion_paths.c15
-rw-r--r--source/blender/editors/animation/anim_ops.c48
-rw-r--r--source/blender/editors/animation/drivers.c69
-rw-r--r--source/blender/editors/animation/fmodifier_ui.c57
-rw-r--r--source/blender/editors/animation/keyframes_draw.c69
-rw-r--r--source/blender/editors/animation/keyframes_edit.c225
-rw-r--r--source/blender/editors/animation/keyframes_general.c96
-rw-r--r--source/blender/editors/animation/keyframing.c234
-rw-r--r--source/blender/editors/animation/keyingsets.c129
16 files changed, 1289 insertions, 646 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index a17ee820595..bab76911449 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -298,8 +298,9 @@ static short acf_generic_indention_flexible(bAnimContext *UNUSED(ac), bAnimListE
FCurve *fcu = (FCurve *)ale->data;
// TODO: we need some way of specifying that the indention color should be one less...
- if (fcu->grp)
+ if (fcu->grp) {
indent++;
+ }
}
/* no indention */
@@ -311,10 +312,12 @@ static short acf_generic_basic_offset(bAnimContext *ac, bAnimListElem *ale)
{
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
- if (acf && acf->get_indent_level)
+ if (acf && acf->get_indent_level) {
return acf->get_indent_level(ac, ale) * INDENT_STEP_SIZE;
- else
+ }
+ else {
return 0;
+ }
}
/* offset based on nodetree type */
@@ -353,13 +356,15 @@ static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale)
offset += U.widget_unit;
}
/* materials and particles animdata */
- else if (ELEM(GS(ale->id->name), ID_MA, ID_PA))
+ else if (ELEM(GS(ale->id->name), ID_MA, ID_PA)) {
offset += (short)(0.7f * U.widget_unit);
- /* If not in Action Editor mode, action-groups (and their children)
+ /* If not in Action Editor mode, action-groups (and their children)
* must carry some offset too. */
- else if (ac->datatype != ANIMCONT_ACTION)
+ }
+ else if (ac->datatype != ANIMCONT_ACTION) {
offset += (short)(0.7f * U.widget_unit);
+ }
/* nodetree animdata */
if (GS(ale->id->name) == ID_NT) {
@@ -379,8 +384,9 @@ static void acf_generic_idblock_name(bAnimListElem *ale, char *name)
ID *id = (ID *)ale->data; /* data pointed to should be an ID block */
/* just copy the name... */
- if (id && name)
+ if (id && name) {
BLI_strncpy(name, id->name + 2, ANIM_CHAN_NAME_SIZE);
+ }
}
/* name property for ID block entries */
@@ -477,8 +483,9 @@ static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float ymi
/* name for summary entries */
static void acf_summary_name(bAnimListElem *UNUSED(ale), char *name)
{
- if (name)
+ if (name) {
BLI_strncpy(name, IFACE_("Dope Sheet Summary"), ANIM_CHAN_NAME_SIZE);
+ }
}
// FIXME: this is really a temp icon I think
@@ -636,8 +643,9 @@ static void *acf_scene_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (scene->adt)
+ if (scene->adt) {
return GET_ACF_FLAG_PTR(scene->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -711,8 +719,9 @@ static void acf_object_name(bAnimListElem *ale, char *name)
Object *ob = base->object;
/* just copy the name... */
- if (ob && name)
+ if (ob && name) {
BLI_strncpy(name, ob->id.name + 2, ANIM_CHAN_NAME_SIZE);
+ }
}
/* name property for object */
@@ -804,8 +813,9 @@ static void *acf_object_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings se
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
case ACHANNEL_SETTING_ALWAYS_VISIBLE:
- if (ob->adt)
+ if (ob->adt) {
return GET_ACF_FLAG_PTR(ob->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -844,20 +854,24 @@ static void acf_group_color(bAnimContext *ac, bAnimListElem *ale, float r_color[
unsigned char cp[3];
/* highlight only for active */
- if (ale->flag & AGRP_ACTIVE)
+ if (ale->flag & AGRP_ACTIVE) {
copy_v3_v3_char((char *)cp, agrp->cs.select);
- else
+ }
+ else {
copy_v3_v3_char((char *)cp, agrp->cs.solid);
+ }
/* copy the colors over, transforming from bytes to floats */
rgb_uchar_to_float(r_color, cp);
}
else {
/* highlight only for active */
- if (ale->flag & AGRP_ACTIVE)
+ if (ale->flag & AGRP_ACTIVE) {
UI_GetThemeColor3fv(TH_GROUP_ACTIVE, r_color);
- else
+ }
+ else {
UI_GetThemeColor3fv(TH_GROUP, r_color);
+ }
}
}
@@ -885,8 +899,9 @@ static void acf_group_name(bAnimListElem *ale, char *name)
bActionGroup *agrp = (bActionGroup *)ale->data;
/* just copy the name... */
- if (agrp && name)
+ if (agrp && name) {
BLI_strncpy(name, agrp->name, ANIM_CHAN_NAME_SIZE);
+ }
}
/* name property for group entries */
@@ -1039,10 +1054,12 @@ static bool acf_fcurve_setting_valid(bAnimContext *ac,
/* conditionally available */
case ACHANNEL_SETTING_PROTECT: /* Protection is only valid when there's keyframes */
- if (fcu->bezt)
+ if (fcu->bezt) {
return true;
- else
+ }
+ else {
return false; // NOTE: in this special case, we need to draw ICON_ZOOMOUT
+ }
case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */
return (ac->spacetype == SPACE_GRAPH);
@@ -1492,8 +1509,9 @@ static void *acf_dsmat_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (ma->adt)
+ if (ma->adt) {
return GET_ACF_FLAG_PTR(ma->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -1572,8 +1590,9 @@ static void *acf_dslight_setting_ptr(bAnimListElem *ale,
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (la->adt)
+ if (la->adt) {
return GET_ACF_FLAG_PTR(la->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -1657,8 +1676,9 @@ static void *acf_dstex_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (tex->adt)
+ if (tex->adt) {
return GET_ACF_FLAG_PTR(tex->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -1822,8 +1842,9 @@ static void *acf_dscam_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
case ACHANNEL_SETTING_ALWAYS_VISIBLE:
- if (ca->adt)
+ if (ca->adt) {
return GET_ACF_FLAG_PTR(ca->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -1910,8 +1931,9 @@ static void *acf_dscur_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (cu->adt)
+ if (cu->adt) {
return GET_ACF_FLAG_PTR(cu->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -1988,8 +2010,9 @@ static void *acf_dsskey_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings se
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (key->adt)
+ if (key->adt) {
return GET_ACF_FLAG_PTR(key->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2066,8 +2089,9 @@ static void *acf_dswor_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (wo->adt)
+ if (wo->adt) {
return GET_ACF_FLAG_PTR(wo->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2144,8 +2168,9 @@ static void *acf_dspart_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings se
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (part->adt)
+ if (part->adt) {
return GET_ACF_FLAG_PTR(part->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2224,8 +2249,9 @@ static void *acf_dsmball_setting_ptr(bAnimListElem *ale,
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (mb->adt)
+ if (mb->adt) {
return GET_ACF_FLAG_PTR(mb->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2302,8 +2328,9 @@ static void *acf_dsarm_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (arm->adt)
+ if (arm->adt) {
return GET_ACF_FLAG_PTR(arm->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2393,8 +2420,9 @@ static void *acf_dsntree_setting_ptr(bAnimListElem *ale,
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (ntree->adt)
+ if (ntree->adt) {
return GET_ACF_FLAG_PTR(ntree->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2473,8 +2501,9 @@ static void *acf_dslinestyle_setting_ptr(bAnimListElem *ale,
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (linestyle->adt)
+ if (linestyle->adt) {
return GET_ACF_FLAG_PTR(linestyle->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2551,8 +2580,9 @@ static void *acf_dsmesh_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings se
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (me->adt)
+ if (me->adt) {
return GET_ACF_FLAG_PTR(me->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2630,8 +2660,9 @@ static void *acf_dslat_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (lt->adt)
+ if (lt->adt) {
return GET_ACF_FLAG_PTR(lt->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2709,8 +2740,9 @@ static void *acf_dsspk_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (spk->adt)
+ if (spk->adt) {
return GET_ACF_FLAG_PTR(spk->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2789,8 +2821,9 @@ static void *acf_dsgpencil_setting_ptr(bAnimListElem *ale,
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (gpd->adt)
+ if (gpd->adt) {
return GET_ACF_FLAG_PTR(gpd->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2908,10 +2941,12 @@ static void acf_shapekey_name(bAnimListElem *ale, char *name)
/* just copy the name... */
if (kb && name) {
/* if the KeyBlock had a name, use it, otherwise use the index */
- if (kb->name[0])
+ if (kb->name[0]) {
BLI_strncpy(name, kb->name, ANIM_CHAN_NAME_SIZE);
- else
+ }
+ else {
BLI_snprintf(name, ANIM_CHAN_NAME_SIZE, IFACE_("Key %d"), ale->index);
+ }
}
}
@@ -3098,8 +3133,9 @@ static void acf_gpl_name(bAnimListElem *ale, char *name)
{
bGPDlayer *gpl = (bGPDlayer *)ale->data;
- if (gpl && name)
+ if (gpl && name) {
BLI_strncpy(name, gpl->info, ANIM_CHAN_NAME_SIZE);
+ }
}
/* name property for grease pencil layer entries */
@@ -3276,8 +3312,9 @@ static void acf_masklay_name(bAnimListElem *ale, char *name)
{
MaskLayer *masklay = (MaskLayer *)ale->data;
- if (masklay && name)
+ if (masklay && name) {
BLI_strncpy(name, masklay->name, ANIM_CHAN_NAME_SIZE);
+ }
}
/* name property for grease pencil layer entries */
@@ -3387,8 +3424,9 @@ static void acf_nlatrack_name(bAnimListElem *ale, char *name)
{
NlaTrack *nlt = (NlaTrack *)ale->data;
- if (nlt && name)
+ if (nlt && name) {
BLI_strncpy(name, nlt->name, ANIM_CHAN_NAME_SIZE);
+ }
}
/* name property for nla track entries */
@@ -3559,10 +3597,12 @@ static void acf_nlaaction_backdrop(bAnimContext *ac, bAnimListElem *ale, float y
*/
nla_action_get_color(adt, (bAction *)ale->data, color);
- if (adt && (adt->flag & ADT_NLA_EDIT_ON))
+ if (adt && (adt->flag & ADT_NLA_EDIT_ON)) {
color[3] = 1.0f;
- else
+ }
+ else {
color[3] = (adt && (adt->flag & ADT_NLA_SOLO_TRACK)) ? 0.3f : 1.0f;
+ }
/* only on top left corner, to show that this channel sits on top of the preceding ones
* while still linking into the action line strip to the right
@@ -3755,17 +3795,20 @@ static void ANIM_init_channel_typeinfo_data(void)
const bAnimChannelType *ANIM_channel_get_typeinfo(bAnimListElem *ale)
{
/* santiy checks */
- if (ale == NULL)
+ if (ale == NULL) {
return NULL;
+ }
/* init the typeinfo if not available yet... */
ANIM_init_channel_typeinfo_data();
/* check if type is in bounds... */
- if ((ale->type >= 0) && (ale->type < ANIMTYPE_NUM_TYPES))
+ if ((ale->type >= 0) && (ale->type < ANIMTYPE_NUM_TYPES)) {
return animchannelTypeInfo[ale->type];
- else
+ }
+ else {
return NULL;
+ }
}
/* --------------------------- */
@@ -3776,26 +3819,31 @@ void ANIM_channel_debug_print_info(bAnimListElem *ale, short indent_level)
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
/* print indents */
- for (; indent_level > 0; indent_level--)
+ for (; indent_level > 0; indent_level--) {
printf(" ");
+ }
/* print info */
if (acf) {
char name[ANIM_CHAN_NAME_SIZE]; /* hopefully this will be enough! */
/* get UI name */
- if (acf->name)
+ if (acf->name) {
acf->name(ale, name);
- else
+ }
+ else {
BLI_strncpy(name, "<No name>", sizeof(name));
+ }
/* print type name + ui name */
printf("ChanType: <%s> Name: \"%s\"\n", acf->channel_type_name, name);
}
- else if (ale)
+ else if (ale) {
printf("ChanType: <Unknown - %d>\n", ale->type);
- else
+ }
+ else {
printf("<Invalid channel - NULL>\n");
+ }
}
/* --------------------------- */
@@ -3825,28 +3873,34 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, eAnimChanne
{
const int *val = (int *)ptr;
- if (negflag)
+ if (negflag) {
return ((*val) & flag) == 0;
- else
+ }
+ else {
return ((*val) & flag) != 0;
+ }
}
case sizeof(short): /* short pointer for setting */
{
const short *val = (short *)ptr;
- if (negflag)
+ if (negflag) {
return ((*val) & flag) == 0;
- else
+ }
+ else {
return ((*val) & flag) != 0;
+ }
}
case sizeof(char): /* char pointer for setting */
{
const char *val = (char *)ptr;
- if (negflag)
+ if (negflag) {
return ((*val) & flag) == 0;
- else
+ }
+ else {
return ((*val) & flag) != 0;
+ }
}
}
}
@@ -3962,14 +4016,17 @@ void ANIM_channel_draw(
float y, ymid, ytext;
/* sanity checks - don't draw anything */
- if (ELEM(NULL, acf, ale))
+ if (ELEM(NULL, acf, ale)) {
return;
+ }
/* get initial offset */
- if (acf->get_offset)
+ if (acf->get_offset) {
offset = acf->get_offset(ac, ale);
- else
+ }
+ else {
offset = 0;
+ }
/* calculate appropriate y-coordinates for icon buttons */
y = (ymaxc - yminc) / 2 + yminc;
@@ -3978,10 +4035,12 @@ void ANIM_channel_draw(
ytext = y - 0.2f * U.widget_unit;
/* check if channel is selected */
- if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT))
+ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT)) {
selected = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT);
- else
+ }
+ else {
selected = 0;
+ }
/* set blending again, as may not be set in previous step */
GPU_blend_set_func_separate(
@@ -3989,8 +4048,9 @@ void ANIM_channel_draw(
GPU_blend(true);
/* step 1) draw backdrop ........................................... */
- if (acf->draw_backdrop)
+ if (acf->draw_backdrop) {
acf->draw_backdrop(ac, ale, yminc, ymaxc);
+ }
/* step 2) draw expand widget ....................................... */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_EXPAND)) {
@@ -4063,10 +4123,12 @@ void ANIM_channel_draw(
/* set text color */
/* XXX: if active, highlight differently? */
- if (selected)
+ if (selected) {
UI_GetThemeColor4ubv(TH_TEXT_HI, col);
- else
+ }
+ else {
UI_GetThemeColor4ubv(TH_TEXT, col);
+ }
/* get name */
acf->name(ale, name);
@@ -4132,25 +4194,30 @@ void ANIM_channel_draw(
/* check if there's enough space for the toggles if the sliders are drawn too */
if (!(draw_sliders) || (BLI_rcti_size_x(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2)) {
/* protect... */
- if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT))
+ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) {
offset += ICON_WIDTH;
+ }
/* mute... */
- if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE))
+ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE)) {
offset += ICON_WIDTH;
- if (ale->type == ANIMTYPE_GPLAYER)
+ }
+ if (ale->type == ANIMTYPE_GPLAYER) {
offset += ICON_WIDTH;
+ }
/* pinned... */
- if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PINNED))
+ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PINNED)) {
offset += ICON_WIDTH;
+ }
/* NOTE: technically, NLA Action "pushdown" should be here too,
* but there are no sliders there. */
/* NLA action channels have slightly different spacing requirements... */
- if (ale->type == ANIMTYPE_NLAACTION)
+ if (ale->type == ANIMTYPE_NLAACTION) {
ymin_ofs = NLACHANNEL_SKIP;
+ }
}
/* Draw slider:
@@ -4226,8 +4293,9 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void
}
/* verify animation context */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return;
+ }
/* check if the setting is on... */
on = ANIM_channel_setting_get(&ac, ale_setting, setting);
@@ -4304,8 +4372,9 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi
/* try to resolve the path stored in the F-Curve */
if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) {
/* set the special 'replace' flag if on a keyframe */
- if (fcurve_frame_has_keyframe(fcu, cfra, 0))
+ if (fcurve_frame_has_keyframe(fcu, cfra, 0)) {
flag |= INSERTKEY_REPLACE;
+ }
/* insert a keyframe for this F-Curve */
done = insert_keyframe_direct(
@@ -4363,20 +4432,23 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi
FCurve *fcu = verify_fcurve(bmain, act, NULL, &ptr, rna_path, 0, 1);
/* set the special 'replace' flag if on a keyframe */
- if (fcurve_frame_has_keyframe(fcu, cfra, 0))
+ if (fcurve_frame_has_keyframe(fcu, cfra, 0)) {
flag |= INSERTKEY_REPLACE;
+ }
/* insert a keyframe for this F-Curve */
done = insert_keyframe_direct(
depsgraph, reports, ptr, prop, fcu, cfra, ts->keyframe_type, nla_context, flag);
- if (done)
+ if (done) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
+ }
}
/* free the path */
- if (rna_path)
+ if (rna_path) {
MEM_freeN(rna_path);
+ }
BKE_animsys_free_nla_keyframing_context_cache(&nla_cache);
}
@@ -4413,15 +4485,17 @@ static void achannel_setting_slider_nla_curve_cb(bContext *C,
if (fcu && prop) {
/* set the special 'replace' flag if on a keyframe */
- if (fcurve_frame_has_keyframe(fcu, cfra, 0))
+ if (fcurve_frame_has_keyframe(fcu, cfra, 0)) {
flag |= INSERTKEY_REPLACE;
+ }
/* insert a keyframe for this F-Curve */
done = insert_keyframe_direct(
depsgraph, reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, flag);
- if (done)
+ if (done) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
+ }
}
}
@@ -4454,12 +4528,15 @@ static void draw_setting_widget(bAnimContext *ac,
//icon = ((enabled) ? ICON_VISIBLE_IPO_ON : ICON_VISIBLE_IPO_OFF);
icon = ICON_VISIBLE_IPO_OFF;
- if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE))
+ if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
tooltip = TIP_("F-Curve is visible in Graph Editor for editing");
- else if (ale->type == ANIMTYPE_GPLAYER)
+ }
+ else if (ale->type == ANIMTYPE_GPLAYER) {
tooltip = TIP_("Grease Pencil layer is visible in the viewport");
- else
+ }
+ else {
tooltip = TIP_("Channels are visible in Graph Editor for editing");
+ }
break;
case ACHANNEL_SETTING_ALWAYS_VISIBLE:
@@ -4493,10 +4570,12 @@ static void draw_setting_widget(bAnimContext *ac,
//icon = ((enabled) ? ICON_LOCKED : ICON_UNLOCKED);
icon = ICON_UNLOCKED;
- if (ale->datatype != ALE_NLASTRIP)
+ if (ale->datatype != ALE_NLASTRIP) {
tooltip = TIP_("Editability of keyframes for this channel");
- else
+ }
+ else {
tooltip = TIP_("Editability of NLA Strips in this track");
+ }
break;
case ACHANNEL_SETTING_MUTE: /* muted speaker */
@@ -4539,16 +4618,20 @@ static void draw_setting_widget(bAnimContext *ac,
/* type of button */
if (usetoggle) {
- if (negflag)
+ if (negflag) {
butType = UI_BTYPE_ICON_TOGGLE_N;
- else
+ }
+ else {
butType = UI_BTYPE_ICON_TOGGLE;
+ }
}
else {
- if (negflag)
+ if (negflag) {
butType = UI_BTYPE_TOGGLE_N;
- else
+ }
+ else {
butType = UI_BTYPE_TOGGLE;
+ }
}
/* draw button for setting */
if (ptr && flag) {
@@ -4662,8 +4745,9 @@ void ANIM_channel_draw_widgets(const bContext *C,
const bool is_being_renamed = achannel_is_being_renamed(ac, acf, channel_index);
/* sanity checks - don't draw anything */
- if (ELEM(NULL, acf, ale, block))
+ if (ELEM(NULL, acf, ale, block)) {
return;
+ }
/* get initial offset */
short offset = rect->xmin;
@@ -5002,15 +5086,18 @@ void ANIM_channel_draw_widgets(const bContext *C,
channel_height);
/* assign keyframing function according to slider type */
- if (ale->type == ANIMTYPE_SHAPEKEY)
+ if (ale->type == ANIMTYPE_SHAPEKEY) {
UI_but_func_set(but, achannel_setting_slider_shapekey_cb, ale->id, ale->data);
- else
+ }
+ else {
UI_but_func_set(but, achannel_setting_slider_cb, ale->id, ale->data);
+ }
}
/* free the path if necessary */
- if (free_path)
+ if (free_path) {
MEM_freeN(rna_path);
+ }
}
}
else { /* Special Slider for stuff without RNA Access ---------- */
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index d85457bbc4f..d0eb2d187fd 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -85,14 +85,16 @@ void ANIM_set_active_channel(bAnimContext *ac,
/* try to build list of filtered items */
ANIM_animdata_filter(ac, &anim_data, filter, data, datatype);
- if (BLI_listbase_is_empty(&anim_data))
+ if (BLI_listbase_is_empty(&anim_data)) {
return;
+ }
/* only clear the 'active' flag for the channels of the same type */
for (ale = anim_data.first; ale; ale = ale->next) {
/* skip if types don't match */
- if (channel_type != ale->type)
+ if (channel_type != ale->type) {
continue;
+ }
/* flag to set depends on type */
switch (ale->type) {
@@ -263,13 +265,15 @@ void ANIM_deselect_anim_channels(
/* See if we should be selecting or deselecting */
if (test) {
for (ale = anim_data.first; ale; ale = ale->next) {
- if (sel == 0)
+ if (sel == 0) {
break;
+ }
switch (ale->type) {
case ANIMTYPE_SCENE:
- if (ale->flag & SCE_DS_SELECTED)
+ if (ale->flag & SCE_DS_SELECTED) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
case ANIMTYPE_OBJECT:
#if 0 /* for now, do not take object selection into account, since it gets too annoying */
@@ -278,21 +282,25 @@ void ANIM_deselect_anim_channels(
#endif
break;
case ANIMTYPE_GROUP:
- if (ale->flag & AGRP_SELECTED)
+ if (ale->flag & AGRP_SELECTED) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
case ANIMTYPE_FCURVE:
case ANIMTYPE_NLACURVE:
- if (ale->flag & FCURVE_SELECTED)
+ if (ale->flag & FCURVE_SELECTED) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
case ANIMTYPE_SHAPEKEY:
- if (ale->flag & KEYBLOCK_SEL)
+ if (ale->flag & KEYBLOCK_SEL) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
case ANIMTYPE_NLATRACK:
- if (ale->flag & NLATRACK_SELECTED)
+ if (ale->flag & NLATRACK_SELECTED) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
case ANIMTYPE_FILLACTD: /* Action Expander */
@@ -314,17 +322,20 @@ void ANIM_deselect_anim_channels(
case ANIMTYPE_DSSPK:
case ANIMTYPE_DSGPENCIL:
case ANIMTYPE_DSMCLIP: {
- if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED))
+ if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
}
case ANIMTYPE_GPLAYER:
- if (ale->flag & GP_LAYER_SELECT)
+ if (ale->flag & GP_LAYER_SELECT) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
case ANIMTYPE_MASKLAYER:
- if (ale->flag & MASK_LAYERFLAG_SELECT)
+ if (ale->flag & MASK_LAYERFLAG_SELECT) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
}
}
@@ -451,8 +462,9 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
int prevLevel = 0, matchLevel = 0;
/* sanity check */
- if (ELEM(NULL, anim_data, anim_data->first))
+ if (ELEM(NULL, anim_data, anim_data->first)) {
return;
+ }
if (setting == ACHANNEL_SETTING_ALWAYS_VISIBLE) {
return;
@@ -508,8 +520,9 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
int level;
/* if no channel info was found, skip, since this type might not have any useful info */
- if (acf == NULL)
+ if (acf == NULL) {
continue;
+ }
/* get the level of the current channel traversed
* - we define the level as simply being the offset for the start of the channel
@@ -533,13 +546,15 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
/* if previous level was a base-level (i.e. 0 offset / root of one hierarchy),
* stop here
*/
- if (prevLevel == 0)
+ if (prevLevel == 0) {
break;
- /* otherwise, this level weaves into another sibling hierarchy to the previous one just
+ /* otherwise, this level weaves into another sibling hierarchy to the previous one just
* finished, so skip until we get to the parent of this level
*/
- else
+ }
+ else {
continue;
+ }
}
}
}
@@ -552,8 +567,9 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
int level;
/* if no channel info was found, skip, since this type might not have any useful info */
- if (acf == NULL)
+ if (acf == NULL) {
continue;
+ }
/* get the level of the current channel traversed
* - we define the level as simply being the offset for the start of the channel
@@ -563,14 +579,16 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
/* if the level is 'greater than' (i.e. less important) the channel that was changed,
* flush the new status...
*/
- if (level > matchLevel)
+ if (level > matchLevel) {
ANIM_channel_setting_set(ac, ale, setting, mode);
- /* however, if the level is 'less than or equal to' the channel that was changed,
+ /* however, if the level is 'less than or equal to' the channel that was changed,
* (i.e. the current channel is as important if not more important than the changed channel)
* then we should stop, since we've found the last one of the children we should flush
*/
- else
+ }
+ else {
break;
+ }
/* store this level as the 'old' level now */
// prevLevel = level; // XXX: prevLevel is unused
@@ -587,8 +605,9 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f
* (this doesn't guarantee that the F-Curve is in there, but at least we tried
* - if no F-Curve, there is nothing to remove
*/
- if (ELEM(NULL, adt, fcu))
+ if (ELEM(NULL, adt, fcu)) {
return;
+ }
/* remove from whatever list it came from
* - Action Group
@@ -650,11 +669,13 @@ static bool animedit_poll_channels_active(bContext *C)
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
- if (ELEM(NULL, sa, CTX_wm_region(C)))
+ if (ELEM(NULL, sa, CTX_wm_region(C))) {
return 0;
+ }
/* animation editor test */
- if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA) == 0)
+ if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA) == 0) {
return 0;
+ }
return 1;
}
@@ -667,16 +688,19 @@ static bool animedit_poll_channels_nla_tweakmode_off(bContext *C)
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
- if (ELEM(NULL, sa, CTX_wm_region(C)))
+ if (ELEM(NULL, sa, CTX_wm_region(C))) {
return 0;
+ }
/* animation editor test */
- if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA) == 0)
+ if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA) == 0) {
return 0;
+ }
/* NLA TweakMode test */
if (sa->spacetype == SPACE_NLA) {
- if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON))
+ if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON)) {
return 0;
+ }
}
return 1;
@@ -725,8 +749,9 @@ typedef enum eReorderIslandFlag {
static bool rearrange_island_ok(tReorderChannelIsland *island)
{
/* island must not be untouchable */
- if (island->flag & REORDER_ISLAND_UNTOUCHABLE)
+ if (island->flag & REORDER_ISLAND_UNTOUCHABLE) {
return 0;
+ }
/* island should be selected to be moved */
return (island->flag & REORDER_ISLAND_SELECTED) && !(island->flag & REORDER_ISLAND_MOVED);
@@ -917,12 +942,15 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands,
island = MEM_callocN(sizeof(tReorderChannelIsland), "tReorderChannelIsland");
BLI_addtail(islands, island);
- if (is_sel)
+ if (is_sel) {
island->flag |= REORDER_ISLAND_SELECTED;
- if (is_untouchable)
+ }
+ if (is_untouchable) {
island->flag |= REORDER_ISLAND_UNTOUCHABLE;
- if (is_hidden)
+ }
+ if (is_hidden) {
island->flag |= REORDER_ISLAND_HIDDEN;
+ }
}
/* add channel to island - need to remove it from its existing list first though */
@@ -987,8 +1015,9 @@ static bool rearrange_animchannel_islands(ListBase *list,
bool done = false;
/* don't waste effort on an empty list */
- if (BLI_listbase_is_empty(list))
+ if (BLI_listbase_is_empty(list)) {
return 0;
+ }
/* group channels into islands */
for (channel = list->first; channel; channel = chanNext) {
@@ -1044,8 +1073,9 @@ static void rearrange_nla_channels(bAnimContext *ac, AnimData *adt, eRearrangeAn
/* get rearranging function */
rearrange_func = rearrange_get_mode_func(mode);
- if (rearrange_func == NULL)
+ if (rearrange_func == NULL) {
return;
+ }
/* Filter visible data. */
rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_NLATRACK);
@@ -1071,12 +1101,14 @@ static void rearrange_driver_channels(bAnimContext *ac,
AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode);
ListBase anim_data_visible = {NULL, NULL};
- if (rearrange_func == NULL)
+ if (rearrange_func == NULL) {
return;
+ }
/* only consider drivers if they're accessible */
- if (EXPANDED_DRVD(adt) == 0)
+ if (EXPANDED_DRVD(adt) == 0) {
return;
+ }
/* Filter visible data. */
rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_FCURVE);
@@ -1097,8 +1129,9 @@ static void split_groups_action_temp(bAction *act, bActionGroup *tgrp)
bActionGroup *agrp;
FCurve *fcu;
- if (act == NULL)
+ if (act == NULL) {
return;
+ }
/* Separate F-Curves into lists per group */
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
@@ -1190,8 +1223,9 @@ static void rearrange_action_channels(bAnimContext *ac, bAction *act, eRearrange
/* get rearranging function */
AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode);
- if (rearrange_func == NULL)
+ if (rearrange_func == NULL) {
return;
+ }
/* make sure we're only operating with groups (vs a mixture of groups+curves) */
split_groups_action_temp(act, &tgrp);
@@ -1245,12 +1279,14 @@ static void rearrange_nla_control_channels(bAnimContext *ac,
/* get rearranging function */
AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode);
- if (rearrange_func == NULL)
+ if (rearrange_func == NULL) {
return;
+ }
/* skip if these curves aren't being shown */
- if (adt->flag & ADT_NLA_SKEYS_COLLAPSED)
+ if (adt->flag & ADT_NLA_SKEYS_COLLAPSED) {
return;
+ }
/* Filter visible data. */
rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_NLACURVE);
@@ -1278,8 +1314,9 @@ static void rearrange_gpencil_channels(bAnimContext *ac, eRearrangeAnimChan_Mode
/* get rearranging function */
AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode);
- if (rearrange_func == NULL)
+ if (rearrange_func == NULL) {
return;
+ }
/* get Grease Pencil datablocks */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA);
@@ -1291,8 +1328,9 @@ static void rearrange_gpencil_channels(bAnimContext *ac, eRearrangeAnimChan_Mode
/* only consider layers if this datablock is open */
BLI_assert(ale->type == ANIMTYPE_GPDATABLOCK);
- if ((gpd->flag & GP_DATA_EXPAND) == 0)
+ if ((gpd->flag & GP_DATA_EXPAND) == 0) {
continue;
+ }
/* Filter visible data. */
rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_GPLAYER);
@@ -1317,8 +1355,9 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op)
eRearrangeAnimChan_Mode mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get mode */
mode = RNA_enum_get(op->ptr, "direction");
@@ -1361,24 +1400,29 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op)
case ANIMCONT_ACTION: /* Single Action only... */
case ANIMCONT_SHAPEKEY: // DOUBLE CHECK ME...
{
- if (adt->action)
+ if (adt->action) {
rearrange_action_channels(&ac, adt->action, mode);
- else if (G.debug & G_DEBUG)
+ }
+ else if (G.debug & G_DEBUG) {
printf("Animdata has no action\n");
+ }
break;
}
default: /* DopeSheet/Graph Editor - Some Actions + NLA Control Curves */
{
/* NLA Control Curves */
- if (adt->nla_tracks.first)
+ if (adt->nla_tracks.first) {
rearrange_nla_control_channels(&ac, adt, mode);
+ }
/* Action */
- if (adt->action)
+ if (adt->action) {
rearrange_action_channels(&ac, adt->action, mode);
- else if (G.debug & G_DEBUG)
+ }
+ else if (G.debug & G_DEBUG) {
printf("Animdata has no action\n");
+ }
break;
}
}
@@ -1426,8 +1470,9 @@ static bool animchannels_grouping_poll(bContext *C)
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
- if (ELEM(NULL, sa, CTX_wm_region(C)))
+ if (ELEM(NULL, sa, CTX_wm_region(C))) {
return 0;
+ }
/* animation editor test - must be suitable modes only */
sl = CTX_wm_space_data(C);
@@ -1438,8 +1483,9 @@ static bool animchannels_grouping_poll(bContext *C)
SpaceAction *saction = (SpaceAction *)sl;
/* dopesheet and action only - all others are for other datatypes or have no groups */
- if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_DOPESHEET) == 0)
+ if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_DOPESHEET) == 0) {
return 0;
+ }
break;
}
@@ -1447,8 +1493,9 @@ static bool animchannels_grouping_poll(bContext *C)
SpaceGraph *sipo = (SpaceGraph *)sl;
/* drivers can't have groups... */
- if (sipo->mode != SIPO_MODE_ANIMATION)
+ if (sipo->mode != SIPO_MODE_ANIMATION) {
return 0;
+ }
break;
}
@@ -1513,8 +1560,9 @@ static int animchannels_group_exec(bContext *C, wmOperator *op)
char name[MAX_NAME];
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get name for new group */
RNA_string_get(op->ptr, "name", name);
@@ -1581,8 +1629,9 @@ static int animchannels_ungroup_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* just selected F-Curves... */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL |
@@ -1666,12 +1715,14 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* cannot delete in shapekey */
- if (ac.datatype == ANIMCONT_SHAPEKEY)
+ if (ac.datatype == ANIMCONT_SHAPEKEY) {
return OPERATOR_CANCELLED;
+ }
/* do groups only first (unless in Drivers mode, where there are none) */
if (ac.datatype != ANIMCONT_DRIVERS) {
@@ -1689,8 +1740,9 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
FCurve *fcu, *fcn;
/* skip this group if no AnimData available, as we can't safely remove the F-Curves */
- if (adt == NULL)
+ if (adt == NULL) {
continue;
+ }
/* delete all of the Group's F-Curves, but no others */
for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcn) {
@@ -1706,8 +1758,9 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
BLI_freelinkN(&adt->action->groups, agrp);
DEG_id_tag_update_ex(CTX_data_main(C), &adt->action->id, ID_RECALC_ANIMATION);
}
- else
+ else {
MEM_freeN(agrp);
+ }
}
}
@@ -1867,8 +1920,9 @@ static void setflag_anim_channels(bAnimContext *ac,
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS |
ANIMFILTER_NODUPLIS);
}
- if (onlysel)
+ if (onlysel) {
filter |= ANIMFILTER_SEL;
+ }
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
/* if toggling, check if disable or enable */
@@ -1889,15 +1943,17 @@ static void setflag_anim_channels(bAnimContext *ac,
/* apply the setting */
for (ale = anim_data.first; ale; ale = ale->next) {
/* skip channel if setting is not available */
- if (ANIM_channel_setting_get(ac, ale, setting) == -1)
+ if (ANIM_channel_setting_get(ac, ale, setting) == -1) {
continue;
+ }
/* set the setting in the appropriate way */
ANIM_channel_setting_set(ac, ale, setting, mode);
/* if flush status... */
- if (flush)
+ if (flush) {
ANIM_flush_setting_anim_channels(ac, &all_data, ale, setting, mode);
+ }
}
ANIM_animdata_freelist(&anim_data);
@@ -1914,16 +1970,18 @@ static int animchannels_setflag_exec(bContext *C, wmOperator *op)
bool flush = true;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* mode (eAnimChannels_SetFlag), setting (eAnimChannel_Settings) */
mode = RNA_enum_get(op->ptr, "mode");
setting = RNA_enum_get(op->ptr, "type");
/* check if setting is flushable */
- if (setting == ACHANNEL_SETTING_EXPAND)
+ if (setting == ACHANNEL_SETTING_EXPAND) {
flush = false;
+ }
/* modify setting
* - only selected channels are affected
@@ -2049,12 +2107,14 @@ static int animchannels_expand_exec(bContext *C, wmOperator *op)
bool onlysel = true;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* only affect selected channels? */
- if (RNA_boolean_get(op->ptr, "all"))
+ if (RNA_boolean_get(op->ptr, "all")) {
onlysel = false;
+ }
/* modify setting */
setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_ADD, onlysel, false);
@@ -2092,12 +2152,14 @@ static int animchannels_collapse_exec(bContext *C, wmOperator *op)
bool onlysel = true;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* only affect selected channels? */
- if (RNA_boolean_get(op->ptr, "all"))
+ if (RNA_boolean_get(op->ptr, "all")) {
onlysel = false;
+ }
/* modify setting */
setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_CLEAR, onlysel, false);
@@ -2148,8 +2210,9 @@ static int animchannels_clean_empty_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get animdata blocks */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA);
@@ -2241,12 +2304,14 @@ static bool animchannels_enable_poll(bContext *C)
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
- if (ELEM(NULL, sa, CTX_wm_region(C)))
+ if (ELEM(NULL, sa, CTX_wm_region(C))) {
return 0;
+ }
/* animation editor test - Action/Dopesheet/etc. and Graph only */
- if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH) == 0)
+ if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH) == 0) {
return 0;
+ }
return 1;
}
@@ -2260,8 +2325,9 @@ static int animchannels_enable_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS);
@@ -2275,8 +2341,9 @@ static int animchannels_enable_exec(bContext *C, wmOperator *UNUSED(op))
fcu->flag &= ~FCURVE_DISABLED;
/* for drivers, let's do the same too */
- if (fcu->driver)
+ if (fcu->driver) {
fcu->driver->flag &= ~DRIVER_FLAG_INVALID;
+ }
/* tag everything for updates - in particular, this is needed to get drivers working again */
ale->update |= ANIM_UPDATE_DEPS;
@@ -2313,8 +2380,9 @@ static bool animchannels_find_poll(bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
- if (sa == NULL)
+ if (sa == NULL) {
return 0;
+ }
/* animation editor with dopesheet */
return ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA);
@@ -2326,8 +2394,9 @@ static int animchannels_find_invoke(bContext *C, wmOperator *op, const wmEvent *
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* set initial filter text, and enable filter */
RNA_string_set(op->ptr, "query", ac.ads->searchstr);
@@ -2342,8 +2411,9 @@ static int animchannels_find_exec(bContext *C, wmOperator *op)
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* update filter text */
RNA_string_get(op->ptr, "query", ac.ads->searchstr);
@@ -2385,8 +2455,9 @@ static int animchannels_deselectall_exec(bContext *C, wmOperator *op)
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* 'standard' behavior - check if selected, then apply relevant selection */
const int action = RNA_enum_get(op->ptr, "action");
@@ -2465,10 +2536,12 @@ static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectm
/* loop over data, doing box select */
for (ale = anim_data.first; ale; ale = ale->next) {
- if (ac->datatype == ANIMCONT_NLA)
+ if (ac->datatype == ANIMCONT_NLA) {
ymin = ymax - NLACHANNEL_STEP(snla);
- else
+ }
+ else {
ymin = ymax - ACHANNEL_STEP(ac);
+ }
/* if channel is within border-select region, alter it */
if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))) {
@@ -2515,8 +2588,9 @@ static int animchannels_box_select_exec(bContext *C, wmOperator *op)
const bool extend = RNA_boolean_get(op->ptr, "extend");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get settings from operator */
WM_operator_properties_border_to_rcti(op, &rect);
@@ -2583,9 +2657,10 @@ static bool rename_anim_channels(bAnimContext *ac, int channel_index)
ale = BLI_findlink(&anim_data, channel_index);
if (ale == NULL) {
/* channel not found */
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: animation channel (index = %d) not found in rename_anim_channels()\n",
channel_index);
+ }
ANIM_animdata_freelist(&anim_data);
return false;
@@ -2678,17 +2753,20 @@ static int animchannels_rename_invoke(bContext *C, wmOperator *UNUSED(op), const
int channel_index;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
channel_index = animchannels_channel_get(&ac, event->mval);
/* handle click */
- if (rename_anim_channels(&ac, channel_index))
+ if (rename_anim_channels(&ac, channel_index)) {
return OPERATOR_FINISHED;
- else
+ }
+ else {
/* allow event to be handled by selectall operator */
return OPERATOR_PASS_THROUGH;
+ }
}
static void ANIM_OT_channels_rename(wmOperatorType *ot)
@@ -2722,9 +2800,10 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
ale = BLI_findlink(&anim_data, channel_index);
if (ale == NULL) {
/* channel not found */
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: animation channel (index = %d) not found in mouse_anim_channels()\n",
channel_index);
+ }
ANIM_animdata_freelist(&anim_data);
return 0;
@@ -2750,13 +2829,15 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
if (selectmode == SELECT_INVERT) {
/* swap select */
sce->flag ^= SCE_DS_SELECTED;
- if (adt)
+ if (adt) {
adt->flag ^= ADT_UI_SELECTED;
+ }
}
else {
sce->flag |= SCE_DS_SELECTED;
- if (adt)
+ if (adt) {
adt->flag |= ADT_UI_SELECTED;
+ }
}
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
@@ -2779,8 +2860,9 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
ED_object_base_select(base, BA_INVERT);
BKE_scene_object_base_flag_sync_from_base(base);
- if (adt)
+ if (adt) {
adt->flag ^= ADT_UI_SELECTED;
+ }
}
else {
Base *b;
@@ -2790,22 +2872,25 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
for (b = view_layer->object_bases.first; b; b = b->next) {
ED_object_base_select(b, BA_DESELECT);
BKE_scene_object_base_flag_sync_from_base(b);
- if (b->object->adt)
+ if (b->object->adt) {
b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE);
+ }
}
/* select object now */
ED_object_base_select(base, BA_SELECT);
BKE_scene_object_base_flag_sync_from_base(base);
- if (adt)
+ if (adt) {
adt->flag |= ADT_UI_SELECTED;
+ }
}
/* change active object - regardless of whether it is now selected [T37883] */
ED_object_base_activate(C, base); /* adds notifier */
- if ((adt) && (adt->flag & ADT_UI_SELECTED))
+ if ((adt) && (adt->flag & ADT_UI_SELECTED)) {
adt->flag |= ADT_UI_ACTIVE;
+ }
/* Ensure we exit editmode on whatever object was active before
* to avoid getting stuck there - T48747. */
@@ -2850,8 +2935,9 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
}
/* set active? */
- if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED))
+ if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) {
ale->adt->flag |= ADT_UI_ACTIVE;
+ }
}
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
@@ -2899,19 +2985,22 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
/* deselect all other channels */
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
- if (pchan)
+ if (pchan) {
ED_pose_deselect_all(ob, SEL_DESELECT, false);
+ }
/* only select channels in group and group itself */
- for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next)
+ for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) {
fcu->flag |= FCURVE_SELECTED;
+ }
agrp->flag |= AGRP_SELECTED;
}
else {
/* select group by itself */
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
- if (pchan)
+ if (pchan) {
ED_pose_deselect_all(ob, SEL_DESELECT, false);
+ }
agrp->flag |= AGRP_SELECTED;
}
@@ -2919,13 +3008,15 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
/* if group is selected now, make group the 'active' one in the visible list */
if (agrp->flag & AGRP_SELECTED) {
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP);
- if (pchan)
+ if (pchan) {
ED_pose_bone_select(ob, pchan, true);
+ }
}
else {
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, NULL, ANIMTYPE_GROUP);
- if (pchan)
+ if (pchan) {
ED_pose_bone_select(ob, pchan, false);
+ }
}
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
@@ -2947,8 +3038,9 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
}
/* if F-Curve is selected now, make F-Curve the 'active' one in the visible list */
- if (fcu->flag & FCURVE_SELECTED)
+ if (fcu->flag & FCURVE_SELECTED) {
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ale->type);
+ }
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
break;
@@ -3052,8 +3144,9 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
break;
}
default:
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: Invalid channel type in mouse_anim_channels()\n");
+ }
break;
}
@@ -3078,8 +3171,9 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmE
float x, y;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get useful pointers from animation context data */
ar = ac.ar;
@@ -3169,9 +3263,10 @@ static bool select_anim_channel_keys(bAnimContext *ac, int channel_index, bool e
ale = BLI_findlink(&anim_data, channel_index);
if (ale == NULL) {
/* channel not found */
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: animation channel (index = %d) not found in rename_anim_channels()\n",
channel_index);
+ }
ANIM_animdata_freelist(&anim_data);
return false;
@@ -3221,8 +3316,9 @@ static int animchannels_channel_select_keys_invoke(bContext *C,
bool extend = RNA_boolean_get(op->ptr, "extend");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
channel_index = animchannels_channel_get(&ac, event->mval);
@@ -3231,9 +3327,10 @@ static int animchannels_channel_select_keys_invoke(bContext *C,
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
- else
+ else {
/* allow event to be handled by selectall operator */
return OPERATOR_PASS_THROUGH;
+ }
}
static void ANIM_OT_channel_select_keys(wmOperatorType *ot)
diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c
index 5d25d732fe8..d7fe326f2ee 100644
--- a/source/blender/editors/animation/anim_deps.c
+++ b/source/blender/editors/animation/anim_deps.c
@@ -63,8 +63,9 @@ void ANIM_list_elem_update(Main *bmain, Scene *scene, bAnimListElem *ale)
AnimData *adt;
id = ale->id;
- if (!id)
+ if (!id) {
return;
+ }
/* tag AnimData for refresh so that other views will update in realtime with these changes */
adt = BKE_animdata_from_id(id);
@@ -97,8 +98,9 @@ void ANIM_list_elem_update(Main *bmain, Scene *scene, bAnimListElem *ale)
RNA_id_pointer_create(id, &id_ptr);
- if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop))
+ if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) {
RNA_property_update_main(bmain, scene, &ptr, prop);
+ }
}
else {
/* in other case we do standard depsgraph update, ideally
@@ -141,8 +143,9 @@ static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGro
/* major priority is selection status
* so we need both a group and an owner
*/
- if (ELEM(NULL, agrp, owner_id))
+ if (ELEM(NULL, agrp, owner_id)) {
return;
+ }
/* for standard Objects, check if group is the name of some bone */
if (GS(owner_id->name) == ID_OB) {
@@ -160,10 +163,12 @@ static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGro
bActionGroup *bgrp;
/* if one matches, sync the selection status */
- if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED))
+ if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) {
agrp->flag |= AGRP_SELECTED;
- else
+ }
+ else {
agrp->flag &= ~AGRP_SELECTED;
+ }
/* also sync active group status */
if ((ob == ac->obact) && (pchan->bone == arm->act_bone)) {
@@ -204,8 +209,9 @@ static void animchan_sync_fcurve(bAnimContext *UNUSED(ac),
/* major priority is selection status, so refer to the checks done in anim_filter.c
* skip_fcurve_selected_data() for reference about what's going on here...
*/
- if (ELEM(NULL, fcu, fcu->rna_path, owner_id))
+ if (ELEM(NULL, fcu, fcu->rna_path, owner_id)) {
return;
+ }
if (GS(owner_id->name) == ID_SCE) {
Scene *scene = (Scene *)owner_id;
@@ -219,15 +225,18 @@ static void animchan_sync_fcurve(bAnimContext *UNUSED(ac),
/* get strip name, and check if this strip is selected */
seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all[");
seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, false);
- if (seq_name)
+ if (seq_name) {
MEM_freeN(seq_name);
+ }
/* update selection status */
if (seq) {
- if (seq->flag & SELECT)
+ if (seq->flag & SELECT) {
fcu->flag |= FCURVE_SELECTED;
- else
+ }
+ else {
fcu->flag &= ~FCURVE_SELECTED;
+ }
}
}
}
@@ -242,16 +251,19 @@ static void animchan_sync_fcurve(bAnimContext *UNUSED(ac),
/* get strip name, and check if this strip is selected */
node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes[");
node = nodeFindNodebyName(ntree, node_name);
- if (node_name)
+ if (node_name) {
MEM_freeN(node_name);
+ }
/* update selection/active status */
if (node) {
/* update selection status */
- if (node->flag & NODE_SELECT)
+ if (node->flag & NODE_SELECT) {
fcu->flag |= FCURVE_SELECTED;
- else
+ }
+ else {
fcu->flag &= ~FCURVE_SELECTED;
+ }
/* update active status */
/* XXX: this may interfere with setting bones as active if both exist at once;
@@ -311,8 +323,9 @@ void ANIM_sync_animchannels_to_data(const bContext *C)
FCurve *active_fcurve = NULL;
/* get animation context info for filtering the channels */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return;
+ }
/* filter data */
@@ -382,14 +395,16 @@ void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data)
if (ale->update & ANIM_UPDATE_ORDER) {
ale->update &= ~ANIM_UPDATE_ORDER;
- if (fcu)
+ if (fcu) {
sort_time_fcurve(fcu);
+ }
}
if (ale->update & ANIM_UPDATE_HANDLES) {
ale->update &= ~ANIM_UPDATE_HANDLES;
- if (fcu)
+ if (fcu) {
calchandles_fcurve(fcu);
+ }
}
if (ale->update & ANIM_UPDATE_DEPS) {
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index bf6dfe3938b..d5116858970 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -237,12 +237,14 @@ void ANIM_draw_framerange(Scene *scene, View2D *v2d)
AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale)
{
/* sanity checks */
- if (ac == NULL)
+ if (ac == NULL) {
return NULL;
+ }
/* abort if rendering - we may get some race condition issues... */
- if (G.is_rendering)
+ if (G.is_rendering) {
return NULL;
+ }
/* apart from strictly keyframe-related contexts, this shouldn't even happen */
// XXX: nla and channel here may not be necessary...
@@ -257,8 +259,9 @@ AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale)
if (ale) {
/* NLA Control Curves occur on NLA strips,
* and shouldn't be subjected to this kind of mapping. */
- if (ale->type != ANIMTYPE_NLACURVE)
+ if (ale->type != ANIMTYPE_NLACURVE) {
return ale->adt;
+ }
}
}
@@ -323,10 +326,12 @@ void ANIM_nla_mapping_apply_fcurve(AnimData *adt, FCurve *fcu, bool restore, boo
ked.i1 = (int)only_keys;
/* get editing callback */
- if (restore)
+ if (restore) {
map_cb = bezt_nlamapping_restore;
- else
+ }
+ else {
map_cb = bezt_nlamapping_apply;
+ }
/* apply to F-Curve */
ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, map_cb, NULL);
@@ -355,15 +360,17 @@ static float normalization_factor_get(Scene *scene, FCurve *fcu, short flag, flo
float factor = 1.0f, offset = 0.0f;
if (flag & ANIM_UNITCONV_RESTORE) {
- if (r_offset)
+ if (r_offset) {
*r_offset = fcu->prev_offset;
+ }
return 1.0f / fcu->prev_norm_factor;
}
if (flag & ANIM_UNITCONV_NORMALIZE_FREEZE) {
- if (r_offset)
+ if (r_offset) {
*r_offset = fcu->prev_offset;
+ }
if (fcu->prev_norm_factor == 0.0f) {
/* Happens when Auto Normalize was disabled before
* any curves were displayed.
@@ -374,8 +381,9 @@ static float normalization_factor_get(Scene *scene, FCurve *fcu, short flag, flo
}
if (G.moving & G_TRANSFORM_FCURVES) {
- if (r_offset)
+ if (r_offset) {
*r_offset = fcu->prev_offset;
+ }
if (fcu->prev_norm_factor == 0.0f) {
/* Same as above. */
return 1.0f;
@@ -499,8 +507,9 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short flag
return normalization_factor_get(scene, fcu, flag, r_offset);
}
- if (r_offset)
+ if (r_offset) {
*r_offset = 0.0f;
+ }
/* sanity checks */
if (id && fcu && fcu->rna_path) {
@@ -514,10 +523,12 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short flag
if (RNA_SUBTYPE_UNIT(RNA_property_subtype(prop)) == PROP_UNIT_ROTATION) {
/* if the radians flag is not set, default to using degrees which need conversions */
if ((scene) && (scene->unit.system_rotation == USER_UNIT_ROT_RADIANS) == 0) {
- if (flag & ANIM_UNITCONV_RESTORE)
+ if (flag & ANIM_UNITCONV_RESTORE) {
return DEG2RADF(1.0f); /* degrees to radians */
- else
+ }
+ else {
return RAD2DEGF(1.0f); /* radians to degrees */
+ }
}
}
@@ -577,8 +588,9 @@ static bool find_prev_next_keyframes(struct bContext *C, int *nextfra, int *prev
}
else {
/* this changes the frame, so set the frame and we're done */
- if (++nextcount == U.view_frame_keyframes)
+ if (++nextcount == U.view_frame_keyframes) {
donenext = true;
+ }
}
cfranext = aknext->cfra;
}
@@ -593,8 +605,9 @@ static bool find_prev_next_keyframes(struct bContext *C, int *nextfra, int *prev
}
else {
/* this changes the frame, so set the frame and we're done */
- if (++prevcount == U.view_frame_keyframes)
+ if (++prevcount == U.view_frame_keyframes) {
doneprev = true;
+ }
}
cfraprev = akprev->cfra;
}
@@ -605,15 +618,19 @@ static bool find_prev_next_keyframes(struct bContext *C, int *nextfra, int *prev
/* any success? */
if (doneprev || donenext) {
- if (doneprev)
+ if (doneprev) {
*prevfra = cfraprev;
- else
+ }
+ else {
*prevfra = CFRA - (cfranext - CFRA);
+ }
- if (donenext)
+ if (donenext) {
*nextfra = cfranext;
- else
+ }
+ else {
*nextfra = CFRA + (CFRA - cfraprev);
+ }
return true;
}
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 41d23eb31ba..674f530894d 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -114,8 +114,9 @@ static void animedit_get_yscale_factor(bAnimContext *ac)
ac->yscale_fac = btheme->space_action.keyframe_scale_fac;
/* clamp to avoid problems with uninitialised values... */
- if (ac->yscale_fac < 0.1f)
+ if (ac->yscale_fac < 0.1f) {
ac->yscale_fac = 1.0f;
+ }
//printf("yscale_fac = %f\n", ac->yscale_fac);
}
@@ -130,8 +131,9 @@ static Key *actedit_get_shapekeys(bAnimContext *ac)
Key *key;
ob = OBACT(view_layer);
- if (ob == NULL)
+ if (ob == NULL) {
return NULL;
+ }
/* XXX pinning is not available in 'ShapeKey' mode... */
//if (saction->pin) return NULL;
@@ -140,8 +142,9 @@ static Key *actedit_get_shapekeys(bAnimContext *ac)
key = BKE_key_from_object(ob);
if (key) {
- if (key->type == KEY_RELATIVE)
+ if (key->type == KEY_RELATIVE) {
return key;
+ }
}
return NULL;
@@ -158,10 +161,12 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction)
case SACTCONT_ACTION: /* 'Action Editor' */
/* if not pinned, sync with active object */
if (/*saction->pin == 0*/ true) {
- if (ac->obact && ac->obact->adt)
+ if (ac->obact && ac->obact->adt) {
saction->action = ac->obact->adt->action;
- else
+ }
+ else {
saction->action = NULL;
+ }
}
ac->datatype = ANIMCONT_ACTION;
@@ -178,10 +183,12 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction)
if (/*saction->pin == 0*/ true) {
Key *key = (Key *)ac->data;
- if (key && key->adt)
+ if (key && key->adt) {
saction->action = key->adt->action;
- else
+ }
+ else {
saction->action = NULL;
+ }
}
ac->mode = saction->mode;
@@ -246,10 +253,12 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction)
* dopesheet filters (i.e. we'd have to figure out where to host those settings,
* to be on a scene level like this flag currently is, along with several other unknowns).
*/
- if (ac->scene->flag & SCE_KEYS_NO_SELONLY)
+ if (ac->scene->flag & SCE_KEYS_NO_SELONLY) {
saction->ads.filterflag &= ~ADS_FILTER_ONLYSEL;
- else
+ }
+ else {
saction->ads.filterflag |= ADS_FILTER_ONLYSEL;
+ }
ac->datatype = ANIMCONT_TIMELINE;
ac->data = &saction->ads;
@@ -279,10 +288,12 @@ static bool graphedit_get_context(bAnimContext *ac, SpaceGraph *sipo)
ac->ads = sipo->ads;
/* set settings for Graph Editor - "Selected = Editable" */
- if (sipo->flag & SIPO_SELCUVERTSONLY)
+ if (sipo->flag & SIPO_SELCUVERTSONLY) {
sipo->ads->filterflag |= ADS_FILTER_SELEDIT;
- else
+ }
+ else {
sipo->ads->filterflag &= ~ADS_FILTER_SELEDIT;
+ }
/* sync settings with current view status, then return appropriate data */
switch (sipo->mode) {
@@ -323,8 +334,9 @@ static bool graphedit_get_context(bAnimContext *ac, SpaceGraph *sipo)
static bool nlaedit_get_context(bAnimContext *ac, SpaceNla *snla)
{
/* init dopesheet data if non-existent (i.e. for old files) */
- if (snla->ads == NULL)
+ if (snla->ads == NULL) {
snla->ads = MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet");
+ }
ac->ads = snla->ads;
/* sync settings with current view status, then return appropriate data */
@@ -389,8 +401,9 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
Scene *scene = CTX_data_scene(C);
/* clear old context info */
- if (ac == NULL)
+ if (ac == NULL) {
return false;
+ }
memset(ac, 0, sizeof(bAnimContext));
/* get useful default context settings from context */
@@ -992,8 +1005,9 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
/* get bone-name, and check if this bone is selected */
bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
- if (bone_name)
+ if (bone_name) {
MEM_freeN(bone_name);
+ }
/* check whether to continue or skip */
if ((pchan) && (pchan->bone)) {
@@ -1003,17 +1017,20 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
bArmature *arm = (bArmature *)ob->data;
/* skipping - not visible on currently visible layers */
- if ((arm->layer & pchan->bone->layer) == 0)
+ if ((arm->layer & pchan->bone->layer) == 0) {
return true;
+ }
/* skipping - is currently hidden */
- if (pchan->bone->flag & BONE_HIDDEN_P)
+ if (pchan->bone->flag & BONE_HIDDEN_P) {
return true;
+ }
}
/* can only add this F-Curve if it is selected */
if (ads->filterflag & ADS_FILTER_ONLYSEL) {
- if ((pchan->bone->flag & BONE_SELECTED) == 0)
+ if ((pchan->bone->flag & BONE_SELECTED) == 0) {
return true;
+ }
}
}
}
@@ -1031,14 +1048,16 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
/* get strip name, and check if this strip is selected */
seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all[");
seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, false);
- if (seq_name)
+ if (seq_name) {
MEM_freeN(seq_name);
+ }
}
/* can only add this F-Curve if it is selected */
if (ads->filterflag & ADS_FILTER_ONLYSEL) {
- if ((seq == NULL) || (seq->flag & SELECT) == 0)
+ if ((seq == NULL) || (seq->flag & SELECT) == 0) {
return true;
+ }
}
}
}
@@ -1053,13 +1072,15 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
/* get strip name, and check if this strip is selected */
node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes[");
node = nodeFindNodebyName(ntree, node_name);
- if (node_name)
+ if (node_name) {
MEM_freeN(node_name);
+ }
/* can only add this F-Curve if it is selected */
if (ads->filterflag & ADS_FILTER_ONLYSEL) {
- if ((node) && (node->flag & NODE_SELECT) == 0)
+ if ((node) && (node->flag & NODE_SELECT) == 0) {
return true;
+ }
}
}
}
@@ -1151,15 +1172,17 @@ static bool fcurve_has_errors(FCurve *fcu)
* BUT this may not hold with PyDrivers as this flag gets cleared
* if no critical errors prevent the driver from working...
*/
- if (driver->flag & DRIVER_FLAG_INVALID)
+ if (driver->flag & DRIVER_FLAG_INVALID) {
return true;
+ }
/* check variables for other things that need linting... */
// TODO: maybe it would be more efficient just to have a quick flag for this?
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) {
- if (dtar->flag & DTAR_FLAG_INVALID)
+ if (dtar->flag & DTAR_FLAG_INVALID) {
return true;
+ }
}
DRIVER_TARGETS_LOOPER_END;
}
@@ -1198,8 +1221,9 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads,
if ((filter_mode & ANIMFILTER_TMP_IGNORE_ONLYSEL) == 0) {
if ((ads->filterflag & ADS_FILTER_ONLYSEL) ||
(ads->filterflag & ADS_FILTER_INCL_HIDDEN) == 0) {
- if (skip_fcurve_selected_data(ads, fcu, owner_id, filter_mode))
+ if (skip_fcurve_selected_data(ads, fcu, owner_id, filter_mode)) {
continue;
+ }
}
}
}
@@ -1215,15 +1239,17 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads,
if (!(filter_mode & ANIMFILTER_ACTIVE) || (fcu->flag & FCURVE_ACTIVE)) {
/* name based filtering... */
if (((ads) && (ads->searchstr[0] != '\0')) && (owner_id)) {
- if (skip_fcurve_with_name(ads, fcu, channel_type, owner, owner_id))
+ if (skip_fcurve_with_name(ads, fcu, channel_type, owner, owner_id)) {
continue;
+ }
}
/* error-based filtering... */
if ((ads) && (ads->filterflag & ADS_FILTER_ONLY_ERRORS)) {
/* skip if no errors... */
- if (fcurve_has_errors(fcu) == false)
+ if (fcurve_has_errors(fcu) == false) {
continue;
+ }
}
/* this F-Curve can be used, so return it */
@@ -1309,8 +1335,9 @@ static size_t animfilter_act_group(bAnimContext *ac,
(filter_mode & (ANIMFILTER_SEL | ANIMFILTER_UNSEL))) {
/* If the group itself isn't selected appropriately,
* we shouldn't consider it's children either. */
- if (ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) == 0)
+ if (ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) == 0) {
return 0;
+ }
/* if we're still here,
* then the selection status of the curves within this group should not matter,
@@ -1386,15 +1413,17 @@ static size_t animfilter_action(bAnimContext *ac,
/* don't include anything from this action if it is linked in from another file,
* and we're getting stuff for editing...
*/
- if ((filter_mode & ANIMFILTER_FOREDIT) && ID_IS_LINKED(act))
+ if ((filter_mode & ANIMFILTER_FOREDIT) && ID_IS_LINKED(act)) {
return 0;
+ }
/* do groups */
// TODO: do nested groups?
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
/* store reference to last channel of group */
- if (agrp->channels.last)
+ if (agrp->channels.last) {
lastchan = agrp->channels.last;
+ }
/* action group's channels */
items += animfilter_act_group(ac, anim_data, ads, act, agrp, filter_mode, owner_id);
@@ -1462,10 +1491,12 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac),
* assume that the caller of this has already checked that these should be included */
for (nlt = first; nlt; nlt = next) {
/* 'next' NLA-Track to use depends on whether we're filtering for drawing or not */
- if (filter_mode & ANIMFILTER_LIST_CHANNELS)
+ if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
next = nlt->prev;
- else
+ }
+ else {
next = nlt->next;
+ }
/* if we're in NLA-tweakmode, don't show this track if it was disabled (due to tweaking) for now
* - active track should still get shown though (even though it has disabled flag set)
@@ -1473,8 +1504,9 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac),
// FIXME: the channels after should still get drawn, just 'differently',
// and after an active-action channel.
if ((adt->flag & ADT_NLA_EDIT_ON) && (nlt->flag & NLATRACK_DISABLED) &&
- (adt->act_track != nlt))
+ (adt->act_track != nlt)) {
continue;
+ }
/* only work with this channel and its subchannels if it is editable */
if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_NLT(nlt)) {
@@ -1629,8 +1661,9 @@ static size_t animdata_filter_shapekey(bAnimContext *ac,
/* loop through the channels adding ShapeKeys as appropriate */
for (kb = key->block.first; kb; kb = kb->next) {
/* skip the first one, since that's the non-animatable basis */
- if (kb == key->block.first)
+ if (kb == key->block.first) {
continue;
+ }
/* only work with this channel and its subchannels if it is editable */
if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_SHAPEKEY(kb)) {
@@ -1683,8 +1716,9 @@ static size_t animdata_filter_gpencil_layers_data(ListBase *anim_data,
if (!(filter_mode & ANIMFILTER_ACTIVE) || (gpl->flag & GP_LAYER_ACTIVE)) {
/* skip layer if the name doesn't match the filter string */
if ((ads) && (ads->searchstr[0] != '\0')) {
- if (name_matches_dopesheet_filter(ads, gpl->info) == false)
+ if (name_matches_dopesheet_filter(ads, gpl->info) == false) {
continue;
+ }
}
/* add to list */
ANIMCHANNEL_NEW_CHANNEL(gpl, ANIMTYPE_GPLAYER, gpd, NULL);
@@ -1778,12 +1812,14 @@ static size_t animdata_filter_gpencil(bAnimContext *ac,
if ((filter_mode & ANIMFILTER_DATA_VISIBLE) &&
!(ads->filterflag & ADS_FILTER_INCL_HIDDEN)) {
/* layer visibility - we check both object and base, since these may not be in sync yet */
- if ((base->flag & BASE_VISIBLE) == 0)
+ if ((base->flag & BASE_VISIBLE) == 0) {
continue;
+ }
/* outliner restrict-flag */
- if (ob->restrictflag & OB_RESTRICT_VIEW)
+ if (ob->restrictflag & OB_RESTRICT_VIEW) {
continue;
+ }
}
/* check selection and object type filters */
@@ -1798,8 +1834,9 @@ static size_t animdata_filter_gpencil(bAnimContext *ac,
* - used to ease the process of doing multiple-character choreographies
*/
if (ads->filter_grp != NULL) {
- if (BKE_collection_has_object_recursive(ads->filter_grp, ob) == 0)
+ if (BKE_collection_has_object_recursive(ads->filter_grp, ob) == 0) {
continue;
+ }
}
/* finally, include this object's grease pencil datablock */
@@ -1815,8 +1852,9 @@ static size_t animdata_filter_gpencil(bAnimContext *ac,
* but only those that seem to be useful somewhere */
for (gpd = ac->bmain->gpencils.first; gpd; gpd = gpd->id.next) {
/* only show if gpd is used by something... */
- if (ID_REAL_USERS(gpd) < 1)
+ if (ID_REAL_USERS(gpd) < 1) {
continue;
+ }
/* add GP frames from this datablock */
items += animdata_filter_gpencil_data(anim_data, ads, gpd, filter_mode);
@@ -1944,8 +1982,9 @@ static size_t animdata_filter_mask(Main *bmain,
size_t tmp_items = 0;
/* only show if mask is used by something... */
- if (ID_REAL_USERS(mask) < 1)
+ if (ID_REAL_USERS(mask) < 1) {
continue;
+ }
/* add mask animation channels */
BEGIN_ANIMFILTER_SUBCHANNELS (EXPANDED_MASK(mask)) {
@@ -2164,8 +2203,9 @@ static size_t animdata_filter_ds_textures(
int a = 0;
/* get datatype specific data first */
- if (owner_id == NULL)
+ if (owner_id == NULL) {
return 0;
+ }
switch (GS(owner_id->name)) {
case ID_PA: {
@@ -2175,9 +2215,10 @@ static size_t animdata_filter_ds_textures(
}
default: {
/* invalid/unsupported option */
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("ERROR: Unsupported owner_id (i.e. texture stack) for filter textures - %s\n",
owner_id->name);
+ }
return 0;
}
}
@@ -2187,8 +2228,9 @@ static size_t animdata_filter_ds_textures(
Tex *tex = (mtex[a]) ? mtex[a]->tex : NULL;
/* for now, if no texture returned, skip (this shouldn't confuse the user I hope) */
- if (tex == NULL)
+ if (tex == NULL) {
continue;
+ }
/* add texture's anim channels */
items += animdata_filter_ds_texture(ac, anim_data, ads, tex, owner_id, filter_mode);
@@ -2211,9 +2253,10 @@ static size_t animdata_filter_ds_material(
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ma, filter_mode);
/* nodes */
- if ((ma->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE))
+ if ((ma->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) {
tmp_items += animdata_filter_ds_nodetree(
ac, &tmp_data, ads, (ID *)ma, ma->nodetree, filter_mode);
+ }
}
END_ANIMFILTER_SUBCHANNELS;
@@ -2312,8 +2355,9 @@ static void animfilter_modifier_idpoin_cb(void *afm_ptr,
/* NOTE: the walker only guarantees to give us all the ID-ptr *slots*,
* not just the ones which are actually used, so be careful!
*/
- if (id == NULL)
+ if (id == NULL) {
return;
+ }
/* check if this is something we're interested in... */
switch (GS(id->name)) {
@@ -2382,8 +2426,9 @@ static size_t animdata_filter_ds_particles(
size_t tmp_items = 0;
/* if no material returned, skip - so that we don't get weird blank entries... */
- if (ELEM(NULL, psys->part, psys->part->adt))
+ if (ELEM(NULL, psys->part, psys->part->adt)) {
continue;
+ }
/* add particle-system's animation data to temp collection */
BEGIN_ANIMFILTER_SUBCHANNELS (FILTER_PART_OBJD(psys->part)) {
@@ -2391,9 +2436,10 @@ static size_t animdata_filter_ds_particles(
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)psys->part, filter_mode);
/* textures */
- if (!(ads->filterflag & ADS_FILTER_NOTEX))
+ if (!(ads->filterflag & ADS_FILTER_NOTEX)) {
tmp_items += animdata_filter_ds_textures(
ac, &tmp_data, ads, (ID *)psys->part, filter_mode);
+ }
}
END_ANIMFILTER_SUBCHANNELS;
@@ -2434,8 +2480,9 @@ static size_t animdata_filter_ds_obdata(
{
Camera *ca = (Camera *)ob->data;
- if (ads->filterflag & ADS_FILTER_NOCAM)
+ if (ads->filterflag & ADS_FILTER_NOCAM) {
return 0;
+ }
type = ANIMTYPE_DSCAM;
expanded = FILTER_CAM_OBJD(ca);
@@ -2445,8 +2492,9 @@ static size_t animdata_filter_ds_obdata(
{
Light *la = (Light *)ob->data;
- if (ads->filterflag & ADS_FILTER_NOLAM)
+ if (ads->filterflag & ADS_FILTER_NOLAM) {
return 0;
+ }
type = ANIMTYPE_DSLAM;
expanded = FILTER_LAM_OBJD(la);
@@ -2458,8 +2506,9 @@ static size_t animdata_filter_ds_obdata(
{
Curve *cu = (Curve *)ob->data;
- if (ads->filterflag & ADS_FILTER_NOCUR)
+ if (ads->filterflag & ADS_FILTER_NOCUR) {
return 0;
+ }
type = ANIMTYPE_DSCUR;
expanded = FILTER_CUR_OBJD(cu);
@@ -2469,8 +2518,9 @@ static size_t animdata_filter_ds_obdata(
{
MetaBall *mb = (MetaBall *)ob->data;
- if (ads->filterflag & ADS_FILTER_NOMBA)
+ if (ads->filterflag & ADS_FILTER_NOMBA) {
return 0;
+ }
type = ANIMTYPE_DSMBALL;
expanded = FILTER_MBALL_OBJD(mb);
@@ -2480,8 +2530,9 @@ static size_t animdata_filter_ds_obdata(
{
bArmature *arm = (bArmature *)ob->data;
- if (ads->filterflag & ADS_FILTER_NOARM)
+ if (ads->filterflag & ADS_FILTER_NOARM) {
return 0;
+ }
type = ANIMTYPE_DSARM;
expanded = FILTER_ARM_OBJD(arm);
@@ -2491,8 +2542,9 @@ static size_t animdata_filter_ds_obdata(
{
Mesh *me = (Mesh *)ob->data;
- if (ads->filterflag & ADS_FILTER_NOMESH)
+ if (ads->filterflag & ADS_FILTER_NOMESH) {
return 0;
+ }
type = ANIMTYPE_DSMESH;
expanded = FILTER_MESH_OBJD(me);
@@ -2502,8 +2554,9 @@ static size_t animdata_filter_ds_obdata(
{
Lattice *lt = (Lattice *)ob->data;
- if (ads->filterflag & ADS_FILTER_NOLAT)
+ if (ads->filterflag & ADS_FILTER_NOLAT) {
return 0;
+ }
type = ANIMTYPE_DSLAT;
expanded = FILTER_LATTICE_OBJD(lt);
@@ -2532,9 +2585,10 @@ static size_t animdata_filter_ds_obdata(
bNodeTree *ntree = la->nodetree;
/* nodetree */
- if ((ntree) && !(ads->filterflag & ADS_FILTER_NONTREE))
+ if ((ntree) && !(ads->filterflag & ADS_FILTER_NONTREE)) {
tmp_items += animdata_filter_ds_nodetree(
ac, &tmp_data, ads, &la->id, ntree, filter_mode);
+ }
break;
}
}
@@ -2740,9 +2794,10 @@ static size_t animdata_filter_ds_world(
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)wo, filter_mode);
/* nodes */
- if ((wo->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE))
+ if ((wo->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) {
tmp_items += animdata_filter_ds_nodetree(
ac, &tmp_data, ads, (ID *)wo, wo->nodetree, filter_mode);
+ }
}
END_ANIMFILTER_SUBCHANNELS;
@@ -2938,8 +2993,9 @@ static bool animdata_filter_base_is_ok(bDopeSheet *ads, Base *base, int filter_m
{
Object *ob = base->object;
- if (base->object == NULL)
+ if (base->object == NULL) {
return false;
+ }
/* firstly, check if object can be included, by the following factors:
* - if only visible, must check for layer and also viewport visibility
@@ -2952,20 +3008,23 @@ static bool animdata_filter_base_is_ok(bDopeSheet *ads, Base *base, int filter_m
*/
if ((filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ads->filterflag & ADS_FILTER_INCL_HIDDEN)) {
/* layer visibility - we check both object and base, since these may not be in sync yet */
- if ((base->flag & BASE_VISIBLE) == 0)
+ if ((base->flag & BASE_VISIBLE) == 0) {
return false;
+ }
/* outliner restrict-flag */
- if (ob->restrictflag & OB_RESTRICT_VIEW)
+ if (ob->restrictflag & OB_RESTRICT_VIEW) {
return false;
+ }
}
/* if only F-Curves with visible flags set can be shown, check that
* datablock hasn't been set to invisible
*/
if (filter_mode & ANIMFILTER_CURVE_VISIBLE) {
- if ((ob->adt) && (ob->adt->flag & ADT_CURVES_NOT_VISIBLE))
+ if ((ob->adt) && (ob->adt->flag & ADT_CURVES_NOT_VISIBLE)) {
return false;
+ }
}
/* Pinned curves are visible regardless of selection flags. */
@@ -2998,8 +3057,9 @@ static bool animdata_filter_base_is_ok(bDopeSheet *ads, Base *base, int filter_m
* - used to ease the process of doing multiple-character choreographies
*/
if (ads->filter_grp != NULL) {
- if (BKE_collection_has_object_recursive(ads->filter_grp, ob) == 0)
+ if (BKE_collection_has_object_recursive(ads->filter_grp, ob) == 0) {
return false;
+ }
}
/* no reason to exclude this object... */
@@ -3055,10 +3115,11 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac,
/* check that we do indeed have a scene */
if ((ads->source == NULL) || (GS(ads->source->name) != ID_SCE)) {
printf("Dope Sheet Error: No scene!\n");
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("\tPointer = %p, Name = '%s'\n",
(void *)ads->source,
(ads->source) ? ads->source->name : NULL);
+ }
return 0;
}
@@ -3166,8 +3227,9 @@ static short animdata_filter_dopesheet_summary(bAnimContext *ac,
/* If summary is collapsed, don't show other channels beneath this - this check is put inside
* the summary check so that it doesn't interfere with normal operation.
*/
- if (ads->flag & ADS_FLAG_SUMMARY_COLLAPSED)
+ if (ads->flag & ADS_FLAG_SUMMARY_COLLAPSED) {
return 0;
+ }
}
/* the other channels beneath this can be shown */
@@ -3229,10 +3291,12 @@ static size_t animdata_filter_remove_invalid(ListBase *anim_data)
for (ale = anim_data->first; ale; ale = next) {
next = ale->next;
- if (ale->type == ANIMTYPE_NONE)
+ if (ale->type == ANIMTYPE_NONE) {
BLI_freelinkN(anim_data, ale);
- else
+ }
+ else {
items++;
+ }
}
return items;
@@ -3313,8 +3377,9 @@ size_t ANIM_animdata_filter(bAnimContext *ac,
else {
/* The check for the DopeSheet summary is included here
* since the summary works here too. */
- if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
+ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
items += animfilter_action(ac, anim_data, ads, data, filter_mode, (ID *)obact);
+ }
}
break;
@@ -3333,8 +3398,9 @@ size_t ANIM_animdata_filter(bAnimContext *ac,
else {
/* The check for the DopeSheet summary is included here
* since the summary works here too. */
- if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
+ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
items = animdata_filter_shapekey(ac, anim_data, key, filter_mode);
+ }
}
break;
@@ -3342,13 +3408,15 @@ size_t ANIM_animdata_filter(bAnimContext *ac,
/* Modes for Specialty Data Types (i.e. not keyframes) */
case ANIMCONT_GPENCIL: {
- if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
+ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
items = animdata_filter_gpencil(ac, anim_data, data, filter_mode);
+ }
break;
}
case ANIMCONT_MASK: {
- if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
+ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
items = animdata_filter_mask(ac->bmain, anim_data, data, filter_mode);
+ }
break;
}
@@ -3356,8 +3424,9 @@ size_t ANIM_animdata_filter(bAnimContext *ac,
case ANIMCONT_DOPESHEET: /* 'DopeSheet Editor' */
{
/* the DopeSheet editor is the primary place where the DopeSheet summaries are useful */
- if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
+ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
items += animdata_filter_dopesheet(ac, anim_data, data, filter_mode);
+ }
break;
}
case ANIMCONT_FCURVES: /* Graph Editor -> F-Curves/Animation Editing */
@@ -3373,8 +3442,9 @@ size_t ANIM_animdata_filter(bAnimContext *ac,
/* Timeline Mode - Basically the same as dopesheet, except we only have the summary for now */
case ANIMCONT_TIMELINE: {
/* the DopeSheet editor is the primary place where the DopeSheet summaries are useful */
- if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
+ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
items += animdata_filter_dopesheet(ac, anim_data, data, filter_mode);
+ }
break;
}
@@ -3399,8 +3469,9 @@ size_t ANIM_animdata_filter(bAnimContext *ac,
items = animdata_filter_remove_invalid(anim_data);
/* remove duplicates (if required) */
- if (filter_mode & ANIMFILTER_NODUPLIS)
+ if (filter_mode & ANIMFILTER_NODUPLIS) {
items = animdata_filter_remove_duplis(anim_data);
+ }
}
/* return the number of items in the list */
diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c
index e34d12bc8fa..19fd521d7d9 100644
--- a/source/blender/editors/animation/anim_ipo_utils.c
+++ b/source/blender/editors/animation/anim_ipo_utils.c
@@ -56,15 +56,19 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
int icon = 0;
/* sanity checks */
- if (name == NULL)
+ if (name == NULL) {
return icon;
+ }
else if (ELEM(NULL, id, fcu, fcu->rna_path)) {
- if (fcu == NULL)
+ if (fcu == NULL) {
strcpy(name, IFACE_("<invalid>"));
- else if (fcu->rna_path == NULL)
+ }
+ else if (fcu->rna_path == NULL) {
strcpy(name, IFACE_("<no path>"));
- else /* id == NULL */
+ }
+ else { /* id == NULL */
BLI_snprintf(name, 256, "%s[%d]", fcu->rna_path, fcu->array_index);
+ }
}
else {
PointerRNA id_ptr, ptr;
@@ -111,10 +115,12 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
free_structname = 1;
/* free the temp names */
- if (pchanName)
+ if (pchanName) {
MEM_freeN(pchanName);
- if (constName)
+ }
+ if (constName) {
MEM_freeN(constName);
+ }
}
else if (ptr.data != ptr.id.data) {
PropertyRNA *nameprop = RNA_struct_name_property(ptr.type);
@@ -123,8 +129,9 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
structname = RNA_property_string_get_alloc(&ptr, nameprop, NULL, 0, NULL);
free_structname = 1;
}
- else
+ else {
structname = RNA_struct_ui_name(ptr.type);
+ }
}
/* Property Name is straightforward */
@@ -135,10 +142,12 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
char c = RNA_property_array_item_char(prop, fcu->array_index);
/* we need to write the index to a temp buffer (in py syntax) */
- if (c)
+ if (c) {
BLI_snprintf(arrayindbuf, sizeof(arrayindbuf), "%c ", c);
- else
+ }
+ else {
BLI_snprintf(arrayindbuf, sizeof(arrayindbuf), "[%d]", fcu->array_index);
+ }
arrayname = &arrayindbuf[0];
}
@@ -150,14 +159,17 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
/* putting this all together into the buffer */
/* XXX we need to check for invalid names...
* XXX the name length limit needs to be passed in or as some define */
- if (structname)
+ if (structname) {
BLI_snprintf(name, 256, "%s%s (%s)", arrayname, propname, structname);
- else
+ }
+ else {
BLI_snprintf(name, 256, "%s%s", arrayname, propname);
+ }
/* free temp name if nameprop is set */
- if (free_structname)
+ if (free_structname) {
MEM_freeN((void *)structname);
+ }
/* Icon for this property's owner:
* use the struct's icon if it is set
@@ -216,8 +228,9 @@ void getcolor_fcurve_rainbow(int cur, int tot, float out[3])
/* the base color can get offset a bit so that the colors aren't so identical */
hsv[0] += fac * HSV_BANDWIDTH;
- if (hsv[0] > 1.0f)
+ if (hsv[0] > 1.0f) {
hsv[0] = fmod(hsv[0], 1.0f);
+ }
/* saturation adjustments for more visible range */
hsv[1] = ((hsv[0] > 0.5f) && (hsv[0] < 0.8f)) ? 0.5f : 0.6f;
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 8bffb943824..e90599b05c8 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -107,10 +107,12 @@ ListBase *ED_context_get_markers(const bContext *C)
/* public API for getting markers from "animation" context */
ListBase *ED_animcontext_get_markers(const bAnimContext *ac)
{
- if (ac)
+ if (ac) {
return context_get_markers(ac->scene, ac->sa);
- else
+ }
+ else {
return NULL;
+ }
}
/* --------------------------------- */
@@ -212,10 +214,12 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la
max = -FLT_MAX;
for (marker = markers->first; marker; marker = marker->next) {
if (!sel || (marker->flag & SELECT)) {
- if (marker->frame < min)
+ if (marker->frame < min) {
min = (float)marker->frame;
- if (marker->frame > max)
+ }
+ if (marker->frame > max) {
max = (float)marker->frame;
+ }
}
}
@@ -232,15 +236,17 @@ static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only
CfraElem *ce, *cen;
/* should this one only be considered if it is selected? */
- if ((only_sel) && ((marker->flag & SELECT) == 0))
+ if ((only_sel) && ((marker->flag & SELECT) == 0)) {
return;
+ }
/* insertion sort - try to find a previous cfra elem */
for (ce = lb->first; ce; ce = ce->next) {
if (ce->cfra == marker->frame) {
/* do because of double keys */
- if (marker->flag & SELECT)
+ if (marker->flag & SELECT) {
ce->sel = marker->flag;
+ }
return;
}
else if (ce->cfra > marker->frame) {
@@ -249,10 +255,12 @@ static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only
}
cen = MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem");
- if (ce)
+ if (ce) {
BLI_insertlinkbefore(lb, ce, cen);
- else
+ }
+ else {
BLI_addtail(lb, cen);
+ }
cen->cfra = marker->frame;
cen->sel = marker->flag;
@@ -281,8 +289,9 @@ void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel)
return;
}
- for (marker = markers->first; marker; marker = marker->next)
+ for (marker = markers->first; marker; marker = marker->next) {
add_marker_to_cfra_elem(lb, marker, only_sel);
+ }
}
void ED_markers_deselect_all(ListBase *markers, int action)
@@ -316,8 +325,9 @@ TimeMarker *ED_markers_get_first_selected(ListBase *markers)
if (markers) {
for (marker = markers->first; marker; marker = marker->next) {
- if (marker->flag & SELECT)
+ if (marker->flag & SELECT) {
return marker;
+ }
}
}
@@ -571,8 +581,9 @@ static bool ed_markers_poll_selected_markers(bContext *C)
ListBase *markers = ED_context_get_markers(C);
/* first things first: markers can only exist in timeline views */
- if (ED_operator_animview_active(C) == 0)
+ if (ED_operator_animview_active(C) == 0) {
return 0;
+ }
/* check if some marker is selected */
return ED_markers_get_first_selected(markers) != NULL;
@@ -583,12 +594,14 @@ static bool ed_markers_poll_selected_no_locked_markers(bContext *C)
ListBase *markers = ED_context_get_markers(C);
ToolSettings *ts = CTX_data_tool_settings(C);
- if (ts->lock_markers)
+ if (ts->lock_markers) {
return 0;
+ }
/* first things first: markers can only exist in timeline views */
- if (ED_operator_animview_active(C) == 0)
+ if (ED_operator_animview_active(C) == 0) {
return 0;
+ }
/* check if some marker is selected */
return ED_markers_get_first_selected(markers) != NULL;
@@ -600,12 +613,14 @@ static bool ed_markers_poll_markers_exist(bContext *C)
ListBase *markers = ED_context_get_markers(C);
ToolSettings *ts = CTX_data_tool_settings(C);
- if (ts->lock_markers)
+ if (ts->lock_markers) {
return 0;
+ }
/* first things first: markers can only exist in timeline views */
- if (ED_operator_animview_active(C) == 0)
+ if (ED_operator_animview_active(C) == 0) {
return 0;
+ }
/* list of markers must exist, as well as some markers in it! */
return (markers && markers->first);
@@ -634,14 +649,17 @@ static int ed_markers_opwrap_invoke_custom(bContext *C,
/* removed check for Y coord of event, keymap has bounbox now */
/* allow operator to run now */
- if (invoke_func)
+ if (invoke_func) {
retval = invoke_func(C, op, event);
- else if (op->type->exec)
+ }
+ else if (op->type->exec) {
retval = op->type->exec(C, op);
- else
+ }
+ else {
BKE_report(op->reports,
RPT_ERROR,
"Programming error: operator does not actually have code to do anything!");
+ }
/* unless successful, must add "pass-through"
* to let normal operator's have a chance at tackling this event */
@@ -671,19 +689,22 @@ static int ed_marker_add_exec(bContext *C, wmOperator *UNUSED(op))
TimeMarker *marker;
int frame = CTX_data_scene(C)->r.cfra;
- if (markers == NULL)
+ if (markers == NULL) {
return OPERATOR_CANCELLED;
+ }
/* prefer not having 2 markers at the same place,
* though the user can move them to overlap once added */
for (marker = markers->first; marker; marker = marker->next) {
- if (marker->frame == frame)
+ if (marker->frame == frame) {
return OPERATOR_CANCELLED;
+ }
}
/* deselect all */
- for (marker = markers->first; marker; marker = marker->next)
+ for (marker = markers->first; marker; marker = marker->next) {
marker->flag &= ~SELECT;
+ }
marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
marker->flag = SELECT;
@@ -1081,8 +1102,9 @@ static void ed_marker_duplicate_apply(bContext *C)
ListBase *markers = ED_context_get_markers(C);
TimeMarker *marker, *newmarker;
- if (markers == NULL)
+ if (markers == NULL) {
return;
+ }
/* go through the list of markers, duplicate selected markers and add duplicated copies
* to the beginning of the list (unselect original markers)
@@ -1191,8 +1213,9 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool
float viewx;
int x, cfra;
- if (markers == NULL)
+ if (markers == NULL) {
return OPERATOR_PASS_THROUGH;
+ }
x = event->x - ar->winrct.xmin;
@@ -1211,8 +1234,9 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool
TimeMarker *marker;
int sel = 0;
- if (!extend)
+ if (!extend) {
BKE_view_layer_base_deselect_all(view_layer);
+ }
for (marker = markers->first; marker; marker = marker->next) {
if (marker->frame == cfra) {
@@ -1227,8 +1251,9 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool
base = BKE_view_layer_base_find(view_layer, marker->camera);
if (base) {
ED_object_base_select(base, sel);
- if (sel)
+ if (sel) {
ED_object_base_activate(C, base);
+ }
}
}
}
@@ -1317,8 +1342,9 @@ static int ed_marker_box_select_exec(bContext *C, wmOperator *op)
WM_operator_properties_border_to_rctf(op, &rect);
UI_view2d_region_to_view_rctf(v2d, &rect, &rect);
- if (markers == NULL)
+ if (markers == NULL) {
return 0;
+ }
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const bool select = (sel_op != SEL_OP_SUB);
@@ -1412,8 +1438,9 @@ static int ed_marker_delete_exec(bContext *C, wmOperator *UNUSED(op))
TimeMarker *marker, *nmarker;
bool changed = false;
- if (markers == NULL)
+ if (markers == NULL) {
return OPERATOR_CANCELLED;
+ }
for (marker = markers->first; marker; marker = nmarker) {
nmarker = marker->next;
@@ -1477,8 +1504,9 @@ static int ed_marker_rename_invoke_wrapper(bContext *C, wmOperator *op, const wm
{
/* must initialize the marker name first if there is a marker selected */
TimeMarker *marker = ED_markers_get_first_selected(ED_context_get_markers(C));
- if (marker)
+ if (marker) {
RNA_string_set(op->ptr, "name", marker->name);
+ }
/* now see if the operator is usable */
return ed_markers_opwrap_invoke_custom(C, op, event, WM_operator_props_popup_confirm);
@@ -1600,8 +1628,9 @@ static int ed_marker_camera_bind_exec(bContext *C, wmOperator *op)
}
/* add new marker, unless we already have one on this frame, in which case, replace it */
- if (markers == NULL)
+ if (markers == NULL) {
return OPERATOR_CANCELLED;
+ }
marker = ED_markers_find_nearest_marker(markers, CFRA);
if ((marker == NULL) || (marker->frame != CFRA)) {
diff --git a/source/blender/editors/animation/anim_motion_paths.c b/source/blender/editors/animation/anim_motion_paths.c
index 5ea36627e7a..e3c4e2a8cfb 100644
--- a/source/blender/editors/animation/anim_motion_paths.c
+++ b/source/blender/editors/animation/anim_motion_paths.c
@@ -216,8 +216,9 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph,
bool current_frame_only)
{
/* sanity check */
- if (ELEM(NULL, targets, targets->first))
+ if (ELEM(NULL, targets, targets->first)) {
return;
+ }
/* Compute frame range to bake within.
* TODO: this method could be improved...
@@ -263,10 +264,12 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph,
bAnimVizSettings *avs;
/* get pointer to animviz settings for each target */
- if (mpt->pchan)
+ if (mpt->pchan) {
avs = &mpt->ob->pose->avs;
- else
+ }
+ else {
avs = &mpt->ob->avs;
+ }
/* it is assumed that keyframes for bones are all grouped in a single group
* unless an option is set to always use the whole action
@@ -320,10 +323,12 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph,
bMotionPath *mpath = mpt->mpath;
/* get pointer to animviz settings for each target */
- if (mpt->pchan)
+ if (mpt->pchan) {
avs = &mpt->ob->pose->avs;
- else
+ }
+ else {
avs = &mpt->ob->avs;
+ }
/* clear the flag requesting recalculation of targets */
avs->recalc &= ~ANIMVIZ_RECALC_PATHS;
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index 91cbc2ff3e0..45bb8f3b11e 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -62,8 +62,9 @@ static bool change_frame_poll(bContext *C)
ScrArea *sa = CTX_wm_area(C);
/* XXX temp? prevent changes during render */
- if (G.is_rendering)
+ if (G.is_rendering) {
return false;
+ }
/* although it's only included in keymaps for regions using ED_KEYMAP_ANIMATION,
* this shouldn't show up in 3D editor (or others without 2D timeline view) via search
@@ -157,8 +158,9 @@ static void change_frame_seq_preview_begin(bContext *C, const wmEvent *event)
ED_sequencer_special_preview_set(C, event->mval);
}
}
- if (screen)
+ if (screen) {
screen->scrubbing = true;
+ }
}
static void change_frame_seq_preview_end(bContext *C)
@@ -225,8 +227,9 @@ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event)
case RIGHTMOUSE:
case MIDDLEMOUSE:
/* We check for either mouse-button to end, to work with all user keymaps. */
- if (event->val == KM_RELEASE)
+ if (event->val == KM_RELEASE) {
ret = OPERATOR_FINISHED;
+ }
break;
case LEFTCTRLKEY:
@@ -281,8 +284,9 @@ static bool anim_set_end_frames_poll(bContext *C)
ScrArea *sa = CTX_wm_area(C);
/* XXX temp? prevent changes during render */
- if (G.is_rendering)
+ if (G.is_rendering) {
return false;
+ }
/* although it's only included in keymaps for regions using ED_KEYMAP_ANIMATION,
* this shouldn't show up in 3D editor (or others without 2D timeline view) via search
@@ -302,22 +306,27 @@ static int anim_set_sfra_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
int frame;
- if (scene == NULL)
+ if (scene == NULL) {
return OPERATOR_CANCELLED;
+ }
frame = CFRA;
/* if Preview Range is defined, set the 'start' frame for that */
- if (PRVRANGEON)
+ if (PRVRANGEON) {
scene->r.psfra = frame;
- else
+ }
+ else {
scene->r.sfra = frame;
+ }
if (PEFRA < frame) {
- if (PRVRANGEON)
+ if (PRVRANGEON) {
scene->r.pefra = frame;
- else
+ }
+ else {
scene->r.efra = frame;
+ }
}
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
@@ -345,22 +354,27 @@ static int anim_set_efra_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
int frame;
- if (scene == NULL)
+ if (scene == NULL) {
return OPERATOR_CANCELLED;
+ }
frame = CFRA;
/* if Preview Range is defined, set the 'end' frame for that */
- if (PRVRANGEON)
+ if (PRVRANGEON) {
scene->r.pefra = frame;
- else
+ }
+ else {
scene->r.efra = frame;
+ }
if (PSFRA > frame) {
- if (PRVRANGEON)
+ if (PRVRANGEON) {
scene->r.psfra = frame;
- else
+ }
+ else {
scene->r.sfra = frame;
+ }
}
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
@@ -405,8 +419,9 @@ static int previewrange_define_exec(bContext *C, wmOperator *op)
*/
FRAMENUMBER_MIN_CLAMP(sfra);
FRAMENUMBER_MIN_CLAMP(efra);
- if (efra < sfra)
+ if (efra < sfra) {
efra = sfra;
+ }
scene->r.flag |= SCER_PRV_RANGE;
scene->r.psfra = round_fl_to_int(sfra);
@@ -452,8 +467,9 @@ static int previewrange_clear_exec(bContext *C, wmOperator *UNUSED(op))
ScrArea *curarea = CTX_wm_area(C);
/* sanity checks */
- if (ELEM(NULL, scene, curarea))
+ if (ELEM(NULL, scene, curarea)) {
return OPERATOR_CANCELLED;
+ }
/* simply clear values */
scene->r.flag &= ~SCER_PRV_RANGE;
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index 3f930aae47f..34d7fac041f 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -73,13 +73,15 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde
FCurve *fcu;
/* sanity checks */
- if (ELEM(NULL, id, rna_path))
+ if (ELEM(NULL, id, rna_path)) {
return NULL;
+ }
/* init animdata if none available yet */
adt = BKE_animdata_from_id(id);
- if ((adt == NULL) && (add))
+ if ((adt == NULL) && (add)) {
adt = BKE_animdata_add_id(id);
+ }
if (adt == NULL) {
/* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */
return NULL;
@@ -233,31 +235,40 @@ static int add_driver_with_target(ReportList *UNUSED(reports),
/* Transform channel depends on type */
if (STREQ(prop_name, "location")) {
- if (src_index == 2)
+ if (src_index == 2) {
dtar->transChan = DTAR_TRANSCHAN_LOCZ;
- else if (src_index == 1)
+ }
+ else if (src_index == 1) {
dtar->transChan = DTAR_TRANSCHAN_LOCY;
- else
+ }
+ else {
dtar->transChan = DTAR_TRANSCHAN_LOCX;
+ }
}
else if (STREQ(prop_name, "scale")) {
- if (src_index == 2)
+ if (src_index == 2) {
dtar->transChan = DTAR_TRANSCHAN_SCALEZ;
- else if (src_index == 1)
+ }
+ else if (src_index == 1) {
dtar->transChan = DTAR_TRANSCHAN_SCALEY;
- else
+ }
+ else {
dtar->transChan = DTAR_TRANSCHAN_SCALEX;
+ }
}
else {
/* XXX: With quaternions and axis-angle, this mapping might not be correct...
* But since those have 4 elements instead, there's not much we can do
*/
- if (src_index == 2)
+ if (src_index == 2) {
dtar->transChan = DTAR_TRANSCHAN_ROTZ;
- else if (src_index == 1)
+ }
+ else if (src_index == 1) {
dtar->transChan = DTAR_TRANSCHAN_ROTY;
- else
+ }
+ else {
dtar->transChan = DTAR_TRANSCHAN_ROTX;
+ }
}
}
else {
@@ -438,12 +449,14 @@ int ANIM_add_driver(
array_index_max = RNA_property_array_length(&ptr, prop);
array_index = 0;
}
- else
+ else {
array_index_max = array_index;
+ }
/* maximum index should be greater than the start index */
- if (array_index == array_index_max)
+ if (array_index == array_index_max) {
array_index_max += 1;
+ }
/* will only loop once unless the array index was -1 */
for (; array_index < array_index_max; array_index++) {
@@ -477,26 +490,32 @@ int ANIM_add_driver(
float fval;
if (proptype == PROP_BOOLEAN) {
- if (!array)
+ if (!array) {
val = RNA_property_boolean_get(&ptr, prop);
- else
+ }
+ else {
val = RNA_property_boolean_get_index(&ptr, prop, array_index);
+ }
BLI_snprintf(expression, maxlen, "%s%s", dvar_prefix, (val) ? "True" : "False");
}
else if (proptype == PROP_INT) {
- if (!array)
+ if (!array) {
val = RNA_property_int_get(&ptr, prop);
- else
+ }
+ else {
val = RNA_property_int_get_index(&ptr, prop, array_index);
+ }
BLI_snprintf(expression, maxlen, "%s%d", dvar_prefix, val);
}
else if (proptype == PROP_FLOAT) {
- if (!array)
+ if (!array) {
fval = RNA_property_float_get(&ptr, prop);
- else
+ }
+ else {
fval = RNA_property_float_get_index(&ptr, prop, array_index);
+ }
BLI_snprintf(expression, maxlen, "%s%.3f", dvar_prefix, fval);
BLI_str_rstrip_float_zero(expression, '\0');
@@ -587,8 +606,9 @@ static FCurve *channeldriver_copypaste_buf = NULL;
void ANIM_drivers_copybuf_free(void)
{
/* free the buffer F-Curve if it exists, as if it were just another F-Curve */
- if (channeldriver_copypaste_buf)
+ if (channeldriver_copypaste_buf) {
free_fcurve(channeldriver_copypaste_buf);
+ }
channeldriver_copypaste_buf = NULL;
}
@@ -868,8 +888,9 @@ static const EnumPropertyItem *driver_mapping_type_itemsf(bContext *C,
int totitem = 0;
- if (!C) /* needed for docs */
+ if (!C) { /* needed for docs */
return prop_driver_create_mapping_types;
+ }
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
@@ -929,8 +950,9 @@ static int add_driver_button_none(bContext *C, wmOperator *op, short mapping_typ
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
- if (mapping_type == CREATEDRIVER_MAPPING_NONE_ALL)
+ if (mapping_type == CREATEDRIVER_MAPPING_NONE_ALL) {
index = -1;
+ }
if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) {
char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL);
@@ -1084,8 +1106,9 @@ static int remove_driver_button_exec(bContext *C, wmOperator *op)
/* try to find driver using property retrieved from UI */
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
- if (all)
+ if (all) {
index = -1;
+ }
if (ptr.id.data && ptr.data && prop) {
char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL);
diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c
index 9e96023b272..f4e1268ab77 100644
--- a/source/blender/editors/animation/fmodifier_ui.c
+++ b/source/blender/editors/animation/fmodifier_ui.c
@@ -77,8 +77,9 @@ static void validate_fmodifier_cb(bContext *UNUSED(C), void *fcm_v, void *UNUSED
const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
/* call the verify callback on the modifier if applicable */
- if (fmi && fmi->verify_data)
+ if (fmi && fmi->verify_data) {
fmi->verify_data(fcm);
+ }
}
/* callback to remove the given modifier */
@@ -210,7 +211,7 @@ static void draw_modifier__generator(uiLayout *layout,
cp = data->coefficients;
for (i = 0; (i < data->arraysize) && (cp); i++, cp++) {
/* To align with first line... */
- if (i)
+ if (i) {
uiDefBut(block,
UI_BTYPE_LABEL,
1,
@@ -225,7 +226,8 @@ static void draw_modifier__generator(uiLayout *layout,
0,
0,
"");
- else
+ }
+ else {
uiDefBut(block,
UI_BTYPE_LABEL,
1,
@@ -240,6 +242,7 @@ static void draw_modifier__generator(uiLayout *layout,
0,
0,
"");
+ }
/* coefficient */
uiDefButF(block,
@@ -258,12 +261,15 @@ static void draw_modifier__generator(uiLayout *layout,
TIP_("Coefficient for polynomial"));
/* 'x' param (and '+' if necessary) */
- if (i == 0)
+ if (i == 0) {
BLI_strncpy(xval, "", sizeof(xval));
- else if (i == 1)
+ }
+ else if (i == 1) {
BLI_strncpy(xval, "x", sizeof(xval));
- else
+ }
+ else {
BLI_snprintf(xval, sizeof(xval), "x^%u", i);
+ }
uiDefBut(block,
UI_BTYPE_LABEL,
1,
@@ -328,7 +334,7 @@ static void draw_modifier__generator(uiLayout *layout,
cp = data->coefficients;
for (i = 0; (i < data->poly_order) && (cp); i++, cp += 2) {
/* To align with first line */
- if (i)
+ if (i) {
uiDefBut(block,
UI_BTYPE_LABEL,
1,
@@ -343,7 +349,8 @@ static void draw_modifier__generator(uiLayout *layout,
0,
0,
"");
- else
+ }
+ else {
uiDefBut(block,
UI_BTYPE_LABEL,
1,
@@ -358,6 +365,7 @@ static void draw_modifier__generator(uiLayout *layout,
0,
0,
"");
+ }
/* opening bracket */
uiDefBut(
block, UI_BTYPE_LABEL, 1, "(", 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
@@ -429,7 +437,7 @@ static void draw_modifier__generator(uiLayout *layout,
row = uiLayoutRow(layout, true);
block = uiLayoutGetBlock(row);
}
- else
+ else {
uiDefBut(block,
UI_BTYPE_LABEL,
1,
@@ -444,6 +452,7 @@ static void draw_modifier__generator(uiLayout *layout,
0,
0,
"");
+ }
}
break;
}
@@ -569,15 +578,17 @@ static void fmod_envelope_addpoint_cb(bContext *C, void *fcm_dv, void *UNUSED(ar
fedn = MEM_callocN((env->totvert + 1) * sizeof(FCM_EnvelopeData), "FCM_EnvelopeData");
/* add the points that should occur before the point to be pasted */
- if (i > 0)
+ if (i > 0) {
memcpy(fedn, env->data, i * sizeof(FCM_EnvelopeData));
+ }
/* add point to paste at index i */
*(fedn + i) = fed;
/* add the points that occur after the point to be pasted */
- if (i < env->totvert)
+ if (i < env->totvert) {
memcpy(fedn + i + 1, env->data + i, (env->totvert - i) * sizeof(FCM_EnvelopeData));
+ }
/* replace (+ free) old with new */
MEM_freeN(env->data);
@@ -885,10 +896,12 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout,
uiItemR(sub, &ptr, "active", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
/* name */
- if (fmi)
+ if (fmi) {
uiItemL(sub, IFACE_(fmi->name), ICON_NONE);
- else
+ }
+ else {
uiItemL(sub, IFACE_("<Unknown Modifier>"), ICON_NONE);
+ }
/* right-align ------------------------------------------- */
sub = uiLayoutRow(row, true);
@@ -1025,8 +1038,9 @@ bool ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, bool active)
bool ok = true;
/* sanity checks */
- if (ELEM(NULL, modifiers, modifiers->first))
+ if (ELEM(NULL, modifiers, modifiers->first)) {
return 0;
+ }
/* copy the whole list, or just the active one? */
if (active) {
@@ -1036,11 +1050,13 @@ bool ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, bool active)
FModifier *fcmN = copy_fmodifier(fcm);
BLI_addtail(&fmodifier_copypaste_buf, fcmN);
}
- else
+ else {
ok = 0;
+ }
}
- else
+ else {
copy_fmodifiers(&fmodifier_copypaste_buf, modifiers);
+ }
/* did we succeed? */
return ok;
@@ -1055,14 +1071,16 @@ bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace, FCurve *c
bool ok = false;
/* sanity checks */
- if (modifiers == NULL)
+ if (modifiers == NULL) {
return 0;
+ }
bool was_cyclic = curve && BKE_fcurve_is_cyclic(curve);
/* if replacing the list, free the existing modifiers */
- if (replace)
+ if (replace) {
free_fmodifiers(modifiers);
+ }
/* now copy over all the modifiers in the buffer to the end of the list */
for (fcm = fmodifier_copypaste_buf.first; fcm; fcm = fcm->next) {
@@ -1080,8 +1098,9 @@ bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace, FCurve *c
}
/* adding or removing the Cycles modifier requires an update to handles */
- if (curve && BKE_fcurve_is_cyclic(curve) != was_cyclic)
+ if (curve && BKE_fcurve_is_cyclic(curve) != was_cyclic) {
calchandles_fcurve(curve);
+ }
/* did we succeed? */
return ok;
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index 86b438846c9..22350f997f3 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -77,13 +77,16 @@ short compare_ak_cfraPtr(void *node, void *data)
const float *cframe = data;
float val = *cframe;
- if (is_cfra_eq(val, ak->cfra))
+ if (is_cfra_eq(val, ak->cfra)) {
return 0;
+ }
- if (val < ak->cfra)
+ if (val < ak->cfra) {
return -1;
- else
+ }
+ else {
return 1;
+ }
}
/* --------------- */
@@ -205,16 +208,18 @@ static void nupdate_ak_bezt(void *node, void *data)
BezTriple *bezt = chain->cur;
/* set selection status and 'touched' status */
- if (BEZT_ISSEL_ANY(bezt))
+ if (BEZT_ISSEL_ANY(bezt)) {
ak->sel = SELECT;
+ }
/* count keyframes in this column */
ak->totkey++;
/* For keyframe type, 'proper' keyframes have priority over breakdowns
* (and other types for now). */
- if (BEZKEYTYPE(bezt) == BEZT_KEYTYPE_KEYFRAME)
+ if (BEZKEYTYPE(bezt) == BEZT_KEYTYPE_KEYFRAME) {
ak->key_type = BEZT_KEYTYPE_KEYFRAME;
+ }
/* For interpolation type, select the highest value (enum is sorted). */
ak->handle_type = MAX2(ak->handle_type, bezt_handle_type(bezt));
@@ -268,16 +273,18 @@ static void nupdate_ak_gpframe(void *node, void *data)
bGPDframe *gpf = (bGPDframe *)data;
/* set selection status and 'touched' status */
- if (gpf->flag & GP_FRAME_SELECT)
+ if (gpf->flag & GP_FRAME_SELECT) {
ak->sel = SELECT;
+ }
/* count keyframes in this column */
ak->totkey++;
/* for keyframe type, 'proper' keyframes have priority over breakdowns
* (and other types for now). */
- if (gpf->key_type == BEZT_KEYTYPE_KEYFRAME)
+ if (gpf->key_type == BEZT_KEYTYPE_KEYFRAME) {
ak->key_type = BEZT_KEYTYPE_KEYFRAME;
+ }
}
/* ......... */
@@ -314,8 +321,9 @@ static void nupdate_ak_masklayshape(void *node, void *data)
MaskLayerShape *masklay_shape = (MaskLayerShape *)data;
/* set selection status and 'touched' status */
- if (masklay_shape->flag & MASK_SHAPE_SELECT)
+ if (masklay_shape->flag & MASK_SHAPE_SELECT) {
ak->sel = SELECT;
+ }
/* count keyframes in this column */
ak->totkey++;
@@ -326,32 +334,38 @@ static void nupdate_ak_masklayshape(void *node, void *data)
/* Add the given BezTriple to the given 'list' of Keyframes */
static void add_bezt_to_keycolumns_list(DLRBT_Tree *keys, BezTripleChain *bezt)
{
- if (ELEM(NULL, keys, bezt))
+ if (ELEM(NULL, keys, bezt)) {
return;
- else
+ }
+ else {
BLI_dlrbTree_add(keys, compare_ak_bezt, nalloc_ak_bezt, nupdate_ak_bezt, bezt);
+ }
}
/* Add the given GPencil Frame to the given 'list' of Keyframes */
static void add_gpframe_to_keycolumns_list(DLRBT_Tree *keys, bGPDframe *gpf)
{
- if (ELEM(NULL, keys, gpf))
+ if (ELEM(NULL, keys, gpf)) {
return;
- else
+ }
+ else {
BLI_dlrbTree_add(keys, compare_ak_gpframe, nalloc_ak_gpframe, nupdate_ak_gpframe, gpf);
+ }
}
/* Add the given MaskLayerShape Frame to the given 'list' of Keyframes */
static void add_masklay_to_keycolumns_list(DLRBT_Tree *keys, MaskLayerShape *masklay_shape)
{
- if (ELEM(NULL, keys, masklay_shape))
+ if (ELEM(NULL, keys, masklay_shape)) {
return;
- else
+ }
+ else {
BLI_dlrbTree_add(keys,
compare_ak_masklayshape,
nalloc_ak_masklayshape,
nupdate_ak_masklayshape,
masklay_shape);
+ }
}
/* ActKeyBlocks (Long Keyframes) ------------------------------------------ */
@@ -528,8 +542,9 @@ bool actkeyblock_is_valid(ActKeyColumn *ac)
int actkeyblock_get_valid_hold(ActKeyColumn *ac)
{
/* check that block is valid */
- if (!actkeyblock_is_valid(ac))
+ if (!actkeyblock_is_valid(ac)) {
return 0;
+ }
const int hold_mask = (ACTKEYBLOCK_FLAG_ANY_HOLD | ACTKEYBLOCK_FLAG_STATIC_HOLD |
ACTKEYBLOCK_FLAG_ANY_HOLD);
@@ -784,8 +799,9 @@ static void draw_keylist(View2D *v2d,
* This might give some improvements,
* since we current have to flip between view/region matrices.
*/
- if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax))
+ if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax)) {
key_len++;
+ }
}
if (key_len > 0) {
@@ -1046,8 +1062,9 @@ void scene_to_keylist(bDopeSheet *ads, Scene *sce, DLRBT_Tree *keys, int saction
bAnimListElem dummychan = {NULL};
- if (sce == NULL)
+ if (sce == NULL) {
return;
+ }
/* create a dummy wrapper data to work with */
dummychan.type = ANIMTYPE_SCENE;
@@ -1064,8 +1081,9 @@ void scene_to_keylist(bDopeSheet *ads, Scene *sce, DLRBT_Tree *keys, int saction
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* loop through each F-Curve, grabbing the keyframes */
- for (ale = anim_data.first; ale; ale = ale->next)
+ for (ale = anim_data.first; ale; ale = ale->next) {
fcurve_to_keylist(ale->adt, ale->data, keys, saction_flag);
+ }
ANIM_animdata_freelist(&anim_data);
}
@@ -1080,8 +1098,9 @@ void ob_to_keylist(bDopeSheet *ads, Object *ob, DLRBT_Tree *keys, int saction_fl
bAnimListElem dummychan = {NULL};
Base dummybase = {NULL};
- if (ob == NULL)
+ if (ob == NULL) {
return;
+ }
/* create a dummy wrapper data to work with */
dummybase.object = ob;
@@ -1100,8 +1119,9 @@ void ob_to_keylist(bDopeSheet *ads, Object *ob, DLRBT_Tree *keys, int saction_fl
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* loop through each F-Curve, grabbing the keyframes */
- for (ale = anim_data.first; ale; ale = ale->next)
+ for (ale = anim_data.first; ale; ale = ale->next) {
fcurve_to_keylist(ale->adt, ale->data, keys, saction_flag);
+ }
ANIM_animdata_freelist(&anim_data);
}
@@ -1144,8 +1164,9 @@ void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, int saction
{
if (fcu && fcu->totvert && fcu->bezt) {
/* apply NLA-mapping (if applicable) */
- if (adt)
+ if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 0);
+ }
/* Check if the curve is cyclic. */
bool is_cyclic = BKE_fcurve_is_cyclic(fcu) && (fcu->totvert >= 2);
@@ -1170,8 +1191,9 @@ void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, int saction
update_keyblocks(keys, fcu->bezt, fcu->totvert);
/* unapply NLA-mapping if applicable */
- if (adt)
+ if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 0);
+ }
}
}
@@ -1222,8 +1244,9 @@ void gpl_to_keylist(bDopeSheet *UNUSED(ads), bGPDlayer *gpl, DLRBT_Tree *keys)
if (gpl && keys) {
/* Although the frames should already be in an ordered list,
* they are not suitable for displaying yet. */
- for (gpf = gpl->frames.first; gpf; gpf = gpf->next)
+ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
add_gpframe_to_keycolumns_list(keys, gpf);
+ }
update_keyblocks(keys, NULL, 0);
}
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c
index e0df1942495..815d4c5f3af 100644
--- a/source/blender/editors/animation/keyframes_edit.c
+++ b/source/blender/editors/animation/keyframes_edit.c
@@ -82,8 +82,9 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked,
unsigned int i;
/* sanity check */
- if (ELEM(NULL, fcu, fcu->bezt))
+ if (ELEM(NULL, fcu, fcu->bezt)) {
return 0;
+ }
/* set the F-Curve into the editdata so that it can be accessed */
if (ked) {
@@ -107,27 +108,31 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked,
/* Only operate on this BezTriple if it fulfills the criteria of the validation func */
if ((ok = key_ok(ked, bezt))) {
- if (ked)
+ if (ked) {
ked->curflags = ok;
+ }
/* Exit with return-code '1' if function returns positive
* This is useful if finding if some BezTriple satisfies a condition.
*/
- if (key_cb(ked, bezt))
+ if (key_cb(ked, bezt)) {
return 1;
+ }
}
}
}
else {
for (bezt = fcu->bezt, i = 0; i < fcu->totvert; bezt++, i++) {
- if (ked)
+ if (ked) {
ked->curIndex = i;
+ }
/* Exit with return-code '1' if function returns positive
* This is useful if finding if some BezTriple satisfies a condition.
*/
- if (key_cb(ked, bezt))
+ if (key_cb(ked, bezt)) {
return 1;
+ }
}
}
}
@@ -140,8 +145,9 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked,
}
/* if fcu_cb (F-Curve post-editing callback) has been specified then execute it */
- if (fcu_cb)
+ if (fcu_cb) {
fcu_cb(fcu);
+ }
/* done */
return 0;
@@ -159,13 +165,15 @@ static short agrp_keyframes_loop(KeyframeEditData *ked,
FCurve *fcu;
/* sanity check */
- if (agrp == NULL)
+ if (agrp == NULL) {
return 0;
+ }
/* only iterate over the F-Curves that are in this group */
for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) {
- if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb))
+ if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb)) {
return 1;
+ }
}
return 0;
@@ -181,13 +189,15 @@ static short act_keyframes_loop(KeyframeEditData *ked,
FCurve *fcu;
/* sanity check */
- if (act == NULL)
+ if (act == NULL) {
return 0;
+ }
/* just loop through all F-Curves */
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
- if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb))
+ if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb)) {
return 1;
+ }
}
return 0;
@@ -210,8 +220,9 @@ static short ob_keyframes_loop(KeyframeEditData *ked,
bAnimListElem dummychan = {NULL};
Base dummybase = {NULL};
- if (ob == NULL)
+ if (ob == NULL) {
return 0;
+ }
/* create a dummy wrapper data to work with */
dummybase.object = ob;
@@ -259,8 +270,9 @@ static short scene_keyframes_loop(KeyframeEditData *ked,
bAnimListElem dummychan = {NULL};
- if (sce == NULL)
+ if (sce == NULL) {
return 0;
+ }
/* create a dummy wrapper data to work with */
dummychan.type = ANIMTYPE_SCENE;
@@ -302,8 +314,9 @@ static short summary_keyframes_loop(KeyframeEditData *ked,
int filter, ret_code = 0;
/* sanity check */
- if (ac == NULL)
+ if (ac == NULL) {
return 0;
+ }
/* get F-Curves to take keyframes from */
filter = ANIMFILTER_DATA_VISIBLE;
@@ -328,10 +341,12 @@ static short summary_keyframes_loop(KeyframeEditData *ked,
if (ked->iterflags & (KED_F1_NLA_UNMAP | KED_F2_NLA_UNMAP)) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
- if (ked->iterflags & KED_F1_NLA_UNMAP)
+ if (ked->iterflags & KED_F1_NLA_UNMAP) {
ked->f1 = BKE_nla_tweakedit_remap(adt, f1, NLATIME_CONVERT_UNMAP);
- if (ked->iterflags & KED_F2_NLA_UNMAP)
+ }
+ if (ked->iterflags & KED_F2_NLA_UNMAP) {
ked->f2 = BKE_nla_tweakedit_remap(adt, f2, NLATIME_CONVERT_UNMAP);
+ }
}
/* now operate on the channel as per normal */
@@ -349,8 +364,9 @@ static short summary_keyframes_loop(KeyframeEditData *ked,
}
}
- if (ret_code)
+ if (ret_code) {
break;
+ }
}
ANIM_animdata_freelist(&anim_data);
@@ -369,8 +385,9 @@ short ANIM_animchannel_keyframes_loop(KeyframeEditData *ked,
FcuEditFunc fcu_cb)
{
/* sanity checks */
- if (ale == NULL)
+ if (ale == NULL) {
return 0;
+ }
/* method to use depends on the type of keyframe data */
switch (ale->datatype) {
@@ -408,8 +425,9 @@ short ANIM_animchanneldata_keyframes_loop(KeyframeEditData *ked,
FcuEditFunc fcu_cb)
{
/* sanity checks */
- if (data == NULL)
+ if (data == NULL) {
return 0;
+ }
/* method to use depends on the type of keyframe data */
switch (keytype) {
@@ -522,10 +540,12 @@ static short ok_bezier_selected(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
/* this macro checks all beztriple handles for selection...
* only one of the verts has to be selected for this to be ok...
*/
- if (BEZT_ISSEL_ANY(bezt))
+ if (BEZT_ISSEL_ANY(bezt)) {
return KEYFRAME_OK_ALL;
- else
+ }
+ else {
return 0;
+ }
}
static short ok_bezier_value(KeyframeEditData *ked, BezTriple *bezt)
@@ -571,8 +591,9 @@ static short ok_bezier_region(KeyframeEditData *ked, BezTriple *bezt)
/* return ok flags */
return ok;
}
- else
+ else {
return 0;
+ }
}
/**
@@ -607,8 +628,9 @@ static short ok_bezier_region_lasso(KeyframeEditData *ked, BezTriple *bezt)
/* return ok flags */
return ok;
}
- else
+ else {
return 0;
+ }
}
static short ok_bezier_channel_lasso(KeyframeEditData *ked, BezTriple *bezt)
@@ -632,8 +654,9 @@ static short ok_bezier_channel_lasso(KeyframeEditData *ked, BezTriple *bezt)
pt[0] = bezt->vec[1][0];
pt[1] = ked->channel_y;
- if (keyframe_region_lasso_test(data, pt))
+ if (keyframe_region_lasso_test(data, pt)) {
return KEYFRAME_OK_KEY;
+ }
}
return 0;
}
@@ -669,8 +692,9 @@ static short ok_bezier_region_circle(KeyframeEditData *ked, BezTriple *bezt)
/* return ok flags */
return ok;
}
- else
+ else {
return 0;
+ }
}
static short ok_bezier_channel_circle(KeyframeEditData *ked, BezTriple *bezt)
@@ -694,8 +718,9 @@ static short ok_bezier_channel_circle(KeyframeEditData *ked, BezTriple *bezt)
pt[0] = bezt->vec[1][0];
pt[1] = ked->channel_y;
- if (keyframe_region_circle_test(data, pt))
+ if (keyframe_region_circle_test(data, pt)) {
return KEYFRAME_OK_KEY;
+ }
}
return 0;
}
@@ -802,8 +827,9 @@ void bezt_remap_times(KeyframeEditData *ked, BezTriple *bezt)
/* snaps the keyframe to the nearest frame */
static short snap_bezier_nearest(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->vec[1][0] = (float)(floorf(bezt->vec[1][0] + 0.5f));
+ }
return 0;
}
@@ -813,8 +839,9 @@ static short snap_bezier_nearestsec(KeyframeEditData *ked, BezTriple *bezt)
const Scene *scene = ked->scene;
const float secf = (float)FPS;
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->vec[1][0] = (floorf(bezt->vec[1][0] / secf + 0.5f) * secf);
+ }
return 0;
}
@@ -822,16 +849,18 @@ static short snap_bezier_nearestsec(KeyframeEditData *ked, BezTriple *bezt)
static short snap_bezier_cframe(KeyframeEditData *ked, BezTriple *bezt)
{
const Scene *scene = ked->scene;
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->vec[1][0] = (float)CFRA;
+ }
return 0;
}
/* snaps the keyframe time to the nearest marker's frame */
static short snap_bezier_nearmarker(KeyframeEditData *ked, BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->vec[1][0] = (float)ED_markers_find_nearest_marker_time(&ked->list, bezt->vec[1][0]);
+ }
return 0;
}
@@ -841,10 +870,12 @@ static short snap_bezier_horizontal(KeyframeEditData *UNUSED(ked), BezTriple *be
if (bezt->f2 & SELECT) {
bezt->vec[0][1] = bezt->vec[2][1] = bezt->vec[1][1];
- if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM, HD_VECT))
+ if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) {
bezt->h1 = HD_ALIGN;
- if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM, HD_VECT))
+ }
+ if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) {
bezt->h2 = HD_ALIGN;
+ }
}
return 0;
}
@@ -852,16 +883,18 @@ static short snap_bezier_horizontal(KeyframeEditData *UNUSED(ked), BezTriple *be
/* frame to snap to is stored in the custom data -> first float value slot */
static short snap_bezier_time(KeyframeEditData *ked, BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->vec[1][0] = ked->f1;
+ }
return 0;
}
/* value to snap to is stored in the custom data -> first float value slot */
static short snap_bezier_value(KeyframeEditData *ked, BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->vec[1][1] = ked->f1;
+ }
return 0;
}
@@ -1020,10 +1053,12 @@ KeyframeEditFunc ANIM_editkeyframes_mirror(short type)
static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) {
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
bezt->h1 = HD_AUTO;
- if (bezt->f3 & SELECT)
+ }
+ if (bezt->f3 & SELECT) {
bezt->h2 = HD_AUTO;
+ }
ENSURE_HANDLES_MATCH(bezt);
}
@@ -1036,10 +1071,12 @@ static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) {
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
bezt->h1 = HD_AUTO_ANIM;
- if (bezt->f3 & SELECT)
+ }
+ if (bezt->f3 & SELECT) {
bezt->h2 = HD_AUTO_ANIM;
+ }
ENSURE_HANDLES_MATCH(bezt);
}
@@ -1049,10 +1086,12 @@ static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *b
/* Sets the selected bezier handles to type 'vector' */
static short set_bezier_vector(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
bezt->h1 = HD_VECT;
- if (bezt->f3 & SELECT)
+ }
+ if (bezt->f3 & SELECT) {
bezt->h2 = HD_VECT;
+ }
return 0;
}
@@ -1061,30 +1100,36 @@ static short set_bezier_vector(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
// currently this isn't used, but may be restored later
static short bezier_isfree(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if ((bezt->f1 & SELECT) && (bezt->h1))
+ if ((bezt->f1 & SELECT) && (bezt->h1)) {
return 1;
- if ((bezt->f3 & SELECT) && (bezt->h2))
+ }
+ if ((bezt->f3 & SELECT) && (bezt->h2)) {
return 1;
+ }
return 0;
}
/* Sets selected bezier handles to type 'align' */
static short set_bezier_align(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
bezt->h1 = HD_ALIGN;
- if (bezt->f3 & SELECT)
+ }
+ if (bezt->f3 & SELECT) {
bezt->h2 = HD_ALIGN;
+ }
return 0;
}
/* Sets selected bezier handles to type 'free' */
static short set_bezier_free(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
bezt->h1 = HD_FREE;
- if (bezt->f3 & SELECT)
+ }
+ if (bezt->f3 & SELECT) {
bezt->h2 = HD_FREE;
+ }
return 0;
}
@@ -1114,92 +1159,105 @@ KeyframeEditFunc ANIM_editkeyframes_handles(short code)
static short set_bezt_constant(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_CONST;
+ }
return 0;
}
static short set_bezt_linear(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_LIN;
+ }
return 0;
}
static short set_bezt_bezier(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_BEZ;
+ }
return 0;
}
static short set_bezt_back(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_BACK;
+ }
return 0;
}
static short set_bezt_bounce(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_BOUNCE;
+ }
return 0;
}
static short set_bezt_circle(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_CIRC;
+ }
return 0;
}
static short set_bezt_cubic(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_CUBIC;
+ }
return 0;
}
static short set_bezt_elastic(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_ELASTIC;
+ }
return 0;
}
static short set_bezt_expo(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_EXPO;
+ }
return 0;
}
static short set_bezt_quad(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_QUAD;
+ }
return 0;
}
static short set_bezt_quart(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_QUART;
+ }
return 0;
}
static short set_bezt_quint(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_QUINT;
+ }
return 0;
}
static short set_bezt_sine(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_SINE;
+ }
return 0;
}
@@ -1245,36 +1303,41 @@ KeyframeEditFunc ANIM_editkeyframes_ipo(short code)
static short set_keytype_keyframe(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
BEZKEYTYPE(bezt) = BEZT_KEYTYPE_KEYFRAME;
+ }
return 0;
}
static short set_keytype_breakdown(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
BEZKEYTYPE(bezt) = BEZT_KEYTYPE_BREAKDOWN;
+ }
return 0;
}
static short set_keytype_extreme(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
BEZKEYTYPE(bezt) = BEZT_KEYTYPE_EXTREME;
+ }
return 0;
}
static short set_keytype_jitter(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
BEZKEYTYPE(bezt) = BEZT_KEYTYPE_JITTER;
+ }
return 0;
}
static short set_keytype_moving_hold(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
BEZKEYTYPE(bezt) = BEZT_KEYTYPE_MOVEHOLD;
+ }
return 0;
}
@@ -1304,29 +1367,33 @@ KeyframeEditFunc ANIM_editkeyframes_keytype(short code)
static short set_easingtype_easein(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->easing = BEZT_IPO_EASE_IN;
+ }
return 0;
}
static short set_easingtype_easeout(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->easing = BEZT_IPO_EASE_OUT;
+ }
return 0;
}
static short set_easingtype_easeinout(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->easing = BEZT_IPO_EASE_IN_OUT;
+ }
return 0;
}
static short set_easingtype_easeauto(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->easing = BEZT_IPO_EASE_AUTO;
+ }
return 0;
}
@@ -1355,12 +1422,15 @@ static short select_bezier_add(KeyframeEditData *ked, BezTriple *bezt)
{
/* if we've got info on what to select, use it, otherwise select all */
if ((ked) && (ked->iterflags & KEYFRAME_ITER_INCL_HANDLES)) {
- if (ked->curflags & KEYFRAME_OK_KEY)
+ if (ked->curflags & KEYFRAME_OK_KEY) {
bezt->f2 |= SELECT;
- if (ked->curflags & KEYFRAME_OK_H1)
+ }
+ if (ked->curflags & KEYFRAME_OK_H1) {
bezt->f1 |= SELECT;
- if (ked->curflags & KEYFRAME_OK_H2)
+ }
+ if (ked->curflags & KEYFRAME_OK_H2) {
bezt->f3 |= SELECT;
+ }
}
else {
BEZT_SEL_ALL(bezt);
@@ -1373,12 +1443,15 @@ static short select_bezier_subtract(KeyframeEditData *ked, BezTriple *bezt)
{
/* if we've got info on what to deselect, use it, otherwise deselect all */
if ((ked) && (ked->iterflags & KEYFRAME_ITER_INCL_HANDLES)) {
- if (ked->curflags & KEYFRAME_OK_KEY)
+ if (ked->curflags & KEYFRAME_OK_KEY) {
bezt->f2 &= ~SELECT;
- if (ked->curflags & KEYFRAME_OK_H1)
+ }
+ if (ked->curflags & KEYFRAME_OK_H1) {
bezt->f1 &= ~SELECT;
- if (ked->curflags & KEYFRAME_OK_H2)
+ }
+ if (ked->curflags & KEYFRAME_OK_H2) {
bezt->f3 &= ~SELECT;
+ }
}
else {
BEZT_DESEL_ALL(bezt);
@@ -1476,8 +1549,9 @@ static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt)
if (i > 0) {
BezTriple *prev = bezt - 1;
- if (BEZT_ISSEL_ANY(prev) == 0)
+ if (BEZT_ISSEL_ANY(prev) == 0) {
return 0;
+ }
}
else if (i == 0) {
/* current keyframe is selected at an endpoint, so should get deselected */
@@ -1488,8 +1562,9 @@ static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt)
if (i < (fcu->totvert - 1)) {
BezTriple *next = bezt + 1;
- if (BEZT_ISSEL_ANY(next) == 0)
+ if (BEZT_ISSEL_ANY(next) == 0) {
return 0;
+ }
}
else if (i == (fcu->totvert - 1)) {
/* current keyframe is selected at an endpoint, so should get deselected */
diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c
index 3109ae6c553..5214c5f78fa 100644
--- a/source/blender/editors/animation/keyframes_general.c
+++ b/source/blender/editors/animation/keyframes_general.c
@@ -70,17 +70,20 @@
void delete_fcurve_key(FCurve *fcu, int index, bool do_recalc)
{
/* sanity check */
- if (fcu == NULL)
+ if (fcu == NULL) {
return;
+ }
/* verify the index:
* 1) cannot be greater than the number of available keyframes
* 2) negative indices are for specifying a value from the end of the array
*/
- if (abs(index) >= fcu->totvert)
+ if (abs(index) >= fcu->totvert) {
return;
- else if (index < 0)
+ }
+ else if (index < 0) {
index += fcu->totvert;
+ }
/* Delete this keyframe */
memmove(
@@ -88,14 +91,16 @@ void delete_fcurve_key(FCurve *fcu, int index, bool do_recalc)
fcu->totvert--;
if (fcu->totvert == 0) {
- if (fcu->bezt)
+ if (fcu->bezt) {
MEM_freeN(fcu->bezt);
+ }
fcu->bezt = NULL;
}
/* recalc handles - only if it won't cause problems */
- if (do_recalc)
+ if (do_recalc) {
calchandles_fcurve(fcu);
+ }
}
/* Delete selected keyframes in given F-Curve */
@@ -104,8 +109,9 @@ bool delete_fcurve_keys(FCurve *fcu)
int i;
bool changed = false;
- if (fcu->bezt == NULL) /* ignore baked curves */
+ if (fcu->bezt == NULL) { /* ignore baked curves */
return false;
+ }
/* Delete selected BezTriples */
for (i = 0; i < fcu->totvert; i++) {
@@ -118,16 +124,18 @@ bool delete_fcurve_keys(FCurve *fcu)
}
/* Free the array of BezTriples if there are not keyframes */
- if (fcu->totvert == 0)
+ if (fcu->totvert == 0) {
clear_fcurve_keys(fcu);
+ }
return changed;
}
void clear_fcurve_keys(FCurve *fcu)
{
- if (fcu->bezt)
+ if (fcu->bezt) {
MEM_freeN(fcu->bezt);
+ }
fcu->bezt = NULL;
fcu->totvert = 0;
@@ -142,8 +150,9 @@ void duplicate_fcurve_keys(FCurve *fcu)
int i;
/* this can only work when there is an F-Curve, and also when there are some BezTriples */
- if (ELEM(NULL, fcu, fcu->bezt))
+ if (ELEM(NULL, fcu, fcu->bezt)) {
return;
+ }
for (i = 0; i < fcu->totvert; i++) {
/* If a key is selected */
@@ -283,8 +292,9 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
}
/* now free the memory used by the old BezTriples */
- if (old_bezts)
+ if (old_bezts) {
MEM_freeN(old_bezts);
+ }
/* final step, if there is just one key in fcurve, check if it's
* the default value and if is, remove fcurve completely. */
@@ -296,8 +306,9 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
/* get property to read from, and get value as appropriate */
if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) {
- if (RNA_property_type(prop) == PROP_FLOAT)
+ if (RNA_property_type(prop) == PROP_FLOAT) {
default_value = RNA_property_float_get_default_index(&ptr, prop, fcu->array_index);
+ }
}
if (fcu->bezt->vec[1][1] == default_value) {
@@ -336,8 +347,9 @@ void smooth_fcurve(FCurve *fcu)
/* first loop through - count how many verts are selected */
bezt = fcu->bezt;
for (i = 0; i < fcu->totvert; i++, bezt++) {
- if (BEZT_ISSEL_ANY(bezt))
+ if (BEZT_ISSEL_ANY(bezt)) {
totSel++;
+ }
}
/* if any points were selected, allocate tSmooth_Bezt points to work on */
@@ -357,10 +369,12 @@ void smooth_fcurve(FCurve *fcu)
tsb->h3 = &bezt->vec[2][1];
/* advance to the next tsb to populate */
- if (x < totSel - 1)
+ if (x < totSel - 1) {
tsb++;
- else
+ }
+ else {
break;
+ }
}
}
@@ -433,8 +447,9 @@ void sample_fcurve(FCurve *fcu)
int sfra, range;
int i, n;
- if (fcu->bezt == NULL) /* ignore baked */
+ if (fcu->bezt == NULL) { /* ignore baked */
return;
+ }
/* find selected keyframes... once pair has been found, add keyframes */
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
@@ -543,12 +558,14 @@ void ANIM_fcurves_copybuf_free(void)
acn = aci->next;
/* free keyframes */
- if (aci->bezt)
+ if (aci->bezt) {
MEM_freeN(aci->bezt);
+ }
/* free RNA-path */
- if (aci->rna_path)
+ if (aci->rna_path) {
MEM_freeN(aci->rna_path);
+ }
/* free ourself */
BLI_freelinkN(&animcopybuf, aci);
@@ -583,8 +600,9 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
* - this check should also eliminate any problems associated with using sample-data
*/
if (ANIM_fcurve_keyframes_loop(
- NULL, fcu, NULL, ANIM_editkeyframes_ok(BEZT_OK_SELECTED), NULL) == 0)
+ NULL, fcu, NULL, ANIM_editkeyframes_ok(BEZT_OK_SELECTED), NULL) == 0) {
continue;
+ }
/* init copybuf item info */
aci = MEM_callocN(sizeof(tAnimCopybufItem), "AnimCopybufItem");
@@ -607,8 +625,9 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
if (pchan) {
aci->is_bone = true;
}
- if (bone_name)
+ if (bone_name) {
MEM_freeN(bone_name);
+ }
}
BLI_addtail(&animcopybuf, aci);
@@ -622,8 +641,9 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
newbuf = MEM_callocN(sizeof(BezTriple) * (aci->totvert + 1), "copybuf beztriple");
/* assume that since we are just re-sizing the array, just copy all existing data across */
- if (aci->bezt)
+ if (aci->bezt) {
memcpy(newbuf, aci->bezt, sizeof(BezTriple) * (aci->totvert));
+ }
/* copy current beztriple across too */
nbezt = &newbuf[aci->totvert];
@@ -633,23 +653,27 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
BEZT_SEL_ALL(nbezt);
/* free old array and set the new */
- if (aci->bezt)
+ if (aci->bezt) {
MEM_freeN(aci->bezt);
+ }
aci->bezt = newbuf;
aci->totvert++;
/* check if this is the earliest frame encountered so far */
- if (bezt->vec[1][0] < animcopy_firstframe)
+ if (bezt->vec[1][0] < animcopy_firstframe) {
animcopy_firstframe = bezt->vec[1][0];
- if (bezt->vec[1][0] > animcopy_lastframe)
+ }
+ if (bezt->vec[1][0] > animcopy_lastframe) {
animcopy_lastframe = bezt->vec[1][0];
+ }
}
}
}
/* check if anything ended up in the buffer */
- if (ELEM(NULL, animcopybuf.first, animcopybuf.last))
+ if (ELEM(NULL, animcopybuf.first, animcopybuf.last)) {
return -1;
+ }
/* in case 'relative' paste method is used */
animcopy_cfra = CFRA;
@@ -762,8 +786,9 @@ static tAnimCopybufItem *pastebuf_match_path_property(Main *bmain,
if (len_id <= len_path) {
/* note, paths which end with "] will fail with this test - Animated ID Props */
if (STREQ(identifier, fcu->rna_path + (len_path - len_id))) {
- if ((from_single) || (aci->array_index == fcu->array_index))
+ if ((from_single) || (aci->array_index == fcu->array_index)) {
break;
+ }
}
}
}
@@ -803,17 +828,21 @@ static void do_curve_mirror_flippping(tAnimCopybufItem *aci, BezTriple *bezt)
if (aci->is_bone) {
const size_t slength = strlen(aci->rna_path);
bool flip = false;
- if (BLI_strn_endswith(aci->rna_path, "location", slength) && aci->array_index == 0)
+ if (BLI_strn_endswith(aci->rna_path, "location", slength) && aci->array_index == 0) {
flip = true;
+ }
else if (BLI_strn_endswith(aci->rna_path, "rotation_quaternion", slength) &&
- ELEM(aci->array_index, 2, 3))
+ ELEM(aci->array_index, 2, 3)) {
flip = true;
+ }
else if (BLI_strn_endswith(aci->rna_path, "rotation_euler", slength) &&
- ELEM(aci->array_index, 1, 2))
+ ELEM(aci->array_index, 1, 2)) {
flip = true;
+ }
else if (BLI_strn_endswith(aci->rna_path, "rotation_axis_angle", slength) &&
- ELEM(aci->array_index, 2, 3))
+ ELEM(aci->array_index, 2, 3)) {
flip = true;
+ }
if (flip) {
bezt->vec[0][1] = -bezt->vec[0][1];
@@ -879,8 +908,9 @@ static void paste_animedit_keys_fcurve(
/* just start pasting, with the first keyframe on the current frame, and so on */
for (i = 0, bezt = aci->bezt; i < aci->totvert; i++, bezt++) {
/* temporarily apply offset to src beztriple while copying */
- if (flip)
+ if (flip) {
do_curve_mirror_flippping(aci, bezt);
+ }
bezt->vec[0][0] += offset;
bezt->vec[1][0] += offset;
@@ -897,8 +927,9 @@ static void paste_animedit_keys_fcurve(
bezt->vec[1][0] -= offset;
bezt->vec[2][0] -= offset;
- if (flip)
+ if (flip) {
do_curve_mirror_flippping(aci, bezt);
+ }
}
/* recalculate F-Curve's handles? */
@@ -1054,8 +1085,9 @@ short paste_animedit_keys(bAnimContext *ac,
}
/* don't continue if some fcurves were pasted */
- if (totmatch)
+ if (totmatch) {
break;
+ }
}
}
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 56c52665613..4851665c9f3 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -94,27 +94,32 @@ short ANIM_get_keyframing_flags(Scene *scene, short incl_mode)
/* standard flags */
{
/* visual keying */
- if (IS_AUTOKEY_FLAG(scene, AUTOMATKEY))
+ if (IS_AUTOKEY_FLAG(scene, AUTOMATKEY)) {
flag |= INSERTKEY_MATRIX;
+ }
/* only needed */
- if (IS_AUTOKEY_FLAG(scene, INSERTNEEDED))
+ if (IS_AUTOKEY_FLAG(scene, INSERTNEEDED)) {
flag |= INSERTKEY_NEEDED;
+ }
/* default F-Curve color mode - RGB from XYZ indices */
- if (IS_AUTOKEY_FLAG(scene, XYZ2RGB))
+ if (IS_AUTOKEY_FLAG(scene, XYZ2RGB)) {
flag |= INSERTKEY_XYZ2RGB;
+ }
}
/* only if including settings from the autokeying mode... */
if (incl_mode) {
/* keyframing mode - only replace existing keyframes */
- if (IS_AUTOKEY_MODE(scene, EDITKEYS))
+ if (IS_AUTOKEY_MODE(scene, EDITKEYS)) {
flag |= INSERTKEY_REPLACE;
+ }
/* cycle-aware keyframe insertion - preserve cycle period and flow */
- if (IS_AUTOKEY_FLAG(scene, CYCLEAWARE))
+ if (IS_AUTOKEY_FLAG(scene, CYCLEAWARE)) {
flag |= INSERTKEY_CYCLE_AWARE;
+ }
}
return flag;
@@ -132,8 +137,9 @@ bAction *verify_adt_action(Main *bmain, ID *id, short add)
/* init animdata if none available yet */
adt = BKE_animdata_from_id(id);
- if ((adt == NULL) && (add))
+ if ((adt == NULL) && (add)) {
adt = BKE_animdata_add_id(id);
+ }
if (adt == NULL) {
/* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */
printf("ERROR: Couldn't add AnimData (ID = %s)\n", (id) ? (id->name) : "<None>");
@@ -181,8 +187,9 @@ FCurve *verify_fcurve(Main *bmain,
FCurve *fcu;
/* sanity checks */
- if (ELEM(NULL, act, rna_path))
+ if (ELEM(NULL, act, rna_path)) {
return NULL;
+ }
/* try to find f-curve matching for this setting
* - add if not found and allowed to add one
@@ -196,8 +203,9 @@ FCurve *verify_fcurve(Main *bmain,
fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED);
fcu->auto_smoothing = FCURVE_SMOOTH_CONT_ACCEL;
- if (BLI_listbase_is_empty(&act->curves))
+ if (BLI_listbase_is_empty(&act->curves)) {
fcu->flag |= FCURVE_ACTIVE; /* first one added active */
+ }
/* store path - make copy, and store that */
fcu->rna_path = BLI_strdup(rna_path);
@@ -414,15 +422,17 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag)
/* Add the beztriples that should occur before the beztriple to be pasted
* (originally in fcu). */
- if (i > 0)
+ if (i > 0) {
memcpy(newb, fcu->bezt, i * sizeof(BezTriple));
+ }
/* add beztriple to paste at index i */
*(newb + i) = *bezt;
/* add the beztriples that occur after the beztriple to be pasted (originally in fcu) */
- if (i < fcu->totvert)
+ if (i < fcu->totvert) {
memcpy(newb + i + 1, fcu->bezt + i, (fcu->totvert - i) * sizeof(BezTriple));
+ }
/* replace (+ free) old with new, only if necessary to do so */
MEM_freeN(fcu->bezt);
@@ -533,15 +543,17 @@ int insert_vert_fcurve(
/* what if 'a' is a negative index?
* for now, just exit to prevent any segfaults
*/
- if (a < 0)
+ if (a < 0) {
return -1;
+ }
/* don't recalculate handles if fast is set
* - this is a hack to make importers faster
* - we may calculate twice (due to autohandle needing to be calculated twice)
*/
- if ((flag & INSERTKEY_FAST) == 0)
+ if ((flag & INSERTKEY_FAST) == 0) {
calchandles_fcurve(fcu);
+ }
/* set handletype and interpolation */
if ((fcu->totvert > 2) && (flag & INSERTKEY_REPLACE) == 0) {
@@ -553,18 +565,21 @@ int insert_vert_fcurve(
* - When replacing, the user may have specified some interpolation that should be kept.
*/
if (fcu->totvert > oldTot) {
- if (a > 0)
+ if (a > 0) {
bezt->ipo = (bezt - 1)->ipo;
- else if (a < fcu->totvert - 1)
+ }
+ else if (a < fcu->totvert - 1) {
bezt->ipo = (bezt + 1)->ipo;
+ }
}
/* don't recalculate handles if fast is set
* - this is a hack to make importers faster
* - we may calculate twice (due to autohandle needing to be calculated twice)
*/
- if ((flag & INSERTKEY_FAST) == 0)
+ if ((flag & INSERTKEY_FAST) == 0) {
calchandles_fcurve(fcu);
+ }
}
/* return the index at which the keyframe was added */
@@ -593,11 +608,13 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
float valA = 0.0f, valB = 0.0f;
/* safety checking */
- if (fcu == NULL)
+ if (fcu == NULL) {
return KEYNEEDED_JUSTADD;
+ }
totCount = fcu->totvert;
- if (totCount == 0)
+ if (totCount == 0) {
return KEYNEEDED_JUSTADD;
+ }
/* loop through checking if any are the same */
bezt = fcu->bezt;
@@ -634,10 +651,12 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
realVal = evaluate_fcurve(fcu, cFrame);
/* compare whether it's the same as proposed */
- if (IS_EQF(realVal, nValue))
+ if (IS_EQF(realVal, nValue)) {
return KEYNEEDED_DONTADD;
- else
+ }
+ else {
return KEYNEEDED_JUSTADD;
+ }
}
}
@@ -647,18 +666,21 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
* stays around or not depends on whether the values of previous/current
* beztriples and new keyframe are the same.
*/
- if (IS_EQF(prevVal, nValue) && IS_EQF(beztVal, nValue) && IS_EQF(prevVal, beztVal))
+ if (IS_EQF(prevVal, nValue) && IS_EQF(beztVal, nValue) && IS_EQF(prevVal, beztVal)) {
return KEYNEEDED_DELNEXT;
- else
+ }
+ else {
return KEYNEEDED_JUSTADD;
+ }
}
}
else {
/* just add a keyframe if there's only one keyframe
* and the new one occurs before the existing one does.
*/
- if ((cFrame < beztPosi) && (totCount == 1))
+ if ((cFrame < beztPosi) && (totCount == 1)) {
return KEYNEEDED_JUSTADD;
+ }
}
/* continue. frame to do not yet passed (or other conditions not met) */
@@ -666,8 +688,9 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
prev = bezt;
bezt++;
}
- else
+ else {
break;
+ }
}
/* Frame in which to add a new-keyframe occurs after all other keys
@@ -680,15 +703,19 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
bezt = (fcu->bezt + (fcu->totvert - 1));
valA = bezt->vec[1][1];
- if (prev)
+ if (prev) {
valB = prev->vec[1][1];
- else
+ }
+ else {
valB = bezt->vec[1][1] + 1.0f;
+ }
- if (IS_EQF(valA, nValue) && IS_EQF(valA, valB))
+ if (IS_EQF(valA, nValue) && IS_EQF(valA, valB)) {
return KEYNEEDED_DELPREV;
- else
+ }
+ else {
return KEYNEEDED_JUSTADD;
+ }
}
/* ------------------ RNA Data-Access Functions ------------------ */
@@ -794,8 +821,9 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop)
const char *identifier = NULL;
/* validate data */
- if (ELEM(NULL, ptr, ptr->data, prop))
+ if (ELEM(NULL, ptr, ptr->data, prop)) {
return false;
+ }
/* get first constraint and determine type of keyframe constraints to check for
* - constraints can be on either Objects or PoseChannels, so we only check if the
@@ -824,8 +852,9 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop)
}
/* check if any data to search using */
- if (ELEM(NULL, con, identifier) && (has_parent == false) && (has_rigidbody == false))
+ if (ELEM(NULL, con, identifier) && (has_parent == false) && (has_rigidbody == false)) {
return false;
+ }
/* location or rotation identifiers only... */
if (identifier == NULL) {
@@ -849,16 +878,19 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop)
/* only search if a searchtype and initial constraint are available */
if (searchtype) {
/* parent or rigidbody are always matching */
- if (has_parent || has_rigidbody)
+ if (has_parent || has_rigidbody) {
return true;
+ }
/* constraints */
for (; con; con = con->next) {
/* only consider constraint if it is not disabled, and has influence */
- if (con->flag & CONSTRAINT_DISABLE)
+ if (con->flag & CONSTRAINT_DISABLE) {
continue;
- if (con->enforce == 0.0f)
+ }
+ if (con->enforce == 0.0f) {
continue;
+ }
/* some constraints may alter these transforms */
switch (con->type) {
@@ -876,48 +908,59 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop)
/* single-transform constraints */
case CONSTRAINT_TYPE_TRACKTO:
- if (searchtype == VISUALKEY_ROT)
+ if (searchtype == VISUALKEY_ROT) {
return true;
+ }
break;
case CONSTRAINT_TYPE_DAMPTRACK:
- if (searchtype == VISUALKEY_ROT)
+ if (searchtype == VISUALKEY_ROT) {
return true;
+ }
break;
case CONSTRAINT_TYPE_ROTLIMIT:
- if (searchtype == VISUALKEY_ROT)
+ if (searchtype == VISUALKEY_ROT) {
return true;
+ }
break;
case CONSTRAINT_TYPE_LOCLIMIT:
- if (searchtype == VISUALKEY_LOC)
+ if (searchtype == VISUALKEY_LOC) {
return true;
+ }
break;
case CONSTRAINT_TYPE_SIZELIMIT:
- if (searchtype == VISUALKEY_SCA)
+ if (searchtype == VISUALKEY_SCA) {
return true;
+ }
break;
case CONSTRAINT_TYPE_DISTLIMIT:
- if (searchtype == VISUALKEY_LOC)
+ if (searchtype == VISUALKEY_LOC) {
return true;
+ }
break;
case CONSTRAINT_TYPE_ROTLIKE:
- if (searchtype == VISUALKEY_ROT)
+ if (searchtype == VISUALKEY_ROT) {
return true;
+ }
break;
case CONSTRAINT_TYPE_LOCLIKE:
- if (searchtype == VISUALKEY_LOC)
+ if (searchtype == VISUALKEY_LOC) {
return true;
+ }
break;
case CONSTRAINT_TYPE_SIZELIKE:
- if (searchtype == VISUALKEY_SCA)
+ if (searchtype == VISUALKEY_SCA) {
return true;
+ }
break;
case CONSTRAINT_TYPE_LOCKTRACK:
- if (searchtype == VISUALKEY_ROT)
+ if (searchtype == VISUALKEY_ROT) {
return true;
+ }
break;
case CONSTRAINT_TYPE_MINMAX:
- if (searchtype == VISUALKEY_LOC)
+ if (searchtype == VISUALKEY_LOC) {
return true;
+ }
break;
default:
@@ -1512,8 +1555,9 @@ static bool delete_keyframe_fcurve(AnimData *adt, FCurve *fcu, float cfra)
/* Only delete curve too if it won't be doing anything anymore */
if ((fcu->totvert == 0) &&
- (list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE) == 0))
+ (list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE) == 0)) {
ANIM_fcurve_delete_from_animdata(NULL, adt, fcu);
+ }
/* return success */
return true;
@@ -1598,8 +1642,9 @@ short delete_keyframe(Main *bmain,
* but don't do this for standard arrays since that can cause corruption issues
* (extra unused curves)
*/
- if (array_index_max == array_index)
+ if (array_index_max == array_index) {
array_index_max++;
+ }
}
/* will only loop once unless the array index was -1 */
@@ -1607,8 +1652,9 @@ short delete_keyframe(Main *bmain,
FCurve *fcu = verify_fcurve(bmain, act, group, &ptr, rna_path, array_index, 0);
/* check if F-Curve exists and/or whether it can be edited */
- if (fcu == NULL)
+ if (fcu == NULL) {
continue;
+ }
if (BKE_fcurve_is_protected(fcu)) {
BKE_reportf(reports,
@@ -1698,8 +1744,9 @@ static short clear_keyframe(Main *bmain,
* but don't do this for standard arrays since that can cause corruption issues
* (extra unused curves)
*/
- if (array_index_max == array_index)
+ if (array_index_max == array_index) {
array_index_max++;
+ }
}
/* will only loop once unless the array index was -1 */
@@ -1707,8 +1754,9 @@ static short clear_keyframe(Main *bmain,
FCurve *fcu = verify_fcurve(bmain, act, group, &ptr, rna_path, array_index, 0);
/* check if F-Curve exists and/or whether it can be edited */
- if (fcu == NULL)
+ if (fcu == NULL) {
continue;
+ }
if (BKE_fcurve_is_protected(fcu)) {
BKE_reportf(reports,
@@ -1751,8 +1799,9 @@ static bool modify_key_op_poll(bContext *C)
Scene *scene = CTX_data_scene(C);
/* if no area or active scene */
- if (ELEM(NULL, sa, scene))
+ if (ELEM(NULL, sa, scene)) {
return false;
+ }
/* should be fine */
return true;
@@ -1784,12 +1833,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);
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
BKE_reportf(op->reports,
RPT_INFO,
"Keying set '%s' - successfully added %d keyframes",
ks->name,
success);
+ }
/* restore the edit mode if necessary */
if (ob_edit_mode) {
@@ -1803,18 +1853,20 @@ static int insert_key_exec(bContext *C, wmOperator *op)
}
else if (success) {
/* if the appropriate properties have been set, make a note that we've inserted something */
- if (RNA_boolean_get(op->ptr, "confirm_success"))
+ if (RNA_boolean_get(op->ptr, "confirm_success")) {
BKE_reportf(op->reports,
RPT_INFO,
"Successfully added %d keyframes for keying set '%s'",
success,
ks->name);
+ }
/* send notifiers that keyframes have been changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
}
- else
+ else {
BKE_report(op->reports, RPT_WARNING, "Keying set failed to insert any keyframes");
+ }
return OPERATOR_FINISHED;
}
@@ -2006,8 +2058,9 @@ 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);
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("KeyingSet '%s' - Successfully removed %d Keyframes\n", ks->name, success);
+ }
/* report failure or do updates? */
if (success == MODIFYKEY_INVALID_CONTEXT) {
@@ -2016,18 +2069,20 @@ static int delete_key_exec(bContext *C, wmOperator *op)
}
else if (success) {
/* if the appropriate properties have been set, make a note that we've inserted something */
- if (RNA_boolean_get(op->ptr, "confirm_success"))
+ if (RNA_boolean_get(op->ptr, "confirm_success")) {
BKE_reportf(op->reports,
RPT_INFO,
"Successfully removed %d keyframes for keying set '%s'",
success,
ks->name);
+ }
/* send notifiers that keyframes have been changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL);
}
- else
+ else {
BKE_report(op->reports, RPT_WARNING, "Keying set failed to remove any keyframes");
+ }
return OPERATOR_FINISHED;
}
@@ -2127,13 +2182,15 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op))
/* get bone-name, and check if this bone is selected */
bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
- if (bone_name)
+ if (bone_name) {
MEM_freeN(bone_name);
+ }
/* delete if bone is selected*/
if ((pchan) && (pchan->bone)) {
- if (pchan->bone->flag & BONE_SELECTED)
+ if (pchan->bone->flag & BONE_SELECTED) {
can_delete = true;
+ }
}
}
}
@@ -2220,8 +2277,9 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op)
/* get bone-name, and check if this bone is selected */
bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
- if (bone_name)
+ if (bone_name) {
MEM_freeN(bone_name);
+ }
/* skip if bone is not selected */
if ((pchan) && (pchan->bone)) {
@@ -2229,15 +2287,18 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op)
bArmature *arm = (bArmature *)ob->data;
/* skipping - not visible on currently visible layers */
- if ((arm->layer & pchan->bone->layer) == 0)
+ if ((arm->layer & pchan->bone->layer) == 0) {
continue;
+ }
/* skipping - is currently hidden */
- if (pchan->bone->flag & BONE_HIDDEN_P)
+ if (pchan->bone->flag & BONE_HIDDEN_P) {
continue;
+ }
/* selection flag... */
- if ((pchan->bone->flag & BONE_SELECTED) == 0)
+ if ((pchan->bone->flag & BONE_SELECTED) == 0) {
continue;
+ }
}
}
@@ -2250,14 +2311,16 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op)
}
/* report success (or failure) */
- if (success)
+ if (success) {
BKE_reportf(op->reports,
RPT_INFO,
"Object '%s' successfully had %d keyframes removed",
id->name + 2,
success);
- else
+ }
+ else {
BKE_reportf(op->reports, RPT_ERROR, "No keyframes removed from Object '%s'", id->name + 2);
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
}
@@ -2532,8 +2595,9 @@ static int delete_key_button_exec(bContext *C, wmOperator *op)
bmain, op->reports, ptr.id.data, NULL, NULL, path, index, cfra, 0);
MEM_freeN(path);
}
- else if (G.debug & G_DEBUG)
+ else if (G.debug & G_DEBUG) {
printf("Button Delete-Key: no path to property\n");
+ }
}
}
else if (G.debug & G_DEBUG) {
@@ -2599,8 +2663,9 @@ static int clear_key_button_exec(bContext *C, wmOperator *op)
success += clear_keyframe(bmain, op->reports, ptr.id.data, NULL, NULL, path, index, 0);
MEM_freeN(path);
}
- else if (G.debug & G_DEBUG)
+ else if (G.debug & G_DEBUG) {
printf("Button Clear-Key: no path to property\n");
+ }
}
else if (G.debug & G_DEBUG) {
printf("ptr.data = %p, prop = %p\n", (void *)ptr.data, (void *)prop);
@@ -2643,8 +2708,9 @@ bool autokeyframe_cfra_can_key(Scene *scene, ID *id)
float cfra = (float)CFRA; // XXX for now, this will do
/* only filter if auto-key mode requires this */
- if (IS_AUTOKEY_ON(scene) == 0)
+ if (IS_AUTOKEY_ON(scene) == 0) {
return false;
+ }
if (IS_AUTOKEY_MODE(scene, EDITKEYS)) {
/* Replace Mode:
@@ -2675,8 +2741,9 @@ bool autokeyframe_cfra_can_key(Scene *scene, ID *id)
bool fcurve_frame_has_keyframe(FCurve *fcu, float frame, short filter)
{
/* quick sanity check */
- if (ELEM(NULL, fcu, fcu->bezt))
+ if (ELEM(NULL, fcu, fcu->bezt)) {
return false;
+ }
/* we either include all regardless of muting, or only non-muted */
if ((filter & ANIMFILTER_KEYS_MUTED) || (fcu->flag & FCURVE_MUTED) == 0) {
@@ -2688,8 +2755,9 @@ bool fcurve_frame_has_keyframe(FCurve *fcu, float frame, short filter)
*/
if (replace) {
/* sanity check: 'i' may in rare cases exceed arraylen */
- if ((i >= 0) && (i < fcu->totvert))
+ if ((i >= 0) && (i < fcu->totvert)) {
return true;
+ }
}
}
@@ -2727,12 +2795,14 @@ static bool action_frame_has_keyframe(bAction *act, float frame, short filter)
FCurve *fcu;
/* can only find if there is data */
- if (act == NULL)
+ if (act == NULL) {
return false;
+ }
/* if only check non-muted, check if muted */
- if ((filter & ANIMFILTER_KEYS_MUTED) || (act->flag & ACT_MUTED))
+ if ((filter & ANIMFILTER_KEYS_MUTED) || (act->flag & ACT_MUTED)) {
return false;
+ }
/* loop over F-Curves, using binary-search to try to find matches
* - this assumes that keyframes are only beztriples
@@ -2740,8 +2810,9 @@ static bool action_frame_has_keyframe(bAction *act, float frame, short filter)
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
/* only check if there are keyframes (currently only of type BezTriple) */
if (fcu->bezt && fcu->totvert) {
- if (fcurve_frame_has_keyframe(fcu, frame, filter))
+ if (fcurve_frame_has_keyframe(fcu, frame, filter)) {
return true;
+ }
}
}
@@ -2753,8 +2824,9 @@ static bool action_frame_has_keyframe(bAction *act, float frame, short filter)
static bool object_frame_has_keyframe(Object *ob, float frame, short filter)
{
/* error checking */
- if (ob == NULL)
+ if (ob == NULL) {
return false;
+ }
/* check own animation data - specifically, the action it contains */
if ((ob->adt) && (ob->adt->action)) {
@@ -2764,8 +2836,9 @@ static bool object_frame_has_keyframe(Object *ob, float frame, short filter)
*/
float ob_frame = BKE_nla_tweakedit_remap(ob->adt, frame, NLATIME_CONVERT_UNMAP);
- if (action_frame_has_keyframe(ob->adt->action, ob_frame, filter))
+ if (action_frame_has_keyframe(ob->adt->action, ob_frame, filter)) {
return true;
+ }
}
/* try shapekey keyframes (if available, and allowed by filter) */
@@ -2777,8 +2850,9 @@ static bool object_frame_has_keyframe(Object *ob, float frame, short filter)
*/
/* 1. test for relative (with keyframes) */
- if (id_frame_has_keyframe((ID *)key, frame, filter))
+ if (id_frame_has_keyframe((ID *)key, frame, filter)) {
return true;
+ }
/* 2. test for time */
/* TODO... yet to be implemented (this feature may evolve before then anyway) */
@@ -2791,8 +2865,9 @@ static bool object_frame_has_keyframe(Object *ob, float frame, short filter)
Material *ma = give_current_material(ob, (ob->actcol + 1));
/* we only retrieve the active material... */
- if (id_frame_has_keyframe((ID *)ma, frame, filter))
+ if (id_frame_has_keyframe((ID *)ma, frame, filter)) {
return true;
+ }
}
else {
int a;
@@ -2801,8 +2876,9 @@ static bool object_frame_has_keyframe(Object *ob, float frame, short filter)
for (a = 0; a < ob->totcol; a++) {
Material *ma = give_current_material(ob, a + 1);
- if (id_frame_has_keyframe((ID *)ma, frame, filter))
+ if (id_frame_has_keyframe((ID *)ma, frame, filter)) {
return true;
+ }
}
}
}
@@ -2817,8 +2893,9 @@ static bool object_frame_has_keyframe(Object *ob, float frame, short filter)
bool id_frame_has_keyframe(ID *id, float frame, short filter)
{
/* sanity checks */
- if (id == NULL)
+ if (id == NULL) {
return false;
+ }
/* perform special checks for 'macro' types */
switch (GS(id->name)) {
@@ -2834,8 +2911,9 @@ bool id_frame_has_keyframe(ID *id, float frame, short filter)
AnimData *adt = BKE_animdata_from_id(id);
/* only check keyframes in active action */
- if (adt)
+ if (adt) {
return action_frame_has_keyframe(adt->action, frame, filter);
+ }
break;
}
}
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index 90651a55a42..7362a7e04a1 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -76,8 +76,9 @@ static bool keyingset_poll_active_edit(bContext *C)
{
Scene *scene = CTX_data_scene(C);
- if (scene == NULL)
+ if (scene == NULL) {
return 0;
+ }
/* there must be an active KeyingSet (and KeyingSets) */
return ((scene->active_keyingset > 0) && (scene->keyingsets.first));
@@ -89,12 +90,15 @@ static bool keyingset_poll_activePath_edit(bContext *C)
Scene *scene = CTX_data_scene(C);
KeyingSet *ks;
- if (scene == NULL)
+ if (scene == NULL) {
return 0;
- if (scene->active_keyingset <= 0)
+ }
+ if (scene->active_keyingset <= 0) {
return 0;
- else
+ }
+ else {
ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
+ }
/* there must be an active KeyingSet and an active path */
return ((ks) && (ks->paths.first) && (ks->active_path > 0));
@@ -157,8 +161,9 @@ static int remove_active_keyingset_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Cannot remove built in keying set");
return OPERATOR_CANCELLED;
}
- else
+ else {
ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
+ }
/* free KeyingSet's data, then remove it from the scene */
BKE_keyingset_free(ks);
@@ -201,8 +206,9 @@ static int add_empty_ks_path_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No active keying set to add empty path to");
return OPERATOR_CANCELLED;
}
- else
+ else {
ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
+ }
/* don't use the API method for this, since that checks on values... */
ksp = MEM_callocN(sizeof(KS_Path), "KeyingSetPath Empty");
@@ -307,8 +313,9 @@ static int add_keyingset_button_exec(bContext *C, wmOperator *op)
keyingflag |= ANIM_get_keyframing_flags(scene, 0);
- if (IS_AUTOKEY_FLAG(scene, XYZ2RGB))
+ if (IS_AUTOKEY_FLAG(scene, XYZ2RGB)) {
keyingflag |= INSERTKEY_XYZ2RGB;
+ }
/* call the API func, and set the active keyingset index */
ks = BKE_keyingset_add(
@@ -531,8 +538,9 @@ ListBase builtin_keyingsets = {NULL, NULL};
KeyingSetInfo *ANIM_keyingset_info_find_name(const char name[])
{
/* sanity checks */
- if ((name == NULL) || (name[0] == 0))
+ if ((name == NULL) || (name[0] == 0)) {
return NULL;
+ }
/* search by comparing names */
return BLI_findstring(&keyingset_type_infos, name, offsetof(KeyingSetInfo, idname));
@@ -544,19 +552,23 @@ KeyingSet *ANIM_builtin_keyingset_get_named(KeyingSet *prevKS, const char name[]
KeyingSet *ks, *first = NULL;
/* sanity checks any name to check? */
- if (name[0] == 0)
+ if (name[0] == 0) {
return NULL;
+ }
/* get first KeyingSet to use */
- if (prevKS && prevKS->next)
+ if (prevKS && prevKS->next) {
first = prevKS->next;
- else
+ }
+ else {
first = builtin_keyingsets.first;
+ }
/* loop over KeyingSets checking names */
for (ks = first; ks; ks = ks->next) {
- if (STREQ(name, ks->idname))
+ if (STREQ(name, ks->idname)) {
return ks;
+ }
}
/* complain about missing keying sets on debug builds */
@@ -609,8 +621,9 @@ void ANIM_keyingset_info_unregister(Main *bmain, KeyingSetInfo *ksi)
BKE_keyingset_free(ks);
BLI_remlink(&builtin_keyingsets, ks);
- for (scene = bmain->scenes.first; scene; scene = scene->id.next)
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
BLI_remlink_safe(&scene->keyingsets, ks);
+ }
MEM_freeN(ks);
}
@@ -631,8 +644,9 @@ void ANIM_keyingset_infos_exit(void)
next = ksi->next;
/* free extra RNA data, and remove from list */
- if (ksi->ext.free)
+ if (ksi->ext.free) {
ksi->ext.free(ksi->ext.data);
+ }
BLI_freelinkN(&keyingset_type_infos, ksi);
}
@@ -644,8 +658,9 @@ void ANIM_keyingset_infos_exit(void)
bool ANIM_keyingset_find_id(KeyingSet *ks, ID *id)
{
/* sanity checks */
- if (ELEM(NULL, ks, id))
+ if (ELEM(NULL, ks, id)) {
return false;
+ }
return BLI_findptr(&ks->paths, id, offsetof(KS_Path, id)) != NULL;
}
@@ -659,18 +674,21 @@ bool ANIM_keyingset_find_id(KeyingSet *ks, ID *id)
KeyingSet *ANIM_scene_get_active_keyingset(Scene *scene)
{
/* if no scene, we've got no hope of finding the Keying Set */
- if (scene == NULL)
+ if (scene == NULL) {
return NULL;
+ }
/* currently, there are several possibilities here:
* - 0: no active keying set
* - > 0: one of the user-defined Keying Sets, but indices start from 0 (hence the -1)
* - < 0: a builtin keying set
*/
- if (scene->active_keyingset > 0)
+ if (scene->active_keyingset > 0) {
return BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
- else
+ }
+ else {
return BLI_findlink(&builtin_keyingsets, (-scene->active_keyingset) - 1);
+ }
}
/* Get the index of the Keying Set provided, for the given Scene */
@@ -679,8 +697,9 @@ int ANIM_scene_get_keyingset_index(Scene *scene, KeyingSet *ks)
int index;
/* if no KeyingSet provided, have none */
- if (ks == NULL)
+ if (ks == NULL) {
return 0;
+ }
/* check if the KeyingSet exists in scene list */
if (scene) {
@@ -688,8 +707,9 @@ int ANIM_scene_get_keyingset_index(Scene *scene, KeyingSet *ks)
* - (absolute) Scene KeyingSets are from (>= 1)
*/
index = BLI_findindex(&scene->keyingsets, ks);
- if (index != -1)
+ if (index != -1) {
return (index + 1);
+ }
}
/* still here, so try builtins list too
@@ -697,10 +717,12 @@ int ANIM_scene_get_keyingset_index(Scene *scene, KeyingSet *ks)
* - none/invalid is (= 0)
*/
index = BLI_findindex(&builtin_keyingsets, ks);
- if (index != -1)
+ if (index != -1) {
return -(index + 1);
- else
+ }
+ else {
return 0;
+ }
}
/* Get Keying Set to use for Auto-Keyframing some transforms */
@@ -710,12 +732,15 @@ KeyingSet *ANIM_get_keyingset_for_autokeying(Scene *scene, const char *transform
* - use the active KeyingSet if defined (and user wants to use it for all autokeying),
* or otherwise key transforms only
*/
- if (IS_AUTOKEY_FLAG(scene, ONLYKEYINGSET) && (scene->active_keyingset))
+ if (IS_AUTOKEY_FLAG(scene, ONLYKEYINGSET) && (scene->active_keyingset)) {
return ANIM_scene_get_active_keyingset(scene);
- else if (IS_AUTOKEY_FLAG(scene, INSERTAVAIL))
+ }
+ else if (IS_AUTOKEY_FLAG(scene, INSERTAVAIL)) {
return ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_AVAILABLE_ID);
- else
+ }
+ else {
return ANIM_builtin_keyingset_get_named(NULL, transformKSName);
+ }
}
/* Menu of All Keying Sets ----------------------------- */
@@ -835,8 +860,9 @@ bool ANIM_keyingset_context_ok_poll(bContext *C, KeyingSet *ks)
KeyingSetInfo *ksi = ANIM_keyingset_info_find_name(ks->typeinfo);
/* get the associated 'type info' for this KeyingSet */
- if (ksi == NULL)
+ if (ksi == NULL) {
return 0;
+ }
/* TODO: check for missing callbacks! */
/* check if it can be used in the current context */
@@ -883,20 +909,24 @@ void ANIM_relative_keyingset_add_source(ListBase *dsources, ID *id, StructRNA *s
* - we must have somewhere to output the data
* - we must have both srna+data (and with id too optionally), or id by itself only
*/
- if (dsources == NULL)
+ if (dsources == NULL) {
return;
- if (ELEM(NULL, srna, data) && (id == NULL))
+ }
+ if (ELEM(NULL, srna, data) && (id == NULL)) {
return;
+ }
/* allocate new elem, and add to the list */
ds = MEM_callocN(sizeof(tRKS_DSource), "tRKS_DSource");
BLI_addtail(dsources, ds);
/* depending on what data we have, create using ID or full pointer call */
- if (srna && data)
+ if (srna && data) {
RNA_pointer_create(id, srna, data, &ds->ptr);
- else
+ }
+ else {
RNA_id_pointer_create(id, &ds->ptr);
+ }
}
/* KeyingSet Operations (Insert/Delete Keyframes) ------------ */
@@ -911,8 +941,9 @@ void ANIM_relative_keyingset_add_source(ListBase *dsources, ID *id, StructRNA *s
short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks)
{
/* sanity check */
- if (ks == NULL)
+ if (ks == NULL) {
return 0;
+ }
/* if relative Keying Sets, poll and build up the paths */
if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) {
@@ -924,8 +955,9 @@ short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks)
BKE_keyingset_free(ks);
/* get the associated 'type info' for this KeyingSet */
- if (ksi == NULL)
+ if (ksi == NULL) {
return MODIFYKEY_MISSING_TYPEINFO;
+ }
/* TODO: check for missing callbacks! */
/* check if it can be used in the current context */
@@ -933,15 +965,18 @@ short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks)
/* if a list of data sources are provided, run a special iterator over them,
* otherwise, just continue per normal
*/
- if (dsources)
+ if (dsources) {
RKS_ITER_overrides_list(ksi, C, ks, dsources);
- else
+ }
+ else {
ksi->iter(ksi, C, ks);
+ }
/* if we don't have any paths now, then this still qualifies as invalid context */
// FIXME: we need some error conditions (to be retrieved from the iterator why this failed!)
- if (BLI_listbase_is_empty(&ks->paths))
+ if (BLI_listbase_is_empty(&ks->paths)) {
return MODIFYKEY_INVALID_CONTEXT;
+ }
}
else {
/* poll callback tells us that KeyingSet is useless in current context */
@@ -1005,16 +1040,18 @@ int ANIM_apply_keyingset(
char keytype = scene->toolsettings->keyframe_type;
/* sanity checks */
- if (ks == NULL)
+ if (ks == NULL) {
return 0;
+ }
/* get flags to use */
if (mode == MODIFYKEY_MODE_INSERT) {
/* use context settings as base */
kflag = keyingset_apply_keying_flags(base_kflags, ks->keyingoverride, ks->keyingflag);
}
- else if (mode == MODIFYKEY_MODE_DELETE)
+ else if (mode == MODIFYKEY_MODE_DELETE) {
kflag = 0;
+ }
/* if relative Keying Sets, poll and build up the paths */
success = ANIM_validate_keyingset(C, dsources, ks);
@@ -1045,12 +1082,15 @@ int ANIM_apply_keyingset(
kflag2 = keyingset_apply_keying_flags(kflag, ksp->keyingoverride, ksp->keyingflag);
/* get pointer to name of group to add channels to */
- if (ksp->groupmode == KSP_GROUP_NONE)
+ if (ksp->groupmode == KSP_GROUP_NONE) {
groupname = NULL;
- else if (ksp->groupmode == KSP_GROUP_KSNAME)
+ }
+ else if (ksp->groupmode == KSP_GROUP_KSNAME) {
groupname = ks->name;
- else
+ }
+ else {
groupname = ksp->group;
+ }
/* init arraylen and i - arraylen should be greater than i so that
* normal non-array entries get keyframed correctly
@@ -1072,15 +1112,16 @@ int ANIM_apply_keyingset(
}
/* we should do at least one step */
- if (arraylen == i)
+ if (arraylen == i) {
arraylen++;
+ }
/* for each possible index, perform operation
* - assume that arraylen is greater than index
*/
for (; i < arraylen; i++) {
/* action to take depends on mode */
- if (mode == MODIFYKEY_MODE_INSERT)
+ if (mode == MODIFYKEY_MODE_INSERT) {
success += insert_keyframe(bmain,
depsgraph,
reports,
@@ -1093,9 +1134,11 @@ int ANIM_apply_keyingset(
keytype,
&nla_cache,
kflag2);
- else if (mode == MODIFYKEY_MODE_DELETE)
+ }
+ else if (mode == MODIFYKEY_MODE_DELETE) {
success += delete_keyframe(
bmain, reports, ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag2);
+ }
}
/* set recalc-flags */