Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/include/BIF_editaction.h1
-rw-r--r--source/blender/include/BIF_editnla.h1
-rw-r--r--source/blender/include/BSE_editipo.h1
-rw-r--r--source/blender/src/editaction.c45
-rw-r--r--source/blender/src/editipo_mods.c10
-rw-r--r--source/blender/src/editnla.c22
-rw-r--r--source/blender/src/header_action.c14
-rw-r--r--source/blender/src/header_nla.c4
8 files changed, 90 insertions, 8 deletions
diff --git a/source/blender/include/BIF_editaction.h b/source/blender/include/BIF_editaction.h
index 47ffb3fea00..3ca0bbdb1f8 100644
--- a/source/blender/include/BIF_editaction.h
+++ b/source/blender/include/BIF_editaction.h
@@ -71,6 +71,7 @@ void transform_actionchannel_keys(int mode, int dummy);
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);
diff --git a/source/blender/include/BIF_editnla.h b/source/blender/include/BIF_editnla.h
index b9ccfc60379..1b62de6a317 100644
--- a/source/blender/include/BIF_editnla.h
+++ b/source/blender/include/BIF_editnla.h
@@ -52,6 +52,7 @@ void shift_nlastrips_up(void);
void shift_nlastrips_down(void);
void reset_action_strips(int val);
void synchronize_action_strips(void);
+void snap_action_strips(void);
#endif
diff --git a/source/blender/include/BSE_editipo.h b/source/blender/include/BSE_editipo.h
index 4b3dbc283c4..729e49e2e8d 100644
--- a/source/blender/include/BSE_editipo.h
+++ b/source/blender/include/BSE_editipo.h
@@ -132,6 +132,7 @@ void sampledata_to_ipocurve(float *data, int sfra, int efra, struct IpoCurve *ic
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);
diff --git a/source/blender/src/editaction.c b/source/blender/src/editaction.c
index 0ba59b07337..bd7e978daec 100644
--- a/source/blender/src/editaction.c
+++ b/source/blender/src/editaction.c
@@ -1542,6 +1542,7 @@ void delete_actionchannel_keys(void)
allqueue(REDRAWNLA, 0);
}
+
static void delete_actionchannels (void)
{
bConstraintChannel *conchan=NULL, *nextconchan;
@@ -1641,7 +1642,8 @@ void sethandles_actionchannel_keys(int code)
allqueue(REDRAWNLA, 0);
}
-void set_ipotype_actionchannels(int ipotype) {
+void set_ipotype_actionchannels(int ipotype)
+{
bAction *act;
bActionChannel *chan;
@@ -1687,6 +1689,35 @@ void set_ipotype_actionchannels(int ipotype) {
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) {
@@ -2152,11 +2183,15 @@ void winqreadactionspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
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;
diff --git a/source/blender/src/editipo_mods.c b/source/blender/src/editipo_mods.c
index 468e49b3ec8..fc890a8bd9f 100644
--- a/source/blender/src/editipo_mods.c
+++ b/source/blender/src/editipo_mods.c
@@ -549,8 +549,18 @@ void sethandles_ipo_keys(Ipo *ipo, int code)
}
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)
diff --git a/source/blender/src/editnla.c b/source/blender/src/editnla.c
index 790494d9d44..00857d3c841 100644
--- a/source/blender/src/editnla.c
+++ b/source/blender/src/editnla.c
@@ -230,6 +230,24 @@ void reset_action_strips(int val)
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;
@@ -334,6 +352,10 @@ void winqreadnlaspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
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);
diff --git a/source/blender/src/header_action.c b/source/blender/src/header_action.c
index 55617c0bed5..cd3628ef857 100644
--- a/source/blender/src/header_action.c
+++ b/source/blender/src/header_action.c
@@ -91,6 +91,7 @@
#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
@@ -607,6 +608,9 @@ static void do_action_keymenu(void *arg, int event)
case ACTMENU_KEY_BAKE:
bake_action_with_client (G.saction->action, OBACT, 0.01);
break;
+ case ACTMENU_KEY_SNAP:
+ set_snap_actionchannels();
+ break;
}
}
@@ -620,9 +624,12 @@ static uiBlock *action_keymenu(void *arg_unused)
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, "");
@@ -630,6 +637,7 @@ static uiBlock *action_keymenu(void *arg_unused)
"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,
diff --git a/source/blender/src/header_nla.c b/source/blender/src/header_nla.c
index 1f885c67215..636334e2e9a 100644
--- a/source/blender/src/header_nla.c
+++ b/source/blender/src/header_nla.c
@@ -273,6 +273,9 @@ static void do_nla_stripmenu(void *arg, int event)
case 9: /* reset start/end of action */
reset_action_strips(2);
break;
+ case 10: /* snap to frame */
+ snap_action_strips();
+ break;
}
}
@@ -288,6 +291,7 @@ static uiBlock *nla_stripmenu(void *arg_unused)
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, "");