1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
17  * All rights reserved.
18  */
19 
20 #pragma once
21 
22 /** \file
23  * \ingroup bke
24  */
25 
26 #include "BLI_sys_types.h" /* for bool */
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 struct AnimData;
33 struct BlendDataReader;
34 struct BlendExpander;
35 struct BlendLibReader;
36 struct BlendWriter;
37 struct ID;
38 struct LibraryForeachIDData;
39 struct Main;
40 struct ReportList;
41 struct bAction;
42 
43 /* ************************************* */
44 /* AnimData API */
45 
46 /* Check if the given ID-block can have AnimData */
47 bool id_type_can_have_animdata(const short id_type);
48 bool id_can_have_animdata(const struct ID *id);
49 
50 /* Get AnimData from the given ID-block */
51 struct AnimData *BKE_animdata_from_id(struct ID *id);
52 
53 /* Add AnimData to the given ID-block */
54 struct AnimData *BKE_animdata_add_id(struct ID *id);
55 
56 /* Set active action used by AnimData from the given ID-block */
57 bool BKE_animdata_set_action(struct ReportList *reports, struct ID *id, struct bAction *act);
58 
59 bool BKE_animdata_action_editable(const struct AnimData *adt);
60 
61 /* Ensure that the action's idroot is set correctly given the ID type of the owner.
62  * Return true if it is, false if it was already set to an incompatible type. */
63 bool BKE_animdata_action_ensure_idroot(const struct ID *owner, struct bAction *action);
64 
65 /* Free AnimData */
66 void BKE_animdata_free(struct ID *id, const bool do_id_user);
67 
68 /* Return true if the ID-block has non-empty AnimData. */
69 bool BKE_animdata_id_is_animated(const struct ID *id);
70 
71 void BKE_animdata_foreach_id(struct AnimData *adt, struct LibraryForeachIDData *data);
72 
73 /* Copy AnimData */
74 struct AnimData *BKE_animdata_copy(struct Main *bmain, struct AnimData *adt, const int flag);
75 
76 /* Copy AnimData */
77 bool BKE_animdata_copy_id(struct Main *bmain,
78                           struct ID *id_to,
79                           struct ID *id_from,
80                           const int flag);
81 
82 /* Copy AnimData Actions */
83 void BKE_animdata_copy_id_action(struct Main *bmain, struct ID *id);
84 
85 void BKE_animdata_duplicate_id_action(struct Main *bmain,
86                                       struct ID *id,
87                                       const uint duplicate_flags);
88 
89 /* Merge copies of data from source AnimData block */
90 typedef enum eAnimData_MergeCopy_Modes {
91   /* Keep destination action */
92   ADT_MERGECOPY_KEEP_DST = 0,
93 
94   /* Use src action (make a new copy) */
95   ADT_MERGECOPY_SRC_COPY = 1,
96 
97   /* Use src action (but just reference the existing version) */
98   ADT_MERGECOPY_SRC_REF = 2,
99 } eAnimData_MergeCopy_Modes;
100 
101 void BKE_animdata_merge_copy(struct Main *bmain,
102                              struct ID *dst_id,
103                              struct ID *src_id,
104                              eAnimData_MergeCopy_Modes action_mode,
105                              bool fix_drivers);
106 
107 void BKE_animdata_blend_write(struct BlendWriter *writer, struct AnimData *adt);
108 void BKE_animdata_blend_read_data(struct BlendDataReader *reader, struct AnimData *adt);
109 void BKE_animdata_blend_read_lib(struct BlendLibReader *reader,
110                                  struct ID *id,
111                                  struct AnimData *adt);
112 void BKE_animdata_blend_read_expand(struct BlendExpander *expander, struct AnimData *adt);
113 
114 #ifdef __cplusplus
115 }
116 #endif
117