void transform_meshchannel_keys(char mode, struct Key *key);
struct Key *get_action_mesh_key(void);
int get_nearest_key_num(struct Key *key, short *mval, float *x);
+void set_snap_actionchannels(void);
/* Handles */
void sethandles_meshchannel_keys(int code, struct Key *key);
void shift_nlastrips_down(void);
void reset_action_strips(int val);
void synchronize_action_strips(void);
+void snap_action_strips(void);
#endif
void ipo_record(void);
void sethandles_ipo_keys(struct Ipo *ipo, int code);
+void snap_ipo_keys(struct Ipo *ipo);
void setipotype_ipo(struct Ipo *ipo, int code);
void set_ipo_key_selection(struct Ipo *ipo, int sel);
int is_ipo_key_selected(struct Ipo *ipo);
allqueue(REDRAWNLA, 0);
}
+
static void delete_actionchannels (void)
{
bConstraintChannel *conchan=NULL, *nextconchan;
allqueue(REDRAWNLA, 0);
}
-void set_ipotype_actionchannels(int ipotype) {
+void set_ipotype_actionchannels(int ipotype)
+{
bAction *act;
bActionChannel *chan;
allqueue(REDRAWNLA, 0);
}
+void set_snap_actionchannels(void)
+{
+
+ bAction *act;
+ bActionChannel *chan;
+
+ /* Get the selected action, exit if none are selected
+ */
+ act = G.saction->action;
+ if (!act)
+ return;
+
+ /* Loop through the channels */
+ for (chan = act->chanbase.first; chan; chan=chan->next){
+ if (chan->ipo) {
+ snap_ipo_keys(chan->ipo);
+ }
+ }
+
+ /* Clean up and redraw stuff */
+ remake_action_ipos (act);
+ BIF_undo_push("Snap Ipo Action channel");
+ allspace(REMAKEIPO, 0);
+ allqueue(REDRAWACTION, 0);
+ allqueue(REDRAWIPO, 0);
+ allqueue(REDRAWNLA, 0);
+}
+
+
static void select_all_keys_frames(bAction *act, short *mval,
short *mvalo, int selectmode) {
case SKEY:
if (mval[0]>=ACTWIDTH) {
- if (key) {
- transform_meshchannel_keys('s', key);
+ if(G.qual & LR_SHIFTKEY) {
+ if(okee("Snap to frame"))
+ set_snap_actionchannels();
}
- else if (act) {
- transform_actionchannel_keys ('s', 0);
+ else {
+ if (key)
+ transform_meshchannel_keys('s', key);
+ else if (act)
+ transform_actionchannel_keys ('s', 0);
}
}
break;
}
break;
}
+}
+static int snap_bezier(BezTriple *bezt)
+{
+ if(bezt->f2 & SELECT)
+ bezt->vec[1][0]= (float)(floor(bezt->vec[1][0]+0.5));
+ return 0;
+}
+void snap_ipo_keys(Ipo *ipo)
+{
+ ipo_keys_bezier_loop(ipo, snap_bezier, calchandles_ipocurve);
}
static void ipo_curves_auto_horiz(void)
allqueue (REDRAWNLA, 0);
}
+void snap_action_strips(void)
+{
+ Base *base;
+ bActionStrip *strip;
+
+ for (base=G.scene->base.first; base; base=base->next) {
+ for (strip = base->object->nlastrips.last; strip; strip=strip->prev) {
+ if (strip->flag & ACTSTRIP_SELECT) {
+ strip->start= floor(strip->start+0.5);
+ }
+ }
+ }
+ BIF_undo_push("Snap NLA strips");
+ allqueue (REDRAWVIEW3D, 0);
+ allqueue (REDRAWACTION, 0);
+ allqueue (REDRAWNLA, 0);
+}
+
void winqreadnlaspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
{
unsigned short event= evt->event;
else if(val==2)
reset_action_strips(2);
}
+ else if(G.qual & LR_SHIFTKEY) {
+ if(okee("Snap Strips to Frame"))
+ snap_action_strips();
+ }
else {
if (mval[0]>=NLAWIDTH)
transform_nlachannel_keys ('s', 0);
#define ACTMENU_KEY_DUPLICATE 0
#define ACTMENU_KEY_DELETE 1
#define ACTMENU_KEY_BAKE 2
+#define ACTMENU_KEY_SNAP 3
#define ACTMENU_KEY_TRANSFORM_MOVE 0
#define ACTMENU_KEY_TRANSFORM_SCALE 1
case ACTMENU_KEY_BAKE:
bake_action_with_client (G.saction->action, OBACT, 0.01);
break;
+ case ACTMENU_KEY_SNAP:
+ set_snap_actionchannels();
+ break;
}
}
uiBlockSetButmFunc(block, do_action_keymenu, NULL);
uiDefIconTextBlockBut(block, action_keymenu_transformmenu,
- NULL, ICON_RIGHTARROW_THIN,
- "Transform", 0, yco-=20, 120, 20, "");
-
+ NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 20, "");
+
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
+ "Snap to Frame|Shift S", 0, yco-=20,
+ menuwidth, 19, NULL, 0.0, 0.0, 0, ACTMENU_KEY_SNAP, "");
+
uiDefBut(block, SEPR, 0, "", 0, yco-=6,
menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
"Duplicate|Shift D", 0, yco-=20,
menuwidth, 19, NULL, 0.0, 0.0, 0,
ACTMENU_KEY_DUPLICATE, "");
+
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
"Delete|X", 0, yco-=20,
menuwidth, 19, NULL, 0.0, 0.0, 0,
case 9: /* reset start/end of action */
reset_action_strips(2);
break;
+ case 10: /* snap to frame */
+ snap_action_strips();
+ break;
}
}
uiDefIconTextBlockBut(block, nla_strip_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 20, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Strip Size|ALT S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Action Start/End|ALT S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Snap to Frame|Shift S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 10, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");