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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21 * All rights reserved.
23 * Contributor(s): Original design: Reevan McKay
24 * Contributor(s): Full recode, Ton Roosendaal, Crete 2005
25 * Contributor(s): Animation recode, Joshua Leung
27 * ***** END GPL LICENSE BLOCK *****
31 #ifndef DNA_ACTION_TYPES_H
32 #define DNA_ACTION_TYPES_H
34 #include "DNA_listBase.h"
36 #include "DNA_gpencil_types.h"
37 #include "DNA_view2d_types.h"
38 #include "DNA_userdef_types.h"
43 /* ************************************************ */
46 /* Motion Paths ------------------------------------ */
47 /* (used for Pose Channels and Objects) */
49 /* Data point for motion path */
50 typedef struct bMotionPathVert {
51 float co[3]; /* coordinates of point in 3D-space */
52 int flag; /* quick settings */
55 /* Motion Path data cache - for elements providing transforms (i.e. Objects or PoseChannels) */
56 typedef struct bMotionPath {
57 bMotionPathVert *points; /* path samples */
58 int length; /* the number of cached verts */
60 int start_frame; /* for drawing paths, the start frame number */
61 int end_frame; /* for drawing paths, the end frame number */
63 int flag; /* extra settings */
68 /* Animation Visualisation Settings - for Objects or Armatures (not PoseChannels) */
69 typedef struct bAnimVizSettings {
71 int pathflag; /* eMotionPath_Settings */
73 int pathsf, pathef; /* start and end frames of path-calculation range */
74 int pathbc, pathac; /* number of frames before/after current frame of path-calculation */
77 /* bMotionPathSettings->flag */
78 typedef enum eMotionPath_Settings {
79 /* show frames on path */
80 MOTIONPATH_FLAG_FNUMS = (1<<0),
81 /* show keyframes on path */
82 MOTIONPATH_FLAG_KFRAS = (1<<1),
83 /* for bones - calculate head-points for curves instead of tips */
84 MOTIONPATH_FLAG_HEADS = (1<<2),
85 /* show path around current frame */
86 MOTIONPATH_FLAG_ACFRA = (1<<3),
87 /* show keyframe/frame numbers */
88 MOTIONPATH_FLAG_KFNOS = (1<<4)
89 } eMotionPath_Settings;
91 /* ************************************************ */
94 /* PoseChannel ------------------------------------ */
98 * A PoseChannel stores the results of Actions and transform information
99 * with respect to the restposition of Armature bones
101 typedef struct bPoseChannel {
102 struct bPoseChannel *next, *prev;
104 IDProperty *prop; /* User-Defined Properties on this PoseChannel */
106 ListBase constraints;/* Constraints that act on this PoseChannel */
107 char name[32]; /* Channels need longer names than normal blender objects */
109 short flag; /* dynamic, for detecting transform changes */
110 short constflag; /* for quick detecting which constraints affect this channel */
111 short ikflag; /* settings for IK bones */
112 short selectflag; /* copy of bone flag, so you can work with library armatures */
113 short protectflag; /* protect channels from being transformed */
114 short agrp_index; /* index of action-group this bone belongs to (0 = default/no group) */
116 int pathlen; /* for drawing paths, the amount of frames */
117 int pathsf; /* for drawing paths, the start frame number */
118 int pathef; /* for drawing paths, the end frame number */
120 struct Bone *bone; /* set on read file or rebuild pose */
121 struct bPoseChannel *parent; /* set on read file or rebuild pose */
122 struct bPoseChannel *child; /* set on read file or rebuild pose, the 'ik' child, for b-bones */
123 struct ListBase iktree; /* only while evaluating pose */
125 /* only while deform, stores precalculated b_bone deform mats,
129 void *b_bone_dual_quats;
131 /* transforms - written in by actions or transform */
135 /* rotations - written in by actions or transform (but only one representation gets used at any time) */
136 float eul[3]; /* euler rotation */
137 float quat[4]; /* quaternion rotation */
138 float rotAxis[3], rotAngle; /* axis-angle rotation */
139 short rotmode; /* eRotationModes - rotation representation to use */
142 float chan_mat[4][4]; /* matrix result of loc/quat/size , and where we put deform in, see next line */
143 float pose_mat[4][4]; /* constraints accumulate here. in the end, pose_mat = bone->arm_mat * chan_mat */
144 float constinv[4][4]; /* inverse result of constraints. doesn't include effect of restposition, parent, and local transform*/
146 float pose_head[3]; /* actually pose_mat[3] */
147 float pose_tail[3]; /* also used for drawing help lines... */
149 float limitmin[3], limitmax[3]; /* DOF constraint */
150 float stiffness[3]; /* DOF stiffness */
152 float ikrotweight; /* weight of joint rotation constraint */
153 float iklinweight; /* weight of joint stretch constraint */
155 float *path; /* totpath x 3 x float */
156 struct Object *custom; /* draws custom object instead of this channel */
160 /* PoseChannel (transform) flags */
161 typedef enum ePchan_Flag {
166 /* old IK/cache stuff... */
167 POSE_IK_MAT = (1<<3),
168 POSE_UNUSED2 = (1<<4),
169 POSE_UNUSED3 = (1<<5),
170 POSE_UNUSED4 = (1<<6),
171 POSE_UNUSED5 = (1<<7),
172 /* has Standard IK */
173 POSE_HAS_IK = (1<<8),
179 POSE_STRIDE = (1<<12),
180 /* standard IK solving */
181 POSE_IKTREE = (1<<13),
183 POSE_HAS_IKS = (1<<14),
184 /* spline IK solving */
185 POSE_IKSPLINE = (1<<15),
188 /* PoseChannel constflag (constraint detection) */
189 typedef enum ePchan_ConstFlag {
190 PCHAN_HAS_IK = (1<<0),
191 PCHAN_HAS_CONST = (1<<1),
192 /* only used for drawing Posemode, not stored in channel */
193 PCHAN_HAS_ACTION = (1<<2),
194 PCHAN_HAS_TARGET = (1<<3),
195 /* only for drawing Posemode too */
196 PCHAN_HAS_STRIDE = (1<<4),
198 PCHAN_HAS_SPLINEIK = (1<<5),
201 /* PoseChannel->ikflag */
202 typedef enum ePchan_IkFlag {
203 BONE_IK_NO_XDOF = (1<<0),
204 BONE_IK_NO_YDOF = (1<<1),
205 BONE_IK_NO_ZDOF = (1<<2),
207 BONE_IK_XLIMIT = (1<<3),
208 BONE_IK_YLIMIT = (1<<4),
209 BONE_IK_ZLIMIT = (1<<5),
211 BONE_IK_ROTCTL = (1<<6),
212 BONE_IK_LINCTL = (1<<7),
214 BONE_IK_NO_XDOF_TEMP = (1<<10),
215 BONE_IK_NO_YDOF_TEMP = (1<<11),
216 BONE_IK_NO_ZDOF_TEMP = (1<<12),
219 /* PoseChannel->rotmode and Object->rotmode */
220 typedef enum eRotationModes {
221 /* quaternion rotations (default, and for older Blender versions) */
223 /* euler rotations - keep in sync with enum in BLI_math.h */
224 ROT_MODE_EUL = 1, /* Blender 'default' (classic) - must be as 1 to sync with arithb defines */
225 ROT_MODE_XYZ = 1, /* Blender 'default' (classic) - must be as 1 to sync with arithb defines */
231 /* NOTE: space is reserved here for 18 other possible
232 * euler rotation orders not implemented
234 ROT_MODE_MAX, /* sentinel for Py API */
235 /* axis angle rotations */
236 ROT_MODE_AXISANGLE = -1
239 /* Pose ------------------------------------ */
243 * It is only found under ob->pose. It is not library data, even
244 * though there is a define for it (hack for the outliner).
246 typedef struct bPose {
247 ListBase chanbase; /* list of pose channels, PoseBones in RNA */
249 short flag, proxy_layer; /* proxy layer: copy from armature, gets synced */
251 float ctime; /* local action time of this pose */
252 float stride_offset[3]; /* applied to object */
253 float cyclic_offset[3]; /* result of match and cycles, applied in where_is_pose() */
256 ListBase agroups; /* list of bActionGroups */
258 int active_group; /* index of active group (starts from 1) */
259 int iksolver; /* ik solver to use, see ePose_IKSolverType */
260 void *ikdata; /* temporary IK data, depends on the IK solver. Not saved in file */
261 void *ikparam; /* IK solver parameters, structure depends on iksolver */
266 typedef enum ePose_Flags {
267 /* results in armature_rebuild_pose being called */
268 POSE_RECALC = (1<<0),
269 /* prevents any channel from getting overridden by anim from IPO */
270 POSE_LOCKED = (1<<1),
271 /* clears the POSE_LOCKED flag for the next time the pose is evaluated */
272 POSE_DO_UNLOCK = (1<<2),
273 /* pose has constraints which depend on time (used when depsgraph updates for a new frame) */
274 POSE_CONSTRAINTS_TIMEDEPEND = (1<<3),
275 /* recalculate bone paths */
276 POSE_RECALCPATHS = (1<<4),
277 /* set by armature_rebuild_pose to give a chance to the IK solver to rebuild IK tree */
278 POSE_WAS_REBUILT = (1<<5),
279 /* set by game_copy_pose to indicate that this pose is used in the game engine */
280 POSE_GAME_ENGINE = (1<<6),
283 /* IK Solvers ------------------------------------ */
285 /* bPose->iksolver and bPose->ikparam->iksolver */
289 } ePose_IKSolverType;
291 /* header for all bPose->ikparam structures */
292 typedef struct bIKParam {
296 /* bPose->ikparam when bPose->iksolver=1 */
297 typedef struct bItasc {
307 float maxvel; /* max velocity to SDLS solver */
308 float dampmax; /* maximum damping for DLS solver */
309 float dampeps; /* threshold of singular value from which the damping start progressively */
314 ITASC_AUTO_STEP = (1<<0),
315 ITASC_INITIAL_REITERATION = (1<<1),
316 ITASC_REITERATION = (1<<2),
317 ITASC_SIMULATION = (1<<3),
322 ITASC_SOLVER_SDLS = 0, /* selective damped least square, suitable for CopyPose constraint */
323 ITASC_SOLVER_DLS /* damped least square with numerical filtering of damping */
326 /* ************************************************ */
329 /* Groups -------------------------------------- */
331 /* Action-Channel Group (agrp)
333 * These are stored as a list per-Action, and are only used to
334 * group that Action's channels in an Animation Editor.
336 * Even though all FCurves live in a big list per Action, each group they are in also
337 * holds references to the achans within that list which belong to it. Care must be taken to
338 * ensure that action-groups never end up being the sole 'owner' of a channel.
340 * This is also exploited for bone-groups. Bone-Groups are stored per bPose, and are used
341 * primarily to colour bones in the 3d-view. There are other benefits too, but those are mostly related
344 typedef struct bActionGroup {
345 struct bActionGroup *next, *prev;
347 ListBase channels; /* Note: this must not be touched by standard listbase functions which would clear links to other channels */
349 int flag; /* settings for this action-group */
350 int customCol; /* index of custom color set to use when used for bones (0=default - used for all old files, -1=custom set) */
351 char name[64]; /* name of the group */
353 ThemeWireColor cs; /* color set to use when customCol == -1 */
356 /* Action Group flags */
357 typedef enum eActionGroup_Flag {
358 /* group is selected */
359 AGRP_SELECTED = (1<<0),
360 /* group is 'active' / last selected one */
361 AGRP_ACTIVE = (1<<1),
362 /* keyframes/channels belonging to it cannot be edited */
363 AGRP_PROTECTED = (1<<2),
364 /* for UI, sub-channels are shown */
365 AGRP_EXPANDED = (1<<3),
366 /* sub-channels are not evaluated */
368 /* sub-channels are not visible in Graph Editor */
369 AGRP_NOTVISIBLE = (1<<5),
376 /* Actions -------------------------------------- */
378 /* Action - reusable F-Curve 'bag' (act)
380 * This contains F-Curves that may affect settings from more than one ID blocktype and/or
381 * datablock (i.e. sub-data linked/used directly to the ID block that the animation data is linked to),
382 * but with the restriction that the other unrelated data (i.e. data that is not directly used or linked to
383 * by the source ID block).
385 * It serves as a 'unit' of reusable animation information (i.e. keyframes/motion data), that
386 * affects a group of related settings (as defined by the user).
388 typedef struct bAction {
389 ID id; /* ID-serialisation for relinking */
391 ListBase curves; /* function-curves (FCurve) */
392 ListBase chanbase; /* legacy data - Action Channels (bActionChannel) in pre-2.5 animation system */
393 ListBase groups; /* groups of function-curves (bActionGroup) */
394 ListBase markers; /* markers local to the Action (used to provide Pose-Libraries) */
396 int flag; /* settings for this action */
397 int active_marker; /* index of the active marker */
401 /* Flags for the action */
402 typedef enum eAction_Flags {
403 /* flags for displaying in UI */
404 ACT_COLLAPSED = (1<<0),
405 ACT_SELECTED = (1<<1),
407 /* flags for evaluation/editing */
409 ACT_PROTECTED = (1<<10),
410 ACT_DISABLED = (1<<11),
414 /* ************************************************ */
415 /* Action/Dopesheet Editor */
417 /* Storage for Dopesheet/Grease-Pencil Editor data */
418 typedef struct bDopeSheet {
419 ID *source; /* currently ID_SCE (for Dopesheet), and ID_SC (for Grease Pencil) */
420 ListBase chanbase; /* cache for channels (only initialised when pinned) */ // XXX not used!
422 int filterflag; /* flags to use for filtering data */
423 int flag; /* standard flags */
427 /* DopeSheet filter-flag */
428 typedef enum DOPESHEET_FILTERFLAG {
429 /* general filtering */
430 ADS_FILTER_ONLYSEL = (1<<0), /* only include channels relating to selected data */
432 /* temporary (runtime flags) */
433 ADS_FILTER_ONLYDRIVERS = (1<<1), /* for 'Drivers' editor - only include Driver data from AnimData */
434 ADS_FILTER_ONLYNLA = (1<<2), /* for 'NLA' editor - only include NLA data from AnimData */
435 ADS_FILTER_SELEDIT = (1<<3), /* for Graph Editor - used to indicate whether to include a filtering flag or not */
436 ADS_FILTER_SUMMARY = (1<<4), /* for 'DopeSheet' Editor - include 'summary' line */
438 /* datatype-based filtering */
439 ADS_FILTER_NOSHAPEKEYS = (1<<6),
440 ADS_FILTER_NOCAM = (1<<10),
441 ADS_FILTER_NOMAT = (1<<11),
442 ADS_FILTER_NOLAM = (1<<12),
443 ADS_FILTER_NOCUR = (1<<13),
444 ADS_FILTER_NOWOR = (1<<14),
445 ADS_FILTER_NOSCE = (1<<15),
446 ADS_FILTER_NOPART = (1<<16),
447 ADS_FILTER_NOMBA = (1<<17),
448 ADS_FILTER_NOARM = (1<<18),
449 ADS_FILTER_NONTREE = (1<<19),
451 /* NLA-specific filters */
452 ADS_FILTER_NLA_NOACT = (1<<20), /* if the AnimData block has no NLA data, don't include to just show Action-line */
454 /* combination filters (some only used at runtime) */
455 ADS_FILTER_NOOBDATA = (ADS_FILTER_NOCAM|ADS_FILTER_NOMAT|ADS_FILTER_NOLAM|ADS_FILTER_NOCUR|ADS_FILTER_NOPART|ADS_FILTER_NOARM),
456 } DOPESHEET_FILTERFLAG;
458 /* DopeSheet general flags */
459 typedef enum DOPESHEET_FLAG {
460 ADS_FLAG_SUMMARY_COLLAPSED = (1<<0), /* when summary is shown, it is collapsed, so all other channels get hidden */
465 /* Action Editor Space. This is defined here instead of in DNA_space_types.h */
466 typedef struct SpaceAction {
467 struct SpaceLink *next, *prev;
468 ListBase regionbase; /* storage of regions for inactive spaces */
472 short blockhandler[8];
474 View2D v2d; /* depricated, copied to region */
476 bAction *action; /* the currently active action */
477 bDopeSheet ads; /* the currently active context (when not showing action) */
479 char mode, autosnap; /* mode: editing context; autosnap: automatic keyframe snapping mode */
480 short flag, actnr; /* flag: bitmapped settings; */
481 short pin, lock; /* pin: keep showing current action; actnr: used for finding chosen action from menu; lock: lock time to other windows */
482 short actwidth; /* width of the left-hand side name panel (in pixels?) */ // XXX depreceated!
483 float timeslide; /* for Time-Slide transform mode drawing - current frame? */
486 /* SpaceAction flag */
487 typedef enum eSAction_Flag {
488 /* during transform (only set for TimeSlide) */
489 SACTION_MOVING = (1<<0),
490 /* show sliders (if relevant) */
491 SACTION_SLIDERS = (1<<1),
492 /* draw time in seconds instead of time in frames */
493 SACTION_DRAWTIME = (1<<2),
494 /* don't filter action channels according to visibility */
495 SACTION_NOHIDE = (1<<3),
496 /* don't kill overlapping keyframes after transform */
497 SACTION_NOTRANSKEYCULL = (1<<4),
498 /* don't include keyframes that are out of view */
499 SACTION_HORIZOPTIMISEON = (1<<5),
500 /* hack for moving pose-markers (temp flag) */
501 SACTION_POSEMARKERS_MOVE = (1<<6),
502 /* don't draw action channels using group colours (where applicable) */
503 SACTION_NODRAWGCOLORS = (1<<7),
504 /* don't draw current frame number beside frame indicator */
505 SACTION_NODRAWCFRANUM = (1<<8),
508 /* SpaceAction Mode Settings */
509 // XXX should this be used by other editors too?
510 typedef enum eAnimEdit_Context {
511 /* action (default) */
513 /* editing of shapekey's IPO block */
515 /* editing of gpencil data */
521 /* SpaceAction AutoSnap Settings (also used by other Animation Editors) */
522 typedef enum eAnimEdit_AutoSnap {
525 /* snap to 1.0 frame/second intervals */
527 /* snap to actual frames/seconds (nla-action time) */
529 /* snap to nearest marker */
531 } eAnimEdit_AutoSnap;
534 /* ************************************************ */
537 /* WARNING: Action Channels are now depreceated... they were part of the old animation system!
538 * (ONLY USED FOR DO_VERSIONS...)
540 * Action Channels belong to Actions. They are linked with an IPO block, and can also own
541 * Constraint Channels in certain situations.
543 * Action-Channels can only belong to one group at a time, but they still live the Action's
544 * list of achans (to preserve backwards compatability, and also minimise the code
545 * that would need to be recoded). Grouped achans are stored at the start of the list, according
546 * to the position of the group in the list, and their position within the group.
548 typedef struct bActionChannel {
549 struct bActionChannel *next, *prev;
550 bActionGroup *grp; /* Action Group this Action Channel belongs to */
552 struct Ipo *ipo; /* IPO block this action channel references */
553 ListBase constraintChannels; /* Constraint Channels (when Action Channel represents an Object or Bone) */
555 int flag; /* settings accessed via bitmapping */
556 char name[32]; /* channel name */
557 int temp; /* temporary setting - may be used to indicate group that channel belongs to during syncing */
560 /* Action Channel flags (ONLY USED FOR DO_VERSIONS...) */
561 typedef enum ACHAN_FLAG {
562 ACHAN_SELECTED = (1<<0),
563 ACHAN_HILIGHTED = (1<<1),
564 ACHAN_HIDDEN = (1<<2),
565 ACHAN_PROTECTED = (1<<3),
566 ACHAN_EXPANDED = (1<<4),
567 ACHAN_SHOWIPO = (1<<5),
568 ACHAN_SHOWCONS = (1<<6),
569 ACHAN_MOVED = (1<<31),