2 * $Id: BIF_keyframing.h 17216 2008-10-29 11:20:02Z aligorith $
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) 2008, Blender Foundation
21 * This is a new part of Blender (with some old code)
23 * Contributor(s): Joshua Leung
25 * ***** END GPL LICENSE BLOCK *****
28 #ifndef BIF_KEYFRAMING_H
29 #define BIF_KEYFRAMING_H
38 /* ************ IPO/IPO-Curve Management ************** */
39 // XXX these will need to be updated for RNA-IPO stuff
41 struct Ipo *verify_ipo(struct ID *from, short blocktype, char actname[], char constname[], char bonename[], short add);
42 struct IpoCurve *verify_ipocurve(struct ID *from, short blocktype, char actname[], char constname[], char bonename[], int adrcode, short add);
44 /* ************ Keyframing Management **************** */
46 /* Lesser Keyframing API call:
47 * Use this when validation of necessary animation data isn't necessary as it already
48 * exists, and there is a beztriple that can be directly copied into the array.
50 int insert_bezt_icu(struct IpoCurve *icu, struct BezTriple *bezt);
52 /* Main Keyframing API call:
53 * Use this when validation of necessary animation data isn't necessary as it
54 * already exists. It will insert a keyframe using the current value being keyframed.
56 void insert_vert_icu(struct IpoCurve *icu, float x, float y, short flag);
59 /* flags for use by keyframe creation/deletion calls */
61 /* used by isnertkey() and insert_vert_icu() */
62 INSERTKEY_NEEDED = (1<<0), /* only insert keyframes where they're needed */
63 INSERTKEY_MATRIX = (1<<1), /* insert 'visual' keyframes where possible/needed */
64 INSERTKEY_FAST = (1<<2), /* don't recalculate handles,etc. after adding key */
65 INSERTKEY_FASTR = (1<<3), /* don't realloc mem (or increase count, as array has already been set out) */
66 INSERTKEY_REPLACE = (1<<4), /* only replace an existing keyframe (this overrides INSERTKEY_NEEDED) */
68 /* used by common_*key() functions - Note: these are generally mutually exclusive (only one will work at a time) */
69 COMMONKEY_ADDMAP = (1<<10), /* common key: add texture-slot offset bitflag to adrcode before use */
70 COMMONKEY_PCHANROT = (1<<11), /* common key: extend channel list using relevant pchan-rotations */
71 /* all possible items for common_*key() functions */
72 COMMONKEY_MODES = (COMMONKEY_ADDMAP|COMMONKEY_PCHANROT)
77 /* Main Keyframing API calls:
78 * Use this to create any necessary animation data, and then insert a keyframe
79 * using the current value being keyframed, in the relevant place. Returns success.
81 // TODO: adapt this for new data-api -> this blocktype, etc. stuff is evil!
82 short insertkey(struct ID *id, int blocktype, char *actname, char *constname, int adrcode, short flag);
84 /* Main Keyframing API call:
85 * Use this to delete keyframe on current frame for relevant channel. Will perform checks just in case.
87 short deletekey(struct ID *id, int blocktype, char *actname, char *constname, int adrcode, short flag);
90 /* Main Keyframe Management calls:
91 * These handle keyframes management from various spaces. They will handle the menus
92 * required for each space.
94 void common_insertkey(const struct bContext *C);
95 void common_deletekey(const struct bContext *C);
97 /* ************ Auto-Keyframing ********************** */
99 * - All the defines for this (User-Pref settings and Per-Scene settings)
100 * are defined in DNA_userdef_types.h
101 * - Scene settings take presidence over those for userprefs, with old files
102 * inheriting userpref settings for the scene settings
103 * - "On/Off + Mode" are stored per Scene, but "settings" are currently stored
107 /* Auto-Keying macros for use by various tools */
108 /* check if auto-keyframing is enabled (per scene takes presidence) */
109 #define IS_AUTOKEY_ON ((scene) ? (scene->autokey_mode & AUTOKEY_ON) : (U.autokey_mode & AUTOKEY_ON))
110 /* check the mode for auto-keyframing (per scene takes presidence) */
111 #define IS_AUTOKEY_MODE(mode) ((scene) ? (scene->autokey_mode == AUTOKEY_MODE_##mode) : (U.autokey_mode == AUTOKEY_MODE_##mode))
112 /* check if a flag is set for auto-keyframing (as userprefs only!) */
113 #define IS_AUTOKEY_FLAG(flag) (U.autokey_flag & AUTOKEY_FLAG_##flag)
115 /* ************ Keyframe Checking ******************** */
117 /* Main Keyframe Checking API call:
118 * Checks whether a keyframe exists for the given ID-block one the given frame.
119 * - It is recommended to call this method over the other keyframe-checkers directly,
120 * in case some detail of the implementation changes...
121 * - frame: the value of this is quite often result of frame_to_float(CFRA)
123 short id_frame_has_keyframe(struct ID *id, float frame, short filter);
125 /* filter flags for id_cfra_has_keyframe
127 * WARNING: do not alter order of these, as also stored in files
128 * (for v3d->keyflags)
132 ANIMFILTER_KEYS_LOCAL = (1<<0), /* only include locally available anim data */
133 ANIMFILTER_KEYS_MUTED = (1<<1), /* include muted elements */
134 ANIMFILTER_KEYS_ACTIVE = (1<<2), /* only include active-subelements */
136 /* object specific */
137 ANIMFILTER_KEYS_NOMAT = (1<<9), /* don't include material keyframes */
138 ANIMFILTER_KEYS_NOSKEY = (1<<10), /* don't include shape keys (for geometry) */
141 #endif /* BIF_KEYFRAMING_H */