From e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 17 Apr 2019 06:17:24 +0200 Subject: ClangFormat: apply to source, most of intern Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat --- source/blender/editors/animation/anim_deps.c | 623 ++++++++++++++------------- 1 file changed, 320 insertions(+), 303 deletions(-) (limited to 'source/blender/editors/animation/anim_deps.c') diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c index dfb1a456364..53fec2e1ef7 100644 --- a/source/blender/editors/animation/anim_deps.c +++ b/source/blender/editors/animation/anim_deps.c @@ -21,7 +21,6 @@ * \ingroup edanimation */ - #include #include "MEM_guardedalloc.h" @@ -59,58 +58,68 @@ */ void ANIM_list_elem_update(Main *bmain, Scene *scene, bAnimListElem *ale) { - ID *id; - FCurve *fcu; - AnimData *adt; - - id = ale->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); - if (adt) { - DEG_id_tag_update(id, ID_RECALC_ANIMATION); - if (adt->action != NULL) { - DEG_id_tag_update(&adt->action->id, ID_RECALC_ANIMATION); - } - } - - /* Tag copy on the main object if updating anything directly inside AnimData */ - if (ELEM(ale->type, ANIMTYPE_ANIMDATA, ANIMTYPE_NLAACTION, ANIMTYPE_NLATRACK, ANIMTYPE_NLACURVE)) { - DEG_id_tag_update(id, ID_RECALC_ANIMATION); - return; - } - - /* update data */ - fcu = (ale->datatype == ALE_FCURVE) ? ale->key_data : NULL; - - if (fcu && fcu->rna_path) { - /* if we have an fcurve, call the update for the property we - * are editing, this is then expected to do the proper redraws - * and depsgraph updates */ - PointerRNA id_ptr, ptr; - PropertyRNA *prop; - - RNA_id_pointer_create(id, &id_ptr); - - 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 - * we'd be calling property update functions here too ... */ - DEG_id_tag_update(id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); // XXX or do we want something more restrictive? - } + ID *id; + FCurve *fcu; + AnimData *adt; + + id = ale->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); + if (adt) { + DEG_id_tag_update(id, ID_RECALC_ANIMATION); + if (adt->action != NULL) { + DEG_id_tag_update(&adt->action->id, ID_RECALC_ANIMATION); + } + } + + /* Tag copy on the main object if updating anything directly inside AnimData */ + if (ELEM(ale->type, + ANIMTYPE_ANIMDATA, + ANIMTYPE_NLAACTION, + ANIMTYPE_NLATRACK, + ANIMTYPE_NLACURVE)) { + DEG_id_tag_update(id, ID_RECALC_ANIMATION); + return; + } + + /* update data */ + fcu = (ale->datatype == ALE_FCURVE) ? ale->key_data : NULL; + + if (fcu && fcu->rna_path) { + /* if we have an fcurve, call the update for the property we + * are editing, this is then expected to do the proper redraws + * and depsgraph updates */ + PointerRNA id_ptr, ptr; + PropertyRNA *prop; + + RNA_id_pointer_create(id, &id_ptr); + + 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 + * we'd be calling property update functions here too ... */ + DEG_id_tag_update(id, + ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | + ID_RECALC_ANIMATION); // XXX or do we want something more restrictive? + } } /* tags the given ID block for refreshes (if applicable) due to * Animation Editor editing */ void ANIM_id_update(Main *bmain, ID *id) { - if (id) { - DEG_id_tag_update_ex(bmain, id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); // XXX or do we want something more restrictive? - } + if (id) { + DEG_id_tag_update_ex( + bmain, + id, + ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | + ID_RECALC_ANIMATION); // XXX or do we want something more restrictive? + } } /* **************************** animation data <-> data syncing ******************************** */ @@ -126,161 +135,165 @@ void ANIM_id_update(Main *bmain, ID *id) /* perform syncing updates for Action Groups */ static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGroup **active_agrp) { - bActionGroup *agrp = (bActionGroup *)ale->data; - ID *owner_id = ale->id; - - /* major priority is selection status - * so we need both a group and an owner - */ - 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) { - Object *ob = (Object *)owner_id; - - /* check if there are bones, and whether the name matches any - * NOTE: this feature will only really work if groups by default contain the F-Curves for a single bone - */ - if (ob->pose) { - bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, agrp->name); - bArmature *arm = ob->data; - - if (pchan) { - bActionGroup *bgrp; - - /* if one matches, sync the selection status */ - if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) - agrp->flag |= AGRP_SELECTED; - else - agrp->flag &= ~AGRP_SELECTED; - - /* also sync active group status */ - if ((ob == ac->obact) && (pchan->bone == arm->act_bone)) { - /* if no previous F-Curve has active flag, then we're the first and only one to get it */ - if (*active_agrp == NULL) { - agrp->flag |= AGRP_ACTIVE; - *active_agrp = agrp; - } - else { - /* someone else has already taken it - set as not active */ - agrp->flag &= ~AGRP_ACTIVE; - } - } - else { - /* this can't possibly be active now */ - agrp->flag &= ~AGRP_ACTIVE; - } - - /* sync group colors */ - bgrp = (bActionGroup *)BLI_findlink(&ob->pose->agroups, (pchan->agrp_index - 1)); - if (bgrp) { - agrp->customCol = bgrp->customCol; - action_group_colors_sync(agrp, bgrp); - } - } - } - } + bActionGroup *agrp = (bActionGroup *)ale->data; + ID *owner_id = ale->id; + + /* major priority is selection status + * so we need both a group and an owner + */ + 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) { + Object *ob = (Object *)owner_id; + + /* check if there are bones, and whether the name matches any + * NOTE: this feature will only really work if groups by default contain the F-Curves for a single bone + */ + if (ob->pose) { + bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, agrp->name); + bArmature *arm = ob->data; + + if (pchan) { + bActionGroup *bgrp; + + /* if one matches, sync the selection status */ + if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) + agrp->flag |= AGRP_SELECTED; + else + agrp->flag &= ~AGRP_SELECTED; + + /* also sync active group status */ + if ((ob == ac->obact) && (pchan->bone == arm->act_bone)) { + /* if no previous F-Curve has active flag, then we're the first and only one to get it */ + if (*active_agrp == NULL) { + agrp->flag |= AGRP_ACTIVE; + *active_agrp = agrp; + } + else { + /* someone else has already taken it - set as not active */ + agrp->flag &= ~AGRP_ACTIVE; + } + } + else { + /* this can't possibly be active now */ + agrp->flag &= ~AGRP_ACTIVE; + } + + /* sync group colors */ + bgrp = (bActionGroup *)BLI_findlink(&ob->pose->agroups, (pchan->agrp_index - 1)); + if (bgrp) { + agrp->customCol = bgrp->customCol; + action_group_colors_sync(agrp, bgrp); + } + } + } + } } /* perform syncing updates for F-Curves */ -static void animchan_sync_fcurve(bAnimContext *UNUSED(ac), bAnimListElem *ale, FCurve **active_fcurve) +static void animchan_sync_fcurve(bAnimContext *UNUSED(ac), + bAnimListElem *ale, + FCurve **active_fcurve) { - FCurve *fcu = (FCurve *)ale->data; - ID *owner_id = ale->id; - - /* 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)) - return; - - if (GS(owner_id->name) == ID_SCE) { - Scene *scene = (Scene *)owner_id; - - /* only affect if F-Curve involves sequence_editor.sequences */ - if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) { - Editing *ed = BKE_sequencer_editing_get(scene, false); - Sequence *seq; - char *seq_name; - - /* 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) MEM_freeN(seq_name); - - /* update selection status */ - if (seq) { - if (seq->flag & SELECT) - fcu->flag |= FCURVE_SELECTED; - else - fcu->flag &= ~FCURVE_SELECTED; - } - } - } - else if (GS(owner_id->name) == ID_NT) { - bNodeTree *ntree = (bNodeTree *)owner_id; - - /* check for selected nodes */ - if ((fcu->rna_path) && strstr(fcu->rna_path, "nodes")) { - bNode *node; - char *node_name; - - /* 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) MEM_freeN(node_name); - - /* update selection/active status */ - if (node) { - /* update selection status */ - if (node->flag & NODE_SELECT) - fcu->flag |= FCURVE_SELECTED; - else - fcu->flag &= ~FCURVE_SELECTED; - - /* update active status */ - /* XXX: this may interfere with setting bones as active if both exist at once; - * then again, if that's the case, production setups aren't likely to be animating - * nodes while working with bones? - */ - if (node->flag & NODE_ACTIVE) { - if (*active_fcurve == NULL) { - fcu->flag |= FCURVE_ACTIVE; - *active_fcurve = fcu; - } - else { - fcu->flag &= ~FCURVE_ACTIVE; - } - } - else { - fcu->flag &= ~FCURVE_ACTIVE; - } - } - } - } + FCurve *fcu = (FCurve *)ale->data; + ID *owner_id = ale->id; + + /* 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)) + return; + + if (GS(owner_id->name) == ID_SCE) { + Scene *scene = (Scene *)owner_id; + + /* only affect if F-Curve involves sequence_editor.sequences */ + if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) { + Editing *ed = BKE_sequencer_editing_get(scene, false); + Sequence *seq; + char *seq_name; + + /* 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) + MEM_freeN(seq_name); + + /* update selection status */ + if (seq) { + if (seq->flag & SELECT) + fcu->flag |= FCURVE_SELECTED; + else + fcu->flag &= ~FCURVE_SELECTED; + } + } + } + else if (GS(owner_id->name) == ID_NT) { + bNodeTree *ntree = (bNodeTree *)owner_id; + + /* check for selected nodes */ + if ((fcu->rna_path) && strstr(fcu->rna_path, "nodes")) { + bNode *node; + char *node_name; + + /* 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) + MEM_freeN(node_name); + + /* update selection/active status */ + if (node) { + /* update selection status */ + if (node->flag & NODE_SELECT) + fcu->flag |= FCURVE_SELECTED; + else + fcu->flag &= ~FCURVE_SELECTED; + + /* update active status */ + /* XXX: this may interfere with setting bones as active if both exist at once; + * then again, if that's the case, production setups aren't likely to be animating + * nodes while working with bones? + */ + if (node->flag & NODE_ACTIVE) { + if (*active_fcurve == NULL) { + fcu->flag |= FCURVE_ACTIVE; + *active_fcurve = fcu; + } + else { + fcu->flag &= ~FCURVE_ACTIVE; + } + } + else { + fcu->flag &= ~FCURVE_ACTIVE; + } + } + } + } } /* perform syncing updates for GPencil Layers */ static void animchan_sync_gplayer(bAnimContext *UNUSED(ac), bAnimListElem *ale) { - bGPDlayer *gpl = (bGPDlayer *)ale->data; - - /* Make sure the selection flags agree with the "active" flag. - * The selection flags are used in the Dopesheet only, whereas - * the active flag is used everywhere else. Hence, we try to - * sync these here so that it all seems to be have as the user - * expects - T50184 - * - * Assume that we only really do this when the active status changes. - * (NOTE: This may prove annoying if it means selection is always lost) - */ - if (gpl->flag & GP_LAYER_ACTIVE) { - gpl->flag |= GP_LAYER_SELECT; - } - else { - gpl->flag &= ~GP_LAYER_SELECT; - } + bGPDlayer *gpl = (bGPDlayer *)ale->data; + + /* Make sure the selection flags agree with the "active" flag. + * The selection flags are used in the Dopesheet only, whereas + * the active flag is used everywhere else. Hence, we try to + * sync these here so that it all seems to be have as the user + * expects - T50184 + * + * Assume that we only really do this when the active status changes. + * (NOTE: This may prove annoying if it means selection is always lost) + */ + if (gpl->flag & GP_LAYER_ACTIVE) { + gpl->flag |= GP_LAYER_SELECT; + } + else { + gpl->flag &= ~GP_LAYER_SELECT; + } } /* ---------------- */ @@ -288,131 +301,135 @@ static void animchan_sync_gplayer(bAnimContext *UNUSED(ac), bAnimListElem *ale) /* Main call to be exported to animation editors */ void ANIM_sync_animchannels_to_data(const bContext *C) { - bAnimContext ac; - ListBase anim_data = {NULL, NULL}; - bAnimListElem *ale; - int filter; - - bActionGroup *active_agrp = NULL; - FCurve *active_fcurve = NULL; - - /* get animation context info for filtering the channels */ - if (ANIM_animdata_get_context(C, &ac) == 0) - return; - - /* filter data */ - /* NOTE: we want all channels, since we want to be able to set selection status on some of them even when collapsed - * However, don't include duplicates so that selection statuses don't override each other - */ - filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS; - ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - - /* flush settings as appropriate depending on the types of the channels */ - for (ale = anim_data.first; ale; ale = ale->next) { - switch (ale->type) { - case ANIMTYPE_GROUP: - animchan_sync_group(&ac, ale, &active_agrp); - break; - - case ANIMTYPE_FCURVE: - animchan_sync_fcurve(&ac, ale, &active_fcurve); - break; - - case ANIMTYPE_GPLAYER: - animchan_sync_gplayer(&ac, ale); - break; - } - } - - ANIM_animdata_freelist(&anim_data); + bAnimContext ac; + ListBase anim_data = {NULL, NULL}; + bAnimListElem *ale; + int filter; + + bActionGroup *active_agrp = NULL; + FCurve *active_fcurve = NULL; + + /* get animation context info for filtering the channels */ + if (ANIM_animdata_get_context(C, &ac) == 0) + return; + + /* filter data */ + /* NOTE: we want all channels, since we want to be able to set selection status on some of them even when collapsed + * However, don't include duplicates so that selection statuses don't override each other + */ + filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS; + ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + + /* flush settings as appropriate depending on the types of the channels */ + for (ale = anim_data.first; ale; ale = ale->next) { + switch (ale->type) { + case ANIMTYPE_GROUP: + animchan_sync_group(&ac, ale, &active_agrp); + break; + + case ANIMTYPE_FCURVE: + animchan_sync_fcurve(&ac, ale, &active_fcurve); + break; + + case ANIMTYPE_GPLAYER: + animchan_sync_gplayer(&ac, ale); + break; + } + } + + ANIM_animdata_freelist(&anim_data); } void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data) { - bAnimListElem *ale; + bAnimListElem *ale; - if (ELEM(ac->datatype, ANIMCONT_MASK)) { + if (ELEM(ac->datatype, ANIMCONT_MASK)) { #ifdef DEBUG - /* quiet assert */ - for (ale = anim_data->first; ale; ale = ale->next) { - ale->update = 0; - } + /* quiet assert */ + for (ale = anim_data->first; ale; ale = ale->next) { + ale->update = 0; + } #endif - return; - } - - for (ale = anim_data->first; ale; ale = ale->next) { - if (ale->type == ANIMTYPE_GPLAYER) { - bGPDlayer *gpl = ale->data; - - if (ale->update & ANIM_UPDATE_ORDER) { - ale->update &= ~ANIM_UPDATE_ORDER; - if (gpl) { - //gpencil_sort_frames(gpl); - } - } - - if (ale->update & ANIM_UPDATE_DEPS) { - ale->update &= ~ANIM_UPDATE_DEPS; - ANIM_list_elem_update(ac->bmain, ac->scene, ale); - } - /* disable handles to avoid crash */ - if (ale->update & ANIM_UPDATE_HANDLES) { - ale->update &= ~ANIM_UPDATE_HANDLES; - } - } - else if (ale->datatype == ALE_FCURVE) { - FCurve *fcu = ale->key_data; - - if (ale->update & ANIM_UPDATE_ORDER) { - ale->update &= ~ANIM_UPDATE_ORDER; - if (fcu) - sort_time_fcurve(fcu); - } - - if (ale->update & ANIM_UPDATE_HANDLES) { - ale->update &= ~ANIM_UPDATE_HANDLES; - if (fcu) - calchandles_fcurve(fcu); - } - - if (ale->update & ANIM_UPDATE_DEPS) { - ale->update &= ~ANIM_UPDATE_DEPS; - ANIM_list_elem_update(ac->bmain, ac->scene, ale); - } - } - else if (ELEM(ale->type, ANIMTYPE_ANIMDATA, ANIMTYPE_NLAACTION, ANIMTYPE_NLATRACK, ANIMTYPE_NLACURVE)) { - if (ale->update & ANIM_UPDATE_DEPS) { - ale->update &= ~ANIM_UPDATE_DEPS; - ANIM_list_elem_update(ac->bmain, ac->scene, ale); - } - } - else if (ale->update) { + return; + } + + for (ale = anim_data->first; ale; ale = ale->next) { + if (ale->type == ANIMTYPE_GPLAYER) { + bGPDlayer *gpl = ale->data; + + if (ale->update & ANIM_UPDATE_ORDER) { + ale->update &= ~ANIM_UPDATE_ORDER; + if (gpl) { + //gpencil_sort_frames(gpl); + } + } + + if (ale->update & ANIM_UPDATE_DEPS) { + ale->update &= ~ANIM_UPDATE_DEPS; + ANIM_list_elem_update(ac->bmain, ac->scene, ale); + } + /* disable handles to avoid crash */ + if (ale->update & ANIM_UPDATE_HANDLES) { + ale->update &= ~ANIM_UPDATE_HANDLES; + } + } + else if (ale->datatype == ALE_FCURVE) { + FCurve *fcu = ale->key_data; + + if (ale->update & ANIM_UPDATE_ORDER) { + ale->update &= ~ANIM_UPDATE_ORDER; + if (fcu) + sort_time_fcurve(fcu); + } + + if (ale->update & ANIM_UPDATE_HANDLES) { + ale->update &= ~ANIM_UPDATE_HANDLES; + if (fcu) + calchandles_fcurve(fcu); + } + + if (ale->update & ANIM_UPDATE_DEPS) { + ale->update &= ~ANIM_UPDATE_DEPS; + ANIM_list_elem_update(ac->bmain, ac->scene, ale); + } + } + else if (ELEM(ale->type, + ANIMTYPE_ANIMDATA, + ANIMTYPE_NLAACTION, + ANIMTYPE_NLATRACK, + ANIMTYPE_NLACURVE)) { + if (ale->update & ANIM_UPDATE_DEPS) { + ale->update &= ~ANIM_UPDATE_DEPS; + ANIM_list_elem_update(ac->bmain, ac->scene, ale); + } + } + else if (ale->update) { #if 0 - if (G.debug & G_DEBUG) { - printf("%s: Unhandled animchannel updates (%d) for type=%d (%p)\n", - __func__, ale->update, ale->type, ale->data); - } + if (G.debug & G_DEBUG) { + printf("%s: Unhandled animchannel updates (%d) for type=%d (%p)\n", + __func__, ale->update, ale->type, ale->data); + } #endif - /* Prevent crashes in cases where it can't be handled */ - ale->update = 0; - } + /* Prevent crashes in cases where it can't be handled */ + ale->update = 0; + } - BLI_assert(ale->update == 0); - } + BLI_assert(ale->update == 0); + } } void ANIM_animdata_freelist(ListBase *anim_data) { #ifndef NDEBUG - bAnimListElem *ale, *ale_next; - for (ale = anim_data->first; ale; ale = ale_next) { - ale_next = ale->next; - BLI_assert(ale->update == 0); - MEM_freeN(ale); - } - BLI_listbase_clear(anim_data); + bAnimListElem *ale, *ale_next; + for (ale = anim_data->first; ale; ale = ale_next) { + ale_next = ale->next; + BLI_assert(ale->update == 0); + MEM_freeN(ale); + } + BLI_listbase_clear(anim_data); #else - BLI_freelistN(anim_data); + BLI_freelistN(anim_data); #endif } -- cgit v1.2.3