[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13190] trunk/blender/source/blender: == Auto-Keyframing Refactor (Peach Request) ==
Joshua Leung
aligorith at gmail.com
Thu Jan 10 02:36:24 CET 2008
Revision: 13190
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13190
Author: aligorith
Date: 2008-01-10 02:36:22 +0100 (Thu, 10 Jan 2008)
Log Message:
-----------
== Auto-Keyframing Refactor (Peach Request) ==
Refactored Auto-Keyframing to make it easier to add more options. There are now three "states" for auto-keying: off, add/replace keys, replace keys.
Description of modes:
1) No auto-keying is done
2) Add new keyframes or replace existing ones if possible (old behaviour)
3) Only modify existing keys, but not insert new ones.
Internally, I've moved the auto-keying settings out of G.flag and U.uiflag and moved them into their own variables in Userdef, and provided some macros to access those easily. As a result, old auto-keying settings are currently lost.
Also, removed the manual calls to insertkey done in pose-relax. The reason auto-keying didn't work before was because the bones didn't have the BONE_TRANSFORM flag applied. Now, these are set temporarily.
Todo(s):
* Make icons for the TimeLine header menu (currently just a text menu)
* Add version-patches for old files
* Double-check code for all places that use auto-keying (i.e. PoseLib)
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/BKE_global.h
trunk/blender/source/blender/include/transform.h
trunk/blender/source/blender/makesdna/DNA_userdef_types.h
trunk/blender/source/blender/src/editipo.c
trunk/blender/source/blender/src/editview.c
trunk/blender/source/blender/src/header_time.c
trunk/blender/source/blender/src/poselib.c
trunk/blender/source/blender/src/poseobject.c
trunk/blender/source/blender/src/space.c
trunk/blender/source/blender/src/transform_conversions.c
Modified: trunk/blender/source/blender/blenkernel/BKE_global.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_global.h 2008-01-10 00:07:31 UTC (rev 13189)
+++ trunk/blender/source/blender/blenkernel/BKE_global.h 2008-01-10 01:36:22 UTC (rev 13190)
@@ -180,7 +180,7 @@
#define G_DRAW_FACEAREA (1 << 23)
#define G_DRAW_EDGEANG (1 << 24)
-#define G_RECORDKEYS (1 << 25)
+/* #define G_RECORDKEYS (1 << 25) also removed */
/*#ifdef WITH_VERSE*/
#define G_VERSE_CONNECTED (1 << 26)
#define G_DRAW_VERSE_DEBUG (1 << 27)
@@ -189,7 +189,7 @@
#define G_SCULPTMODE (1 << 29)
#define G_PARTICLEEDIT (1 << 30)
-#define G_AUTOMATKEYS (1 << 30)
+/* #define G_AUTOMATKEYS (1 << 30) also removed */
#define G_HIDDENHANDLES (1 << 31) /* used for curves only */
/* macro for testing face select mode
Modified: trunk/blender/source/blender/include/transform.h
===================================================================
--- trunk/blender/source/blender/include/transform.h 2008-01-10 00:07:31 UTC (rev 13189)
+++ trunk/blender/source/blender/include/transform.h 2008-01-10 01:36:22 UTC (rev 13190)
@@ -382,6 +382,7 @@
void transform_autoik_update(TransInfo *t, short mode);
/* auto-keying stuff used by special_aftertrans_update */
+short autokeyframe_cfra_can_key(struct Object *ob);
void autokeyframe_ob_cb_func(struct Object *ob, int tmode);
void autokeyframe_pose_cb_func(struct Object *ob, int tmode, short targetless_ik);
Modified: trunk/blender/source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_userdef_types.h 2008-01-10 00:07:31 UTC (rev 13189)
+++ trunk/blender/source/blender/makesdna/DNA_userdef_types.h 2008-01-10 01:36:22 UTC (rev 13190)
@@ -197,8 +197,11 @@
short glreslimit;
char versemaster[160];
char verseuser[160];
- float glalphaclip, pad;
+ float glalphaclip;
+ short autokey_mode; /* autokeying mode */
+ short autokey_flag; /* flags for autokeying */
+
struct ColorBand coba_weight; /* from texture.h */
} UserDef;
@@ -229,16 +232,14 @@
#define USER_ADD_VIEWALIGNED (1 << 19)
#define USER_ADD_VIEWALIGNED (1 << 19)
-
/* viewzom */
#define USER_ZOOM_CONT 0
#define USER_ZOOM_SCALE 1
#define USER_ZOOM_DOLLY 2
/* uiflag */
-
-#define USER_KEYINSERTACT (1 << 0)
-#define USER_KEYINSERTOBJ (1 << 1)
+// old flag for #define USER_KEYINSERTACT (1 << 0)
+// old flag for #define USER_KEYINSERTOBJ (1 << 1)
#define USER_WHEELZOOMDIR (1 << 2)
#define USER_FILTERFILEEXTS (1 << 3)
#define USER_DRAWVIEWINFO (1 << 4)
@@ -252,16 +253,33 @@
#define USER_LOCKAROUND (1 << 12)
#define USER_GLOBALUNDO (1 << 13)
#define USER_ORBIT_SELECTION (1 << 14)
-#define USER_KEYINSERTAVAI (1 << 15)
+// old flag for #define USER_KEYINSERTAVAI (1 << 15)
#define USER_HIDE_DOT (1 << 16)
#define USER_SHOW_ROTVIEWICON (1 << 17)
#define USER_SHOW_VIEWPORTNAME (1 << 18)
-#define USER_KEYINSERTNEED (1 << 19)
+// old flag for #define USER_KEYINSERTNEED (1 << 19)
#define USER_ZOOM_TO_MOUSEPOS (1 << 20)
-#define USER_SHOW_FPS (1 << 21)
+#define USER_SHOW_FPS (1 << 21)
+/* Auto-Keying mode */
+enum {
+ AUTOKEY_MODE_OFF = 0,
+ AUTOKEY_MODE_NORMAL,
+ AUTOKEY_MODE_EDITKEYS
+} eAutoKeyframe_Mode;
+
+/* Auto-Keying flag */
+enum {
+ AUTOKEY_FLAG_INSERTAVAIL = (1<<0),
+ AUTOKEY_FLAG_INSERTNEEDED = (1<<1),
+ AUTOKEY_FLAG_AUTOMATKEY = (1<<2)
+} eAutoKeyframe_Flag;
+
+/* Auto-Keying macros */
+#define IS_AUTOKEY_MODE(mode) (U.autokey_mode == AUTOKEY_MODE_##mode)
+#define IS_AUTOKEY_FLAG(flag) (U.autokey_flag == AUTOKEY_FLAG_##flag)
+
/* transopts */
-
#define USER_TR_TOOLTIPS (1 << 0)
#define USER_TR_BUTTONS (1 << 1)
#define USER_TR_MENUS (1 << 2)
@@ -272,7 +290,6 @@
#define CONVERT_TO_UTF8 (1 << 7)
/* dupflag */
-
#define USER_DUP_MESH (1 << 0)
#define USER_DUP_CURVE (1 << 1)
#define USER_DUP_SURF (1 << 2)
@@ -286,13 +303,11 @@
#define USER_DUP_ACT (1 << 10)
/* gameflags */
-
#define USER_VERTEX_ARRAYS 1
#define USER_DISABLE_SOUND 2
#define USER_DISABLE_MIPMAP 4
/* vrml flag */
-
#define USER_VRML_LAYERS 1
#define USER_VRML_AUTOSCALE 2
#define USER_VRML_TWOSIDED 4
Modified: trunk/blender/source/blender/src/editipo.c
===================================================================
--- trunk/blender/source/blender/src/editipo.c 2008-01-10 00:07:31 UTC (rev 13189)
+++ trunk/blender/source/blender/src/editipo.c 2008-01-10 01:36:22 UTC (rev 13190)
@@ -2533,7 +2533,7 @@
int vartype;
int matset=0;
- if ((G.flags&G_AUTOMATKEYS)&&(match_adr_constraint(id, blocktype, actname, adrcode))) {
+ if ((IS_AUTOKEY_FLAG(AUTOMATKEY))&&(match_adr_constraint(id, blocktype, actname, adrcode))) {
matset=insertmatrixkey(id, blocktype, actname, constname, adrcode);
}
if (matset==0) {
Modified: trunk/blender/source/blender/src/editview.c
===================================================================
--- trunk/blender/source/blender/src/editview.c 2008-01-10 00:07:31 UTC (rev 13189)
+++ trunk/blender/source/blender/src/editview.c 2008-01-10 01:36:22 UTC (rev 13190)
@@ -2636,7 +2636,7 @@
G.vd->persp= 2;
/* record the motion */
- if (G.flags & G_RECORDKEYS && (!playing_anim || cfra != G.scene->r.cfra)) {
+ if (IS_AUTOKEY_MODE(NORMAL) && (!playing_anim || cfra != G.scene->r.cfra)) {
cfra = G.scene->r.cfra;
if (xlock || zlock || moffset[0] || moffset[1]) {
@@ -2683,7 +2683,7 @@
DAG_object_flush_update(G.scene, G.vd->camera, OB_RECALC_OB);
- if (G.flags & G_RECORDKEYS) {
+ if (IS_AUTOKEY_MODE(NORMAL)) {
allqueue(REDRAWIPO, 0);
allspace(REMAKEIPO, 0);
allqueue(REDRAWNLA, 0);
Modified: trunk/blender/source/blender/src/header_time.c
===================================================================
--- trunk/blender/source/blender/src/header_time.c 2008-01-10 00:07:31 UTC (rev 13189)
+++ trunk/blender/source/blender/src/header_time.c 2008-01-10 01:36:22 UTC (rev 13190)
@@ -524,10 +524,13 @@
xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Skip to End frame (Shift UpArrow)");
xco+= XIC+8;
- uiDefIconButBitI(block, TOG, G_RECORDKEYS, REDRAWINFO, ICON_REC,
- xco, 0, XIC, YIC, &(G.flags), 0, 0, 0, 0, "Automatically insert keyframes in Object and Action Ipo curves");
+ // FIXME: give this icons (and maybe make it XIC wide again) - it used to use the "ICON_REC" (red dot)
+ uiDefButS(block, MENU, REDRAWINFO,
+ "Auto-Keying Mode %t|No Auto-Keying %x0|Add/Replace Keys%x1|Replace Keys %x2",
+ xco, 0, 4*XIC, YIC, &(U.autokey_mode), 0, 1, 0, 0,
+ "Automatic keyframe insertion for Objects and Bones");
- xco+= XIC+16;
+ xco+= (4*XIC)+16;
uiDefIconButBitI(block, TOG, TIME_WITH_SEQ_AUDIO, B_DIFF, ICON_SPEAKER,
xco, 0, XIC, YIC, &(stime->redraws), 0, 0, 0, 0, "Play back and sync with audio from Sequence Editor");
Modified: trunk/blender/source/blender/src/poselib.c
===================================================================
--- trunk/blender/source/blender/src/poselib.c 2008-01-10 00:07:31 UTC (rev 13189)
+++ trunk/blender/source/blender/src/poselib.c 2008-01-10 01:36:22 UTC (rev 13190)
@@ -48,6 +48,7 @@
#include "DNA_object_types.h"
#include "DNA_object_force.h"
#include "DNA_scene_types.h"
+#include "DNA_userdef_types.h"
#include "BKE_action.h"
#include "BKE_armature.h"
@@ -692,7 +693,8 @@
pchan= get_pose_channel(pose, achan->name);
if (pchan) {
- if (G.flags & G_RECORDKEYS) {
+ // TODO: use a standard autokeying function in future (to allow autokeying-editkeys to work)
+ if (IS_AUTOKEY_MODE(NORMAL)) {
ID *id= &pld->ob->id;
/* Set keys on pose */
@@ -1120,7 +1122,7 @@
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
/* updates */
- if (G.flags & G_RECORDKEYS) {
+ if (IS_AUTOKEY_MODE(NORMAL)) {
remake_action_ipos(ob->action);
allqueue(REDRAWIPO, 0);
Modified: trunk/blender/source/blender/src/poseobject.c
===================================================================
--- trunk/blender/source/blender/src/poseobject.c 2008-01-10 00:07:31 UTC (rev 13189)
+++ trunk/blender/source/blender/src/poseobject.c 2008-01-10 01:36:22 UTC (rev 13190)
@@ -45,6 +45,7 @@
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_view3d_types.h"
+#include "DNA_userdef_types.h"
#include "BKE_action.h"
#include "BKE_armature.h"
@@ -826,7 +827,7 @@
EulToQuat(eul, pchan->quat);
}
- if (G.flags & G_RECORDKEYS) {
+ if (autokeyframe_cfra_can_key(ob)) {
ID *id= &ob->id;
/* Set keys on pose */
@@ -863,7 +864,7 @@
/* Update event for pose and deformation children */
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
- if (G.flags & G_RECORDKEYS) {
+ if ((IS_AUTOKEY_MODE(NORMAL))) {
remake_action_ipos(ob->action);
allqueue (REDRAWIPO, 0);
allqueue (REDRAWVIEW3D, 0);
@@ -1153,10 +1154,10 @@
float frame_prev, frame_next;
float quat_prev[4], quat_next[4], quat_interp[4], quat_orig[4];
- /*int do_scale = 0;
+ int do_scale = 0;
int do_loc = 0;
int do_quat = 0;
- int flag = 0;*/
+ int flag = 0;
int do_x, do_y, do_z;
if (!ob) return;
@@ -1167,36 +1168,25 @@
if (!pose || !act || !arm) return;
- for (pchan=pose->chanbase.first; pchan; pchan= pchan->next){
- if(pchan->bone->layer & arm->layer) {
- if(pchan->bone->flag & BONE_SELECTED) {
+ for (pchan=pose->chanbase.first; pchan; pchan= pchan->next) {
+ if (pchan->bone->layer & arm->layer) {
+ if (pchan->bone->flag & BONE_SELECTED) {
/* do we have an ipo curve? */
achan= get_action_channel(act, pchan->name);
- if(achan && achan->ipo) {
+
+ if (achan && achan->ipo) {
/*calc_ipo(achan->ipo, ctime);*/
do_x = pose_relax_icu(find_ipocurve(achan->ipo, AC_LOC_X), framef, &pchan->loc[0], NULL, NULL);
do_y = pose_relax_icu(find_ipocurve(achan->ipo, AC_LOC_Y), framef, &pchan->loc[1], NULL, NULL);
do_z = pose_relax_icu(find_ipocurve(achan->ipo, AC_LOC_Z), framef, &pchan->loc[2], NULL, NULL);
- /* do_loc = do_x + do_y + do_z */
+ do_loc += do_x + do_y + do_z;
- if (G.flags & G_RECORDKEYS) {
- if (do_x) insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_LOC_X, 0);
- if (do_y) insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_LOC_Y, 0);
- if (do_z) insertkey(&ob->id, ID_PO, pchan->name, NULL, AC_LOC_Z, 0);
- }
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list