diff options
author | Joshua Leung <aligorith@gmail.com> | 2007-10-22 09:32:17 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2007-10-22 09:32:17 +0400 |
commit | 2cc41ad890326679b47c9931708d3afc3dae300f (patch) | |
tree | d60c5ab96c6c6c50a039b8d8b92a877a164723e6 /source | |
parent | f721ce13fb529f4fde4668c989c786e4c7d7d708 (diff) |
== Action/NLA Transform ==
Added a new auto-snapping mode: snap to nearest marker.
This mode can be toggled using the ALTKEY.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/action.c | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_action_types.h | 96 | ||||
-rw-r--r-- | source/blender/src/header_action.c | 4 | ||||
-rw-r--r-- | source/blender/src/header_nla.c | 4 | ||||
-rw-r--r-- | source/blender/src/transform.c | 37 |
5 files changed, 94 insertions, 49 deletions
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index b04e0240873..d202178fc0a 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -819,7 +819,7 @@ static void extract_ipochannels_from_action(ListBase *lb, ID *id, bAction *act, if(conchan && conchan->ipo) { calc_ipo(conchan->ipo, ctime); - + icu= conchan->ipo->curve.first; // only one ipo now if(icu) { nic= MEM_callocN(sizeof(NlaIpoChannel), "NlaIpoChannel constr"); diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index 5bdb4419b6e..479bb749196 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -35,7 +35,6 @@ #include "DNA_view2d_types.h" struct SpaceLink; -struct ListBase; struct Object; /* PoseChannel stores the results of Actions (ipos) and transform information @@ -130,6 +129,7 @@ typedef struct SpaceAction { short blockhandler[8]; View2D v2d; + bAction *action; /* the currently active action */ short flag, autosnap; /* flag: bitmapped settings; autosnap: automatic keyframe snapping mode */ short pin, actnr, lock; /* pin: keep showing current action; actnr: used for finding chosen action from menu; lock: lock time to other windows */ @@ -138,38 +138,48 @@ typedef struct SpaceAction { } SpaceAction; /* Action Channel flags */ -#define ACHAN_SELECTED 0x00000001 -#define ACHAN_HILIGHTED 0x00000002 -#define ACHAN_HIDDEN 0x00000004 -#define ACHAN_PROTECTED 0x00000008 -#define ACHAN_EXPANDED 0x00000010 -#define ACHAN_SHOWIPO 0x00000020 -#define ACHAN_SHOWCONS 0x00000040 -#define ACHAN_MOVED 0x80000000 +typedef enum ACHAN_FLAG { + ACHAN_SELECTED = (1<<0), + ACHAN_HILIGHTED = (1<<1), + ACHAN_HIDDEN = (1<<2), + ACHAN_PROTECTED = (1<<3), + ACHAN_EXPANDED = (1<<4), + ACHAN_SHOWIPO = (1<<5), + ACHAN_SHOWCONS = (1<<6), + ACHAN_MOVED = (1<<31), +} ACHAN_FLAG; /* SpaceAction flag */ - /* during transform */ -#define SACTION_MOVING 1 - /* show sliders (if relevant) - limited to shape keys for now */ -#define SACTION_SLIDERS 2 - /* draw time in seconds instead of time in frames */ -#define SACTION_DRAWTIME 4 +typedef enum SACTION_FLAG { + /* during transform */ + SACTION_MOVING = (1<<0), + /* show sliders (if relevant) */ + SACTION_SLIDERS = (1<<1), + /* draw time in seconds instead of time in frames */ + SACTION_DRAWTIME = (1<<2) +} SACTION_FLAG; /* SpaceAction AutoSnap Settings (also used by SpaceNLA) */ - /* no auto-snap */ -#define SACTSNAP_OFF 0 - /* snap to 1.0 frame/second intervals */ -#define SACTSNAP_STEP 1 - /* snap to actual frames/seconds (nla-action time) */ -#define SACTSNAP_FRAME 2 +typedef enum SACTSNAP_MODES { + /* no auto-snap */ + SACTSNAP_OFF = 0 + /* snap to 1.0 frame/second intervals */ + SACTSNAP_STEP, + /* snap to actual frames/seconds (nla-action time) */ + SACTSNAP_FRAME, + /* snap to nearest marker */ + SACTSNAP_MARKER, +} SACTSNAP_MODES; /* Pose->flag */ - /* results in armature_rebuild_pose being called */ -#define POSE_RECALC 1 - /* prevents any channel from getting overridden by anim from IPO */ -#define POSE_LOCKED 2 - /* clears the POSE_LOCKED flag for the next time the pose is evaluated */ -#define POSE_DO_UNLOCK 4 +typedef enum POSE_FLAG { + /* results in armature_rebuild_pose being called */ + POSE_RECALC = (1<<0), + /* prevents any channel from getting overridden by anim from IPO */ + POSE_LOCKED = (1<<1), + /* clears the POSE_LOCKED flag for the next time the pose is evaluated */ + POSE_DO_UNLOCK = (1<<2) +} POSE_FLAG; /* PoseChannel (transform) flags */ enum { @@ -189,22 +199,26 @@ enum { }; /* PoseChannel constflag (constraint detection) */ -#define PCHAN_HAS_IK 1 -#define PCHAN_HAS_CONST 2 - /* only used for drawing Posemode, not stored in channel */ -#define PCHAN_HAS_ACTION 4 -#define PCHAN_HAS_TARGET 8 - /* only for drawing Posemode too */ -#define PCHAN_HAS_STRIDE 16 +typedef PCHAN_CONSTFLAG { + PCHAN_HAS_IK = (1<<0), + PCHAN_HAS_CONST = (1<<1), + /* only used for drawing Posemode, not stored in channel */ + PCHAN_HAS_ACTION = (1<<2), + PCHAN_HAS_TARGET = (1<<3), + /* only for drawing Posemode too */ + PCHAN_HAS_STRIDE = (1<<4) +} PCHAN_CONSTFLAG; /* PoseChannel->ikflag */ -#define BONE_IK_NO_XDOF 1 -#define BONE_IK_NO_YDOF 2 -#define BONE_IK_NO_ZDOF 4 - -#define BONE_IK_XLIMIT 8 -#define BONE_IK_YLIMIT 16 -#define BONE_IK_ZLIMIT 32 +typedef PCHAN_IKFLAG { + BONE_IK_NO_XDOF = (1<<0), + BONE_IK_NO_YDOF = (1<<1), + BONE_IK_NO_ZDOF = (1<<2), + + BONE_IK_XLIMIT = (1<<3), + BONE_IK_YLIMIT = (1<<4), + BONE_IK_ZLIMIT = (1<<5) +} PCHAN_IKFLAG; #endif diff --git a/source/blender/src/header_action.c b/source/blender/src/header_action.c index a305607faad..c6d1b88c95c 100644 --- a/source/blender/src/header_action.c +++ b/source/blender/src/header_action.c @@ -1195,13 +1195,13 @@ void action_buttons(void) if (G.saction->flag & SACTION_DRAWTIME) { uiDefButS(block, MENU, B_REDR, - "Auto-Snap Keyframes %t|Off %x0|Second Step %x1|Nearest Second %x2", + "Auto-Snap Keyframes %t|Off %x0|Second Step %x1|Nearest Second %x2|Nearest Marker %x3", xco,0,70,YIC, &(G.saction->autosnap), 0, 1, 0, 0, "Auto-snapping mode for keyframes when transforming"); } else { uiDefButS(block, MENU, B_REDR, - "Auto-Snap Keyframes %t|Off %x0|Frame Step %x1|Nearest Frame %x2", + "Auto-Snap Keyframes %t|Off %x0|Frame Step %x1|Nearest Frame %x2|Nearest Marker %x3", xco,0,70,YIC, &(G.saction->autosnap), 0, 1, 0, 0, "Auto-snapping mode for keyframes when transforming"); } diff --git a/source/blender/src/header_nla.c b/source/blender/src/header_nla.c index 297e21ef2f6..3a3d3dfdb49 100644 --- a/source/blender/src/header_nla.c +++ b/source/blender/src/header_nla.c @@ -507,13 +507,13 @@ void nla_buttons(void) if (G.snla->flag & SNLA_DRAWTIME) { uiDefButS(block, MENU, B_REDR, - "Auto-Snap Strips/Keyframes %t|Off %x0|Second Step %x1|Nearest Second %x2", + "Auto-Snap Strips/Keyframes %t|Off %x0|Second Step %x1|Nearest Second %x2|Nearest Marker %x3", xco,0,70,YIC, &(G.snla->autosnap), 0, 1, 0, 0, "Auto-snapping mode for strips and keyframes when transforming"); } else { uiDefButS(block, MENU, B_REDR, - "Auto-Snap Strips/Keyframes %t|Off %x0|Frame Step %x1|Nearest Frame %x2", + "Auto-Snap Strips/Keyframes %t|Off %x0|Frame Step %x1|Nearest Frame %x2|Nearest Marker %x3", xco,0,70,YIC, &(G.snla->autosnap), 0, 1, 0, 0, "Auto-snapping mode for strips and keyframes when transforming"); } diff --git a/source/blender/src/transform.c b/source/blender/src/transform.c index bf63442a2cd..fa87a054293 100644 --- a/source/blender/src/transform.c +++ b/source/blender/src/transform.c @@ -3373,6 +3373,8 @@ static short getAnimEdit_SnapMode(TransInfo *t) autosnap= SACTSNAP_STEP; else if (G.qual == LR_SHIFTKEY) autosnap= SACTSNAP_FRAME; + else if (G.qual == LR_ALTKEY) + autosnap= SACTSNAP_MARKER; else autosnap= SACTSNAP_OFF; break; @@ -3382,6 +3384,9 @@ static short getAnimEdit_SnapMode(TransInfo *t) case SACTSNAP_FRAME: autosnap= (G.qual==LR_SHIFTKEY)? SACTSNAP_OFF: SACTSNAP_FRAME; break; + case SACTSNAP_MARKER: + autosnap= (G.qual==LR_ALTKEY)? SACTSNAP_OFF: SACTSNAP_MARKER; + break; } } else if (t->spacetype == SPACE_NLA && G.snla) { @@ -3391,6 +3396,8 @@ static short getAnimEdit_SnapMode(TransInfo *t) autosnap= SACTSNAP_STEP; else if (G.qual == LR_SHIFTKEY) autosnap= SACTSNAP_FRAME; + else if (G.qual == LR_ALTKEY) + autosnap= SACTSNAP_MARKER; else autosnap= SACTSNAP_OFF; break; @@ -3400,6 +3407,9 @@ static short getAnimEdit_SnapMode(TransInfo *t) case SACTSNAP_FRAME: autosnap= (G.qual==LR_SHIFTKEY)? SACTSNAP_OFF: SACTSNAP_FRAME; break; + case SACTSNAP_MARKER: + autosnap= (G.qual==LR_ALTKEY)? SACTSNAP_OFF: SACTSNAP_MARKER; + break; } } else { @@ -3407,6 +3417,8 @@ static short getAnimEdit_SnapMode(TransInfo *t) autosnap= SACTSNAP_STEP; else if (G.qual == LR_SHIFTKEY) autosnap= SACTSNAP_FRAME; + else if (G.qual == LR_ALTKEY) + autosnap= SACTSNAP_MARKER; else autosnap= SACTSNAP_OFF; } @@ -3438,7 +3450,7 @@ static short getAnimEdit_DrawTime(TransInfo *t) /* This function is used by Animation Editor specific transform functions to do - * the Snap Keyframe to Nearest Keyframe + * the Snap Keyframe to Nearest Frame/Marker */ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, Object *ob, short autosnap) { @@ -3466,6 +3478,25 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, Object *ob, short else *(td->val)= val; } + /* snap key to nearest marker? */ + else if (autosnap == SACTSNAP_MARKER) { + float val; + + /* convert frame to nla-action time (if needed) */ + if (ob) + val= get_action_frame_inv(ob, *(td->val)); + else + val= *(td->val); + + /* snap to nearest marker */ + val= (float)find_nearest_marker_time(val); + + /* convert frame out of nla-action time */ + if (ob) + *(td->val)= get_action_frame(ob, val); + else + *(td->val)= val; + } } /* ----------------- Translation ----------------------- */ @@ -3578,7 +3609,7 @@ static void applyTimeTranslate(TransInfo *t, float sval) *(td->val) = td->ival + val; } - /* apply snap-to-nearest-frame? */ + /* apply nearest snapping */ doAnimEdit_SnapFrame(t, td, ob, autosnap); } } @@ -3797,7 +3828,7 @@ static void applyTimeScale(TransInfo *t) { *(td->val) *= fac; *(td->val) += startx; - /* apply snap-to-nearest-frame? */ + /* apply nearest snapping */ doAnimEdit_SnapFrame(t, td, ob, autosnap); } } |