forked from bartvdbraak/blender
NLA & Action goodies;
-> Locked Strip length When changing time of the animation curves in an Action, the strips in NLA just remained the same length, causing very confusing situations. By setting the strips to Locked (Nkey NLA window), it always updates the strip length to make sure all keys are included, and not more. From now on (not on old files) this is the default strip method. -> ALT+C clear size This menu has 2 options, the first clears the size, the 2nd remaps the action (only when you didnt use the new Lock feature). Both options are in the Pulldown menu too -> Key drawing The weird beveled button in Action/NLA didn't accurately show what time it was actually on. I've replaced it with an Icon now, diamond shaped, in a design derived from the TimeLine markers.
This commit is contained in:
parent
8fc7950455
commit
2d960cea74
@ -47,8 +47,12 @@ void borderselect_nla(void);
|
||||
void deselect_nlachannel_keys (int test);
|
||||
void deselect_nlachannels(int test);
|
||||
|
||||
/* NLA Strip operationa */
|
||||
/* NLA Strip operations */
|
||||
void shift_nlastrips_up(void);
|
||||
void shift_nlastrips_down(void);
|
||||
void reset_action_strips(int val);
|
||||
void synchronize_action_strips(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -56,11 +56,13 @@ typedef struct bActionStrip {
|
||||
#define ACTSTRIPMODE_BLEND 0
|
||||
#define ACTSTRIPMODE_ADD 1
|
||||
|
||||
/* strip->flag */
|
||||
#define ACTSTRIP_SELECT 0x01
|
||||
#define ACTSTRIP_USESTRIDE 0x02
|
||||
#define ACTSTRIP_BLENDTONEXT 0x04
|
||||
#define ACTSTRIP_HOLDLASTFRAME 0x08
|
||||
#define ACTSTRIP_ACTIVE 0x10
|
||||
#define ACTSTRIP_LOCK_ACTION 0x20
|
||||
|
||||
#endif
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -686,42 +686,54 @@ void drawactionspace(ScrArea *sa, void *spacedata)
|
||||
curarea->win_swap= WIN_BACK_OK;
|
||||
}
|
||||
|
||||
|
||||
/** Draw a nicely beveled button (in screen space) */
|
||||
static void draw_bevel_but(int x, int y, int w, int h, int sel)
|
||||
#if 0
|
||||
/** Draw a nicely beveled diamond shape (in screen space) */
|
||||
static void draw_key_but(int x, int y, int w, int h, int sel)
|
||||
{
|
||||
int xmin= x, ymin= y;
|
||||
int xmax= x+w-1, ymax= y+h-1;
|
||||
|
||||
/* outline */
|
||||
glColor3ub(0,0,0);
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex2i(xmin, ymin);
|
||||
glVertex2i(xmax, ymin);
|
||||
glVertex2i(xmax, ymax);
|
||||
glVertex2i(xmin, ymax);
|
||||
glEnd();
|
||||
int xc= (xmin+xmax)/2, yc= (ymin+ymax)/2;
|
||||
|
||||
/* interior */
|
||||
if (sel) glColor3ub(0xF1, 0xCA, 0x13);
|
||||
else glColor3ub(0xAC, 0xAC, 0xAC);
|
||||
glRectf(xmin+1, ymin+1, xmax-1, ymax-1);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2i(xc, ymin);
|
||||
glVertex2i(xmax, yc);
|
||||
glVertex2i(xc, ymax);
|
||||
glVertex2i(xmin, yc);
|
||||
glEnd();
|
||||
|
||||
|
||||
/* bevel */
|
||||
glBegin(GL_LINE_LOOP);
|
||||
|
||||
if (sel) glColor3ub(0xD0, 0x7E, 0x06);
|
||||
else glColor3ub(0x8C, 0x8C, 0x8C);
|
||||
glVertex2i(xmax-1, ymin+1);
|
||||
glVertex2i(xmax-1, ymax-1);
|
||||
/* under */
|
||||
glVertex2i(xc, ymin+1);
|
||||
glVertex2i(xmax-1, yc);
|
||||
|
||||
if (sel) glColor3ub(0xF4, 0xEE, 0x8E);
|
||||
else glColor3ub(0xDF, 0xDF, 0xDF);
|
||||
glVertex2i(xmin+1, ymax-1);
|
||||
glVertex2i(xmin+1, ymin+1);
|
||||
/* top */
|
||||
glVertex2i(xc, ymax-1);
|
||||
glVertex2i(xmin+1, yc);
|
||||
glEnd();
|
||||
|
||||
/* outline */
|
||||
glColor3ub(0,0,0);
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex2i(xc, ymin);
|
||||
glVertex2i(xmax, yc);
|
||||
glVertex2i(xc, ymax);
|
||||
glVertex2i(xmin, yc);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void draw_keylist(gla2DDrawInfo *di, int totvert, BezTriple **blist, float ypos)
|
||||
{
|
||||
int v;
|
||||
@ -729,13 +741,20 @@ static void draw_keylist(gla2DDrawInfo *di, int totvert, BezTriple **blist, floa
|
||||
if (!blist)
|
||||
return;
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
for (v = 0; v<totvert; v++){
|
||||
if (v==0 || (blist[v]->vec[1][0] != blist[v-1]->vec[1][0])){
|
||||
int sc_x, sc_y;
|
||||
gla2DDrawTranslatePt(di, blist[v]->vec[1][0], ypos, &sc_x, &sc_y);
|
||||
draw_bevel_but(sc_x-2, sc_y-7, 7, 13, (blist[v]->f2 & 1));
|
||||
// draw_key_but(sc_x-5, sc_y-6, 13, 13, (blist[v]->f2 & 1));
|
||||
|
||||
if(blist[v]->f2 & 1) BIF_draw_icon_blended(sc_x-7, sc_y-6, ICON_SPACE2, TH_HEADER, 0);
|
||||
else BIF_draw_icon_blended(sc_x-7, sc_y-6, ICON_SPACE3, TH_HEADER, 0);
|
||||
|
||||
}
|
||||
}
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
void draw_object_channel(gla2DDrawInfo *di, Object *ob, int flags, float ypos)
|
||||
|
@ -65,13 +65,14 @@
|
||||
#include "BSE_editnla_types.h"
|
||||
#include "BSE_headerbuttons.h"
|
||||
|
||||
#include "BIF_editnla.h"
|
||||
#include "BIF_gl.h"
|
||||
#include "BIF_glutil.h"
|
||||
#include "BIF_interface.h"
|
||||
#include "BIF_mywindow.h"
|
||||
#include "BIF_resources.h"
|
||||
#include "BIF_screen.h"
|
||||
#include "BIF_mywindow.h"
|
||||
#include "BIF_space.h"
|
||||
#include "BIF_interface.h"
|
||||
#include "BIF_glutil.h"
|
||||
|
||||
#include "BDR_drawaction.h"
|
||||
#include "BDR_editcurve.h"
|
||||
@ -327,21 +328,21 @@ static void draw_nla_strips_keys(SpaceNla *snla)
|
||||
}
|
||||
|
||||
/* Draw border */
|
||||
glEnable (GL_BLEND);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glColor4f(1, 1, 1, 0.5);
|
||||
glColor4f(1, 1, 1, 0.7);
|
||||
gla2DDrawTranslatePt(di, strip->start, y, &stripstart, &channel_y);
|
||||
gla2DDrawTranslatePt(di, strip->end, y, &stripend, &channel_y);
|
||||
|
||||
glVertex2f(stripstart, channel_y-NLACHANNELHEIGHT/2+3);
|
||||
glVertex2f(stripstart, channel_y+NLACHANNELHEIGHT/2-3);
|
||||
glVertex2f(stripend, channel_y+NLACHANNELHEIGHT/2-3);
|
||||
glColor4f(0, 0, 0, 0.5);
|
||||
glColor4f(0, 0, 0, 0.7);
|
||||
glVertex2f(stripend, channel_y-NLACHANNELHEIGHT/2+3);
|
||||
glVertex2f(stripstart, channel_y-NLACHANNELHEIGHT/2+3);
|
||||
glEnd();
|
||||
|
||||
glEnable (GL_BLEND);
|
||||
|
||||
/* Show strip extension */
|
||||
if (strip->flag & ACTSTRIP_HOLDLASTFRAME){
|
||||
if (strip->flag & ACTSTRIP_SELECT)
|
||||
@ -384,6 +385,7 @@ static void draw_nla_strips_keys(SpaceNla *snla)
|
||||
/* ******* panel *********** */
|
||||
|
||||
#define B_NLA_PANEL 121
|
||||
#define B_NLA_LOCK 122
|
||||
|
||||
/* For now just returns the first selected strip */
|
||||
bActionStrip *get_active_nlastrip(void)
|
||||
@ -435,7 +437,12 @@ void do_nlabuts(unsigned short event)
|
||||
update_for_newframe_muted();
|
||||
allqueue (REDRAWNLA, 0);
|
||||
allqueue (REDRAWVIEW3D, 0);
|
||||
|
||||
break;
|
||||
case B_NLA_LOCK:
|
||||
synchronize_action_strips();
|
||||
allqueue (REDRAWNLA, 0);
|
||||
allqueue (REDRAWACTION, 0);
|
||||
allqueue (REDRAWVIEW3D, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -461,13 +468,22 @@ static void nla_panel_properties(short cntrl) // NLA_HANDLER_PROPERTIES
|
||||
uiDefBut(block, LABEL, 0, "Options:", 10,60,300,19, 0, 0, 0, 0, 0, "");
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefButF(block, NUM, B_REDR, "Strip Start:", 10,160,150,19, &strip->start, -1000.0, MAXFRAMEF, 100, 0, "First frame in the timeline");
|
||||
uiDefButF(block, NUM, B_REDR, "Strip End:", 160,160,150,19, &strip->end, -1000.0, MAXFRAMEF, 100, 0, "Last frame in the timeline");
|
||||
uiDefButF(block, NUM, B_REDR, "Strip Start:", 10,160,150,19, &strip->start, -1000.0, strip->end-1, 100, 0, "First frame in the timeline");
|
||||
uiDefButF(block, NUM, B_REDR, "Strip End:", 160,160,150,19, &strip->end, strip->start+1, MAXFRAMEF, 100, 0, "Last frame in the timeline");
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefButF(block, NUM, B_REDR, "Action Start:", 10,120,150,19, &strip->actstart, -1000.0, MAXFRAMEF, 100, 0, "First frame of the action to map to the playrange");
|
||||
uiDefButF(block, NUM, B_REDR, "Action End:", 160,120,150,19, &strip->actend, -1000.0, MAXFRAMEF, 100, 0, "Last frame of the action to map to the playrange");
|
||||
|
||||
uiDefIconButBitS(block, ICONTOG, ACTSTRIP_LOCK_ACTION, B_NLA_LOCK, ICON_UNLOCKED, 10,120,20,19, &(strip->flag), 0, 0, 0, 0, "Toggles Action end/start to be automatic mapped to strip duration");
|
||||
if(strip->flag & ACTSTRIP_LOCK_ACTION) {
|
||||
char str[40];
|
||||
sprintf(str, "Action Start: %.2f", strip->actstart);
|
||||
uiDefBut(block, LABEL, B_NOP, str, 30,120,140,19, NULL, 0.0, 0.0, 0, 0, "First frame of the action to map to the playrange");
|
||||
sprintf(str, "Action End: %.2f", strip->actend);
|
||||
uiDefBut(block, LABEL, B_NOP, str, 170,120,140,19, NULL, 0.0, 0.0, 0, 0, "Last frame of the action to map to the playrange");
|
||||
}
|
||||
else {
|
||||
uiDefButF(block, NUM, B_REDR, "Action Start:", 30,120,140,19, &strip->actstart, -1000.0, strip->actend-1, 100, 0, "First frame of the action to map to the playrange");
|
||||
uiDefButF(block, NUM, B_REDR, "Action End:", 170,120,140,19, &strip->actend, strip->actstart+1, MAXFRAMEF, 100, 0, "Last frame of the action to map to the playrange");
|
||||
}
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefButF(block, NUM, B_REDR, "Blendin:", 10,80,150,19, &strip->blendin, 0.0, strip->actend-strip->actstart, 100, 0, "Number of frames of ease-in");
|
||||
uiDefButF(block, NUM, B_REDR, "Blendout:", 160,80,150,19, &strip->blendout, 0.0, strip->actend-strip->actstart, 100, 0, "Number of frames of ease-out");
|
||||
|
@ -72,8 +72,9 @@
|
||||
|
||||
#include "BIF_butspace.h"
|
||||
#include "BIF_editaction.h"
|
||||
#include "BIF_editview.h"
|
||||
#include "BIF_editarmature.h"
|
||||
#include "BIF_editnla.h"
|
||||
#include "BIF_editview.h"
|
||||
#include "BIF_gl.h"
|
||||
#include "BIF_interface.h"
|
||||
#include "BIF_mywindow.h"
|
||||
@ -256,6 +257,7 @@ void select_actionchannel_by_name (bAction *act, char *name, int select)
|
||||
}
|
||||
}
|
||||
|
||||
/* called on changing action ipos or keys */
|
||||
void remake_action_ipos(bAction *act)
|
||||
{
|
||||
bActionChannel *chan;
|
||||
@ -278,6 +280,8 @@ void remake_action_ipos(bAction *act)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
synchronize_action_strips();
|
||||
}
|
||||
|
||||
static void remake_meshaction_ipos(Ipo *ipo)
|
||||
|
@ -86,6 +86,7 @@
|
||||
#include "BIF_editaction.h"
|
||||
#include "BIF_editconstraint.h"
|
||||
#include "BIF_editkey.h"
|
||||
#include "BIF_editnla.h"
|
||||
#include "BIF_editseq.h"
|
||||
#include "BIF_editview.h"
|
||||
#include "BIF_interface.h"
|
||||
@ -224,7 +225,6 @@ void editipo_changed(SpaceIpo *si, int doredraw)
|
||||
if(ei==0)
|
||||
return;
|
||||
|
||||
|
||||
for(a=0; a<si->totipo; a++, ei++) {
|
||||
|
||||
if(ei->icu) {
|
||||
@ -333,6 +333,9 @@ void editipo_changed(SpaceIpo *si, int doredraw)
|
||||
}
|
||||
|
||||
if(si->showkey) make_ipokey();
|
||||
|
||||
if(si->actname[0])
|
||||
synchronize_action_strips();
|
||||
}
|
||||
|
||||
void scale_editipo(void)
|
||||
|
@ -176,7 +176,33 @@ void shift_nlastrips_down(void) {
|
||||
allqueue (REDRAWNLA, 0);
|
||||
}
|
||||
|
||||
static void reset_action_strips(void)
|
||||
void synchronize_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_LOCK_ACTION) {
|
||||
float actstart = calc_action_start(strip->act);
|
||||
float actend = calc_action_end(strip->act);
|
||||
|
||||
if(strip->actstart!=actstart || strip->actend!=actend) {
|
||||
float mapping= (strip->end - strip->start)/(strip->actend - strip->actstart);
|
||||
|
||||
strip->start+= mapping*(actstart - strip->actstart);
|
||||
strip->end+= mapping*(actend - strip->actend);
|
||||
|
||||
strip->actstart= actstart;
|
||||
strip->actend= actend;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void reset_action_strips(int val)
|
||||
{
|
||||
Base *base;
|
||||
bActionStrip *strip;
|
||||
@ -184,12 +210,22 @@ static void reset_action_strips(void)
|
||||
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) {
|
||||
if(val==2) {
|
||||
strip->actstart = calc_action_start(strip->act);
|
||||
strip->actend = calc_action_end(strip->act);
|
||||
}
|
||||
else if(val==1) {
|
||||
float mapping= (strip->actend - strip->actstart)/(strip->end - strip->start);
|
||||
|
||||
strip->end= strip->start + mapping*(strip->end - strip->start);
|
||||
}
|
||||
DAG_object_flush_update(G.scene, base->object, OB_RECALC_OB|OB_RECALC_DATA);
|
||||
}
|
||||
}
|
||||
}
|
||||
BIF_undo_push("Reset NLA strips");
|
||||
allqueue (REDRAWVIEW3D, 0);
|
||||
allqueue (REDRAWACTION, 0);
|
||||
allqueue (REDRAWNLA, 0);
|
||||
}
|
||||
|
||||
@ -291,8 +327,11 @@ void winqreadnlaspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
||||
|
||||
case SKEY:
|
||||
if(G.qual==LR_ALTKEY) {
|
||||
if(okee("Reset Action Strips start/end"))
|
||||
reset_action_strips();
|
||||
val= pupmenu("Action Strip Scale%t|Clear Strip Size%x1|Remap Start/End%x2");
|
||||
if(val==1)
|
||||
reset_action_strips(1);
|
||||
else if(val==2)
|
||||
reset_action_strips(2);
|
||||
}
|
||||
else {
|
||||
if (mval[0]>=NLAWIDTH)
|
||||
@ -459,7 +498,7 @@ static void convert_nla(short mval[2])
|
||||
nstrip->actend = calc_action_end(base->object->action);
|
||||
nstrip->start = nstrip->actstart;
|
||||
nstrip->end = nstrip->actend;
|
||||
nstrip->flag = ACTSTRIP_SELECT;
|
||||
nstrip->flag = ACTSTRIP_SELECT|ACTSTRIP_LOCK_ACTION;
|
||||
set_active_strip(base->object, nstrip);
|
||||
|
||||
nstrip->repeat = 1.0;
|
||||
@ -514,7 +553,7 @@ static void add_nla_block(short event)
|
||||
if(strip->start>strip->end-2)
|
||||
strip->end= strip->start+100;
|
||||
|
||||
strip->flag = ACTSTRIP_SELECT;
|
||||
strip->flag = ACTSTRIP_SELECT|ACTSTRIP_LOCK_ACTION;
|
||||
set_active_strip(nla_base->object, strip);
|
||||
|
||||
strip->repeat = 1.0;
|
||||
@ -1050,6 +1089,8 @@ void transform_nlachannel_keys(int mode, int dummy)
|
||||
firsttime= 0;
|
||||
}
|
||||
|
||||
synchronize_action_strips();
|
||||
|
||||
if(cancel==0) BIF_undo_push("Select all NLA");
|
||||
recalc_all_ipos(); // bad
|
||||
allqueue (REDRAWVIEW3D, 0);
|
||||
@ -1098,6 +1139,8 @@ void delete_nlachannel_keys(void)
|
||||
}
|
||||
}
|
||||
|
||||
synchronize_action_strips();
|
||||
|
||||
BIF_undo_push("Delete NLA keys");
|
||||
recalc_all_ipos(); // bad
|
||||
allspace(REMAKEIPO,0);
|
||||
|
@ -267,6 +267,12 @@ static void do_nla_stripmenu(void *arg, int event)
|
||||
case 7: /* Move Down */
|
||||
shift_nlastrips_down();
|
||||
break;
|
||||
case 8: /* size */
|
||||
reset_action_strips(1);
|
||||
break;
|
||||
case 9: /* reset start/end of action */
|
||||
reset_action_strips(2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -280,13 +286,14 @@ static uiBlock *nla_stripmenu(void *arg_unused)
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Strip Properties...|N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
|
||||
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, "");
|
||||
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
// uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Add Action Strip|Shift A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Duplicate|Shift D", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete|X", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, "");
|
||||
// uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user