BKE_animsys.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /*
  2. * ***** BEGIN GPL LICENSE BLOCK *****
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software Foundation,
  16. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. *
  18. * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
  19. * All rights reserved.
  20. *
  21. * Contributor(s): Joshua Leung (original author)
  22. *
  23. * ***** END GPL LICENSE BLOCK *****
  24. */
  25. #ifndef __BKE_ANIMSYS_H__
  26. #define __BKE_ANIMSYS_H__
  27. /** \file BKE_animsys.h
  28. * \ingroup bke
  29. * \author Joshua Leung
  30. */
  31. struct ID;
  32. struct ListBase;
  33. struct Main;
  34. struct AnimData;
  35. struct KeyingSet;
  36. struct KS_Path;
  37. struct PathResolvedRNA;
  38. struct bContext;
  39. struct PointerRNA;
  40. struct PropertyRNA;
  41. struct ReportList;
  42. struct bAction;
  43. struct bActionGroup;
  44. struct AnimMapper;
  45. /* ************************************* */
  46. /* AnimData API */
  47. /* Check if the given ID-block can have AnimData */
  48. bool id_type_can_have_animdata(const short id_type);
  49. bool id_can_have_animdata(const struct ID *id);
  50. /* Get AnimData from the given ID-block */
  51. struct AnimData *BKE_animdata_from_id(struct ID *id);
  52. /* Add AnimData to the given ID-block */
  53. struct AnimData *BKE_animdata_add_id(struct ID *id);
  54. /* Set active action used by AnimData from the given ID-block */
  55. bool BKE_animdata_set_action(struct ReportList *reports, struct ID *id, struct bAction *act);
  56. /* Free AnimData */
  57. void BKE_animdata_free(struct ID *id, const bool do_id_user);
  58. /* Copy AnimData */
  59. struct AnimData *BKE_animdata_copy(struct AnimData *adt, const bool do_action);
  60. /* Copy AnimData */
  61. bool BKE_animdata_copy_id(struct ID *id_to, struct ID *id_from, const bool do_action);
  62. /* Copy AnimData Actions */
  63. void BKE_animdata_copy_id_action(struct ID *id, const bool set_newid);
  64. /* Merge copies of data from source AnimData block */
  65. typedef enum eAnimData_MergeCopy_Modes {
  66. /* Keep destination action */
  67. ADT_MERGECOPY_KEEP_DST = 0,
  68. /* Use src action (make a new copy) */
  69. ADT_MERGECOPY_SRC_COPY = 1,
  70. /* Use src action (but just reference the existing version) */
  71. ADT_MERGECOPY_SRC_REF = 2
  72. } eAnimData_MergeCopy_Modes;
  73. void BKE_animdata_merge_copy(struct ID *dst_id, struct ID *src_id, eAnimData_MergeCopy_Modes action_mode, bool fix_drivers);
  74. /* ************************************* */
  75. /* KeyingSets API */
  76. /* Used to create a new 'custom' KeyingSet for the user, that will be automatically added to the stack */
  77. struct KeyingSet *BKE_keyingset_add(struct ListBase *list, const char idname[], const char name[], short flag, short keyingflag);
  78. /* Add a path to a KeyingSet */
  79. struct KS_Path *BKE_keyingset_add_path(struct KeyingSet *ks, struct ID *id, const char group_name[], const char rna_path[], int array_index, short flag, short groupmode);
  80. /* Find the destination matching the criteria given */
  81. struct KS_Path *BKE_keyingset_find_path(struct KeyingSet *ks, struct ID *id, const char group_name[], const char rna_path[], int array_index, int group_mode);
  82. /* Copy all KeyingSets in the given list */
  83. void BKE_keyingsets_copy(struct ListBase *newlist, struct ListBase *list);
  84. /* Free the given Keying Set path */
  85. void BKE_keyingset_free_path(struct KeyingSet *ks, struct KS_Path *ksp);
  86. /* Free data for KeyingSet but not set itself */
  87. void BKE_keyingset_free(struct KeyingSet *ks);
  88. /* Free all the KeyingSets in the given list */
  89. void BKE_keyingsets_free(struct ListBase *list);
  90. /* ************************************* */
  91. /* Path Fixing API */
  92. /* Get a "fixed" version of the given path (oldPath) */
  93. char *BKE_animsys_fix_rna_path_rename(ID *owner_id, char *old_path, const char *prefix, const char *oldName,
  94. const char *newName, int oldSubscript, int newSubscript, bool verify_paths);
  95. /* Fix all the paths for the given ID + Action */
  96. void BKE_action_fix_paths_rename(struct ID *owner_id, struct bAction *act, const char *prefix, const char *oldName,
  97. const char *newName, int oldSubscript, int newSubscript, bool verify_paths);
  98. /* Fix all the paths for the given ID+AnimData */
  99. void BKE_animdata_fix_paths_rename(struct ID *owner_id, struct AnimData *adt, struct ID *ref_id, const char *prefix,
  100. const char *oldName, const char *newName, int oldSubscript, int newSubscript,
  101. bool verify_paths);
  102. /* Fix all the paths for the entire database... */
  103. void BKE_animdata_fix_paths_rename_all(ID *ref_id, const char *prefix, const char *oldName, const char *newName);
  104. /* Fix the path after removing elements that are not ID (e.g., node) */
  105. void BKE_animdata_fix_paths_remove(struct ID *id, const char *path);
  106. /* -------------------------------------- */
  107. /* Move animation data from src to destination if it's paths are based on basepaths */
  108. void BKE_animdata_separate_by_basepath(struct ID *srcID, struct ID *dstID, struct ListBase *basepaths);
  109. /* Move F-Curves from src to destination if it's path is based on basepath */
  110. void action_move_fcurves_by_basepath(struct bAction *srcAct, struct bAction *dstAct, const char basepath[]);
  111. char *BKE_animdata_driver_path_hack(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop,
  112. char *base_path);
  113. /* ************************************* */
  114. /* Batch AnimData API */
  115. /* Define for callback looper used in BKE_animdata_main_cb */
  116. typedef void (*ID_AnimData_Edit_Callback)(struct ID *id, struct AnimData *adt, void *user_data);
  117. /* Loop over all datablocks applying callback */
  118. void BKE_animdata_main_cb(struct Main *main, ID_AnimData_Edit_Callback func, void *user_data);
  119. /* ************************************* */
  120. // TODO: overrides, remapping, and path-finding api's
  121. /* ************************************* */
  122. /* Evaluation API */
  123. /* ------------- Main API -------------------- */
  124. /* In general, these ones should be called to do all animation evaluation */
  125. /* Evaluation loop for evaluating animation data */
  126. void BKE_animsys_evaluate_animdata(struct Scene *scene, struct ID *id, struct AnimData *adt, float ctime, short recalc);
  127. /* Evaluation of all ID-blocks with Animation Data blocks - Animation Data Only */
  128. void BKE_animsys_evaluate_all_animation(struct Main *main, struct Scene *scene, float ctime);
  129. /* TODO(sergey): This is mainly a temp public function. */
  130. struct FCurve;
  131. bool BKE_animsys_execute_fcurve(struct PointerRNA *ptr, struct AnimMapper *remap, struct FCurve *fcu, float curval);
  132. /* ------------ Specialized API --------------- */
  133. /* There are a few special tools which require these following functions. They are NOT to be used
  134. * for standard animation evaluation UNDER ANY CIRCUMSTANCES!
  135. *
  136. * i.e. Pose Library (PoseLib) uses some of these for selectively applying poses, but
  137. * Particles/Sequencer performing funky time manipulation is not ok.
  138. */
  139. /* Evaluate Action (F-Curve Bag) */
  140. void animsys_evaluate_action(struct PointerRNA *ptr, struct bAction *act, struct AnimMapper *remap, float ctime);
  141. /* Evaluate Action Group */
  142. void animsys_evaluate_action_group(struct PointerRNA *ptr, struct bAction *act, struct bActionGroup *agrp, struct AnimMapper *remap, float ctime);
  143. /* ************************************* */
  144. /* ------------ Evaluation API --------------- */
  145. struct EvaluationContext;
  146. void BKE_animsys_eval_animdata(struct EvaluationContext *eval_ctx, struct ID *id);
  147. void BKE_animsys_eval_driver(struct EvaluationContext *eval_ctx, struct ID *id, struct FCurve *fcurve);
  148. /* ************************************* */
  149. #endif /* __BKE_ANIMSYS_H__*/