4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
21 * All rights reserved.
23 * The Original Code is: all of this file.
25 * Contributor(s): Joshua Leung (full recode)
27 * ***** END GPL LICENSE BLOCK *****
30 /** \file blender/blenkernel/intern/anim_sys.c
41 #include "MEM_guardedalloc.h"
43 #include "BLI_blenlib.h"
44 #include "BLI_dynstr.h"
45 #include "BLI_utildefines.h"
47 #include "DNA_anim_types.h"
48 #include "DNA_material_types.h"
49 #include "DNA_scene_types.h"
50 #include "DNA_texture_types.h"
52 #include "BKE_animsys.h"
53 #include "BKE_action.h"
54 #include "BKE_fcurve.h"
56 #include "BKE_global.h"
58 #include "BKE_library.h"
59 #include "BKE_report.h"
60 #include "BKE_utildefines.h"
62 #include "RNA_access.h"
64 #include "nla_private.h"
66 /* ***************************************** */
69 /* Getter/Setter -------------------------------------------- */
71 /* Check if ID can have AnimData */
72 short id_type_can_have_animdata (ID *id)
78 /* Only some ID-blocks have this info for now */
79 // TODO: finish adding this for the other blocktypes
80 switch (GS(id->name)) {
83 case ID_ME: case ID_MB: case ID_CU: case ID_AR: case ID_LT:
86 case ID_MA: case ID_TE: case ID_NT:
87 case ID_LA: case ID_CA: case ID_WO:
101 /* Get AnimData from the given ID-block. In order for this to work, we assume that
102 * the AnimData pointer is stored immediately after the given ID-block in the struct,
103 * as per IdAdtTemplate.
105 AnimData *BKE_animdata_from_id (ID *id)
107 /* only some ID-blocks have this info for now, so we cast the
108 * types that do to be of type IdAdtTemplate, and extract the
111 if (id_type_can_have_animdata(id)) {
112 IdAdtTemplate *iat= (IdAdtTemplate *)id;
119 /* Add AnimData to the given ID-block. In order for this to work, we assume that
120 * the AnimData pointer is stored immediately after the given ID-block in the struct,
121 * as per IdAdtTemplate. Also note that
123 AnimData *BKE_id_add_animdata (ID *id)
125 /* Only some ID-blocks have this info for now, so we cast the
126 * types that do to be of type IdAdtTemplate, and add the AnimData
127 * to it using the template
129 if (id_type_can_have_animdata(id)) {
130 IdAdtTemplate *iat= (IdAdtTemplate *)id;
132 /* check if there's already AnimData, in which case, don't add */
133 if (iat->adt == NULL) {
137 adt= iat->adt= MEM_callocN(sizeof(AnimData), "AnimData");
139 /* set default settings */
140 adt->act_influence= 1.0f;
149 /* Action Setter --------------------------------------- */
151 /* Called when user tries to change the active action of an AnimData block (via RNA, Outliner, etc.) */
152 short BKE_animdata_set_action (ReportList *reports, ID *id, bAction *act)
154 AnimData *adt = BKE_animdata_from_id(id);
157 /* animdata validity check */
159 BKE_report(reports, RPT_WARNING, "No AnimData to set action on");
163 /* active action is only editable when it is not a tweaking strip
164 * see rna_AnimData_action_editable() in rna_animation.c
166 if ((adt->flag & ADT_NLA_EDIT_ON) || (adt->actstrip) || (adt->tmpact)) {
167 /* cannot remove, otherwise things turn to custard */
168 BKE_report(reports, RPT_ERROR, "Cannot change action, as it is still being edited in NLA");
172 /* manage usercount for current action */
174 id_us_min((ID*)adt->action);
176 /* assume that AnimData's action can in fact be edited... */
178 /* action must have same type as owner */
179 if (ELEM(act->idroot, 0, GS(id->name))) {
182 id_us_plus((ID*)adt->action);
187 BKE_reportf(reports, RPT_ERROR,
188 "Couldn't set Action '%s' onto ID '%s', as it doesn't have suitably rooted paths for this purpose",
189 act->id.name+2, id->name);
194 /* just clearing the action... */
202 /* Freeing -------------------------------------------- */
204 /* Free AnimData used by the nominated ID-block, and clear ID-block's AnimData pointer */
205 void BKE_free_animdata (ID *id)
207 /* Only some ID-blocks have this info for now, so we cast the
208 * types that do to be of type IdAdtTemplate
210 if (id_type_can_have_animdata(id)) {
211 IdAdtTemplate *iat= (IdAdtTemplate *)id;
212 AnimData *adt= iat->adt;
214 /* check if there's any AnimData to start with */
216 /* unlink action (don't free, as it's in its own list) */
218 adt->action->id.us--;
219 /* same goes for the temporarily displaced action */
221 adt->tmpact->id.us--;
224 free_nladata(&adt->nla_tracks);
226 /* free drivers - stored as a list of F-Curves */
227 free_fcurves(&adt->drivers);
232 /* free animdata now */
239 /* Freeing -------------------------------------------- */
241 /* Make a copy of the given AnimData - to be used when copying datablocks */
242 AnimData *BKE_copy_animdata (AnimData *adt, const short do_action)
246 /* sanity check before duplicating struct */
249 dadt= MEM_dupallocN(adt);
251 /* make a copy of action - at worst, user has to delete copies... */
253 dadt->action= copy_action(adt->action);
254 dadt->tmpact= copy_action(adt->tmpact);
257 id_us_plus((ID *)dadt->action);
258 id_us_plus((ID *)dadt->tmpact);
261 /* duplicate NLA data */
262 copy_nladata(&dadt->nla_tracks, &adt->nla_tracks);
264 /* duplicate drivers (F-Curves) */
265 copy_fcurves(&dadt->drivers, &adt->drivers);
267 /* don't copy overrides */
268 dadt->overrides.first= dadt->overrides.last= NULL;
274 int BKE_copy_animdata_id (ID *id_to, ID *id_from, const short do_action)
278 if ((id_to && id_from) && (GS(id_to->name) != GS(id_from->name)))
281 BKE_free_animdata(id_to);
283 adt = BKE_animdata_from_id(id_from);
285 IdAdtTemplate *iat = (IdAdtTemplate *)id_to;
286 iat->adt= BKE_copy_animdata(adt, do_action);
292 void BKE_copy_animdata_id_action(struct ID *id)
294 AnimData *adt= BKE_animdata_from_id(id);
297 id_us_min((ID *)adt->action);
298 adt->action= copy_action(adt->action);
301 id_us_min((ID *)adt->tmpact);
302 adt->tmpact= copy_action(adt->tmpact);
307 /* Make Local -------------------------------------------- */
309 static void make_local_strips(ListBase *strips)
313 for (strip=strips->first; strip; strip=strip->next) {
314 if (strip->act) make_local_action(strip->act);
315 if (strip->remap && strip->remap->target) make_local_action(strip->remap->target);
317 make_local_strips(&strip->strips);
321 /* Use local copy instead of linked copy of various ID-blocks */
322 void BKE_animdata_make_local(AnimData *adt)
326 /* Actions - Active and Temp */
327 if (adt->action) make_local_action(adt->action);
328 if (adt->tmpact) make_local_action(adt->tmpact);
330 if (adt->remap && adt->remap->target) make_local_action(adt->remap->target);
333 // TODO: need to remap the ID-targets too?
336 for (nlt=adt->nla_tracks.first; nlt; nlt=nlt->next)
337 make_local_strips(&nlt->strips);
341 /* When duplicating data (i.e. objects), drivers referring to the original data will
342 * get updated to point to the duplicated data (if drivers belong to the new data)
344 void BKE_relink_animdata (AnimData *adt)
351 if (adt->drivers.first) {
354 /* check each driver against all the base paths to see if any should go */
355 for (fcu= adt->drivers.first; fcu; fcu=fcu->next) {
356 ChannelDriver *driver= fcu->driver;
359 /* driver variables */
360 for (dvar= driver->variables.first; dvar; dvar=dvar->next) {
361 /* only change the used targets, since the others will need fixing manually anyway */
362 DRIVER_TARGETS_USED_LOOPER(dvar)
364 if (dtar->id && dtar->id->newid) {
365 dtar->id= dtar->id->newid;
368 DRIVER_TARGETS_LOOPER_END
374 /* Sub-ID Regrouping ------------------------------------------- */
376 /* helper heuristic for determining if a path is compatible with the basepath
377 * < path: (str) full RNA-path from some data (usually an F-Curve) to compare
378 * < basepath: (str) shorter path fragment to look for
379 * > returns (bool) whether there is a match
381 static short animpath_matches_basepath (const char path[], const char basepath[])
383 /* we need start of path to be basepath */
384 return (path && basepath) && (strstr(path, basepath) == path);
387 /* Move F-Curves in src action to dst action, setting up all the necessary groups
388 * for this to happen, but only if the F-Curves being moved have the appropriate
390 * - This is used when data moves from one datablock to another, causing the
391 * F-Curves to need to be moved over too
393 void action_move_fcurves_by_basepath (bAction *srcAct, bAction *dstAct, const char basepath[])
395 FCurve *fcu, *fcn=NULL;
398 if ELEM3(NULL, srcAct, dstAct, basepath) {
400 printf("ERROR: action_partition_fcurves_by_basepath(%p, %p, %p) has insufficient info to work with\n",
401 (void *)srcAct, (void *)dstAct, (void *)basepath);
406 /* clear 'temp' flags on all groups in src, as we'll be needing them later
407 * to identify groups that we've managed to empty out here
409 action_groups_clear_tempflags(srcAct);
411 /* iterate over all src F-Curves, moving over the ones that need to be moved */
412 for (fcu = srcAct->curves.first; fcu; fcu = fcn) {
413 /* store next pointer in case we move stuff */
416 /* should F-Curve be moved over?
417 * - we only need the start of the path to match basepath
419 if (animpath_matches_basepath(fcu->rna_path, basepath)) {
420 bActionGroup *agrp = NULL;
424 /* make sure there will be a matching group on the other side for the migrants */
425 agrp = action_groups_find_named(dstAct, fcu->grp->name);
428 /* add a new one with a similar name (usually will be the same though) */
429 agrp = action_groups_add_new(dstAct, fcu->grp->name);
432 /* old groups should be tagged with 'temp' flags so they can be removed later
433 * if we remove everything from them
435 fcu->grp->flag |= AGRP_TEMP;
438 /* perform the migration now */
439 action_groups_remove_channel(srcAct, fcu);
442 action_groups_add_channel(dstAct, agrp, fcu);
444 BLI_addtail(&dstAct->curves, fcu);
448 /* cleanup groups (if present) */
449 if (srcAct->groups.first) {
450 bActionGroup *agrp, *grp=NULL;
452 for (agrp = srcAct->groups.first; agrp; agrp = grp) {
455 /* only tagged groups need to be considered - clearing these tags or removing them */
456 if (agrp->flag & AGRP_TEMP) {
457 /* if group is empty and tagged, then we can remove as this operation
458 * moved out all the channels that were formerly here
460 if (agrp->channels.first == NULL)
461 BLI_freelinkN(&srcAct->groups, agrp);
463 agrp->flag &= ~AGRP_TEMP;
469 /* Transfer the animation data from srcID to dstID where the srcID
470 * animation data is based off "basepath", creating new AnimData and
471 * associated data as necessary
473 void BKE_animdata_separate_by_basepath (ID *srcID, ID *dstID, ListBase *basepaths)
475 AnimData *srcAdt=NULL, *dstAdt=NULL;
479 if ELEM(NULL, srcID, dstID) {
481 printf("ERROR: no source or destination ID to separate AnimData with\n");
485 /* get animdata from src, and create for destination (if needed) */
486 srcAdt = BKE_animdata_from_id(srcID);
487 dstAdt = BKE_id_add_animdata(dstID);
489 if ELEM(NULL, srcAdt, dstAdt) {
491 printf("ERROR: no AnimData for this pair of ID's\n");
496 if (srcAdt->action) {
497 /* set up an action if necessary, and name it in a similar way so that it can be easily found again */
498 if (dstAdt->action == NULL) {
499 dstAdt->action = add_empty_action(srcAdt->action->id.name+2);
501 else if (dstAdt->action == srcAdt->action) {
502 printf("Argh! Source and Destination share animation! ('%s' and '%s' both use '%s') Making new empty action\n",
503 srcID->name, dstID->name, srcAdt->action->id.name);
505 // TODO: review this...
506 id_us_min(&dstAdt->action->id);
507 dstAdt->action = add_empty_action(dstAdt->action->id.name+2);
510 /* loop over base paths, trying to fix for each one... */
511 for (ld = basepaths->first; ld; ld = ld->next) {
512 const char *basepath = (const char *)ld->data;
513 action_move_fcurves_by_basepath(srcAdt->action, dstAdt->action, basepath);
518 if (srcAdt->drivers.first) {
519 FCurve *fcu, *fcn=NULL;
521 /* check each driver against all the base paths to see if any should go */
522 for (fcu = srcAdt->drivers.first; fcu; fcu = fcn) {
525 /* try each basepath in turn, but stop on the first one which works */
526 for (ld = basepaths->first; ld; ld = ld->next) {
527 const char *basepath = (const char *)ld->data;
529 if (animpath_matches_basepath(fcu->rna_path, basepath)) {
530 /* just need to change lists */
531 BLI_remlink(&srcAdt->drivers, fcu);
532 BLI_addtail(&dstAdt->drivers, fcu);
534 // TODO: add depsgraph flushing calls?
536 /* can stop now, as moved already */
544 /* Path Validation -------------------------------------------- */
546 /* Check if a given RNA Path is valid, by tracing it from the given ID, and seeing if we can resolve it */
547 static short check_rna_path_is_valid (ID *owner_id, char *path)
549 PointerRNA id_ptr, ptr;
550 PropertyRNA *prop=NULL;
552 /* make initial RNA pointer to start resolving from */
553 RNA_id_pointer_create(owner_id, &id_ptr);
556 return RNA_path_resolve(&id_ptr, path, &ptr, &prop);
559 /* Check if some given RNA Path needs fixing - free the given path and set a new one as appropriate
560 * NOTE: we assume that oldName and newName have [" "] padding around them
562 static char *rna_path_rename_fix (ID *owner_id, const char *prefix, char *oldName, char *newName, char *oldpath, int verify_paths)
564 char *prefixPtr= strstr(oldpath, prefix);
565 char *oldNamePtr= strstr(oldpath, oldName);
566 int prefixLen= strlen(prefix);
567 int oldNameLen= strlen(oldName);
569 /* only start fixing the path if the prefix and oldName feature in the path,
570 * and prefix occurs immediately before oldName
572 if ( (prefixPtr && oldNamePtr) && (prefixPtr+prefixLen == oldNamePtr) ) {
573 /* if we haven't aren't able to resolve the path now, try again after fixing it */
574 if (!verify_paths || check_rna_path_is_valid(owner_id, oldpath) == 0) {
575 DynStr *ds= BLI_dynstr_new();
576 char *postfixPtr= oldNamePtr+oldNameLen;
577 char *newPath = NULL;
580 /* add the part of the string that goes up to the start of the prefix */
581 if (prefixPtr > oldpath) {
582 oldChar= prefixPtr[0];
584 BLI_dynstr_append(ds, oldpath);
585 prefixPtr[0]= oldChar;
589 BLI_dynstr_append(ds, prefix);
591 /* add the new name (complete with brackets) */
592 BLI_dynstr_append(ds, newName);
594 /* add the postfix */
595 BLI_dynstr_append(ds, postfixPtr);
597 /* create new path, and cleanup old data */
598 newPath= BLI_dynstr_get_cstring(ds);
601 /* check if the new path will solve our problems */
602 // TODO: will need to check whether this step really helps in practice
603 if (!verify_paths || check_rna_path_is_valid(owner_id, newPath)) {
604 /* free the old path, and return the new one, since we've solved the issues */
609 /* still couldn't resolve the path... so, might as well just leave it alone */
615 /* the old path doesn't need to be changed */
619 /* Check RNA-Paths for a list of F-Curves */
620 static void fcurves_path_rename_fix (ID *owner_id, const char *prefix, char *oldName, char *newName, ListBase *curves, int verify_paths)
624 /* we need to check every curve... */
625 for (fcu= curves->first; fcu; fcu= fcu->next) {
626 /* firstly, handle the F-Curve's own path */
628 fcu->rna_path= rna_path_rename_fix(owner_id, prefix, oldName, newName, fcu->rna_path, verify_paths);
632 /* Check RNA-Paths for a list of Drivers */
633 static void drivers_path_rename_fix (ID *owner_id, const char *prefix, char *oldName, char *newName, char *oldKey, char *newKey, ListBase *curves, int verify_paths)
637 /* we need to check every curve - drivers are F-Curves too! */
638 for (fcu= curves->first; fcu; fcu= fcu->next) {
639 /* firstly, handle the F-Curve's own path */
641 fcu->rna_path= rna_path_rename_fix(owner_id, prefix, oldKey, newKey, fcu->rna_path, verify_paths);
645 ChannelDriver *driver= fcu->driver;
648 /* driver variables */
649 for (dvar= driver->variables.first; dvar; dvar=dvar->next) {
650 /* only change the used targets, since the others will need fixing manually anyway */
651 DRIVER_TARGETS_USED_LOOPER(dvar)
653 /* rename RNA path */
654 if (dtar->rna_path && dtar->id)
655 dtar->rna_path= rna_path_rename_fix(dtar->id, prefix, oldKey, newKey, dtar->rna_path, verify_paths);
657 /* also fix the bone-name (if applicable) */
658 if (strstr(prefix, "bones")) {
659 if ( ((dtar->id) && (GS(dtar->id->name) == ID_OB)) &&
660 (dtar->pchan_name[0]) && (strcmp(oldName, dtar->pchan_name)==0) )
662 BLI_strncpy(dtar->pchan_name, newName, sizeof(dtar->pchan_name));
666 DRIVER_TARGETS_LOOPER_END
672 /* Fix all RNA-Paths for Actions linked to NLA Strips */
673 static void nlastrips_path_rename_fix (ID *owner_id, const char *prefix, char *oldName, char *newName, ListBase *strips, int verify_paths)
677 /* recursively check strips, fixing only actions... */
678 for (strip= strips->first; strip; strip= strip->next) {
679 /* fix strip's action */
681 fcurves_path_rename_fix(owner_id, prefix, oldName, newName, &strip->act->curves, verify_paths);
682 /* ignore own F-Curves, since those are local... */
684 /* check sub-strips (if metas) */
685 nlastrips_path_rename_fix(owner_id, prefix, oldName, newName, &strip->strips, verify_paths);
689 /* Fix all RNA-Paths in the AnimData block used by the given ID block
690 * NOTE: it is assumed that the structure we're replacing is <prefix><["><name><"]>
691 * i.e. pose.bones["Bone"]
693 void BKE_animdata_fix_paths_rename (ID *owner_id, AnimData *adt, const char *prefix, char *oldName, char *newName, int oldSubscript, int newSubscript, int verify_paths)
698 /* if no AnimData, no need to proceed */
699 if (ELEM(NULL, owner_id, adt))
702 if ((oldName != NULL) && (newName != NULL)) {
703 /* pad the names with [" "] so that only exact matches are made */
704 oldN= BLI_sprintfN("[\"%s\"]", oldName);
705 newN= BLI_sprintfN("[\"%s\"]", newName);
708 oldN= BLI_sprintfN("[%d]", oldSubscript);
709 newN= BLI_sprintfN("[%d]", newSubscript);
712 /* Active action and temp action */
714 fcurves_path_rename_fix(owner_id, prefix, oldN, newN, &adt->action->curves, verify_paths);
716 fcurves_path_rename_fix(owner_id, prefix, oldN, newN, &adt->tmpact->curves, verify_paths);
718 /* Drivers - Drivers are really F-Curves */
719 drivers_path_rename_fix(owner_id, prefix, oldName, newName, oldN, newN, &adt->drivers, verify_paths);
721 /* NLA Data - Animation Data for Strips */
722 for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next)
723 nlastrips_path_rename_fix(owner_id, prefix, oldN, newN, &nlt->strips, verify_paths);
725 /* free the temp names */
730 /* Whole Database Ops -------------------------------------------- */
732 /* apply the given callback function on all data in main database */
733 void BKE_animdata_main_cb (Main *mainptr, ID_AnimData_Edit_Callback func, void *user_data)
737 /* standard data version */
738 #define ANIMDATA_IDS_CB(first) \
739 for (id= first; id; id= id->next) { \
740 AnimData *adt= BKE_animdata_from_id(id); \
741 if (adt) func(id, adt, user_data); \
744 /* "embedded" nodetree cases (i.e. scene/material/texture->nodetree) */
745 #define ANIMDATA_NODETREE_IDS_CB(first, NtId_Type) \
746 for (id= first; id; id= id->next) { \
747 AnimData *adt= BKE_animdata_from_id(id); \
748 NtId_Type *ntp= (NtId_Type *)id; \
749 if (ntp->nodetree) { \
750 AnimData *adt2= BKE_animdata_from_id((ID *)ntp); \
751 if (adt2) func(id, adt2, user_data); \
753 if (adt) func(id, adt, user_data); \
757 ANIMDATA_IDS_CB(mainptr->nodetree.first);
760 ANIMDATA_NODETREE_IDS_CB(mainptr->tex.first, Tex);
763 ANIMDATA_IDS_CB(mainptr->lamp.first);
766 ANIMDATA_NODETREE_IDS_CB(mainptr->mat.first, Material);
769 ANIMDATA_IDS_CB(mainptr->camera.first);
772 ANIMDATA_IDS_CB(mainptr->key.first);
775 ANIMDATA_IDS_CB(mainptr->mball.first);
778 ANIMDATA_IDS_CB(mainptr->curve.first);
781 ANIMDATA_IDS_CB(mainptr->armature.first);
784 ANIMDATA_IDS_CB(mainptr->latt.first);
787 ANIMDATA_IDS_CB(mainptr->mesh.first);
790 ANIMDATA_IDS_CB(mainptr->particle.first);
793 ANIMDATA_IDS_CB(mainptr->speaker.first);
796 ANIMDATA_IDS_CB(mainptr->object.first);
799 ANIMDATA_IDS_CB(mainptr->world.first);
802 ANIMDATA_NODETREE_IDS_CB(mainptr->scene.first, Scene);
805 /* Fix all RNA-Paths throughout the database (directly access the Global.main version)
806 * NOTE: it is assumed that the structure we're replacing is <prefix><["><name><"]>
807 * i.e. pose.bones["Bone"]
809 /* TODO: use BKE_animdata_main_cb for looping over all data */
810 void BKE_all_animdata_fix_paths_rename (char *prefix, char *oldName, char *newName)
812 Main *mainptr= G.main;
815 /* macro for less typing
816 * - whether animdata exists is checked for by the main renaming callback, though taking
817 * this outside of the function may make things slightly faster?
819 #define RENAMEFIX_ANIM_IDS(first) \
820 for (id= first; id; id= id->next) { \
821 AnimData *adt= BKE_animdata_from_id(id); \
822 BKE_animdata_fix_paths_rename(id, adt, prefix, oldName, newName, 0, 0, 1);\
825 /* another version of this macro for nodetrees */
826 #define RENAMEFIX_ANIM_NODETREE_IDS(first, NtId_Type) \
827 for (id= first; id; id= id->next) { \
828 AnimData *adt= BKE_animdata_from_id(id); \
829 NtId_Type *ntp= (NtId_Type *)id; \
830 if (ntp->nodetree) { \
831 AnimData *adt2= BKE_animdata_from_id((ID *)ntp); \
832 BKE_animdata_fix_paths_rename((ID *)ntp, adt2, prefix, oldName, newName, 0, 0, 1);\
834 BKE_animdata_fix_paths_rename(id, adt, prefix, oldName, newName, 0, 0, 1);\
838 RENAMEFIX_ANIM_IDS(mainptr->nodetree.first);
841 RENAMEFIX_ANIM_NODETREE_IDS(mainptr->tex.first, Tex);
844 RENAMEFIX_ANIM_IDS(mainptr->lamp.first);
847 RENAMEFIX_ANIM_NODETREE_IDS(mainptr->mat.first, Material);
850 RENAMEFIX_ANIM_IDS(mainptr->camera.first);
853 RENAMEFIX_ANIM_IDS(mainptr->key.first);
856 RENAMEFIX_ANIM_IDS(mainptr->mball.first);
859 RENAMEFIX_ANIM_IDS(mainptr->curve.first);
862 RENAMEFIX_ANIM_IDS(mainptr->armature.first);
865 RENAMEFIX_ANIM_IDS(mainptr->latt.first);
868 RENAMEFIX_ANIM_IDS(mainptr->mesh.first);
871 RENAMEFIX_ANIM_IDS(mainptr->particle.first);
874 RENAMEFIX_ANIM_IDS(mainptr->speaker.first);
877 RENAMEFIX_ANIM_IDS(mainptr->object.first);
880 RENAMEFIX_ANIM_IDS(mainptr->world.first);
883 RENAMEFIX_ANIM_NODETREE_IDS(mainptr->scene.first, Scene);
886 /* *********************************** */
889 /* Finding Tools --------------------------- */
891 /* Find the first path that matches the given criteria */
892 // TODO: do we want some method to perform partial matches too?
893 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))
898 if ELEM3(NULL, ks, rna_path, id)
901 /* loop over paths in the current KeyingSet, finding the first one where all settings match
902 * (i.e. the first one where none of the checks fail and equal 0)
904 for (ksp= ks->paths.first; ksp; ksp= ksp->next) {
905 short eq_id=1, eq_path=1, eq_index=1, eq_group=1;
912 if ((ksp->rna_path==NULL) || strcmp(rna_path, ksp->rna_path))
915 /* index - need to compare whole-array setting too... */
916 if (ksp->array_index != array_index)
921 // FIXME: these checks need to be coded... for now, it's not too important though
924 /* if all aspects are ok, return */
925 if (eq_id && eq_path && eq_index && eq_group)
933 /* Defining Tools --------------------------- */
935 /* Used to create a new 'custom' KeyingSet for the user, that will be automatically added to the stack */
936 KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, short keyingflag)
940 /* allocate new KeyingSet */
941 ks= MEM_callocN(sizeof(KeyingSet), "KeyingSet");
943 BLI_strncpy(ks->name, name ? name : "KeyingSet", sizeof(ks->name));
946 ks->keyingflag= keyingflag;
948 /* add KeyingSet to list */
949 BLI_addtail(list, ks);
951 /* make sure KeyingSet has a unique name (this helps with identification) */
952 BLI_uniquename(list, ks, "KeyingSet", '.', offsetof(KeyingSet, name), sizeof(ks->name));
954 /* return new KeyingSet for further editing */
958 /* Add a path to a KeyingSet. Nothing is returned for now...
959 * Checks are performed to ensure that destination is appropriate for the KeyingSet in question
961 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)
966 if ELEM(NULL, ks, rna_path) {
967 printf("ERROR: no Keying Set and/or RNA Path to add path with \n");
971 /* ID is required for all types of KeyingSets */
973 printf("ERROR: No ID provided for Keying Set Path. \n");
977 /* don't add if there is already a matching KS_Path in the KeyingSet */
978 if (BKE_keyingset_find_path(ks, id, group_name, rna_path, array_index, groupmode)) {
980 printf("ERROR: destination already exists in Keying Set \n");
984 /* allocate a new KeyingSet Path */
985 ksp= MEM_callocN(sizeof(KS_Path), "KeyingSet Path");
987 /* just store absolute info */
990 BLI_strncpy(ksp->group, group_name, sizeof(ksp->group));
994 /* store additional info for relative paths (just in case user makes the set relative) */
996 ksp->idtype= GS(id->name);
998 /* just copy path info */
999 // TODO: should array index be checked too?
1000 ksp->rna_path= BLI_strdupn(rna_path, strlen(rna_path));
1001 ksp->array_index= array_index;
1005 ksp->groupmode= groupmode;
1007 /* add KeyingSet path to KeyingSet */
1008 BLI_addtail(&ks->paths, ksp);
1010 /* return this path */
1014 /* Free the given Keying Set path */
1015 void BKE_keyingset_free_path (KeyingSet *ks, KS_Path *ksp)
1018 if ELEM(NULL, ks, ksp)
1021 /* free RNA-path info */
1023 MEM_freeN(ksp->rna_path);
1025 /* free path itself */
1026 BLI_freelinkN(&ks->paths, ksp);
1029 /* Copy all KeyingSets in the given list */
1030 void BKE_keyingsets_copy (ListBase *newlist, ListBase *list)
1035 BLI_duplicatelist(newlist, list);
1037 for (ksn=newlist->first; ksn; ksn=ksn->next) {
1038 BLI_duplicatelist(&ksn->paths, &ksn->paths);
1040 for (kspn=ksn->paths.first; kspn; kspn=kspn->next)
1041 kspn->rna_path= MEM_dupallocN(kspn->rna_path);
1045 /* Freeing Tools --------------------------- */
1047 /* Free data for KeyingSet but not set itself */
1048 void BKE_keyingset_free (KeyingSet *ks)
1050 KS_Path *ksp, *kspn;
1056 /* free each path as we go to avoid looping twice */
1057 for (ksp= ks->paths.first; ksp; ksp= kspn) {
1059 BKE_keyingset_free_path(ks, ksp);
1063 /* Free all the KeyingSets in the given list */
1064 void BKE_keyingsets_free (ListBase *list)
1066 KeyingSet *ks, *ksn;
1072 /* loop over KeyingSets freeing them
1073 * - BKE_keyingset_free() doesn't free the set itself, but it frees its sub-data
1075 for (ks= list->first; ks; ks= ksn) {
1077 BKE_keyingset_free(ks);
1078 BLI_freelinkN(list, ks);
1082 /* ***************************************** */
1083 /* Evaluation Data-Setting Backend */
1085 /* Retrieve string to act as RNA-path, adjusted using mapping-table if provided
1086 * It returns whether the string needs to be freed (i.e. if it was a temp remapped one)
1087 * // 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
1089 * - remap: remapping table to use
1090 * - path: original path string (as stored in F-Curve data)
1091 * - dst: destination string to write data to
1093 static short animsys_remap_path (AnimMapper *UNUSED(remap), char *path, char **dst)
1095 /* is there a valid remapping table to use? */
1097 /* find a matching entry... to use to remap */
1101 /* nothing suitable found, so just set dst to look at path (i.e. no alloc/free needed) */
1107 /* less then 1.0 evaluates to false, use epsilon to avoid float error */
1108 #define ANIMSYS_FLOAT_AS_BOOL(value) ((value) > ((1.0f-FLT_EPSILON)))
1110 /* Write the given value to a setting using RNA, and return success */
1111 static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_index, float value)
1116 //printf("%p %s %i %f\n", ptr, path, array_index, value);
1118 /* get property to write to */
1119 if (RNA_path_resolve(ptr, path, &new_ptr, &prop))
1121 /* set value - only for animatable numerical values */
1122 if (RNA_property_animateable(&new_ptr, prop))
1124 int array_len= RNA_property_array_length(&new_ptr, prop);
1126 if (array_len && array_index >= array_len)
1128 if (G.f & G_DEBUG) {
1129 printf("Animato: Invalid array index. ID = '%s', '%s[%d]', array length is %d \n",
1130 (ptr && ptr->id.data) ? (((ID *)ptr->id.data)->name+2) : "<No ID>",
1131 path, array_index, array_len-1);
1137 switch (RNA_property_type(prop))
1141 RNA_property_boolean_set_index(&new_ptr, prop, array_index, ANIMSYS_FLOAT_AS_BOOL(value));
1143 RNA_property_boolean_set(&new_ptr, prop, ANIMSYS_FLOAT_AS_BOOL(value));
1147 RNA_property_int_set_index(&new_ptr, prop, array_index, (int)value);
1149 RNA_property_int_set(&new_ptr, prop, (int)value);
1153 RNA_property_float_set_index(&new_ptr, prop, array_index, value);
1155 RNA_property_float_set(&new_ptr, prop, value);
1158 RNA_property_enum_set(&new_ptr, prop, (int)value);
1161 /* nothing can be done here... so it is unsuccessful? */
1165 /* buffer property update for later flushing */
1166 if (RNA_property_update_check(prop)) {
1167 short skip_updates_hack = 0;
1169 /* optimisation hacks: skip property updates for those properties
1170 * for we know that which the updates in RNA were really just for
1171 * flushing property editing via UI/Py
1173 if (RNA_struct_is_a(new_ptr.type, &RNA_PoseBone)) {
1174 /* bone transforms - update pose (i.e. tag depsgraph) */
1175 skip_updates_hack = 1;
1178 if (skip_updates_hack == 0)
1179 RNA_property_update_cache_add(&new_ptr, prop);
1187 /* failed to get path */
1188 // XXX don't tag as failed yet though, as there are some legit situations (Action Constraint)
1189 // where some channels will not exist, but shouldn't lock up Action
1190 if (G.f & G_DEBUG) {
1191 printf("Animato: Invalid path. ID = '%s', '%s[%d]' \n",
1192 (ptr && ptr->id.data) ? (((ID *)ptr->id.data)->name+2) : "<No ID>",
1199 /* Simple replacement based data-setting of the FCurve using RNA */
1200 static short animsys_execute_fcurve (PointerRNA *ptr, AnimMapper *remap, FCurve *fcu)
1206 /* get path, remapped as appropriate to work in its new environment */
1207 free_path= animsys_remap_path(remap, fcu->rna_path, &path);
1209 /* write value to setting */
1211 ok= animsys_write_rna_setting(ptr, path, fcu->array_index, fcu->curval);
1213 /* free temp path-info */
1217 /* return whether we were successful */
1221 /* Evaluate all the F-Curves in the given list
1222 * This performs a set of standard checks. If extra checks are required, separate code should be used
1224 static void animsys_evaluate_fcurves (PointerRNA *ptr, ListBase *list, AnimMapper *remap, float ctime)
1228 /* calculate then execute each curve */
1229 for (fcu= list->first; fcu; fcu= fcu->next)
1231 /* check if this F-Curve doesn't belong to a muted group */
1232 if ((fcu->grp == NULL) || (fcu->grp->flag & AGRP_MUTED)==0) {
1233 /* check if this curve should be skipped */
1234 if ((fcu->flag & (FCURVE_MUTED|FCURVE_DISABLED)) == 0)
1236 calculate_fcurve(fcu, ctime);
1237 animsys_execute_fcurve(ptr, remap, fcu);
1243 /* ***************************************** */
1244 /* Driver Evaluation */
1246 /* Evaluate Drivers */
1247 static void animsys_evaluate_drivers (PointerRNA *ptr, AnimData *adt, float ctime)
1251 /* drivers are stored as F-Curves, but we cannot use the standard code, as we need to check if
1252 * the depsgraph requested that this driver be evaluated...
1254 for (fcu= adt->drivers.first; fcu; fcu= fcu->next)
1256 ChannelDriver *driver= fcu->driver;
1259 /* check if this driver's curve should be skipped */
1260 if ((fcu->flag & (FCURVE_MUTED|FCURVE_DISABLED)) == 0)
1262 /* check if driver itself is tagged for recalculation */
1263 if ((driver) && !(driver->flag & DRIVER_FLAG_INVALID)/*&& (driver->flag & DRIVER_FLAG_RECALC)*/) { // XXX driver recalc flag is not set yet by depsgraph!
1264 /* evaluate this using values set already in other places */
1265 // NOTE: for 'layering' option later on, we should check if we should remove old value before adding new to only be done when drivers only changed
1266 calculate_fcurve(fcu, ctime);
1267 ok= animsys_execute_fcurve(ptr, NULL, fcu);
1269 /* clear recalc flag */
1270 driver->flag &= ~DRIVER_FLAG_RECALC;
1272 /* set error-flag if evaluation failed */
1274 driver->flag |= DRIVER_FLAG_INVALID;
1280 /* ***************************************** */
1281 /* Actions Evaluation */
1283 /* strictly not necessary for actual "evaluation", but it is a useful safety check
1284 * to reduce the amount of times that users end up having to "revive" wrongly-assigned
1287 static void action_idcode_patch_check (ID *id, bAction *act)
1292 if (ELEM(NULL, id, act))
1295 idcode = GS(id->name);
1297 /* the actual checks... hopefully not too much of a performance hit in the long run... */
1298 if (act->idroot == 0) {
1299 /* use the current root if not set already (i.e. newly created actions and actions from 2.50-2.57 builds)
1300 * - this has problems if there are 2 users, and the first one encountered is the invalid one
1301 * in which case, the user will need to manually fix this (?)
1303 act->idroot = idcode;
1305 else if (act->idroot != idcode) {
1306 /* only report this error if debug mode is enabled (to save performance everywhere else) */
1307 if (G.f & G_DEBUG) {
1308 printf("AnimSys Safety Check Failed: Action '%s' is not meant to be used from ID-Blocks of type %d such as '%s'\n",
1309 act->id.name+2, idcode, id->name);
1314 /* ----------------------------------------- */
1316 /* Evaluate Action Group */
1317 void animsys_evaluate_action_group (PointerRNA *ptr, bAction *act, bActionGroup *agrp, AnimMapper *remap, float ctime)
1321 /* check if mapper is appropriate for use here (we set to NULL if it's inappropriate) */
1322 if ELEM(NULL, act, agrp) return;
1323 if ((remap) && (remap->target != act)) remap= NULL;
1325 action_idcode_patch_check(ptr->id.data, act);
1327 /* if group is muted, don't evaluated any of the F-Curve */
1328 if (agrp->flag & AGRP_MUTED)
1331 /* calculate then execute each curve */
1332 for (fcu= agrp->channels.first; (fcu) && (fcu->grp == agrp); fcu= fcu->next)
1334 /* check if this curve should be skipped */
1335 if ((fcu->flag & (FCURVE_MUTED|FCURVE_DISABLED)) == 0)
1337 calculate_fcurve(fcu, ctime);
1338 animsys_execute_fcurve(ptr, remap, fcu);
1343 /* Evaluate Action (F-Curve Bag) */
1344 void animsys_evaluate_action (PointerRNA *ptr, bAction *act, AnimMapper *remap, float ctime)
1346 /* check if mapper is appropriate for use here (we set to NULL if it's inappropriate) */
1347 if (act == NULL) return;
1348 if ((remap) && (remap->target != act)) remap= NULL;
1350 action_idcode_patch_check(ptr->id.data, act);
1352 /* calculate then execute each curve */
1353 animsys_evaluate_fcurves(ptr, &act->curves, remap, ctime);
1356 /* ***************************************** */
1357 /* NLA System - Evaluation */
1359 /* calculate influence of strip based for given frame based on blendin/out values */
1360 static float nlastrip_get_influence (NlaStrip *strip, float cframe)
1362 /* sanity checks - normalise the blendin/out values? */
1363 strip->blendin= (float)fabs(strip->blendin);
1364 strip->blendout= (float)fabs(strip->blendout);
1366 /* result depends on where frame is in respect to blendin/out values */
1367 if (IS_EQ(strip->blendin, 0)==0 && (cframe <= (strip->start + strip->blendin))) {
1368 /* there is some blend-in */
1369 return (float)fabs(cframe - strip->start) / (strip->blendin);
1371 else if (IS_EQ(strip->blendout, 0)==0 && (cframe >= (strip->end - strip->blendout))) {
1372 /* there is some blend-out */
1373 return (float)fabs(strip->end - cframe) / (strip->blendout);
1376 /* in the middle of the strip, we should be full strength */
1381 /* evaluate the evaluation time and influence for the strip, storing the results in the strip */
1382 static void nlastrip_evaluate_controls (NlaStrip *strip, float ctime)
1384 /* firstly, analytically generate values for influence and time (if applicable) */
1385 if ((strip->flag & NLASTRIP_FLAG_USR_TIME) == 0)
1386 strip->strip_time= nlastrip_get_frame(strip, ctime, NLATIME_CONVERT_EVAL);
1387 if ((strip->flag & NLASTRIP_FLAG_USR_INFLUENCE) == 0)
1388 strip->influence= nlastrip_get_influence(strip, ctime);
1390 /* now strip's evaluate F-Curves for these settings (if applicable) */
1391 if (strip->fcurves.first) {
1392 PointerRNA strip_ptr;
1394 /* create RNA-pointer needed to set values */
1395 RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &strip_ptr);
1397 /* execute these settings as per normal */
1398 animsys_evaluate_fcurves(&strip_ptr, &strip->fcurves, NULL, ctime);
1401 /* if user can control the evaluation time (using F-Curves), consider the option which allows this time to be clamped
1402 * to lie within extents of the action-clip, so that a steady changing rate of progress through several cycles of the clip
1403 * can be achieved easily
1405 // NOTE: if we add any more of these special cases, we better group them up nicely...
1406 if ((strip->flag & NLASTRIP_FLAG_USR_TIME) && (strip->flag & NLASTRIP_FLAG_USR_TIME_CYCLIC))
1407 strip->strip_time= fmod(strip->strip_time - strip->actstart, strip->actend - strip->actstart);
1410 /* gets the strip active at the current time for a list of strips for evaluation purposes */
1411 NlaEvalStrip *nlastrips_ctime_get_strip (ListBase *list, ListBase *strips, short index, float ctime)
1413 NlaStrip *strip, *estrip=NULL;
1417 /* loop over strips, checking if they fall within the range */
1418 for (strip= strips->first; strip; strip= strip->next) {
1419 /* check if current time occurs within this strip */
1420 if (IN_RANGE_INCL(ctime, strip->start, strip->end)) {
1421 /* this strip is active, so try to use it */
1423 side= NES_TIME_WITHIN;
1427 /* if time occurred before current strip... */
1428 if (ctime < strip->start) {
1429 if (strip == strips->first) {
1430 /* before first strip - only try to use it if it extends backwards in time too */
1431 if (strip->extendmode == NLASTRIP_EXTEND_HOLD)
1434 /* side is 'before' regardless of whether there's a useful strip */
1435 side= NES_TIME_BEFORE;
1438 /* before next strip - previous strip has ended, but next hasn't begun,
1439 * so blending mode depends on whether strip is being held or not...
1440 * - only occurs when no transition strip added, otherwise the transition would have
1441 * been picked up above...
1445 if (strip->extendmode != NLASTRIP_EXTEND_NOTHING)
1447 side= NES_TIME_AFTER;
1452 /* if time occurred after current strip... */
1453 if (ctime > strip->end) {
1454 /* only if this is the last strip should we do anything, and only if that is being held */
1455 if (strip == strips->last) {
1456 if (strip->extendmode != NLASTRIP_EXTEND_NOTHING)
1459 side= NES_TIME_AFTER;
1463 /* otherwise, skip... as the 'before' case will catch it more elegantly! */
1467 /* check if a valid strip was found
1468 * - must not be muted (i.e. will have contribution
1470 if ((estrip == NULL) || (estrip->flag & NLASTRIP_FLAG_MUTED))
1473 /* if ctime was not within the boundaries of the strip, clamp! */
1475 case NES_TIME_BEFORE: /* extend first frame only */
1476 ctime= estrip->start;
1478 case NES_TIME_AFTER: /* extend last frame only */
1483 /* evaluate strip's evaluation controls
1484 * - skip if no influence (i.e. same effect as muting the strip)
1485 * - negative influence is not supported yet... how would that be defined?
1487 // TODO: this sounds a bit hacky having a few isolated F-Curves stuck on some data it operates on...
1488 nlastrip_evaluate_controls(estrip, ctime);
1489 if (estrip->influence <= 0.0f)
1492 /* check if strip has valid data to evaluate,
1493 * and/or perform any additional type-specific actions
1495 switch (estrip->type) {
1496 case NLASTRIP_TYPE_CLIP:
1497 /* clip must have some action to evaluate */
1498 if (estrip->act == NULL)
1501 case NLASTRIP_TYPE_TRANSITION:
1502 /* there must be strips to transition from and to (i.e. prev and next required) */
1503 if (ELEM(NULL, estrip->prev, estrip->next))
1506 /* evaluate controls for the relevant extents of the bordering strips... */
1507 nlastrip_evaluate_controls(estrip->prev, estrip->start);
1508 nlastrip_evaluate_controls(estrip->next, estrip->end);
1512 /* add to list of strips we need to evaluate */
1513 nes= MEM_callocN(sizeof(NlaEvalStrip), "NlaEvalStrip");
1516 nes->strip_mode= side;
1517 nes->track_index= index;
1518 nes->strip_time= estrip->strip_time;
1521 BLI_addtail(list, nes);
1526 /* ---------------------- */
1528 /* find an NlaEvalChannel that matches the given criteria
1529 * - ptr and prop are the RNA data to find a match for
1531 static NlaEvalChannel *nlaevalchan_find_match (ListBase *channels, PointerRNA *ptr, PropertyRNA *prop, int array_index)
1533 NlaEvalChannel *nec;
1536 if (channels == NULL)
1539 /* loop through existing channels, checking for a channel which affects the same property */
1540 for (nec= channels->first; nec; nec= nec->next) {
1541 /* - comparing the PointerRNA's is done by comparing the pointers
1542 * to the actual struct the property resides in, since that all the
1543 * other data stored in PointerRNA cannot allow us to definitively
1546 if ((nec->ptr.data == ptr->data) && (nec->prop == prop) && (nec->index == array_index))
1554 /* verify that an appropriate NlaEvalChannel for this F-Curve exists */
1555 static NlaEvalChannel *nlaevalchan_verify (PointerRNA *ptr, ListBase *channels, NlaEvalStrip *nes, FCurve *fcu, short *newChan)
1557 NlaEvalChannel *nec;
1558 NlaStrip *strip= nes->strip;
1565 if (channels == NULL)
1568 /* get RNA pointer+property info from F-Curve for more convenient handling */
1569 /* get path, remapped as appropriate to work in its new environment */
1570 free_path= animsys_remap_path(strip->remap, fcu->rna_path, &path);
1572 /* a valid property must be available, and it must be animateable */
1573 if (RNA_path_resolve(ptr, path, &new_ptr, &prop) == 0) {
1574 if (G.f & G_DEBUG) printf("NLA Strip Eval: Cannot resolve path \n");
1577 /* only ok if animateable */
1578 else if (RNA_property_animateable(&new_ptr, prop) == 0) {
1579 if (G.f & G_DEBUG) printf("NLA Strip Eval: Property not animateable \n");
1583 /* try to find a match */
1584 nec= nlaevalchan_find_match(channels, &new_ptr, prop, fcu->array_index);
1586 /* allocate a new struct for this if none found */
1588 nec= MEM_callocN(sizeof(NlaEvalChannel), "NlaEvalChannel");
1590 BLI_addtail(channels, nec);
1594 nec->index= fcu->array_index;
1599 /* we can now return */
1603 /* accumulate (i.e. blend) the given value on to the channel it affects */
1604 static void nlaevalchan_accumulate (NlaEvalChannel *nec, NlaEvalStrip *nes, short newChan, float value)
1606 NlaStrip *strip= nes->strip;
1607 short blendmode= strip->blendmode;
1608 float inf= strip->influence;
1610 /* if channel is new, just store value regardless of blending factors, etc. */
1616 /* if this is being performed as part of transition evaluation, incorporate
1617 * an additional weighting factor for the influence
1619 if (nes->strip_mode == NES_TIME_TRANSITION_END)
1620 inf *= nes->strip_time;
1622 /* premultiply the value by the weighting factor */
1623 if (IS_EQ(inf, 0)) return;
1626 /* perform blending */
1627 switch (blendmode) {
1628 case NLASTRIP_MODE_ADD:
1629 /* simply add the scaled value on to the stack */
1630 nec->value += value;
1633 case NLASTRIP_MODE_SUBTRACT:
1634 /* simply subtract the scaled value from the stack */
1635 nec->value -= value;
1638 case NLASTRIP_MODE_MULTIPLY:
1639 /* multiply the scaled value with the stack */
1640 nec->value *= value;
1643 case NLASTRIP_MODE_REPLACE:
1644 default: // TODO: do we really want to blend by default? it seems more uses might prefer add...
1645 /* do linear interpolation
1646 * - the influence of the accumulated data (elsewhere, that is called dstweight)
1647 * is 1 - influence, since the strip's influence is srcweight
1649 nec->value= nec->value * (1.0f - inf) + value;
1654 /* accumulate the results of a temporary buffer with the results of the full-buffer */
1655 static void nlaevalchan_buffers_accumulate (ListBase *channels, ListBase *tmp_buffer, NlaEvalStrip *nes)
1657 NlaEvalChannel *nec, *necn, *necd;
1659 /* optimise - abort if no channels */
1660 if (tmp_buffer->first == NULL)
1663 /* accumulate results in tmp_channels buffer to the accumulation buffer */
1664 for (nec= tmp_buffer->first; nec; nec= necn) {
1665 /* get pointer to next channel in case we remove the current channel from the temp-buffer */
1668 /* try to find an existing matching channel for this setting in the accumulation buffer */
1669 necd= nlaevalchan_find_match(channels, &nec->ptr, nec->prop, nec->index);
1671 /* if there was a matching channel already in the buffer, accumulate to it,
1672 * otherwise, add the current channel to the buffer for efficiency
1675 nlaevalchan_accumulate(necd, nes, 0, nec->value);
1677 BLI_remlink(tmp_buffer, nec);
1678 BLI_addtail(channels, nec);
1682 /* free temp-channels that haven't been assimilated into the buffer */
1683 BLI_freelistN(tmp_buffer);
1686 /* ---------------------- */
1687 /* F-Modifier stack joining/separation utilities - should we generalise these for BLI_listbase.h interface? */
1689 /* Temporarily join two lists of modifiers together, storing the result in a third list */
1690 static void nlaeval_fmodifiers_join_stacks (ListBase *result, ListBase *list1, ListBase *list2)
1692 FModifier *fcm1, *fcm2;
1694 /* if list1 is invalid... */
1695 if ELEM(NULL, list1, list1->first) {
1696 if (list2 && list2->first) {
1697 result->first= list2->first;
1698 result->last= list2->last;
1701 /* if list 2 is invalid... */
1702 else if ELEM(NULL, list2, list2->first) {
1703 result->first= list1->first;
1704 result->last= list1->last;
1707 /* list1 should be added first, and list2 second, with the endpoints of these being the endpoints for result
1708 * - the original lists must be left unchanged though, as we need that fact for restoring
1710 result->first= list1->first;
1711 result->last= list2->last;
1721 /* Split two temporary lists of modifiers */
1722 static void nlaeval_fmodifiers_split_stacks (ListBase *list1, ListBase *list2)
1724 FModifier *fcm1, *fcm2;
1726 /* if list1/2 is invalid... just skip */
1727 if ELEM(NULL, list1, list2)
1729 if ELEM(NULL, list1->first, list2->first)
1736 /* clear their links */
1741 /* ---------------------- */
1743 /* evaluate action-clip strip */
1744 static void nlastrip_evaluate_actionclip (PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes)
1746 ListBase tmp_modifiers = {NULL, NULL};
1747 NlaStrip *strip= nes->strip;
1751 /* sanity checks for action */
1755 if (strip->act == NULL) {
1756 printf("NLA-Strip Eval Error: Strip '%s' has no Action\n", strip->name);
1760 action_idcode_patch_check(ptr->id.data, strip->act);
1762 /* join this strip's modifiers to the parent's modifiers (own modifiers first) */
1763 nlaeval_fmodifiers_join_stacks(&tmp_modifiers, &strip->modifiers, modifiers);
1765 /* evaluate strip's modifiers which modify time to evaluate the base curves at */
1766 evaltime= evaluate_time_fmodifiers(&tmp_modifiers, NULL, 0.0f, strip->strip_time);
1768 /* evaluate all the F-Curves in the action, saving the relevant pointers to data that will need to be used */
1769 for (fcu= strip->act->curves.first; fcu; fcu= fcu->next) {
1770 NlaEvalChannel *nec;
1774 /* check if this curve should be skipped */
1775 if (fcu->flag & (FCURVE_MUTED|FCURVE_DISABLED))
1777 if ((fcu->grp) && (fcu->grp->flag & AGRP_MUTED))
1780 /* evaluate the F-Curve's value for the time given in the strip
1781 * NOTE: we use the modified time here, since strip's F-Curve Modifiers are applied on top of this
1783 value= evaluate_fcurve(fcu, evaltime);
1785 /* apply strip's F-Curve Modifiers on this value
1786 * NOTE: we apply the strip's original evaluation time not the modified one (as per standard F-Curve eval)
1788 evaluate_value_fmodifiers(&tmp_modifiers, fcu, &value, strip->strip_time);
1791 /* get an NLA evaluation channel to work with, and accumulate the evaluated value with the value(s)
1792 * stored in this channel if it has been used already
1794 nec= nlaevalchan_verify(ptr, channels, nes, fcu, &newChan);
1796 nlaevalchan_accumulate(nec, nes, newChan, value);
1799 /* unlink this strip's modifiers from the parent's modifiers again */
1800 nlaeval_fmodifiers_split_stacks(&strip->modifiers, modifiers);
1803 /* evaluate transition strip */
1804 static void nlastrip_evaluate_transition (PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes)
1806 ListBase tmp_channels = {NULL, NULL};
1807 ListBase tmp_modifiers = {NULL, NULL};
1808 NlaEvalStrip tmp_nes;
1811 /* join this strip's modifiers to the parent's modifiers (own modifiers first) */
1812 nlaeval_fmodifiers_join_stacks(&tmp_modifiers, &nes->strip->modifiers, modifiers);
1814 /* get the two strips to operate on
1815 * - we use the endpoints of the strips directly flanking our strip
1816 * using these as the endpoints of the transition (destination and source)
1817 * - these should have already been determined to be valid...
1818 * - if this strip is being played in reverse, we need to swap these endpoints
1819 * otherwise they will be interpolated wrong
1821 if (nes->strip->flag & NLASTRIP_FLAG_REVERSE) {
1822 s1= nes->strip->next;
1823 s2= nes->strip->prev;
1826 s1= nes->strip->prev;
1827 s2= nes->strip->next;
1830 /* prepare template for 'evaluation strip'
1831 * - based on the transition strip's evaluation strip data
1832 * - strip_mode is NES_TIME_TRANSITION_* based on which endpoint
1833 * - strip_time is the 'normalised' (i.e. in-strip) time for evaluation,
1834 * which doubles up as an additional weighting factor for the strip influences
1835 * which allows us to appear to be 'interpolating' between the two extremes
1839 /* evaluate these strips into a temp-buffer (tmp_channels) */
1840 // FIXME: modifier evalation here needs some work...
1842 tmp_nes.strip_mode= NES_TIME_TRANSITION_START;
1844 nlastrip_evaluate(ptr, &tmp_channels, &tmp_modifiers, &tmp_nes);
1847 tmp_nes.strip_mode= NES_TIME_TRANSITION_END;
1849 nlastrip_evaluate(ptr, &tmp_channels, &tmp_modifiers, &tmp_nes);
1852 /* assumulate temp-buffer and full-buffer, using the 'real' strip */
1853 nlaevalchan_buffers_accumulate(channels, &tmp_channels, nes);
1855 /* unlink this strip's modifiers from the parent's modifiers again */
1856 nlaeval_fmodifiers_split_stacks(&nes->strip->modifiers, modifiers);
1859 /* evaluate meta-strip */
1860 static void nlastrip_evaluate_meta (PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes)
1862 ListBase tmp_channels = {NULL, NULL};
1863 ListBase tmp_modifiers = {NULL, NULL};
1864 NlaStrip *strip= nes->strip;
1865 NlaEvalStrip *tmp_nes;
1868 /* meta-strip was calculated normally to have some time to be evaluated at
1869 * and here we 'look inside' the meta strip, treating it as a decorated window to
1870 * it's child strips, which get evaluated as if they were some tracks on a strip
1871 * (but with some extra modifiers to apply).
1873 * NOTE: keep this in sync with animsys_evaluate_nla()
1876 /* join this strip's modifiers to the parent's modifiers (own modifiers first) */
1877 nlaeval_fmodifiers_join_stacks(&tmp_modifiers, &strip->modifiers, modifiers);
1879 /* find the child-strip to evaluate */
1880 evaltime= (nes->strip_time * (strip->end - strip->start)) + strip->start;
1881 tmp_nes= nlastrips_ctime_get_strip(NULL, &strip->strips, -1, evaltime);
1882 if (tmp_nes == NULL)
1885 /* evaluate child-strip into tmp_channels buffer before accumulating
1886 * in the accumulation buffer
1888 nlastrip_evaluate(ptr, &tmp_channels, &tmp_modifiers, tmp_nes);
1890 /* assumulate temp-buffer and full-buffer, using the 'real' strip */
1891 nlaevalchan_buffers_accumulate(channels, &tmp_channels, nes);
1893 /* free temp eval-strip */
1896 /* unlink this strip's modifiers from the parent's modifiers again */
1897 nlaeval_fmodifiers_split_stacks(&strip->modifiers, modifiers);
1900 /* evaluates the given evaluation strip */
1901 void nlastrip_evaluate (PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes)
1903 NlaStrip *strip= nes->strip;
1905 /* to prevent potential infinite recursion problems (i.e. transition strip, beside meta strip containing a transition
1906 * several levels deep inside it), we tag the current strip as being evaluated, and clear this when we leave
1908 // TODO: be careful with this flag, since some edit tools may be running and have set this while animplayback was running
1909 if (strip->flag & NLASTRIP_FLAG_EDIT_TOUCHED)
1911 strip->flag |= NLASTRIP_FLAG_EDIT_TOUCHED;
1913 /* actions to take depend on the type of strip */
1914 switch (strip->type) {
1915 case NLASTRIP_TYPE_CLIP: /* action-clip */
1916 nlastrip_evaluate_actionclip(ptr, channels, modifiers, nes);
1918 case NLASTRIP_TYPE_TRANSITION: /* transition */
1919 nlastrip_evaluate_transition(ptr, channels, modifiers, nes);
1921 case NLASTRIP_TYPE_META: /* meta */
1922 nlastrip_evaluate_meta(ptr, channels, modifiers, nes);
1925 default: /* do nothing */
1929 /* clear temp recursion safe-check */
1930 strip->flag &= ~NLASTRIP_FLAG_EDIT_TOUCHED;
1933 /* write the accumulated settings to */
1934 void nladata_flush_channels (ListBase *channels)
1936 NlaEvalChannel *nec;
1939 if (channels == NULL)
1942 /* for each channel with accumulated values, write its value on the property it affects */
1943 for (nec= channels->first; nec; nec= nec->next) {
1944 PointerRNA *ptr= &nec->ptr;
1945 PropertyRNA *prop= nec->prop;
1946 int array_index= nec->index;
1947 float value= nec->value;
1949 /* write values - see animsys_write_rna_setting() to sync the code */
1950 switch (RNA_property_type(prop))
1953 if (RNA_property_array_length(ptr, prop))
1954 RNA_property_boolean_set_index(ptr, prop, array_index, ANIMSYS_FLOAT_AS_BOOL(value));
1956 RNA_property_boolean_set(ptr, prop, ANIMSYS_FLOAT_AS_BOOL(value));
1959 if (RNA_property_array_length(ptr, prop))
1960 RNA_property_int_set_index(ptr, prop, array_index, (int)value);
1962 RNA_property_int_set(ptr, prop, (int)value);
1965 if (RNA_property_array_length(ptr, prop))
1966 RNA_property_float_set_index(ptr, prop, array_index, value);
1968 RNA_property_float_set(ptr, prop, value);
1971 RNA_property_enum_set(ptr, prop, (int)value);
1974 // can't do anything with other types of property....
1980 /* ---------------------- */
1982 /* NLA Evaluation function - values are calculated and stored in temporary "NlaEvalChannels"
1983 * ! This is exported so that keyframing code can use this for make use of it for anim layers support
1984 * > echannels: (list<NlaEvalChannels>) evaluation channels with calculated values
1986 static void animsys_evaluate_nla (ListBase *echannels, PointerRNA *ptr, AnimData *adt, float ctime)
1989 short track_index=0;
1990 short has_strips = 0;
1992 ListBase estrips= {NULL, NULL};
1995 /* 1. get the stack of strips to evaluate at current time (influence calculated here) */
1996 for (nlt=adt->nla_tracks.first; nlt; nlt=nlt->next, track_index++) {
1997 /* stop here if tweaking is on and this strip is the tweaking track (it will be the first one that's 'disabled')... */
1998 if ((adt->flag & ADT_NLA_EDIT_ON) && (nlt->flag & NLATRACK_DISABLED))
2001 /* skip if we're only considering a track tagged 'solo' */
2002 if ((adt->flag & ADT_NLA_SOLO_TRACK) && (nlt->flag & NLATRACK_SOLO)==0)
2004 /* skip if track is muted */
2005 if (nlt->flag & NLATRACK_MUTED)
2008 /* if this track has strips (but maybe they won't be suitable), set has_strips
2009 * - used for mainly for still allowing normal action evaluation...
2011 if (nlt->strips.first)
2014 /* otherwise, get strip to evaluate for this channel */
2015 nes= nlastrips_ctime_get_strip(&estrips, &nlt->strips, track_index, ctime);
2016 if (nes) nes->track= nlt;
2019 /* add 'active' Action (may be tweaking track) as last strip to evaluate in NLA stack
2020 * - only do this if we're not exclusively evaluating the 'solo' NLA-track
2022 if ((adt->action) && !(adt->flag & ADT_NLA_SOLO_TRACK)) {
2023 /* if there are strips, evaluate action as per NLA rules */
2024 if ((has_strips) || (adt->actstrip)) {
2025 /* make dummy NLA strip, and add that to the stack */
2026 NlaStrip dummy_strip= {NULL};
2027 ListBase dummy_trackslist;
2029 dummy_trackslist.first= dummy_trackslist.last= &dummy_strip;
2031 if ((nlt) && !(adt->flag & ADT_NLA_EDIT_NOMAP)) {
2032 /* edit active action in-place according to its active strip, so copy the data */
2033 memcpy(&dummy_strip, adt->actstrip, sizeof(NlaStrip));
2034 dummy_strip.next = dummy_strip.prev = NULL;
2037 /* set settings of dummy NLA strip from AnimData settings */
2038 dummy_strip.act= adt->action;
2039 dummy_strip.remap= adt->remap;
2041 /* action range is calculated taking F-Modifiers into account (which making new strips doesn't do due to the troublesome nature of that) */
2042 calc_action_range(dummy_strip.act, &dummy_strip.actstart, &dummy_strip.actend, 1);
2043 dummy_strip.start = dummy_strip.actstart;
2044 dummy_strip.end = (IS_EQF(dummy_strip.actstart, dummy_strip.actend)) ? (dummy_strip.actstart + 1.0f): (dummy_strip.actend);
2046 dummy_strip.blendmode= adt->act_blendmode;
2047 dummy_strip.extendmode= adt->act_extendmode;
2048 dummy_strip.influence= adt->act_influence;
2051 /* add this to our list of evaluation strips */
2052 nlastrips_ctime_get_strip(&estrips, &dummy_trackslist, -1, ctime);
2055 /* special case - evaluate as if there isn't any NLA data */
2056 // TODO: this is really just a stop-gap measure...
2057 animsys_evaluate_action(ptr, adt->action, adt->remap, ctime);
2062 /* only continue if there are strips to evaluate */
2063 if (estrips.first == NULL)
2067 /* 2. for each strip, evaluate then accumulate on top of existing channels, but don't set values yet */
2068 for (nes= estrips.first; nes; nes= nes->next)
2069 nlastrip_evaluate(ptr, echannels, NULL, nes);
2071 /* 3. free temporary evaluation data that's not used elsewhere */
2072 BLI_freelistN(&estrips);
2075 /* NLA Evaluation function (mostly for use through do_animdata)
2076 * - All channels that will be affected are not cleared anymore. Instead, we just evaluate into
2077 * some temp channels, where values can be accumulated in one go.
2079 static void animsys_calculate_nla (PointerRNA *ptr, AnimData *adt, float ctime)
2081 ListBase echannels= {NULL, NULL};
2083 // TODO: need to zero out all channels used, otherwise we have problems with threadsafety
2084 // and also when the user jumps between different times instead of moving sequentially...
2086 /* evaluate the NLA stack, obtaining a set of values to flush */
2087 animsys_evaluate_nla(&echannels, ptr, adt, ctime);
2089 /* flush effects of accumulating channels in NLA to the actual data they affect */
2090 nladata_flush_channels(&echannels);
2092 /* free temp data */
2093 BLI_freelistN(&echannels);
2096 /* ***************************************** */
2097 /* Overrides System - Public API */
2099 /* Clear all overides */
2101 /* Add or get existing Override for given setting */
2103 AnimOverride *BKE_animsys_validate_override (PointerRNA *UNUSED(ptr), char *UNUSED(path), int UNUSED(array_index))
2105 // FIXME: need to define how to get overrides
2110 /* -------------------- */
2112 /* Evaluate Overrides */
2113 static void animsys_evaluate_overrides (PointerRNA *ptr, AnimData *adt)
2117 /* for each override, simply execute... */
2118 for (aor= adt->overrides.first; aor; aor= aor->next)
2119 animsys_write_rna_setting(ptr, aor->rna_path, aor->array_index, aor->value);
2122 /* ***************************************** */
2123 /* Evaluation System - Public API */
2125 /* Overview of how this system works:
2126 * 1) Depsgraph sorts data as necessary, so that data is in an order that means
2127 * that all dependences are resolved before dependants.
2128 * 2) All normal animation is evaluated, so that drivers have some basis values to
2130 * a. NLA stacks are done first, as the Active Actions act as 'tweaking' tracks
2131 * which modify the effects of the NLA-stacks
2132 * b. Active Action is evaluated as per normal, on top of the results of the NLA tracks
2134 * --------------< often in a separate phase... >------------------
2136 * 3) Drivers/expressions are evaluated on top of this, in an order where dependences are
2138 * Note: it may be necessary to have some tools to handle the cases where some higher-level
2139 * drivers are added and cause some problematic dependencies that didn't exist in the local levels...
2141 * --------------< always executed >------------------
2143 * Maintainance of editability of settings (XXX):
2144 * In order to ensure that settings that are animated can still be manipulated in the UI without requiring
2145 * that keyframes are added to prevent these values from being overwritten, we use 'overrides'.
2147 * Unresolved things:
2148 * - Handling of multi-user settings (i.e. time-offset, group-instancing) -> big cache grids or nodal system? but stored where?
2149 * - Multiple-block dependencies (i.e. drivers for settings are in both local and higher levels) -> split into separate lists?
2152 * - Currently (as of September 2009), overrides we haven't needed to (fully) implement overrides.
2153 * However, the code fo this is relatively harmless, so is left in the code for now.
2156 /* Evaluation loop for evaluation animation data
2158 * This assumes that the animation-data provided belongs to the ID block in question,
2159 * and that the flags for which parts of the anim-data settings need to be recalculated
2160 * have been set already by the depsgraph. Now, we use the recalc
2162 void BKE_animsys_evaluate_animdata (Scene *scene, ID *id, AnimData *adt, float ctime, short recalc)
2167 if ELEM(NULL, id, adt)
2170 /* get pointer to ID-block for RNA to use */
2171 RNA_id_pointer_create(id, &id_ptr);
2173 /* recalculate keyframe data:
2174 * - NLA before Active Action, as Active Action behaves as 'tweaking track'
2175 * that overrides 'rough' work in NLA
2177 // TODO: need to double check that this all works correctly
2178 if ((recalc & ADT_RECALC_ANIM) || (adt->recalc & ADT_RECALC_ANIM))
2180 /* evaluate NLA data */
2181 if ((adt->nla_tracks.first) && !(adt->flag & ADT_NLA_EVAL_OFF))
2183 /* evaluate NLA-stack
2184 * - active action is evaluated as part of the NLA stack as the last item
2186 animsys_calculate_nla(&id_ptr, adt, ctime);
2188 /* evaluate Active Action only */
2189 else if (adt->action)
2190 animsys_evaluate_action(&id_ptr, adt->action, adt->remap, ctime);
2193 adt->recalc &= ~ADT_RECALC_ANIM;
2196 /* recalculate drivers
2197 * - Drivers need to be evaluated afterwards, as they can either override
2198 * or be layered on top of existing animation data.
2199 * - Drivers should be in the appropriate order to be evaluated without problems...
2201 if ((recalc & ADT_RECALC_DRIVERS) /*&& (adt->recalc & ADT_RECALC_DRIVERS)*/) // XXX for now, don't check yet, as depsgraph hasn't been updated
2203 animsys_evaluate_drivers(&id_ptr, adt, ctime);
2206 /* always execute 'overrides'
2207 * - Overrides allow editing, by overwriting the value(s) set from animation-data, with the
2208 * value last set by the user (and not keyframed yet).
2209 * - Overrides are cleared upon frame change and/or keyframing
2210 * - It is best that we execute this everytime, so that no errors are likely to occur.
2212 animsys_evaluate_overrides(&id_ptr, adt);
2214 /* execute and clear all cached property update functions */
2217 Main *bmain = G.main; // xxx - to get passed in!
2218 RNA_property_update_cache_flush(bmain, scene);
2219 RNA_property_update_cache_free();
2222 /* clear recalc flag now */
2226 /* Evaluation of all ID-blocks with Animation Data blocks - Animation Data Only
2228 * This will evaluate only the animation info available in the animation data-blocks
2229 * encountered. In order to enforce the system by which some settings controlled by a
2230 * 'local' (i.e. belonging in the nearest ID-block that setting is related to, not a
2231 * standard 'root') block are overridden by a larger 'user'
2233 void BKE_animsys_evaluate_all_animation (Main *main, Scene *scene, float ctime)
2238 printf("Evaluate all animation - %f \n", ctime);
2240 /* macros for less typing
2241 * - only evaluate animation data for id if it has users (and not just fake ones)
2242 * - whether animdata exists is checked for by the evaluation function, though taking
2243 * this outside of the function may make things slightly faster?
2245 #define EVAL_ANIM_IDS(first, aflag) \
2246 for (id= first; id; id= id->next) { \
2247 if (ID_REAL_USERS(id) > 0) { \
2248 AnimData *adt= BKE_animdata_from_id(id); \
2249 BKE_animsys_evaluate_animdata(scene, id, adt, ctime, aflag); \
2252 /* another macro for the "embedded" nodetree cases
2253 * - this is like EVAL_ANIM_IDS, but this handles the case "embedded nodetrees"
2254 * (i.e. scene/material/texture->nodetree) which we need a special exception
2255 * for, otherwise they'd get skipped
2256 * - ntp = "node tree parent" = datablock where node tree stuff resides
2258 #define EVAL_ANIM_NODETREE_IDS(first, NtId_Type, aflag) \
2259 for (id= first; id; id= id->next) { \
2260 if (ID_REAL_USERS(id) > 0) { \
2261 AnimData *adt= BKE_animdata_from_id(id); \
2262 NtId_Type *ntp= (NtId_Type *)id; \
2263 if (ntp->nodetree) { \
2264 AnimData *adt2= BKE_animdata_from_id((ID *)ntp->nodetree); \
2265 BKE_animsys_evaluate_animdata(scene, (ID *)ntp->nodetree, adt2, ctime, ADT_RECALC_ANIM); \
2267 BKE_animsys_evaluate_animdata(scene, id, adt, ctime, aflag); \
2272 * when there are no actions, don't go over database and loop over heaps of datablocks,
2273 * which should ultimately be empty, since it is not possible for now to have any animation
2274 * without some actions, and drivers wouldn't get affected by any state changes
2276 * however, if there are some curves, we will need to make sure that their 'ctime' property gets
2277 * set correctly, so this optimisation must be skipped in that case...
2279 if ((main->action.first == NULL) && (main->curve.first == NULL)) {
2281 printf("\tNo Actions, so no animation needs to be evaluated...\n");
2287 EVAL_ANIM_IDS(main->nodetree.first, ADT_RECALC_ANIM);
2290 EVAL_ANIM_NODETREE_IDS(main->tex.first, Tex, ADT_RECALC_ANIM);
2293 EVAL_ANIM_IDS(main->lamp.first, ADT_RECALC_ANIM);
2296 EVAL_ANIM_NODETREE_IDS(main->mat.first, Material, ADT_RECALC_ANIM);
2299 EVAL_ANIM_IDS(main->camera.first, ADT_RECALC_ANIM);
2302 EVAL_ANIM_IDS(main->key.first, ADT_RECALC_ANIM);
2305 EVAL_ANIM_IDS(main->mball.first, ADT_RECALC_ANIM);
2308 EVAL_ANIM_IDS(main->curve.first, ADT_RECALC_ANIM);
2311 EVAL_ANIM_IDS(main->armature.first, ADT_RECALC_ANIM);
2314 EVAL_ANIM_IDS(main->latt.first, ADT_RECALC_ANIM);
2317 EVAL_ANIM_IDS(main->mesh.first, ADT_RECALC_ANIM);
2320 EVAL_ANIM_IDS(main->particle.first, ADT_RECALC_ANIM);
2323 EVAL_ANIM_IDS(main->speaker.first, ADT_RECALC_ANIM);
2326 /* ADT_RECALC_ANIM doesn't need to be supplied here, since object AnimData gets
2327 * this tagged by Depsgraph on framechange. This optimisation means that objects
2328 * linked from other (not-visible) scenes will not need their data calculated.
2330 EVAL_ANIM_IDS(main->object.first, 0);
2333 EVAL_ANIM_IDS(main->world.first, ADT_RECALC_ANIM);
2336 EVAL_ANIM_NODETREE_IDS(main->scene.first, Scene, ADT_RECALC_ANIM);
2339 /* ***************************************** */