Blender  V2.93
BKE_action.h
Go to the documentation of this file.
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) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
20 #pragma once
21 
27 #include "DNA_listBase.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 struct BlendDataReader;
34 struct BlendExpander;
35 struct BlendLibReader;
36 struct BlendWriter;
37 struct bArmature;
38 
39 /* The following structures are defined in DNA_action_types.h, and DNA_anim_types.h */
41 struct FCurve;
42 struct Main;
43 struct Object;
44 struct bAction;
45 struct bActionGroup;
46 struct bItasc;
47 struct bPose;
48 struct bPoseChannel;
50 
51 /* Action Lib Stuff ----------------- */
52 
53 /* Allocate a new bAction with the given name */
54 struct bAction *BKE_action_add(struct Main *bmain, const char name[]);
55 
56 /* Action API ----------------- */
57 
58 /* types of transforms applied to the given item
59  * - these are the return flags for action_get_item_transforms()
60  */
61 typedef enum eAction_TransformFlags {
62  /* location */
63  ACT_TRANS_LOC = (1 << 0),
64  /* rotation */
65  ACT_TRANS_ROT = (1 << 1),
66  /* scaling */
67  ACT_TRANS_SCALE = (1 << 2),
68 
69  /* bbone shape - for all the parameters, provided one is set */
70  ACT_TRANS_BBONE = (1 << 3),
71 
72  /* strictly not a transform, but custom properties are also
73  * quite often used in modern rigs
74  */
75  ACT_TRANS_PROP = (1 << 4),
76 
77  /* all flags */
81 
82 /* Return flags indicating which transforms the given object/posechannel has
83  * - if 'curves' is provided, a list of links to these curves are also returned
84  * whose nodes WILL NEED FREEING
85  */
86 short action_get_item_transforms(struct bAction *act,
87  struct Object *ob,
88  struct bPoseChannel *pchan,
89  ListBase *curves);
90 
91 /* Some kind of bounding box operation on the action */
92 void calc_action_range(const struct bAction *act, float *start, float *end, short incl_modifiers);
93 
94 /* Does action have any motion data at all? */
95 bool action_has_motion(const struct bAction *act);
96 
97 /* Action Groups API ----------------- */
98 
99 /* Get the active action-group for an Action */
100 struct bActionGroup *get_active_actiongroup(struct bAction *act);
101 
102 /* Make the given Action Group the active one */
103 void set_active_action_group(struct bAction *act, struct bActionGroup *agrp, short select);
104 
105 /* Sync colors used for action/bone group with theme settings */
106 void action_group_colors_sync(struct bActionGroup *grp, const struct bActionGroup *ref_grp);
107 
108 /* Add a new action group with the given name to the action */
109 struct bActionGroup *action_groups_add_new(struct bAction *act, const char name[]);
110 
111 /* Add given channel into (active) group */
112 void action_groups_add_channel(struct bAction *act,
113  struct bActionGroup *agrp,
114  struct FCurve *fcurve);
115 
116 /* Remove the given channel from all groups */
117 void action_groups_remove_channel(struct bAction *act, struct FCurve *fcu);
118 
119 /* Reconstruct group channel pointers. */
120 void BKE_action_groups_reconstruct(struct bAction *act);
121 
122 /* Find a group with the given name */
123 struct bActionGroup *BKE_action_group_find_name(struct bAction *act, const char name[]);
124 
125 /* Clear all 'temp' flags on all groups */
126 void action_groups_clear_tempflags(struct bAction *act);
127 
128 /* Pose API ----------------- */
129 
130 void BKE_pose_channel_free(struct bPoseChannel *pchan);
131 void BKE_pose_channel_free_ex(struct bPoseChannel *pchan, bool do_id_user);
132 
135 
137 
139 
140 void BKE_pose_channels_free(struct bPose *pose);
141 void BKE_pose_channels_free_ex(struct bPose *pose, bool do_id_user);
142 
143 void BKE_pose_channels_hash_make(struct bPose *pose);
144 void BKE_pose_channels_hash_free(struct bPose *pose);
145 
146 void BKE_pose_channels_remove(struct Object *ob,
147  bool (*filter_fn)(const char *bone_name, void *user_data),
148  void *user_data);
149 
150 void BKE_pose_free_data_ex(struct bPose *pose, bool do_id_user);
151 void BKE_pose_free_data(struct bPose *pose);
152 void BKE_pose_free(struct bPose *pose);
153 void BKE_pose_free_ex(struct bPose *pose, bool do_id_user);
154 void BKE_pose_copy_data_ex(struct bPose **dst,
155  const struct bPose *src,
156  const int flag,
157  const bool copy_constraints);
158 void BKE_pose_copy_data(struct bPose **dst, const struct bPose *src, const bool copy_constraints);
159 void BKE_pose_channel_copy_data(struct bPoseChannel *pchan, const struct bPoseChannel *pchan_from);
161 struct bPoseChannel *BKE_pose_channel_find_name(const struct bPose *pose, const char *name);
162 struct bPoseChannel *BKE_pose_channel_active(struct Object *ob);
164 struct bPoseChannel *BKE_pose_channel_verify(struct bPose *pose, const char *name);
165 struct bPoseChannel *BKE_pose_channel_get_mirrored(const struct bPose *pose, const char *name);
166 
168 
169 #ifndef NDEBUG
170 bool BKE_pose_channels_is_valid(const struct bPose *pose);
171 #endif
172 
173 /* sets constraint flags */
174 void BKE_pose_update_constraint_flags(struct bPose *pose);
175 
176 /* tag constraint flags for update */
178 
179 /* return the name of structure pointed by pose->ikparam */
180 const char *BKE_pose_ikparam_get_name(struct bPose *pose);
181 
182 /* allocate and initialize pose->ikparam according to pose->iksolver */
183 void BKE_pose_ikparam_init(struct bPose *pose);
184 
185 /* initialize a bItasc structure with default value */
186 void BKE_pose_itasc_init(struct bItasc *itasc);
187 
188 /* Checks if a bone is part of an IK chain or not */
189 bool BKE_pose_channel_in_IK_chain(struct Object *ob, struct bPoseChannel *pchan);
190 
191 /* Bone Groups API --------------------- */
192 
193 /* Adds a new bone-group */
194 struct bActionGroup *BKE_pose_add_group(struct bPose *pose, const char *name);
195 
196 /* Remove a bone-group */
197 void BKE_pose_remove_group(struct bPose *pose, struct bActionGroup *grp, const int index);
198 /* Remove the matching bone-group from its index */
199 void BKE_pose_remove_group_index(struct bPose *pose, const int index);
200 
201 /* Assorted Evaluation ----------------- */
202 
203 /* Used for the Action Constraint */
204 void what_does_obaction(struct Object *ob,
205  struct Object *workob,
206  struct bPose *pose,
207  struct bAction *act,
208  char groupname[],
209  const struct AnimationEvalContext *anim_eval_context);
210 
211 /* for proxy */
213  const struct bPoseChannel *pchanfrom);
214 bool BKE_pose_copy_result(struct bPose *to, struct bPose *from);
215 /* Clear transforms. */
216 void BKE_pose_rest(struct bPose *pose, bool selected_bones_only);
217 
218 /* Tag pose for recalc. Also tag all related data to be recalc. */
219 void BKE_pose_tag_recalc(struct Main *bmain, struct bPose *pose);
220 
221 void BKE_pose_blend_write(struct BlendWriter *writer, struct bPose *pose, struct bArmature *arm);
222 void BKE_pose_blend_read_data(struct BlendDataReader *reader, struct bPose *pose);
223 void BKE_pose_blend_read_lib(struct BlendLibReader *reader, struct Object *ob, struct bPose *pose);
224 void BKE_pose_blend_read_expand(struct BlendExpander *expander, struct bPose *pose);
225 
226 /* action_mirror.c */
227 void BKE_action_flip_with_pose(struct bAction *act, struct Object *ob_arm);
228 
229 #ifdef __cplusplus
230 };
231 #endif
eAction_TransformFlags
Definition: BKE_action.h:61
@ ACT_TRANS_ALL
Definition: BKE_action.h:79
@ ACT_TRANS_PROP
Definition: BKE_action.h:75
@ ACT_TRANS_SCALE
Definition: BKE_action.h:67
@ ACT_TRANS_BBONE
Definition: BKE_action.h:70
@ ACT_TRANS_ROT
Definition: BKE_action.h:65
@ ACT_TRANS_LOC
Definition: BKE_action.h:63
@ ACT_TRANS_ONLY
Definition: BKE_action.h:78
void BKE_pose_channels_remove(struct Object *ob, bool(*filter_fn)(const char *bone_name, void *user_data), void *user_data)
Definition: action.c:986
void BKE_pose_tag_recalc(struct Main *bmain, struct bPose *pose)
Definition: action.c:1726
void BKE_action_groups_reconstruct(struct bAction *act)
Definition: action.c:505
struct bActionGroup * action_groups_add_new(struct bAction *act, const char name[])
Definition: action.c:402
struct bActionGroup * BKE_pose_add_group(struct bPose *pose, const char *name)
Definition: action.c:1322
void BKE_pose_remove_group_index(struct bPose *pose, const int index)
Definition: action.c:1381
void BKE_pose_channels_hash_free(struct bPose *pose)
Definition: action.c:960
void BKE_pose_channel_runtime_reset(struct bPoseChannel_Runtime *runtime)
Definition: action.c:1088
void BKE_pose_channel_runtime_reset_on_copy(struct bPoseChannel_Runtime *runtime)
Definition: action.c:1094
struct bPoseChannel * BKE_pose_channel_find_name(const struct bPose *pose, const char *name)
struct bPoseChannel * BKE_pose_channel_active_or_first_selected(struct Object *ob)
Definition: action.c:736
struct bPoseChannel * BKE_pose_channel_active(struct Object *ob)
Definition: action.c:708
void BKE_pose_check_uuids_unique_and_report(const struct bPose *pose)
void set_active_action_group(struct bAction *act, struct bActionGroup *agrp, short select)
Definition: action.c:350
void BKE_pose_channel_runtime_free(struct bPoseChannel_Runtime *runtime)
Definition: action.c:1102
void BKE_pose_remove_group(struct bPose *pose, struct bActionGroup *grp, const int index)
Definition: action.c:1342
void BKE_pose_blend_read_expand(struct BlendExpander *expander, struct bPose *pose)
Definition: action.c:2000
void BKE_pose_channel_copy_data(struct bPoseChannel *pchan, const struct bPoseChannel *pchan_from)
void BKE_pose_channels_hash_make(struct bPose *pose)
Definition: action.c:948
void BKE_pose_free_ex(struct bPose *pose, bool do_id_user)
Definition: action.c:1175
void BKE_pose_free(struct bPose *pose)
Definition: action.c:1184
void action_groups_remove_channel(struct bAction *act, struct FCurve *fcu)
Definition: action.c:538
void BKE_pose_ikparam_init(struct bPose *pose)
Definition: action.c:896
void BKE_pose_copy_pchan_result(struct bPoseChannel *pchanto, const struct bPoseChannel *pchanfrom)
void BKE_action_flip_with_pose(struct bAction *act, struct Object *ob_arm)
void BKE_pose_itasc_init(struct bItasc *itasc)
Definition: action.c:879
void action_groups_clear_tempflags(struct bAction *act)
Definition: action.c:591
void calc_action_range(const struct bAction *act, float *start, float *end, short incl_modifiers)
void action_group_colors_sync(struct bActionGroup *grp, const struct bActionGroup *ref_grp)
void BKE_pose_channel_free(struct bPoseChannel *pchan)
Definition: action.c:1117
const char * BKE_pose_ikparam_get_name(struct bPose *pose)
Definition: action.c:775
struct bActionGroup * BKE_action_group_find_name(struct bAction *act, const char name[])
Definition: action.c:579
bool action_has_motion(const struct bAction *act)
struct bActionGroup * get_active_actiongroup(struct bAction *act)
Definition: action.c:334
void what_does_obaction(struct Object *ob, struct Object *workob, struct bPose *pose, struct bAction *act, char groupname[], const struct AnimationEvalContext *anim_eval_context)
struct bPoseChannel * BKE_pose_channel_get_mirrored(const struct bPose *pose, const char *name)
void BKE_pose_channel_session_uuid_generate(struct bPoseChannel *pchan)
Definition: action.c:608
void BKE_pose_tag_update_constraint_flags(struct bPose *pose)
Definition: action.c:1314
void BKE_pose_blend_write(struct BlendWriter *writer, struct bPose *pose, struct bArmature *arm)
Definition: action.c:1842
void BKE_pose_channels_free_ex(struct bPose *pose, bool do_id_user)
Definition: action.c:1126
bool BKE_pose_copy_result(struct bPose *to, struct bPose *from)
Definition: action.c:1701
short action_get_item_transforms(struct bAction *act, struct Object *ob, struct bPoseChannel *pchan, ListBase *curves)
Definition: action.c:1503
void BKE_pose_blend_read_data(struct BlendDataReader *reader, struct bPose *pose)
Definition: action.c:1894
void BKE_pose_channel_free_ex(struct bPoseChannel *pchan, bool do_id_user)
Definition: action.c:1059
struct bPoseChannel * BKE_pose_channel_verify(struct bPose *pose, const char *name)
Definition: action.c:638
void BKE_pose_channels_free(struct bPose *pose)
Definition: action.c:1143
bool BKE_pose_channels_is_valid(const struct bPose *pose)
void BKE_pose_free_data(struct bPose *pose)
Definition: action.c:1167
void BKE_pose_update_constraint_flags(struct bPose *pose)
Definition: action.c:1247
bool BKE_pose_channel_in_IK_chain(struct Object *ob, struct bPoseChannel *pchan)
Definition: action.c:939
struct bAction * BKE_action_add(struct Main *bmain, const char name[])
Definition: action.c:320
void action_groups_add_channel(struct bAction *act, struct bActionGroup *agrp, struct FCurve *fcurve)
Definition: action.c:431
void BKE_pose_free_data_ex(struct bPose *pose, bool do_id_user)
Definition: action.c:1148
void BKE_pose_blend_read_lib(struct BlendLibReader *reader, struct Object *ob, struct bPose *pose)
Definition: action.c:1942
void BKE_pose_copy_data_ex(struct bPose **dst, const struct bPose *src, const int flag, const bool copy_constraints)
void BKE_pose_copy_data(struct bPose **dst, const struct bPose *src, const bool copy_constraints)
void BKE_pose_channel_free_bbone_cache(struct bPoseChannel_Runtime *runtime)
Definition: action.c:1108
void BKE_pose_rest(struct bPose *pose, bool selected_bones_only)
Definition: action.c:1636
These structs are the foundation for all linked lists in the library system.
StackEntry * from
void * user_data
Definition: BKE_main.h:116
ListBase curves
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
Definition: util_avxb.h:167