diff options
Diffstat (limited to 'source/blender/blenkernel/intern/anim_sys.c')
-rw-r--r-- | source/blender/blenkernel/intern/anim_sys.c | 861 |
1 files changed, 432 insertions, 429 deletions
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index e5a68fa7476..fd7497f9ba1 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -105,7 +105,7 @@ bool id_type_can_have_animdata(const short id_type) case ID_GD: case ID_CF: return true; - + /* no AnimData */ default: return false; @@ -121,13 +121,13 @@ bool id_can_have_animdata(const ID *id) return id_type_can_have_animdata(GS(id->name)); } -/* Get AnimData from the given ID-block. In order for this to work, we assume that +/* Get AnimData from the given ID-block. In order for this to work, we assume that * the AnimData pointer is stored immediately after the given ID-block in the struct, * as per IdAdtTemplate. */ AnimData *BKE_animdata_from_id(ID *id) { - /* only some ID-blocks have this info for now, so we cast the + /* only some ID-blocks have this info for now, so we cast the * types that do to be of type IdAdtTemplate, and extract the * AnimData that way */ @@ -139,33 +139,33 @@ AnimData *BKE_animdata_from_id(ID *id) return NULL; } -/* Add AnimData to the given ID-block. In order for this to work, we assume that +/* Add AnimData to the given ID-block. In order for this to work, we assume that * the AnimData pointer is stored immediately after the given ID-block in the struct, * as per IdAdtTemplate. Also note that */ AnimData *BKE_animdata_add_id(ID *id) { - /* Only some ID-blocks have this info for now, so we cast the + /* Only some ID-blocks have this info for now, so we cast the * types that do to be of type IdAdtTemplate, and add the AnimData * to it using the template */ if (id_can_have_animdata(id)) { IdAdtTemplate *iat = (IdAdtTemplate *)id; - + /* check if there's already AnimData, in which case, don't add */ if (iat->adt == NULL) { AnimData *adt; - + /* add animdata */ adt = iat->adt = MEM_callocN(sizeof(AnimData), "AnimData"); - + /* set default settings */ adt->act_influence = 1.0f; } - + return iat->adt; } - else + else return NULL; } @@ -176,14 +176,14 @@ bool BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act) { AnimData *adt = BKE_animdata_from_id(id); bool ok = false; - + /* animdata validity check */ if (adt == NULL) { BKE_report(reports, RPT_WARNING, "No AnimData to set action on"); return ok; } - - /* active action is only editable when it is not a tweaking strip + + /* active action is only editable when it is not a tweaking strip * see rna_AnimData_action_editable() in rna_animation.c */ if ((adt->flag & ADT_NLA_EDIT_ON) || (adt->actstrip) || (adt->tmpact)) { @@ -191,11 +191,11 @@ bool BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act) BKE_report(reports, RPT_ERROR, "Cannot change action, as it is still being edited in NLA"); return ok; } - + /* manage usercount for current action */ if (adt->action) id_us_min((ID *)adt->action); - + /* assume that AnimData's action can in fact be edited... */ if (act) { /* action must have same type as owner */ @@ -218,7 +218,7 @@ bool BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act) adt->action = NULL; ok = true; } - + return ok; } @@ -227,13 +227,13 @@ bool BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act) /* Free AnimData used by the nominated ID-block, and clear ID-block's AnimData pointer */ void BKE_animdata_free(ID *id, const bool do_id_user) { - /* Only some ID-blocks have this info for now, so we cast the + /* Only some ID-blocks have this info for now, so we cast the * types that do to be of type IdAdtTemplate */ if (id_can_have_animdata(id)) { IdAdtTemplate *iat = (IdAdtTemplate *)id; AnimData *adt = iat->adt; - + /* check if there's any AnimData to start with */ if (adt) { if (do_id_user) { @@ -244,19 +244,19 @@ void BKE_animdata_free(ID *id, const bool do_id_user) if (adt->tmpact) id_us_min(&adt->tmpact->id); } - + /* free nla data */ BKE_nla_tracks_free(&adt->nla_tracks); - + /* free drivers - stored as a list of F-Curves */ free_fcurves(&adt->drivers); /* free driver array cache */ MEM_SAFE_FREE(adt->driver_array); - + /* free overrides */ /* TODO... */ - + /* free animdata now */ MEM_freeN(adt); iat->adt = NULL; @@ -270,12 +270,12 @@ void BKE_animdata_free(ID *id, const bool do_id_user) AnimData *BKE_animdata_copy(Main *bmain, AnimData *adt, const bool do_action, const bool do_id_user) { AnimData *dadt; - + /* sanity check before duplicating struct */ if (adt == NULL) return NULL; dadt = MEM_dupallocN(adt); - + /* make a copy of action - at worst, user has to delete copies... */ if (do_action) { BLI_assert(bmain != NULL); @@ -288,15 +288,15 @@ AnimData *BKE_animdata_copy(Main *bmain, AnimData *adt, const bool do_action, co } /* duplicate NLA data */ - BKE_nla_tracks_copy(&dadt->nla_tracks, &adt->nla_tracks); - + BKE_nla_tracks_copy(bmain, &dadt->nla_tracks, &adt->nla_tracks); + /* duplicate drivers (F-Curves) */ copy_fcurves(&dadt->drivers, &adt->drivers); dadt->driver_array = NULL; - + /* don't copy overrides */ BLI_listbase_clear(&dadt->overrides); - + /* return */ return dadt; } @@ -319,78 +319,80 @@ bool BKE_animdata_copy_id(Main *bmain, ID *id_to, ID *id_from, const bool do_act return true; } -void BKE_animdata_copy_id_action(ID *id, const bool set_newid) +void BKE_animdata_copy_id_action(Main *bmain, ID *id, const bool set_newid) { AnimData *adt = BKE_animdata_from_id(id); if (adt) { if (adt->action) { id_us_min((ID *)adt->action); - adt->action = set_newid ? ID_NEW_SET(adt->action, BKE_action_copy(G.main, adt->action)) : - BKE_action_copy(G.main, adt->action); + adt->action = set_newid ? ID_NEW_SET(adt->action, BKE_action_copy(bmain, adt->action)) : + BKE_action_copy(bmain, adt->action); } if (adt->tmpact) { id_us_min((ID *)adt->tmpact); - adt->tmpact = set_newid ? ID_NEW_SET(adt->tmpact, BKE_action_copy(G.main, adt->tmpact)) : - BKE_action_copy(G.main, adt->tmpact); + adt->tmpact = set_newid ? ID_NEW_SET(adt->tmpact, BKE_action_copy(bmain, adt->tmpact)) : + BKE_action_copy(bmain, adt->tmpact); } } } /* Merge copies of the data from the src AnimData into the destination AnimData */ -void BKE_animdata_merge_copy(ID *dst_id, ID *src_id, eAnimData_MergeCopy_Modes action_mode, bool fix_drivers) +void BKE_animdata_merge_copy( + Main *bmain, ID *dst_id, ID *src_id, + eAnimData_MergeCopy_Modes action_mode, bool fix_drivers) { AnimData *src = BKE_animdata_from_id(src_id); AnimData *dst = BKE_animdata_from_id(dst_id); - + /* sanity checks */ if (ELEM(NULL, dst, src)) return; - + // TODO: we must unset all "tweakmode" flags if ((src->flag & ADT_NLA_EDIT_ON) || (dst->flag & ADT_NLA_EDIT_ON)) { printf("ERROR: Merging AnimData blocks while editing NLA is dangerous as it may cause data corruption\n"); return; } - + /* handle actions... */ if (action_mode == ADT_MERGECOPY_SRC_COPY) { /* make a copy of the actions */ - dst->action = BKE_action_copy(G.main, src->action); - dst->tmpact = BKE_action_copy(G.main, src->tmpact); + dst->action = BKE_action_copy(bmain, src->action); + dst->tmpact = BKE_action_copy(bmain, src->tmpact); } else if (action_mode == ADT_MERGECOPY_SRC_REF) { /* make a reference to it */ dst->action = src->action; id_us_plus((ID *)dst->action); - + dst->tmpact = src->tmpact; id_us_plus((ID *)dst->tmpact); } - + /* duplicate NLA data */ if (src->nla_tracks.first) { ListBase tracks = {NULL, NULL}; - - BKE_nla_tracks_copy(&tracks, &src->nla_tracks); + + BKE_nla_tracks_copy(bmain, &tracks, &src->nla_tracks); BLI_movelisttolist(&dst->nla_tracks, &tracks); } - + /* duplicate drivers (F-Curves) */ if (src->drivers.first) { ListBase drivers = {NULL, NULL}; - + copy_fcurves(&drivers, &src->drivers); - + /* Fix up all driver targets using the old target id * - This assumes that the src ID is being merged into the dst ID */ if (fix_drivers) { FCurve *fcu; - + for (fcu = drivers.first; fcu; fcu = fcu->next) { ChannelDriver *driver = fcu->driver; DriverVar *dvar; - + for (dvar = driver->variables.first; dvar; dvar = dvar->next) { DRIVER_TARGETS_USED_LOOPER(dvar) { @@ -402,7 +404,7 @@ void BKE_animdata_merge_copy(ID *dst_id, ID *src_id, eAnimData_MergeCopy_Modes a } } } - + BLI_movelisttolist(&dst->drivers, &drivers); } } @@ -422,7 +424,7 @@ static bool animpath_matches_basepath(const char path[], const char basepath[]) return (path && basepath) && STRPREFIX(path, basepath); } -/* Move F-Curves in src action to dst action, setting up all the necessary groups +/* Move F-Curves in src action to dst action, setting up all the necessary groups * for this to happen, but only if the F-Curves being moved have the appropriate * "base path". * - This is used when data moves from one datablock to another, causing the @@ -431,7 +433,7 @@ static bool animpath_matches_basepath(const char path[], const char basepath[]) void action_move_fcurves_by_basepath(bAction *srcAct, bAction *dstAct, const char basepath[]) { FCurve *fcu, *fcn = NULL; - + /* sanity checks */ if (ELEM(NULL, srcAct, dstAct, basepath)) { if (G.debug & G_DEBUG) { @@ -440,56 +442,56 @@ void action_move_fcurves_by_basepath(bAction *srcAct, bAction *dstAct, const cha } return; } - - /* clear 'temp' flags on all groups in src, as we'll be needing them later + + /* clear 'temp' flags on all groups in src, as we'll be needing them later * to identify groups that we've managed to empty out here */ action_groups_clear_tempflags(srcAct); - + /* iterate over all src F-Curves, moving over the ones that need to be moved */ for (fcu = srcAct->curves.first; fcu; fcu = fcn) { /* store next pointer in case we move stuff */ fcn = fcu->next; - + /* should F-Curve be moved over? * - we only need the start of the path to match basepath */ if (animpath_matches_basepath(fcu->rna_path, basepath)) { bActionGroup *agrp = NULL; - + /* if grouped... */ if (fcu->grp) { /* make sure there will be a matching group on the other side for the migrants */ agrp = BKE_action_group_find_name(dstAct, fcu->grp->name); - + if (agrp == NULL) { /* add a new one with a similar name (usually will be the same though) */ agrp = action_groups_add_new(dstAct, fcu->grp->name); } - + /* old groups should be tagged with 'temp' flags so they can be removed later * if we remove everything from them */ fcu->grp->flag |= AGRP_TEMP; } - + /* perform the migration now */ action_groups_remove_channel(srcAct, fcu); - + if (agrp) action_groups_add_channel(dstAct, agrp, fcu); else BLI_addtail(&dstAct->curves, fcu); } } - + /* cleanup groups (if present) */ if (srcAct->groups.first) { bActionGroup *agrp, *grp = NULL; - + for (agrp = srcAct->groups.first; agrp; agrp = grp) { grp = agrp->next; - + /* only tagged groups need to be considered - clearing these tags or removing them */ if (agrp->flag & AGRP_TEMP) { /* if group is empty and tagged, then we can remove as this operation @@ -508,69 +510,70 @@ void action_move_fcurves_by_basepath(bAction *srcAct, bAction *dstAct, const cha * animation data is based off "basepath", creating new AnimData and * associated data as necessary */ -void BKE_animdata_separate_by_basepath(ID *srcID, ID *dstID, ListBase *basepaths) +void BKE_animdata_separate_by_basepath( + Main *bmain, ID *srcID, ID *dstID, ListBase *basepaths) { AnimData *srcAdt = NULL, *dstAdt = NULL; LinkData *ld; - + /* sanity checks */ if (ELEM(NULL, srcID, dstID)) { if (G.debug & G_DEBUG) printf("ERROR: no source or destination ID to separate AnimData with\n"); return; } - + /* get animdata from src, and create for destination (if needed) */ srcAdt = BKE_animdata_from_id(srcID); dstAdt = BKE_animdata_add_id(dstID); - + if (ELEM(NULL, srcAdt, dstAdt)) { if (G.debug & G_DEBUG) printf("ERROR: no AnimData for this pair of ID's\n"); return; } - + /* active action */ if (srcAdt->action) { /* set up an action if necessary, and name it in a similar way so that it can be easily found again */ if (dstAdt->action == NULL) { - dstAdt->action = BKE_action_add(G.main, srcAdt->action->id.name + 2); + dstAdt->action = BKE_action_add(bmain, srcAdt->action->id.name + 2); } else if (dstAdt->action == srcAdt->action) { printf("Argh! Source and Destination share animation! ('%s' and '%s' both use '%s') Making new empty action\n", srcID->name, dstID->name, srcAdt->action->id.name); - + /* TODO: review this... */ id_us_min(&dstAdt->action->id); - dstAdt->action = BKE_action_add(G.main, dstAdt->action->id.name + 2); + dstAdt->action = BKE_action_add(bmain, dstAdt->action->id.name + 2); } - + /* loop over base paths, trying to fix for each one... */ for (ld = basepaths->first; ld; ld = ld->next) { const char *basepath = (const char *)ld->data; action_move_fcurves_by_basepath(srcAdt->action, dstAdt->action, basepath); } } - + /* drivers */ if (srcAdt->drivers.first) { FCurve *fcu, *fcn = NULL; - + /* check each driver against all the base paths to see if any should go */ for (fcu = srcAdt->drivers.first; fcu; fcu = fcn) { fcn = fcu->next; - + /* try each basepath in turn, but stop on the first one which works */ for (ld = basepaths->first; ld; ld = ld->next) { const char *basepath = (const char *)ld->data; - + if (animpath_matches_basepath(fcu->rna_path, basepath)) { /* just need to change lists */ BLI_remlink(&srcAdt->drivers, fcu); BLI_addtail(&dstAdt->drivers, fcu); - + /* TODO: add depsgraph flushing calls? */ - + /* can stop now, as moved already */ break; } @@ -628,15 +631,15 @@ static bool check_rna_path_is_valid(ID *owner_id, const char *path) { PointerRNA id_ptr, ptr; PropertyRNA *prop = NULL; - + /* make initial RNA pointer to start resolving from */ RNA_id_pointer_create(owner_id, &id_ptr); - + /* try to resolve */ - return RNA_path_resolve_property(&id_ptr, path, &ptr, &prop); + return RNA_path_resolve_property(&id_ptr, path, &ptr, &prop); } -/* Check if some given RNA Path needs fixing - free the given path and set a new one as appropriate +/* Check if some given RNA Path needs fixing - free the given path and set a new one as appropriate * NOTE: we assume that oldName and newName have [" "] padding around them */ static char *rna_path_rename_fix(ID *owner_id, const char *prefix, const char *oldName, const char *newName, char *oldpath, bool verify_paths) @@ -645,7 +648,7 @@ static char *rna_path_rename_fix(ID *owner_id, const char *prefix, const char *o char *oldNamePtr = strstr(oldpath, oldName); int prefixLen = strlen(prefix); int oldNameLen = strlen(oldName); - + /* only start fixing the path if the prefix and oldName feature in the path, * and prefix occurs immediately before oldName */ @@ -660,20 +663,20 @@ static char *rna_path_rename_fix(ID *owner_id, const char *prefix, const char *o if (prefixPtr > oldpath) { BLI_dynstr_nappend(ds, oldpath, prefixPtr - oldpath); } - + /* add the prefix */ BLI_dynstr_append(ds, prefix); - + /* add the new name (complete with brackets) */ BLI_dynstr_append(ds, newName); - + /* add the postfix */ BLI_dynstr_append(ds, postfixPtr); - + /* create new path, and cleanup old data */ newPath = BLI_dynstr_get_cstring(ds); BLI_dynstr_free(ds); - + /* check if the new path will solve our problems */ /* TODO: will need to check whether this step really helps in practice */ if (!verify_paths || check_rna_path_is_valid(owner_id, newPath)) { @@ -687,31 +690,31 @@ static char *rna_path_rename_fix(ID *owner_id, const char *prefix, const char *o } } } - + /* the old path doesn't need to be changed */ return oldpath; } /* Check RNA-Paths for a list of F-Curves */ -static void fcurves_path_rename_fix(ID *owner_id, const char *prefix, const char *oldName, const char *newName, +static void fcurves_path_rename_fix(ID *owner_id, const char *prefix, const char *oldName, const char *newName, const char *oldKey, const char *newKey, ListBase *curves, bool verify_paths) { FCurve *fcu; - + /* we need to check every curve... */ for (fcu = curves->first; fcu; fcu = fcu->next) { if (fcu->rna_path) { const char *old_path = fcu->rna_path; - + /* firstly, handle the F-Curve's own path */ fcu->rna_path = rna_path_rename_fix(owner_id, prefix, oldKey, newKey, fcu->rna_path, verify_paths); - + /* if path changed and the F-Curve is grouped, check if its group also needs renaming * (i.e. F-Curve is first of a bone's F-Curves; hence renaming this should also trigger rename) */ if (fcu->rna_path != old_path) { bActionGroup *agrp = fcu->grp; - + if ((agrp) && STREQ(oldName, agrp->name)) { BLI_strncpy(agrp->name, newName, sizeof(agrp->name)); } @@ -725,27 +728,27 @@ static void drivers_path_rename_fix(ID *owner_id, ID *ref_id, const char *prefix const char *oldKey, const char *newKey, ListBase *curves, bool verify_paths) { FCurve *fcu; - + /* we need to check every curve - drivers are F-Curves too! */ for (fcu = curves->first; fcu; fcu = fcu->next) { /* firstly, handle the F-Curve's own path */ if (fcu->rna_path) fcu->rna_path = rna_path_rename_fix(owner_id, prefix, oldKey, newKey, fcu->rna_path, verify_paths); - + /* driver? */ if (fcu->driver) { ChannelDriver *driver = fcu->driver; DriverVar *dvar; - + /* driver variables */ for (dvar = driver->variables.first; dvar; dvar = dvar->next) { /* only change the used targets, since the others will need fixing manually anyway */ - DRIVER_TARGETS_USED_LOOPER(dvar) + DRIVER_TARGETS_USED_LOOPER(dvar) { /* rename RNA path */ if (dtar->rna_path && dtar->id) dtar->rna_path = rna_path_rename_fix(dtar->id, prefix, oldKey, newKey, dtar->rna_path, verify_paths); - + /* also fix the bone-name (if applicable) */ if (strstr(prefix, "bones")) { if ( ((dtar->id) && (GS(dtar->id->name) == ID_OB) && (!ref_id || ((Object *)(dtar->id))->data == ref_id)) && @@ -762,18 +765,18 @@ static void drivers_path_rename_fix(ID *owner_id, ID *ref_id, const char *prefix } /* Fix all RNA-Paths for Actions linked to NLA Strips */ -static void nlastrips_path_rename_fix(ID *owner_id, const char *prefix, const char *oldName, const char *newName, +static void nlastrips_path_rename_fix(ID *owner_id, const char *prefix, const char *oldName, const char *newName, const char *oldKey, const char *newKey, ListBase *strips, bool verify_paths) { NlaStrip *strip; - + /* recursively check strips, fixing only actions... */ for (strip = strips->first; strip; strip = strip->next) { /* fix strip's action */ if (strip->act) fcurves_path_rename_fix(owner_id, prefix, oldName, newName, oldKey, newKey, &strip->act->curves, verify_paths); /* ignore own F-Curves, since those are local... */ - + /* check sub-strips (if metas) */ nlastrips_path_rename_fix(owner_id, prefix, oldName, newName, oldKey, newKey, &strip->strips, verify_paths); } @@ -794,13 +797,13 @@ char *BKE_animsys_fix_rna_path_rename(ID *owner_id, char *old_path, const char * { char *oldN, *newN; char *result; - + /* if no action, no need to proceed */ if (ELEM(NULL, owner_id, old_path)) { if (G.debug & G_DEBUG) printf("%s: early abort\n", __func__); return old_path; } - + /* Name sanitation logic - copied from BKE_animdata_fix_paths_rename() */ if ((oldName != NULL) && (newName != NULL)) { /* pad the names with [" "] so that only exact matches are made */ @@ -818,21 +821,21 @@ char *BKE_animsys_fix_rna_path_rename(ID *owner_id, char *old_path, const char * oldN = BLI_sprintfN("[%d]", oldSubscript); newN = BLI_sprintfN("[%d]", newSubscript); } - + /* fix given path */ if (G.debug & G_DEBUG) printf("%s | %s | oldpath = %p ", oldN, newN, old_path); result = rna_path_rename_fix(owner_id, prefix, oldN, newN, old_path, verify_paths); if (G.debug & G_DEBUG) printf("path rename result = %p\n", result); - + /* free the temp names */ MEM_freeN(oldN); MEM_freeN(newN); - + /* return the resulting path - may be the same path again if nothing changed */ return result; } -/* Fix all RNA_Paths in the given Action, relative to the given ID block +/* Fix all RNA_Paths in the given Action, relative to the given ID block * * This is just an external wrapper for the F-Curve fixing function, * with input validity checks on top of the basic method. @@ -844,11 +847,11 @@ void BKE_action_fix_paths_rename(ID *owner_id, bAction *act, const char *prefix, const char *newName, int oldSubscript, int newSubscript, bool verify_paths) { char *oldN, *newN; - + /* if no action, no need to proceed */ if (ELEM(NULL, owner_id, act)) return; - + /* Name sanitation logic - copied from BKE_animdata_fix_paths_rename() */ if ((oldName != NULL) && (newName != NULL)) { /* pad the names with [" "] so that only exact matches are made */ @@ -866,10 +869,10 @@ void BKE_action_fix_paths_rename(ID *owner_id, bAction *act, const char *prefix, oldN = BLI_sprintfN("[%d]", oldSubscript); newN = BLI_sprintfN("[%d]", newSubscript); } - + /* fix paths in action */ fcurves_path_rename_fix(owner_id, prefix, oldName, newName, oldN, newN, &act->curves, verify_paths); - + /* free the temp names */ MEM_freeN(oldN); MEM_freeN(newN); @@ -884,11 +887,11 @@ void BKE_animdata_fix_paths_rename(ID *owner_id, AnimData *adt, ID *ref_id, cons { NlaTrack *nlt; char *oldN, *newN; - + /* if no AnimData, no need to proceed */ if (ELEM(NULL, owner_id, adt)) return; - + /* Name sanitation logic - shared with BKE_action_fix_paths_rename() */ if ((oldName != NULL) && (newName != NULL)) { /* pad the names with [" "] so that only exact matches are made */ @@ -906,16 +909,16 @@ void BKE_animdata_fix_paths_rename(ID *owner_id, AnimData *adt, ID *ref_id, cons oldN = BLI_sprintfN("[%d]", oldSubscript); newN = BLI_sprintfN("[%d]", newSubscript); } - + /* Active action and temp action */ if (adt->action) fcurves_path_rename_fix(owner_id, prefix, oldName, newName, oldN, newN, &adt->action->curves, verify_paths); if (adt->tmpact) fcurves_path_rename_fix(owner_id, prefix, oldName, newName, oldN, newN, &adt->tmpact->curves, verify_paths); - + /* Drivers - Drivers are really F-Curves */ drivers_path_rename_fix(owner_id, ref_id, prefix, oldName, newName, oldN, newN, &adt->drivers, verify_paths); - + /* NLA Data - Animation Data for Strips */ for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) nlastrips_path_rename_fix(owner_id, prefix, oldName, newName, oldN, newN, &nlt->strips, verify_paths); @@ -1005,7 +1008,7 @@ typedef struct AllFCurvesCbWrapper { static void fcurves_apply_cb(ID *id, ListBase *fcurves, ID_FCurve_Edit_Callback func, void *user_data) { FCurve *fcu; - + for (fcu = fcurves->first; fcu; fcu = fcu->next) { func(id, fcu, user_data); } @@ -1015,13 +1018,13 @@ static void fcurves_apply_cb(ID *id, ListBase *fcurves, ID_FCurve_Edit_Callback static void nlastrips_apply_all_curves_cb(ID *id, ListBase *strips, AllFCurvesCbWrapper *wrapper) { NlaStrip *strip; - + for (strip = strips->first; strip; strip = strip->next) { /* fix strip's action */ if (strip->act) { fcurves_apply_cb(id, &strip->act->curves, wrapper->func, wrapper->user_data); } - + /* check sub-strips (if metas) */ nlastrips_apply_all_curves_cb(id, &strip->strips, wrapper); } @@ -1032,18 +1035,18 @@ static void adt_apply_all_fcurves_cb(ID *id, AnimData *adt, void *wrapper_data) { AllFCurvesCbWrapper *wrapper = wrapper_data; NlaTrack *nlt; - + if (adt->action) { fcurves_apply_cb(id, &adt->action->curves, wrapper->func, wrapper->user_data); } - + if (adt->tmpact) { fcurves_apply_cb(id, &adt->tmpact->curves, wrapper->func, wrapper->user_data); } - + /* free drivers - stored as a list of F-Curves */ fcurves_apply_cb(id, &adt->drivers, wrapper->func, wrapper->user_data); - + /* NLA Data - Animation Data for Strips */ for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { nlastrips_apply_all_curves_cb(id, &nlt->strips, wrapper); @@ -1051,20 +1054,20 @@ static void adt_apply_all_fcurves_cb(ID *id, AnimData *adt, void *wrapper_data) } /* apply the given callback function on all F-Curves attached to data in main database */ -void BKE_fcurves_main_cb(Main *mainptr, ID_FCurve_Edit_Callback func, void *user_data) +void BKE_fcurves_main_cb(Main *bmain, ID_FCurve_Edit_Callback func, void *user_data) { /* Wrap F-Curve operation stuff to pass to the general AnimData-level func */ AllFCurvesCbWrapper wrapper = {func, user_data}; - + /* Use the AnimData-based function so that we don't have to reimplement all that stuff */ - BKE_animdata_main_cb(mainptr, adt_apply_all_fcurves_cb, &wrapper); + BKE_animdata_main_cb(bmain, adt_apply_all_fcurves_cb, &wrapper); } /* Whole Database Ops -------------------------------------------- */ /* apply the given callback function on all data in main database */ -void BKE_animdata_main_cb(Main *mainptr, ID_AnimData_Edit_Callback func, void *user_data) +void BKE_animdata_main_cb(Main *bmain, ID_AnimData_Edit_Callback func, void *user_data) { ID *id; @@ -1074,7 +1077,7 @@ void BKE_animdata_main_cb(Main *mainptr, ID_AnimData_Edit_Callback func, void *u AnimData *adt = BKE_animdata_from_id(id); \ if (adt) func(id, adt, user_data); \ } (void)0 - + /* "embedded" nodetree cases (i.e. scene/material/texture->nodetree) */ #define ANIMDATA_NODETREE_IDS_CB(first, NtId_Type) \ for (id = first; id; id = id->next) { \ @@ -1086,69 +1089,69 @@ void BKE_animdata_main_cb(Main *mainptr, ID_AnimData_Edit_Callback func, void *u } \ if (adt) func(id, adt, user_data); \ } (void)0 - + /* nodes */ - ANIMDATA_IDS_CB(mainptr->nodetree.first); - + ANIMDATA_IDS_CB(bmain->nodetree.first); + /* textures */ - ANIMDATA_NODETREE_IDS_CB(mainptr->tex.first, Tex); - + ANIMDATA_NODETREE_IDS_CB(bmain->tex.first, Tex); + /* lamps */ - ANIMDATA_NODETREE_IDS_CB(mainptr->lamp.first, Lamp); - + ANIMDATA_NODETREE_IDS_CB(bmain->lamp.first, Lamp); + /* materials */ - ANIMDATA_NODETREE_IDS_CB(mainptr->mat.first, Material); - + ANIMDATA_NODETREE_IDS_CB(bmain->mat.first, Material); + /* cameras */ - ANIMDATA_IDS_CB(mainptr->camera.first); - + ANIMDATA_IDS_CB(bmain->camera.first); + /* shapekeys */ - ANIMDATA_IDS_CB(mainptr->key.first); - + ANIMDATA_IDS_CB(bmain->key.first); + /* metaballs */ - ANIMDATA_IDS_CB(mainptr->mball.first); - + ANIMDATA_IDS_CB(bmain->mball.first); + /* curves */ - ANIMDATA_IDS_CB(mainptr->curve.first); - + ANIMDATA_IDS_CB(bmain->curve.first); + /* armatures */ - ANIMDATA_IDS_CB(mainptr->armature.first); - + ANIMDATA_IDS_CB(bmain->armature.first); + /* lattices */ - ANIMDATA_IDS_CB(mainptr->latt.first); - + ANIMDATA_IDS_CB(bmain->latt.first); + /* meshes */ - ANIMDATA_IDS_CB(mainptr->mesh.first); - + ANIMDATA_IDS_CB(bmain->mesh.first); + /* particles */ - ANIMDATA_IDS_CB(mainptr->particle.first); + ANIMDATA_IDS_CB(bmain->particle.first); /* speakers */ - ANIMDATA_IDS_CB(mainptr->speaker.first); + ANIMDATA_IDS_CB(bmain->speaker.first); /* movie clips */ - ANIMDATA_IDS_CB(mainptr->movieclip.first); + ANIMDATA_IDS_CB(bmain->movieclip.first); /* objects */ - ANIMDATA_IDS_CB(mainptr->object.first); + ANIMDATA_IDS_CB(bmain->object.first); /* masks */ - ANIMDATA_IDS_CB(mainptr->mask.first); - + ANIMDATA_IDS_CB(bmain->mask.first); + /* worlds */ - ANIMDATA_NODETREE_IDS_CB(mainptr->world.first, World); + ANIMDATA_NODETREE_IDS_CB(bmain->world.first, World); /* scenes */ - ANIMDATA_NODETREE_IDS_CB(mainptr->scene.first, Scene); + ANIMDATA_NODETREE_IDS_CB(bmain->scene.first, Scene); /* line styles */ - ANIMDATA_IDS_CB(mainptr->linestyle.first); - + ANIMDATA_IDS_CB(bmain->linestyle.first); + /* grease pencil */ - ANIMDATA_IDS_CB(mainptr->gpencil.first); + ANIMDATA_IDS_CB(bmain->gpencil.first); /* cache files */ - ANIMDATA_IDS_CB(mainptr->cachefiles.first); + ANIMDATA_IDS_CB(bmain->cachefiles.first); } /* Fix all RNA-Paths throughout the database (directly access the Global.main version) @@ -1158,11 +1161,11 @@ void BKE_animdata_main_cb(Main *mainptr, ID_AnimData_Edit_Callback func, void *u /* TODO: use BKE_animdata_main_cb for looping over all data */ void BKE_animdata_fix_paths_rename_all(ID *ref_id, const char *prefix, const char *oldName, const char *newName) { - Main *mainptr = G.main; + Main *bmain = G.main; /* XXX UGLY! */ ID *id; - - /* macro for less typing - * - whether animdata exists is checked for by the main renaming callback, though taking + + /* macro for less typing + * - whether animdata exists is checked for by the main renaming callback, though taking * this outside of the function may make things slightly faster? */ #define RENAMEFIX_ANIM_IDS(first) \ @@ -1170,7 +1173,7 @@ void BKE_animdata_fix_paths_rename_all(ID *ref_id, const char *prefix, const cha AnimData *adt = BKE_animdata_from_id(id); \ BKE_animdata_fix_paths_rename(id, adt, ref_id, prefix, oldName, newName, 0, 0, 1); \ } (void)0 - + /* another version of this macro for nodetrees */ #define RENAMEFIX_ANIM_NODETREE_IDS(first, NtId_Type) \ for (id = first; id; id = id->next) { \ @@ -1182,72 +1185,72 @@ void BKE_animdata_fix_paths_rename_all(ID *ref_id, const char *prefix, const cha } \ BKE_animdata_fix_paths_rename(id, adt, ref_id, prefix, oldName, newName, 0, 0, 1); \ } (void)0 - + /* nodes */ - RENAMEFIX_ANIM_IDS(mainptr->nodetree.first); - + RENAMEFIX_ANIM_IDS(bmain->nodetree.first); + /* textures */ - RENAMEFIX_ANIM_NODETREE_IDS(mainptr->tex.first, Tex); - + RENAMEFIX_ANIM_NODETREE_IDS(bmain->tex.first, Tex); + /* lamps */ - RENAMEFIX_ANIM_NODETREE_IDS(mainptr->lamp.first, Lamp); - + RENAMEFIX_ANIM_NODETREE_IDS(bmain->lamp.first, Lamp); + /* materials */ - RENAMEFIX_ANIM_NODETREE_IDS(mainptr->mat.first, Material); - + RENAMEFIX_ANIM_NODETREE_IDS(bmain->mat.first, Material); + /* cameras */ - RENAMEFIX_ANIM_IDS(mainptr->camera.first); - + RENAMEFIX_ANIM_IDS(bmain->camera.first); + /* shapekeys */ - RENAMEFIX_ANIM_IDS(mainptr->key.first); - + RENAMEFIX_ANIM_IDS(bmain->key.first); + /* metaballs */ - RENAMEFIX_ANIM_IDS(mainptr->mball.first); - + RENAMEFIX_ANIM_IDS(bmain->mball.first); + /* curves */ - RENAMEFIX_ANIM_IDS(mainptr->curve.first); - + RENAMEFIX_ANIM_IDS(bmain->curve.first); + /* armatures */ - RENAMEFIX_ANIM_IDS(mainptr->armature.first); - + RENAMEFIX_ANIM_IDS(bmain->armature.first); + /* lattices */ - RENAMEFIX_ANIM_IDS(mainptr->latt.first); - + RENAMEFIX_ANIM_IDS(bmain->latt.first); + /* meshes */ - RENAMEFIX_ANIM_IDS(mainptr->mesh.first); - + RENAMEFIX_ANIM_IDS(bmain->mesh.first); + /* particles */ - RENAMEFIX_ANIM_IDS(mainptr->particle.first); + RENAMEFIX_ANIM_IDS(bmain->particle.first); /* speakers */ - RENAMEFIX_ANIM_IDS(mainptr->speaker.first); + RENAMEFIX_ANIM_IDS(bmain->speaker.first); /* movie clips */ - RENAMEFIX_ANIM_IDS(mainptr->movieclip.first); + RENAMEFIX_ANIM_IDS(bmain->movieclip.first); /* objects */ - RENAMEFIX_ANIM_IDS(mainptr->object.first); + RENAMEFIX_ANIM_IDS(bmain->object.first); /* masks */ - RENAMEFIX_ANIM_IDS(mainptr->mask.first); - + RENAMEFIX_ANIM_IDS(bmain->mask.first); + /* worlds */ - RENAMEFIX_ANIM_NODETREE_IDS(mainptr->world.first, World); - + RENAMEFIX_ANIM_NODETREE_IDS(bmain->world.first, World); + /* linestyles */ - RENAMEFIX_ANIM_IDS(mainptr->linestyle.first); - + RENAMEFIX_ANIM_IDS(bmain->linestyle.first); + /* grease pencil */ - RENAMEFIX_ANIM_IDS(mainptr->gpencil.first); + RENAMEFIX_ANIM_IDS(bmain->gpencil.first); /* cache files */ - RENAMEFIX_ANIM_IDS(mainptr->cachefiles.first); - + RENAMEFIX_ANIM_IDS(bmain->cachefiles.first); + /* scenes */ - RENAMEFIX_ANIM_NODETREE_IDS(mainptr->scene.first, Scene); + RENAMEFIX_ANIM_NODETREE_IDS(bmain->scene.first, Scene); } -/* *********************************** */ +/* *********************************** */ /* KeyingSet API */ /* Finding Tools --------------------------- */ @@ -1257,50 +1260,50 @@ void BKE_animdata_fix_paths_rename_all(ID *ref_id, const char *prefix, const cha KS_Path *BKE_keyingset_find_path(KeyingSet *ks, ID *id, const char group_name[], const char rna_path[], int array_index, int UNUSED(group_mode)) { KS_Path *ksp; - + /* sanity checks */ if (ELEM(NULL, ks, rna_path, id)) return NULL; - - /* loop over paths in the current KeyingSet, finding the first one where all settings match + + /* loop over paths in the current KeyingSet, finding the first one where all settings match * (i.e. the first one where none of the checks fail and equal 0) */ for (ksp = ks->paths.first; ksp; ksp = ksp->next) { short eq_id = 1, eq_path = 1, eq_index = 1, eq_group = 1; - + /* id */ if (id != ksp->id) eq_id = 0; - + /* path */ if ((ksp->rna_path == NULL) || !STREQ(rna_path, ksp->rna_path)) eq_path = 0; - + /* index - need to compare whole-array setting too... */ if (ksp->array_index != array_index) eq_index = 0; - + /* group */ if (group_name) { /* FIXME: these checks need to be coded... for now, it's not too important though */ } - + /* if all aspects are ok, return */ if (eq_id && eq_path && eq_index && eq_group) return ksp; } - + /* none found */ return NULL; } - + /* Defining Tools --------------------------- */ /* Used to create a new 'custom' KeyingSet for the user, that will be automatically added to the stack */ KeyingSet *BKE_keyingset_add(ListBase *list, const char idname[], const char name[], short flag, short keyingflag) { KeyingSet *ks; - + /* allocate new KeyingSet */ ks = MEM_callocN(sizeof(KeyingSet), "KeyingSet"); @@ -1310,16 +1313,16 @@ KeyingSet *BKE_keyingset_add(ListBase *list, const char idname[], const char nam ks->flag = flag; ks->keyingflag = keyingflag; ks->keyingoverride = keyingflag; /* NOTE: assume that if one is set one way, the other should be too, so that it'll work */ - + /* add KeyingSet to list */ BLI_addtail(list, ks); - + /* Make sure KeyingSet has a unique idname */ BLI_uniquename(list, ks, DATA_("KeyingSet"), '.', offsetof(KeyingSet, idname), sizeof(ks->idname)); - + /* Make sure KeyingSet has a unique label (this helps with identification) */ BLI_uniquename(list, ks, DATA_("Keying Set"), '.', offsetof(KeyingSet, name), sizeof(ks->name)); - + /* return new KeyingSet for further editing */ return ks; } @@ -1330,55 +1333,55 @@ KeyingSet *BKE_keyingset_add(ListBase *list, const char idname[], const char nam KS_Path *BKE_keyingset_add_path(KeyingSet *ks, ID *id, const char group_name[], const char rna_path[], int array_index, short flag, short groupmode) { KS_Path *ksp; - + /* sanity checks */ if (ELEM(NULL, ks, rna_path)) { printf("ERROR: no Keying Set and/or RNA Path to add path with\n"); return NULL; } - + /* ID is required for all types of KeyingSets */ if (id == NULL) { printf("ERROR: No ID provided for Keying Set Path\n"); return NULL; } - + /* don't add if there is already a matching KS_Path in the KeyingSet */ if (BKE_keyingset_find_path(ks, id, group_name, rna_path, array_index, groupmode)) { if (G.debug & G_DEBUG) printf("ERROR: destination already exists in Keying Set\n"); return NULL; } - + /* allocate a new KeyingSet Path */ ksp = MEM_callocN(sizeof(KS_Path), "KeyingSet Path"); - + /* just store absolute info */ ksp->id = id; if (group_name) BLI_strncpy(ksp->group, group_name, sizeof(ksp->group)); else ksp->group[0] = '\0'; - + /* store additional info for relative paths (just in case user makes the set relative) */ if (id) ksp->idtype = GS(id->name); - + /* just copy path info */ /* TODO: should array index be checked too? */ ksp->rna_path = BLI_strdup(rna_path); ksp->array_index = array_index; - + /* store flags */ ksp->flag = flag; ksp->groupmode = groupmode; - + /* add KeyingSet path to KeyingSet */ BLI_addtail(&ks->paths, ksp); - + /* return this path */ return ksp; -} +} /* Free the given Keying Set path */ void BKE_keyingset_free_path(KeyingSet *ks, KS_Path *ksp) @@ -1400,12 +1403,12 @@ void BKE_keyingsets_copy(ListBase *newlist, const ListBase *list) { KeyingSet *ksn; KS_Path *kspn; - + BLI_duplicatelist(newlist, list); for (ksn = newlist->first; ksn; ksn = ksn->next) { BLI_duplicatelist(&ksn->paths, &ksn->paths); - + for (kspn = ksn->paths.first; kspn; kspn = kspn->next) kspn->rna_path = MEM_dupallocN(kspn->rna_path); } @@ -1417,11 +1420,11 @@ void BKE_keyingsets_copy(ListBase *newlist, const ListBase *list) void BKE_keyingset_free(KeyingSet *ks) { KS_Path *ksp, *kspn; - + /* sanity check */ if (ks == NULL) return; - + /* free each path as we go to avoid looping twice */ for (ksp = ks->paths.first; ksp; ksp = kspn) { kspn = ksp->next; @@ -1433,12 +1436,12 @@ void BKE_keyingset_free(KeyingSet *ks) void BKE_keyingsets_free(ListBase *list) { KeyingSet *ks, *ksn; - + /* sanity check */ if (list == NULL) return; - - /* loop over KeyingSets freeing them + + /* loop over KeyingSets freeing them * - BKE_keyingset_free() doesn't free the set itself, but it frees its sub-data */ for (ks = list->first; ks; ks = ksn) { @@ -1451,7 +1454,7 @@ void BKE_keyingsets_free(ListBase *list) /* ***************************************** */ /* Evaluation Data-Setting Backend */ -/* Retrieve string to act as RNA-path, adjusted using mapping-table if provided +/* Retrieve string to act as RNA-path, adjusted using mapping-table if provided * It returns whether the string needs to be freed (i.e. if it was a temp remapped one) * // FIXME: maybe it would be faster if we didn't have to alloc/free strings like this all the time, but for now it's safer * @@ -1754,14 +1757,14 @@ static void animsys_evaluate_fcurves( static void animsys_evaluate_drivers(PointerRNA *ptr, AnimData *adt, float ctime) { FCurve *fcu; - + /* drivers are stored as F-Curves, but we cannot use the standard code, as we need to check if * the depsgraph requested that this driver be evaluated... */ for (fcu = adt->drivers.first; fcu; fcu = fcu->next) { ChannelDriver *driver = fcu->driver; bool ok = false; - + /* check if this driver's curve should be skipped */ if ((fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) == 0) { /* check if driver itself is tagged for recalculation */ @@ -1776,13 +1779,13 @@ static void animsys_evaluate_drivers(PointerRNA *ptr, AnimData *adt, float ctime const float curval = calculate_fcurve(&anim_rna, fcu, ctime); ok = animsys_write_rna_setting(&anim_rna, curval); } - + /* clear recalc flag */ driver->flag &= ~DRIVER_FLAG_RECALC; - + /* set error-flag if evaluation failed */ if (ok == 0) - driver->flag |= DRIVER_FLAG_INVALID; + driver->flag |= DRIVER_FLAG_INVALID; } } } @@ -1798,13 +1801,13 @@ static void animsys_evaluate_drivers(PointerRNA *ptr, AnimData *adt, float ctime static void action_idcode_patch_check(ID *id, bAction *act) { int idcode = 0; - + /* just in case */ if (ELEM(NULL, id, act)) return; else idcode = GS(id->name); - + /* the actual checks... hopefully not too much of a performance hit in the long run... */ if (act->idroot == 0) { /* use the current root if not set already (i.e. newly created actions and actions from 2.50-2.57 builds) @@ -1828,17 +1831,17 @@ static void action_idcode_patch_check(ID *id, bAction *act) void animsys_evaluate_action_group(PointerRNA *ptr, bAction *act, bActionGroup *agrp, AnimMapper *remap, float ctime) { FCurve *fcu; - + /* check if mapper is appropriate for use here (we set to NULL if it's inappropriate) */ if (ELEM(NULL, act, agrp)) return; if ((remap) && (remap->target != act)) remap = NULL; - + action_idcode_patch_check(ptr->id.data, act); - + /* if group is muted, don't evaluated any of the F-Curve */ if (agrp->flag & AGRP_MUTED) return; - + /* calculate then execute each curve */ for (fcu = agrp->channels.first; (fcu) && (fcu->grp == agrp); fcu = fcu->next) { /* check if this curve should be skipped */ @@ -1859,9 +1862,9 @@ static void animsys_evaluate_action_ex( /* check if mapper is appropriate for use here (we set to NULL if it's inappropriate) */ if (act == NULL) return; if ((remap) && (remap->target != act)) remap = NULL; - + action_idcode_patch_check(ptr->id.data, act); - + /* calculate then execute each curve */ animsys_evaluate_fcurves(depsgraph, ptr, &act->curves, remap, ctime); } @@ -1880,7 +1883,7 @@ static float nlastrip_get_influence(NlaStrip *strip, float cframe) /* sanity checks - normalize the blendin/out values? */ strip->blendin = fabsf(strip->blendin); strip->blendout = fabsf(strip->blendout); - + /* result depends on where frame is in respect to blendin/out values */ if (IS_EQF(strip->blendin, 0.0f) == false && (cframe <= (strip->start + strip->blendin))) { /* there is some blend-in */ @@ -1902,14 +1905,14 @@ static void nlastrip_evaluate_controls(Depsgraph *depsgraph, NlaStrip *strip, fl /* now strip's evaluate F-Curves for these settings (if applicable) */ if (strip->fcurves.first) { PointerRNA strip_ptr; - + /* create RNA-pointer needed to set values */ RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &strip_ptr); - + /* execute these settings as per normal */ animsys_evaluate_fcurves(depsgraph, &strip_ptr, &strip->fcurves, NULL, ctime); } - + /* analytically generate values for influence and time (if applicable) * - we do this after the F-Curves have been evaluated to override the effects of those * in case the override has been turned off. @@ -1934,7 +1937,7 @@ NlaEvalStrip *nlastrips_ctime_get_strip(Depsgraph *depsgraph, ListBase *list, Li NlaStrip *strip, *estrip = NULL; NlaEvalStrip *nes; short side = 0; - + /* loop over strips, checking if they fall within the range */ for (strip = strips->first; strip; strip = strip->next) { /* check if current time occurs within this strip */ @@ -1944,53 +1947,53 @@ NlaEvalStrip *nlastrips_ctime_get_strip(Depsgraph *depsgraph, ListBase *list, Li side = NES_TIME_WITHIN; break; } - + /* if time occurred before current strip... */ if (ctime < strip->start) { if (strip == strips->first) { /* before first strip - only try to use it if it extends backwards in time too */ if (strip->extendmode == NLASTRIP_EXTEND_HOLD) estrip = strip; - + /* side is 'before' regardless of whether there's a useful strip */ side = NES_TIME_BEFORE; } else { - /* before next strip - previous strip has ended, but next hasn't begun, + /* before next strip - previous strip has ended, but next hasn't begun, * so blending mode depends on whether strip is being held or not... * - only occurs when no transition strip added, otherwise the transition would have * been picked up above... */ strip = strip->prev; - + if (strip->extendmode != NLASTRIP_EXTEND_NOTHING) estrip = strip; side = NES_TIME_AFTER; } break; } - + /* if time occurred after current strip... */ if (ctime > strip->end) { /* only if this is the last strip should we do anything, and only if that is being held */ if (strip == strips->last) { if (strip->extendmode != NLASTRIP_EXTEND_NOTHING) estrip = strip; - + side = NES_TIME_AFTER; break; } - + /* otherwise, skip... as the 'before' case will catch it more elegantly! */ } } - + /* check if a valid strip was found * - must not be muted (i.e. will have contribution */ - if ((estrip == NULL) || (estrip->flag & NLASTRIP_FLAG_MUTED)) + if ((estrip == NULL) || (estrip->flag & NLASTRIP_FLAG_MUTED)) return NULL; - + /* if ctime was not within the boundaries of the strip, clamp! */ switch (side) { case NES_TIME_BEFORE: /* extend first frame only */ @@ -2000,8 +2003,8 @@ NlaEvalStrip *nlastrips_ctime_get_strip(Depsgraph *depsgraph, ListBase *list, Li ctime = estrip->end; break; } - - /* evaluate strip's evaluation controls + + /* evaluate strip's evaluation controls * - skip if no influence (i.e. same effect as muting the strip) * - negative influence is not supported yet... how would that be defined? */ @@ -2009,12 +2012,12 @@ NlaEvalStrip *nlastrips_ctime_get_strip(Depsgraph *depsgraph, ListBase *list, Li nlastrip_evaluate_controls(depsgraph, estrip, ctime); if (estrip->influence <= 0.0f) return NULL; - + /* check if strip has valid data to evaluate, * and/or perform any additional type-specific actions */ switch (estrip->type) { - case NLASTRIP_TYPE_CLIP: + case NLASTRIP_TYPE_CLIP: /* clip must have some action to evaluate */ if (estrip->act == NULL) return NULL; @@ -2023,51 +2026,51 @@ NlaEvalStrip *nlastrips_ctime_get_strip(Depsgraph *depsgraph, ListBase *list, Li /* there must be strips to transition from and to (i.e. prev and next required) */ if (ELEM(NULL, estrip->prev, estrip->next)) return NULL; - + /* evaluate controls for the relevant extents of the bordering strips... */ nlastrip_evaluate_controls(depsgraph, estrip->prev, estrip->start); nlastrip_evaluate_controls(depsgraph, estrip->next, estrip->end); break; } - + /* add to list of strips we need to evaluate */ nes = MEM_callocN(sizeof(NlaEvalStrip), "NlaEvalStrip"); - + nes->strip = estrip; nes->strip_mode = side; nes->track_index = index; nes->strip_time = estrip->strip_time; - + if (list) BLI_addtail(list, nes); - + return nes; } /* ---------------------- */ -/* find an NlaEvalChannel that matches the given criteria +/* find an NlaEvalChannel that matches the given criteria * - ptr and prop are the RNA data to find a match for */ static NlaEvalChannel *nlaevalchan_find_match(ListBase *channels, PointerRNA *ptr, PropertyRNA *prop, int array_index) { NlaEvalChannel *nec; - + /* sanity check */ if (channels == NULL) return NULL; - + /* loop through existing channels, checking for a channel which affects the same property */ for (nec = channels->first; nec; nec = nec->next) { /* - comparing the PointerRNA's is done by comparing the pointers * to the actual struct the property resides in, since that all the - * other data stored in PointerRNA cannot allow us to definitively - * identify the data + * other data stored in PointerRNA cannot allow us to definitively + * identify the data */ if ((nec->ptr.data == ptr->data) && (nec->prop == prop) && (nec->index == array_index)) return nec; } - + /* not found */ return NULL; } @@ -2078,9 +2081,9 @@ static void nlaevalchan_value_init(NlaEvalChannel *nec) PointerRNA *ptr = &nec->ptr; PropertyRNA *prop = nec->prop; int index = nec->index; - - /* NOTE: while this doesn't work for all RNA properties as default values aren't in fact - * set properly for most of them, at least the common ones (which also happen to get used + + /* NOTE: while this doesn't work for all RNA properties as default values aren't in fact + * set properly for most of them, at least the common ones (which also happen to get used * in NLA strips a lot, e.g. scale) are set correctly. */ switch (RNA_property_type(prop)) { @@ -2119,15 +2122,15 @@ static NlaEvalChannel *nlaevalchan_verify(PointerRNA *ptr, ListBase *channels, N PointerRNA new_ptr; char *path = NULL; /* short free_path = 0; */ - + /* sanity checks */ if (channels == NULL) return NULL; - + /* get RNA pointer+property info from F-Curve for more convenient handling */ /* get path, remapped as appropriate to work in its new environment */ /* free_path = */ /* UNUSED */ animsys_remap_path(strip->remap, fcu->rna_path, &path); - + /* a valid property must be available, and it must be animatable */ if (RNA_path_resolve_property(ptr, path, &new_ptr, &prop) == false) { if (G.debug & G_DEBUG) printf("NLA Strip Eval: Cannot resolve path\n"); @@ -2138,27 +2141,27 @@ static NlaEvalChannel *nlaevalchan_verify(PointerRNA *ptr, ListBase *channels, N if (G.debug & G_DEBUG) printf("NLA Strip Eval: Property not animatable\n"); return NULL; } - + /* try to find a match */ nec = nlaevalchan_find_match(channels, &new_ptr, prop, fcu->array_index); - + /* allocate a new struct for this if none found */ if (nec == NULL) { nec = MEM_callocN(sizeof(NlaEvalChannel), "NlaEvalChannel"); BLI_addtail(channels, nec); - + /* store property links for writing to the property later */ nec->ptr = new_ptr; nec->prop = prop; nec->index = fcu->array_index; - + /* initialise value using default value of property [#35856] */ nlaevalchan_value_init(nec); *newChan = true; } else *newChan = false; - + /* we can now return */ return nec; } @@ -2169,7 +2172,7 @@ static void nlaevalchan_accumulate(NlaEvalChannel *nec, NlaEvalStrip *nes, float NlaStrip *strip = nes->strip; short blendmode = strip->blendmode; float inf = strip->influence; - + /* for replace blend mode, and if this is the first strip, * just replace the value regardless of the influence */ if (newChan && blendmode == NLASTRIP_MODE_REPLACE) { @@ -2180,36 +2183,36 @@ static void nlaevalchan_accumulate(NlaEvalChannel *nec, NlaEvalStrip *nes, float /* if this is being performed as part of transition evaluation, incorporate * an additional weighting factor for the influence */ - if (nes->strip_mode == NES_TIME_TRANSITION_END) + if (nes->strip_mode == NES_TIME_TRANSITION_END) inf *= nes->strip_time; - + /* optimisation: no need to try applying if there is no influence */ if (IS_EQF(inf, 0.0f)) return; - + /* perform blending */ switch (blendmode) { case NLASTRIP_MODE_ADD: /* simply add the scaled value on to the stack */ nec->value += (value * inf); break; - + case NLASTRIP_MODE_SUBTRACT: /* simply subtract the scaled value from the stack */ nec->value -= (value * inf); break; - + case NLASTRIP_MODE_MULTIPLY: /* multiply the scaled value with the stack */ - /* Formula Used: - * result = fac * (a * b) + (1 - fac) * a + /* Formula Used: + * result = fac * (a * b) + (1 - fac) * a */ nec->value = inf * (nec->value * value) + (1 - inf) * nec->value; break; - + case NLASTRIP_MODE_REPLACE: default: /* TODO: do we really want to blend by default? it seems more uses might prefer add... */ - /* do linear interpolation - * - the influence of the accumulated data (elsewhere, that is called dstweight) + /* do linear interpolation + * - the influence of the accumulated data (elsewhere, that is called dstweight) * is 1 - influence, since the strip's influence is srcweight */ nec->value = nec->value * (1.0f - inf) + (value * inf); @@ -2221,19 +2224,19 @@ static void nlaevalchan_accumulate(NlaEvalChannel *nec, NlaEvalStrip *nes, float static void nlaevalchan_buffers_accumulate(ListBase *channels, ListBase *tmp_buffer, NlaEvalStrip *nes) { NlaEvalChannel *nec, *necn, *necd; - + /* optimize - abort if no channels */ if (BLI_listbase_is_empty(tmp_buffer)) return; - + /* accumulate results in tmp_channels buffer to the accumulation buffer */ for (nec = tmp_buffer->first; nec; nec = necn) { /* get pointer to next channel in case we remove the current channel from the temp-buffer */ necn = nec->next; - + /* try to find an existing matching channel for this setting in the accumulation buffer */ necd = nlaevalchan_find_match(channels, &nec->ptr, nec->prop, nec->index); - + /* if there was a matching channel already in the buffer, accumulate to it, * otherwise, add the current channel to the buffer for efficiency */ @@ -2244,7 +2247,7 @@ static void nlaevalchan_buffers_accumulate(ListBase *channels, ListBase *tmp_buf BLI_addtail(channels, nec); } } - + /* free temp-channels that haven't been assimilated into the buffer */ BLI_freelistN(tmp_buffer); } @@ -2256,7 +2259,7 @@ static void nlaevalchan_buffers_accumulate(ListBase *channels, ListBase *tmp_buf static void nlaeval_fmodifiers_join_stacks(ListBase *result, ListBase *list1, ListBase *list2) { FModifier *fcm1, *fcm2; - + /* if list1 is invalid... */ if (ELEM(NULL, list1, list1->first)) { if (list2 && list2->first) { @@ -2270,15 +2273,15 @@ static void nlaeval_fmodifiers_join_stacks(ListBase *result, ListBase *list1, Li result->last = list1->last; } else { - /* list1 should be added first, and list2 second, with the endpoints of these being the endpoints for result + /* list1 should be added first, and list2 second, with the endpoints of these being the endpoints for result * - the original lists must be left unchanged though, as we need that fact for restoring */ result->first = list1->first; result->last = list2->last; - + fcm1 = list1->last; fcm2 = list2->first; - + fcm1->next = fcm2; fcm2->prev = fcm1; } @@ -2288,17 +2291,17 @@ static void nlaeval_fmodifiers_join_stacks(ListBase *result, ListBase *list1, Li static void nlaeval_fmodifiers_split_stacks(ListBase *list1, ListBase *list2) { FModifier *fcm1, *fcm2; - + /* if list1/2 is invalid... just skip */ if (ELEM(NULL, list1, list2)) return; if (ELEM(NULL, list1->first, list2->first)) return; - + /* get endpoints */ fcm1 = list1->last; fcm2 = list2->first; - + /* clear their links */ fcm1->next = NULL; fcm2->prev = NULL; @@ -2314,48 +2317,48 @@ static void nlastrip_evaluate_actionclip(PointerRNA *ptr, ListBase *channels, Li NlaStrip *strip = nes->strip; FCurve *fcu; float evaltime; - + /* sanity checks for action */ if (strip == NULL) return; - + if (strip->act == NULL) { printf("NLA-Strip Eval Error: Strip '%s' has no Action\n", strip->name); return; } - + action_idcode_patch_check(ptr->id.data, strip->act); - + /* join this strip's modifiers to the parent's modifiers (own modifiers first) */ nlaeval_fmodifiers_join_stacks(&tmp_modifiers, &strip->modifiers, modifiers); - + /* evaluate strip's modifiers which modify time to evaluate the base curves at */ storage = evaluate_fmodifiers_storage_new(&tmp_modifiers); evaltime = evaluate_time_fmodifiers(storage, &tmp_modifiers, NULL, 0.0f, strip->strip_time); - + /* evaluate all the F-Curves in the action, saving the relevant pointers to data that will need to be used */ for (fcu = strip->act->curves.first; fcu; fcu = fcu->next) { NlaEvalChannel *nec; float value = 0.0f; bool newChan; - + /* check if this curve should be skipped */ if (fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) continue; if ((fcu->grp) && (fcu->grp->flag & AGRP_MUTED)) continue; - - /* evaluate the F-Curve's value for the time given in the strip - * NOTE: we use the modified time here, since strip's F-Curve Modifiers are applied on top of this + + /* evaluate the F-Curve's value for the time given in the strip + * NOTE: we use the modified time here, since strip's F-Curve Modifiers are applied on top of this */ value = evaluate_fcurve(fcu, evaltime); - - /* apply strip's F-Curve Modifiers on this value + + /* apply strip's F-Curve Modifiers on this value * NOTE: we apply the strip's original evaluation time not the modified one (as per standard F-Curve eval) */ evaluate_value_fmodifiers(storage, &tmp_modifiers, fcu, &value, strip->strip_time); - - + + /* get an NLA evaluation channel to work with, and accumulate the evaluated value with the value(s) * stored in this channel if it has been used already */ @@ -2379,11 +2382,11 @@ static void nlastrip_evaluate_transition( ListBase tmp_modifiers = {NULL, NULL}; NlaEvalStrip tmp_nes; NlaStrip *s1, *s2; - + /* join this strip's modifiers to the parent's modifiers (own modifiers first) */ nlaeval_fmodifiers_join_stacks(&tmp_modifiers, &nes->strip->modifiers, modifiers); - - /* get the two strips to operate on + + /* get the two strips to operate on * - we use the endpoints of the strips directly flanking our strip * using these as the endpoints of the transition (destination and source) * - these should have already been determined to be valid... @@ -2398,8 +2401,8 @@ static void nlastrip_evaluate_transition( s1 = nes->strip->prev; s2 = nes->strip->next; } - - /* prepare template for 'evaluation strip' + + /* prepare template for 'evaluation strip' * - based on the transition strip's evaluation strip data * - strip_mode is NES_TIME_TRANSITION_* based on which endpoint * - strip_time is the 'normalized' (i.e. in-strip) time for evaluation, @@ -2407,23 +2410,23 @@ static void nlastrip_evaluate_transition( * which allows us to appear to be 'interpolating' between the two extremes */ tmp_nes = *nes; - + /* evaluate these strips into a temp-buffer (tmp_channels) */ /* FIXME: modifier evaluation here needs some work... */ /* first strip */ tmp_nes.strip_mode = NES_TIME_TRANSITION_START; tmp_nes.strip = s1; nlastrip_evaluate(depsgraph, ptr, &tmp_channels, &tmp_modifiers, &tmp_nes); - + /* second strip */ tmp_nes.strip_mode = NES_TIME_TRANSITION_END; tmp_nes.strip = s2; nlastrip_evaluate(depsgraph, ptr, &tmp_channels, &tmp_modifiers, &tmp_nes); - - + + /* accumulate temp-buffer and full-buffer, using the 'real' strip */ nlaevalchan_buffers_accumulate(channels, &tmp_channels, nes); - + /* unlink this strip's modifiers from the parent's modifiers again */ nlaeval_fmodifiers_split_stacks(&nes->strip->modifiers, modifiers); } @@ -2436,32 +2439,32 @@ static void nlastrip_evaluate_meta( NlaStrip *strip = nes->strip; NlaEvalStrip *tmp_nes; float evaltime; - + /* meta-strip was calculated normally to have some time to be evaluated at * and here we 'look inside' the meta strip, treating it as a decorated window to - * it's child strips, which get evaluated as if they were some tracks on a strip + * it's child strips, which get evaluated as if they were some tracks on a strip * (but with some extra modifiers to apply). * * NOTE: keep this in sync with animsys_evaluate_nla() */ - + /* join this strip's modifiers to the parent's modifiers (own modifiers first) */ - nlaeval_fmodifiers_join_stacks(&tmp_modifiers, &strip->modifiers, modifiers); - + nlaeval_fmodifiers_join_stacks(&tmp_modifiers, &strip->modifiers, modifiers); + /* find the child-strip to evaluate */ evaltime = (nes->strip_time * (strip->end - strip->start)) + strip->start; tmp_nes = nlastrips_ctime_get_strip(depsgraph, NULL, &strip->strips, -1, evaltime); - - /* directly evaluate child strip into accumulation buffer... + + /* directly evaluate child strip into accumulation buffer... * - there's no need to use a temporary buffer (as it causes issues [T40082]) */ if (tmp_nes) { nlastrip_evaluate(depsgraph, ptr, channels, &tmp_modifiers, tmp_nes); - + /* free temp eval-strip */ MEM_freeN(tmp_nes); } - + /* unlink this strip's modifiers from the parent's modifiers again */ nlaeval_fmodifiers_split_stacks(&strip->modifiers, modifiers); } @@ -2470,7 +2473,7 @@ static void nlastrip_evaluate_meta( void nlastrip_evaluate(Depsgraph *depsgraph, PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes) { NlaStrip *strip = nes->strip; - + /* to prevent potential infinite recursion problems (i.e. transition strip, beside meta strip containing a transition * several levels deep inside it), we tag the current strip as being evaluated, and clear this when we leave */ @@ -2478,7 +2481,7 @@ void nlastrip_evaluate(Depsgraph *depsgraph, PointerRNA *ptr, ListBase *channels if (strip->flag & NLASTRIP_FLAG_EDIT_TOUCHED) return; strip->flag |= NLASTRIP_FLAG_EDIT_TOUCHED; - + /* actions to take depend on the type of strip */ switch (strip->type) { case NLASTRIP_TYPE_CLIP: /* action-clip */ @@ -2490,11 +2493,11 @@ void nlastrip_evaluate(Depsgraph *depsgraph, PointerRNA *ptr, ListBase *channels case NLASTRIP_TYPE_META: /* meta */ nlastrip_evaluate_meta(depsgraph, ptr, channels, modifiers, nes); break; - + default: /* do nothing */ break; } - + /* clear temp recursion safe-check */ strip->flag &= ~NLASTRIP_FLAG_EDIT_TOUCHED; } @@ -2503,18 +2506,18 @@ void nlastrip_evaluate(Depsgraph *depsgraph, PointerRNA *ptr, ListBase *channels void nladata_flush_channels(ListBase *channels) { NlaEvalChannel *nec; - + /* sanity checks */ if (channels == NULL) return; - + /* for each channel with accumulated values, write its value on the property it affects */ for (nec = channels->first; nec; nec = nec->next) { PointerRNA *ptr = &nec->ptr; PropertyRNA *prop = nec->prop; int array_index = nec->index; float value = nec->value; - + /* write values - see animsys_write_rna_setting() to sync the code */ switch (RNA_property_type(prop)) { case PROP_BOOLEAN: @@ -2559,19 +2562,19 @@ static void animsys_evaluate_nla(Depsgraph *depsgraph, ListBase *echannels, Poin NlaTrack *nlt; short track_index = 0; bool has_strips = false; - + ListBase estrips = {NULL, NULL}; NlaEvalStrip *nes; - + NlaStrip dummy_strip = {NULL}; /* dummy strip for active action */ - - + + /* 1. get the stack of strips to evaluate at current time (influence calculated here) */ for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next, track_index++) { /* stop here if tweaking is on and this strip is the tweaking track (it will be the first one that's 'disabled')... */ if ((adt->flag & ADT_NLA_EDIT_ON) && (nlt->flag & NLATRACK_DISABLED)) break; - + /* solo and muting are mutually exclusive... */ if (adt->flag & ADT_NLA_SOLO_TRACK) { /* skip if there is a solo track, but this isn't it */ @@ -2581,24 +2584,24 @@ static void animsys_evaluate_nla(Depsgraph *depsgraph, ListBase *echannels, Poin } else { /* no solo tracks - skip track if muted */ - if (nlt->flag & NLATRACK_MUTED) + if (nlt->flag & NLATRACK_MUTED) continue; } - - /* if this track has strips (but maybe they won't be suitable), set has_strips + + /* if this track has strips (but maybe they won't be suitable), set has_strips * - used for mainly for still allowing normal action evaluation... */ if (nlt->strips.first) has_strips = true; - + /* otherwise, get strip to evaluate for this channel */ nes = nlastrips_ctime_get_strip(depsgraph, &estrips, &nlt->strips, track_index, ctime); if (nes) nes->track = nlt; } - + /* add 'active' Action (may be tweaking track) as last strip to evaluate in NLA stack * - only do this if we're not exclusively evaluating the 'solo' NLA-track - * - however, if the 'solo' track houses the current 'tweaking' strip, + * - however, if the 'solo' track houses the current 'tweaking' strip, * then we should allow this to play, otherwise nothing happens */ if ((adt->action) && ((adt->flag & ADT_NLA_SOLO_TRACK) == 0 || (adt->flag & ADT_NLA_EDIT_ON))) { @@ -2606,9 +2609,9 @@ static void animsys_evaluate_nla(Depsgraph *depsgraph, ListBase *echannels, Poin if ((has_strips) || (adt->actstrip)) { /* make dummy NLA strip, and add that to the stack */ ListBase dummy_trackslist; - + dummy_trackslist.first = dummy_trackslist.last = &dummy_strip; - + if ((nlt) && !(adt->flag & ADT_NLA_EDIT_NOMAP)) { /* edit active action in-place according to its active strip, so copy the data */ memcpy(&dummy_strip, adt->actstrip, sizeof(NlaStrip)); @@ -2618,20 +2621,20 @@ static void animsys_evaluate_nla(Depsgraph *depsgraph, ListBase *echannels, Poin /* set settings of dummy NLA strip from AnimData settings */ dummy_strip.act = adt->action; dummy_strip.remap = adt->remap; - + /* action range is calculated taking F-Modifiers into account (which making new strips doesn't do due to the troublesome nature of that) */ calc_action_range(dummy_strip.act, &dummy_strip.actstart, &dummy_strip.actend, 1); dummy_strip.start = dummy_strip.actstart; dummy_strip.end = (IS_EQF(dummy_strip.actstart, dummy_strip.actend)) ? (dummy_strip.actstart + 1.0f) : (dummy_strip.actend); - + dummy_strip.blendmode = adt->act_blendmode; dummy_strip.extendmode = adt->act_extendmode; dummy_strip.influence = adt->act_influence; - + /* NOTE: must set this, or else the default setting overrides, and this setting doesn't work */ dummy_strip.flag |= NLASTRIP_FLAG_USR_INFLUENCE; } - + /* add this to our list of evaluation strips */ nlastrips_ctime_get_strip(depsgraph, &estrips, &dummy_trackslist, -1, ctime); } @@ -2639,27 +2642,27 @@ static void animsys_evaluate_nla(Depsgraph *depsgraph, ListBase *echannels, Poin /* special case - evaluate as if there isn't any NLA data */ /* TODO: this is really just a stop-gap measure... */ if (G.debug & G_DEBUG) printf("NLA Eval: Stopgap for active action on NLA Stack - no strips case\n"); - + animsys_evaluate_action(depsgraph, ptr, adt->action, adt->remap, ctime); BLI_freelistN(&estrips); return; } } - + /* only continue if there are strips to evaluate */ if (BLI_listbase_is_empty(&estrips)) return; - - + + /* 2. for each strip, evaluate then accumulate on top of existing channels, but don't set values yet */ for (nes = estrips.first; nes; nes = nes->next) nlastrip_evaluate(depsgraph, ptr, echannels, NULL, nes); - + /* 3. free temporary evaluation data that's not used elsewhere */ BLI_freelistN(&estrips); } -/* NLA Evaluation function (mostly for use through do_animdata) +/* NLA Evaluation function (mostly for use through do_animdata) * - All channels that will be affected are not cleared anymore. Instead, we just evaluate into * some temp channels, where values can be accumulated in one go. */ @@ -2672,15 +2675,15 @@ static void animsys_calculate_nla(Depsgraph *depsgraph, PointerRNA *ptr, AnimDat /* evaluate the NLA stack, obtaining a set of values to flush */ animsys_evaluate_nla(depsgraph, &echannels, ptr, adt, ctime); - + /* flush effects of accumulating channels in NLA to the actual data they affect */ nladata_flush_channels(&echannels); - + /* free temp data */ BLI_freelistN(&echannels); } -/* ***************************************** */ +/* ***************************************** */ /* Overrides System - Public API */ /* Clear all overrides */ @@ -2700,7 +2703,7 @@ AnimOverride *BKE_animsys_validate_override(PointerRNA *UNUSED(ptr), char *UNUSE static void animsys_evaluate_overrides(PointerRNA *ptr, AnimData *adt) { AnimOverride *aor; - + /* for each override, simply execute... */ for (aor = adt->overrides.first; aor; aor = aor->next) { PathResolvedRNA anim_rna; @@ -2744,7 +2747,7 @@ static void animsys_evaluate_overrides(PointerRNA *ptr, AnimData *adt) * However, the code for this is relatively harmless, so is left in the code for now. */ -/* Evaluation loop for evaluation animation data +/* Evaluation loop for evaluation animation data * * This assumes that the animation-data provided belongs to the ID block in question, * and that the flags for which parts of the anim-data settings need to be recalculated @@ -2753,14 +2756,14 @@ static void animsys_evaluate_overrides(PointerRNA *ptr, AnimData *adt) void BKE_animsys_evaluate_animdata(Depsgraph *depsgraph, Scene *scene, ID *id, AnimData *adt, float ctime, short recalc) { PointerRNA id_ptr; - + /* sanity checks */ if (ELEM(NULL, id, adt)) return; - + /* get pointer to ID-block for RNA to use */ RNA_id_pointer_create(id, &id_ptr); - + /* recalculate keyframe data: * - NLA before Active Action, as Active Action behaves as 'tweaking track' * that overrides 'rough' work in NLA @@ -2769,7 +2772,7 @@ void BKE_animsys_evaluate_animdata(Depsgraph *depsgraph, Scene *scene, ID *id, A if ((recalc & ADT_RECALC_ANIM) || (adt->recalc & ADT_RECALC_ANIM)) { /* evaluate NLA data */ if ((adt->nla_tracks.first) && !(adt->flag & ADT_NLA_EVAL_OFF)) { - /* evaluate NLA-stack + /* evaluate NLA-stack * - active action is evaluated as part of the NLA stack as the last item */ animsys_calculate_nla(depsgraph, &id_ptr, adt, ctime); @@ -2777,13 +2780,13 @@ void BKE_animsys_evaluate_animdata(Depsgraph *depsgraph, Scene *scene, ID *id, A /* evaluate Active Action only */ else if (adt->action) animsys_evaluate_action_ex(depsgraph, &id_ptr, adt->action, adt->remap, ctime); - + /* reset tag */ adt->recalc &= ~ADT_RECALC_ANIM; } - - /* recalculate drivers - * - Drivers need to be evaluated afterwards, as they can either override + + /* recalculate drivers + * - Drivers need to be evaluated afterwards, as they can either override * or be layered on top of existing animation data. * - Drivers should be in the appropriate order to be evaluated without problems... */ @@ -2793,22 +2796,22 @@ void BKE_animsys_evaluate_animdata(Depsgraph *depsgraph, Scene *scene, ID *id, A { animsys_evaluate_drivers(&id_ptr, adt, ctime); } - - /* always execute 'overrides' + + /* always execute 'overrides' * - Overrides allow editing, by overwriting the value(s) set from animation-data, with the - * value last set by the user (and not keyframed yet). + * value last set by the user (and not keyframed yet). * - Overrides are cleared upon frame change and/or keyframing * - It is best that we execute this every time, so that no errors are likely to occur. */ animsys_evaluate_overrides(&id_ptr, adt); - + /* execute and clear all cached property update functions */ if (scene) { Main *bmain = G.main; // xxx - to get passed in! RNA_property_update_cache_flush(bmain, scene); RNA_property_update_cache_free(); } - + /* clear recalc flag now */ adt->recalc = 0; } @@ -2826,10 +2829,10 @@ void BKE_animsys_evaluate_all_animation(Main *main, Depsgraph *depsgraph, Scene if (G.debug & G_DEBUG) printf("Evaluate all animation - %f\n", ctime); - - /* macros for less typing + + /* macros for less typing * - only evaluate animation data for id if it has users (and not just fake ones) - * - whether animdata exists is checked for by the evaluation function, though taking + * - whether animdata exists is checked for by the evaluation function, though taking * this outside of the function may make things slightly faster? */ #define EVAL_ANIM_IDS(first, aflag) \ @@ -2840,8 +2843,8 @@ void BKE_animsys_evaluate_all_animation(Main *main, Depsgraph *depsgraph, Scene } \ } (void)0 - /* another macro for the "embedded" nodetree cases - * - this is like EVAL_ANIM_IDS, but this handles the case "embedded nodetrees" + /* another macro for the "embedded" nodetree cases + * - this is like EVAL_ANIM_IDS, but this handles the case "embedded nodetrees" * (i.e. scene/material/texture->nodetree) which we need a special exception * for, otherwise they'd get skipped * - ntp = "node tree parent" = datablock where node tree stuff resides @@ -2858,10 +2861,10 @@ void BKE_animsys_evaluate_all_animation(Main *main, Depsgraph *depsgraph, Scene BKE_animsys_evaluate_animdata(depsgraph, scene, id, adt, ctime, aflag); \ } \ } (void)0 - - /* optimization: - * when there are no actions, don't go over database and loop over heaps of datablocks, - * which should ultimately be empty, since it is not possible for now to have any animation + + /* optimization: + * when there are no actions, don't go over database and loop over heaps of datablocks, + * which should ultimately be empty, since it is not possible for now to have any animation * without some actions, and drivers wouldn't get affected by any state changes * * however, if there are some curves, we will need to make sure that their 'ctime' property gets @@ -2870,46 +2873,46 @@ void BKE_animsys_evaluate_all_animation(Main *main, Depsgraph *depsgraph, Scene if (BLI_listbase_is_empty(&main->action) && BLI_listbase_is_empty(&main->curve)) { if (G.debug & G_DEBUG) printf("\tNo Actions, so no animation needs to be evaluated...\n"); - + return; } - + /* nodes */ EVAL_ANIM_IDS(main->nodetree.first, ADT_RECALC_ANIM); - + /* textures */ EVAL_ANIM_NODETREE_IDS(main->tex.first, Tex, ADT_RECALC_ANIM); - + /* lamps */ EVAL_ANIM_NODETREE_IDS(main->lamp.first, Lamp, ADT_RECALC_ANIM); - + /* materials */ EVAL_ANIM_NODETREE_IDS(main->mat.first, Material, ADT_RECALC_ANIM); - + /* cameras */ EVAL_ANIM_IDS(main->camera.first, ADT_RECALC_ANIM); - + /* shapekeys */ EVAL_ANIM_IDS(main->key.first, ADT_RECALC_ANIM); - + /* metaballs */ EVAL_ANIM_IDS(main->mball.first, ADT_RECALC_ANIM); - + /* curves */ EVAL_ANIM_IDS(main->curve.first, ADT_RECALC_ANIM); - + /* armatures */ EVAL_ANIM_IDS(main->armature.first, ADT_RECALC_ANIM); - + /* lattices */ EVAL_ANIM_IDS(main->latt.first, ADT_RECALC_ANIM); - + /* meshes */ EVAL_ANIM_IDS(main->mesh.first, ADT_RECALC_ANIM); - + /* particles */ EVAL_ANIM_IDS(main->particle.first, ADT_RECALC_ANIM); - + /* speakers */ EVAL_ANIM_IDS(main->speaker.first, ADT_RECALC_ANIM); @@ -2918,31 +2921,31 @@ void BKE_animsys_evaluate_all_animation(Main *main, Depsgraph *depsgraph, Scene /* linestyles */ EVAL_ANIM_IDS(main->linestyle.first, ADT_RECALC_ANIM); - + /* grease pencil */ EVAL_ANIM_IDS(main->gpencil.first, ADT_RECALC_ANIM); /* cache files */ EVAL_ANIM_IDS(main->cachefiles.first, ADT_RECALC_ANIM); - + /* objects */ /* ADT_RECALC_ANIM doesn't need to be supplied here, since object AnimData gets * this tagged by Depsgraph on framechange. This optimization means that objects * linked from other (not-visible) scenes will not need their data calculated. */ - EVAL_ANIM_IDS(main->object.first, 0); + EVAL_ANIM_IDS(main->object.first, 0); /* masks */ EVAL_ANIM_IDS(main->mask.first, ADT_RECALC_ANIM); - + /* worlds */ EVAL_ANIM_NODETREE_IDS(main->world.first, World, ADT_RECALC_ANIM); - + /* scenes */ EVAL_ANIM_NODETREE_IDS(main->scene.first, Scene, ADT_RECALC_ANIM); } -/* ***************************************** */ +/* ***************************************** */ /* ************** */ /* Evaluation API */ @@ -3017,7 +3020,7 @@ void BKE_animsys_eval_driver(Depsgraph *depsgraph, PathResolvedRNA anim_rna; if (animsys_store_rna_setting(&id_ptr, NULL, fcu->rna_path, fcu->array_index, &anim_rna)) { const float ctime = DEG_get_ctime(depsgraph); - const float curval = calculate_fcurve(&anim_rna, fcu, ctime); + const float curval = evaluate_fcurve_driver(&anim_rna, fcu, driver_orig, ctime); ok = animsys_write_rna_setting(&anim_rna, curval); if (ok && DEG_is_active(depsgraph)) { animsys_write_orig_anim_rna(&id_ptr, NULL, fcu, curval); |