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/src/SConscript4
-rw-r--r--source/blender/src/buttons_object.c175
-rw-r--r--source/blender/src/drawaction.c166
-rw-r--r--source/blender/src/drawipo.c55
-rw-r--r--source/blender/src/drawnla.c419
-rw-r--r--source/blender/src/drawtime.c17
-rw-r--r--source/blender/src/editaction.c291
-rw-r--r--source/blender/src/editarmature.c2
-rw-r--r--source/blender/src/editconstraint.c31
-rw-r--r--source/blender/src/editipo.c3702
-rw-r--r--source/blender/src/editipo_lib.c309
-rw-r--r--source/blender/src/editipo_mods.c1115
-rw-r--r--source/blender/src/editkey.c16
-rw-r--r--source/blender/src/editnla.c998
-rw-r--r--source/blender/src/editobject.c7
-rw-r--r--source/blender/src/editview.c12
-rw-r--r--source/blender/src/glutil.c22
-rw-r--r--source/blender/src/header_action.c40
-rw-r--r--source/blender/src/header_ipo.c325
-rw-r--r--source/blender/src/header_nla.c4
-rw-r--r--source/blender/src/headerbuttons.c156
-rw-r--r--source/blender/src/poseobject.c23
-rw-r--r--source/blender/src/resources.c10
-rw-r--r--source/blender/src/space.c4
-rwxr-xr-xsource/blender/src/transform_conversions.c46
-rw-r--r--source/blender/src/usiblender.c11
26 files changed, 4021 insertions, 3939 deletions
diff --git a/source/blender/src/SConscript b/source/blender/src/SConscript
index 7c745b251da..e2deaa47544 100644
--- a/source/blender/src/SConscript
+++ b/source/blender/src/SConscript
@@ -23,7 +23,7 @@ source_files = ['B.blend.c',
'cmovie.tga.c',
'cursors.c',
'drawaction.c',
- 'drawarmature.c',
+ 'drawarmature.c',
'drawdeps.c',
'drawimage.c',
'drawimasel.c',
@@ -50,6 +50,8 @@ source_files = ['B.blend.c',
'editgroup.c',
'editimasel.c',
'editipo.c',
+ 'editipo_lib.c',
+ 'editipo_mods.c',
'editkey.c',
'editlattice.c',
'editmball.c',
diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c
index 54024d0dee9..cd382f6e89f 100644
--- a/source/blender/src/buttons_object.c
+++ b/source/blender/src/buttons_object.c
@@ -59,7 +59,7 @@
#include "BSE_headerbuttons.h"
#include "BIF_butspace.h"
-#include "BDR_editcurve.h"
+#include "BIF_editaction.h"
#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "BIF_graphics.h"
@@ -74,6 +74,7 @@
#include "BIF_toolbox.h"
#include "BDR_drawobject.h"
+#include "BDR_editcurve.h"
#include "mydevice.h"
#include "blendef.h"
@@ -131,7 +132,10 @@
#include "LBM_fluidsim.h"
#include "BIF_editconstraint.h"
+
#include "BSE_editipo.h"
+#include "BSE_edit.h"
+
#include "BDR_editobject.h"
#include "butspace.h" // own module
@@ -162,8 +166,8 @@ static void constraint_active_func(void *ob_v, void *con_v)
}
/* make sure ipowin and buttons shows it */
- if(ob->ipowin==IPO_CO) {
- allqueue(REDRAWIPO, IPO_CO);
+ if(ob->ipowin==ID_CO) {
+ allqueue(REDRAWIPO, ID_CO);
allspace(REMAKEIPO, 0);
allqueue(REDRAWNLA, 0);
}
@@ -185,38 +189,44 @@ static void add_constraint_to_active(Object *ob, bConstraint *con)
}
}
+/* returns base ID for Ipo, sets actname to channel if appropriate */
+/* should not make action... */
+static void get_constraint_ipo_context(Object *ob, char *actname)
+{
+
+ /* todo; check object if it has ob-level action ipo */
+
+ if (ob->flag & OB_POSEMODE) {
+ bPoseChannel *pchan;
+
+ pchan = get_active_posechannel(ob);
+ if (pchan) {
+ BLI_strncpy(actname, pchan->name, 32);
+ }
+ }
+ else if(ob->ipoflag & OB_ACTION_OB)
+ strcpy(actname, "Object");
+}
+
+/* initialize UI to show Ipo window and make sure channels etc exist */
static void enable_constraint_ipo_func (void *ob_v, void *con_v)
{
Object *ob= ob_v;
bConstraint *con = con_v;
- bConstraintChannel *chan;
- ListBase *conbase;
-
+ char actname[32]="";
+
+ /* verifies if active constraint is set and shown in UI */
constraint_active_func(ob_v, con_v);
-
- conbase = get_active_constraint_channels(ob, 1); // 1 == create
-
- if (!conbase)
- return;
-
- /* See if this list already has an appropriate channel */
- chan = find_constraint_channel(conbase, con->name);
-
- if (!chan){
- /* Add a new constraint channel */
- chan = MEM_callocN(sizeof(bConstraintChannel), "constraintChannel");
- strcpy(chan->name, con->name);
- BLI_addtail(conbase, chan);
- }
-
- /* Ensure there is an ipo to display */
- if (!chan->ipo){
- chan->ipo = add_ipo(con->name, IPO_CO);
- }
-
+
+ /* the context */
+ get_constraint_ipo_context(ob, actname);
+
+ /* adds ipo & channels & curve if needed */
+ verify_ipo((ID *)ob, ID_CO, actname, con->name);
+
/* make sure ipowin shows it */
- ob->ipowin= IPO_CO;
- allqueue(REDRAWIPO, IPO_CO);
+ ob->ipowin= ID_CO;
+ allqueue(REDRAWIPO, ID_CO);
allspace(REMAKEIPO, 0);
allqueue(REDRAWNLA, 0);
}
@@ -226,38 +236,23 @@ static void add_influence_key_to_constraint_func (void *ob_v, void *con_v)
{
Object *ob= ob_v;
bConstraint *con = con_v;
- bConstraintChannel *chan;
- ListBase *conbase;
IpoCurve *icu;
+ char actname[32]="";
+ /* verifies if active constraint is set and shown in UI */
constraint_active_func(ob_v, con_v);
- conbase = get_active_constraint_channels(ob, 1); // 1=make
-
- if (!conbase)
- return;
-
- /* See if this list already has an appropriate channel */
- chan = find_constraint_channel(conbase, con->name);
-
- if (!chan){
- /* Add a new constraint channel */
- chan = MEM_callocN(sizeof(bConstraintChannel), "constraintChannel");
- strcpy(chan->name, con->name);
- BLI_addtail(conbase, chan);
- }
- /* Ensure there is an ipo to display */
- if (!chan->ipo){
- chan->ipo = add_ipo(con->name, IPO_CO);
- }
-
- /* now insert an ipo key */
- icu= get_ipocurve(NULL, IPO_CO, CO_ENFORCE, chan->ipo);
+ /* the context */
+ get_constraint_ipo_context(ob, actname);
+
+ /* adds ipo & channels & curve if needed */
+ icu= verify_ipocurve((ID *)ob, ID_CO, actname, con->name, CO_ENFORCE);
+
insert_vert_ipo(icu, CFRA, con->enforce);
/* make sure ipowin shows it */
- ob->ipowin= IPO_CO;
- allqueue(REDRAWIPO, IPO_CO);
+ ob->ipowin= ID_CO;
+ allqueue(REDRAWIPO, ID_CO);
allspace(REMAKEIPO, 0);
allqueue(REDRAWNLA, 0);
@@ -274,7 +269,7 @@ static void del_constraint_func (void *ob_v, void *con_v)
/* remove ipo channel */
lb= get_active_constraint_channels(ob_v, 0);
if(lb) {
- chan = find_constraint_channel(lb, con->name);
+ chan = get_constraint_channel(lb, con->name);
if(chan) {
if(chan->ipo) chan->ipo->id.us--;
BLI_freelinkN(lb, chan);
@@ -1322,23 +1317,21 @@ void do_object_panels(unsigned short event)
/* write config files (currently no simulation) */
fluidsimBake(ob);
break;
- case B_FLUIDSIM_SELDIR: {
- char str[FILE_MAXDIR+FILE_MAXFILE];
- ScrArea *sa = closest_bigger_area();
- strcpy(str,"//");
- ob= OBACT;
- /* chosse dir for surface files */
- areawinset(sa->win);
- activate_fileselect(FILE_SPECIAL, "Select Directory", str, fluidsimFilesel);
- // continue with redraw... so no brake here!
- }
- case B_FLUIDSIM_FORCEREDRAW: {
- // force redraw
- allqueue(REDRAWBUTSEDIT, 0);
- allqueue(REDRAWVIEW3D, 0);
- countall();
- DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
- }
+ case B_FLUIDSIM_SELDIR:
+ char str[FILE_MAXDIR+FILE_MAXFILE];
+ ScrArea *sa = closest_bigger_area();
+ strcpy(str,"//");
+ ob= OBACT;
+ /* choose dir for surface files */
+ areawinset(sa->win);
+ activate_fileselect(FILE_SPECIAL, "Select Directory", str, fluidsimFilesel);
+ /* continue with redraw... so no brake here! */
+ case B_FLUIDSIM_FORCEREDRAW:
+ /* force redraw */
+ allqueue(REDRAWBUTSEDIT, 0);
+ allqueue(REDRAWVIEW3D, 0);
+ countall();
+ DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
break;
default:
@@ -1371,35 +1364,35 @@ static void object_panel_anim(Object *ob)
if(uiNewPanel(curarea, block, "Anim settings", "Object", 0, 0, 318, 204)==0) return;
uiBlockBeginAlign(block);
- uiDefButC(block, ROW,B_TRACKBUTS,"TrackX", 24,190,59,19, &ob->trackflag, 12.0, 0.0, 0, 0, "Specify the axis that points to another object");
- uiDefButC(block, ROW,B_TRACKBUTS,"Y", 85,190,19,19, &ob->trackflag, 12.0, 1.0, 0, 0, "Specify the axis that points to another object");
- uiDefButC(block, ROW,B_TRACKBUTS,"Z", 104,190,19,19, &ob->trackflag, 12.0, 2.0, 0, 0, "Specify the axis that points to another object");
- uiDefButC(block, ROW,B_TRACKBUTS,"-X", 124,190,24,19, &ob->trackflag, 12.0, 3.0, 0, 0, "Specify the axis that points to another object");
- uiDefButC(block, ROW,B_TRACKBUTS,"-Y", 150,190,24,19, &ob->trackflag, 12.0, 4.0, 0, 0, "Specify the axis that points to another object");
- uiDefButC(block, ROW,B_TRACKBUTS,"-Z", 178,190,24,19, &ob->trackflag, 12.0, 5.0, 0, 0, "Specify the axis that points to another object");
+ uiDefButS(block, ROW,B_TRACKBUTS,"TrackX", 24,190,59,19, &ob->trackflag, 12.0, 0.0, 0, 0, "Specify the axis that points to another object");
+ uiDefButS(block, ROW,B_TRACKBUTS,"Y", 85,190,19,19, &ob->trackflag, 12.0, 1.0, 0, 0, "Specify the axis that points to another object");
+ uiDefButS(block, ROW,B_TRACKBUTS,"Z", 104,190,19,19, &ob->trackflag, 12.0, 2.0, 0, 0, "Specify the axis that points to another object");
+ uiDefButS(block, ROW,B_TRACKBUTS,"-X", 124,190,24,19, &ob->trackflag, 12.0, 3.0, 0, 0, "Specify the axis that points to another object");
+ uiDefButS(block, ROW,B_TRACKBUTS,"-Y", 150,190,24,19, &ob->trackflag, 12.0, 4.0, 0, 0, "Specify the axis that points to another object");
+ uiDefButS(block, ROW,B_TRACKBUTS,"-Z", 178,190,24,19, &ob->trackflag, 12.0, 5.0, 0, 0, "Specify the axis that points to another object");
uiBlockBeginAlign(block);
- uiDefButC(block, ROW,REDRAWVIEW3D,"UpX", 226,190,45,19, &ob->upflag, 13.0, 0.0, 0, 0, "Specify the axis that points up");
- uiDefButC(block, ROW,REDRAWVIEW3D,"Y", 274,190,20,19, &ob->upflag, 13.0, 1.0, 0, 0, "Specify the axis that points up");
- uiDefButC(block, ROW,REDRAWVIEW3D,"Z", 298,190,19,19, &ob->upflag, 13.0, 2.0, 0, 0, "Specify the axis that points up");
+ uiDefButS(block, ROW,REDRAWVIEW3D,"UpX", 226,190,45,19, &ob->upflag, 13.0, 0.0, 0, 0, "Specify the axis that points up");
+ uiDefButS(block, ROW,REDRAWVIEW3D,"Y", 274,190,20,19, &ob->upflag, 13.0, 1.0, 0, 0, "Specify the axis that points up");
+ uiDefButS(block, ROW,REDRAWVIEW3D,"Z", 298,190,19,19, &ob->upflag, 13.0, 2.0, 0, 0, "Specify the axis that points up");
uiBlockBeginAlign(block);
- uiDefButBitC(block, TOG, OB_DRAWKEY, REDRAWVIEW3D, "Draw Key", 24,160,71,19, &ob->ipoflag, 0, 0, 0, 0, "Draw object as key position");
- uiDefButBitC(block, TOG, OB_DRAWKEYSEL, REDRAWVIEW3D, "Draw Key Sel", 97,160,81,19, &ob->ipoflag, 0, 0, 0, 0, "Limit the drawing of object keys");
- uiDefButBitC(block, TOG, OB_POWERTRACK, REDRAWVIEW3D, "Powertrack", 180,160,78,19, &ob->transflag, 0, 0, 0, 0, "Switch objects rotation off");
+ uiDefButBitS(block, TOG, OB_DRAWKEY, REDRAWVIEW3D, "Draw Key", 24,160,71,19, &ob->ipoflag, 0, 0, 0, 0, "Draw object as key position");
+ uiDefButBitS(block, TOG, OB_DRAWKEYSEL, REDRAWVIEW3D, "Draw Key Sel", 97,160,81,19, &ob->ipoflag, 0, 0, 0, 0, "Limit the drawing of object keys");
+ uiDefButBitS(block, TOG, OB_POWERTRACK, REDRAWVIEW3D, "Powertrack", 180,160,78,19, &ob->transflag, 0, 0, 0, 0, "Switch objects rotation off");
uiDefButBitS(block, TOG, PARSLOW, 0, "SlowPar", 260,160,56,19, &ob->partype, 0, 0, 0, 0, "Create a delay in the parent relationship");
uiBlockBeginAlign(block);
- uiDefButBitC(block, TOG, OB_DUPLIFRAMES, REDRAWVIEW3D, "DupliFrames", 24,128,89,19, &ob->transflag, 0, 0, 0, 0, "Make copy of object for every frame");
- uiDefButBitC(block, TOG, OB_DUPLIVERTS, REDRAWVIEW3D, "DupliVerts", 114,128,82,19, &ob->transflag, 0, 0, 0, 0, "Duplicate child objects on all vertices");
- uiDefButBitC(block, TOG, OB_DUPLIROT, REDRAWVIEW3D, "Rot", 200,128,31,19, &ob->transflag, 0, 0, 0, 0, "Rotate dupli according to facenormal");
- uiDefButBitC(block, TOG, OB_DUPLINOSPEED, REDRAWVIEW3D, "No Speed", 234,128,82,19, &ob->transflag, 0, 0, 0, 0, "Set dupliframes to still, regardless of frame");
+ uiDefButBitS(block, TOG, OB_DUPLIFRAMES, REDRAWVIEW3D, "DupliFrames", 24,128,89,19, &ob->transflag, 0, 0, 0, 0, "Make copy of object for every frame");
+ uiDefButBitS(block, TOG, OB_DUPLIVERTS, REDRAWVIEW3D, "DupliVerts", 114,128,82,19, &ob->transflag, 0, 0, 0, 0, "Duplicate child objects on all vertices");
+ uiDefButBitS(block, TOG, OB_DUPLIROT, REDRAWVIEW3D, "Rot", 200,128,31,19, &ob->transflag, 0, 0, 0, 0, "Rotate dupli according to facenormal");
+ uiDefButBitS(block, TOG, OB_DUPLINOSPEED, REDRAWVIEW3D, "No Speed", 234,128,82,19, &ob->transflag, 0, 0, 0, 0, "Set dupliframes to still, regardless of frame");
uiBlockBeginAlign(block);
uiDefButS(block, NUM, REDRAWVIEW3D, "DupSta:", 24,105,141,19, &ob->dupsta, 1.0, (MAXFRAMEF - 1.0f), 0, 0, "Specify startframe for Dupliframes");
uiDefButS(block, NUM, REDRAWVIEW3D, "DupOn:", 170,105,146,19, &ob->dupon, 1.0, 1500.0, 0, 0, "");
uiDefButS(block, NUM, REDRAWVIEW3D, "DupEnd", 24,82,140,19, &ob->dupend, 1.0, MAXFRAMEF, 0, 0, "Specify endframe for Dupliframes");
uiDefButS(block, NUM, REDRAWVIEW3D, "DupOff", 171,82,145,19, &ob->dupoff, 0.0, 1500.0, 0, 0, "");
uiBlockBeginAlign(block);
- uiDefButBitC(block, TOG, OB_OFFS_OB, REDRAWALL, "Offs Ob", 24,51,56,20, &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on its own objectipo");
- uiDefButBitC(block, TOG, OB_OFFS_PARENT, REDRAWALL, "Offs Par", 82,51,56,20 , &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on the parent");
- uiDefButBitC(block, TOG, OB_OFFS_PARTICLE, REDRAWALL, "Offs Particle", 140,51,103,20, &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on the particle effect");
+ uiDefButBitS(block, TOG, OB_OFFS_OB, REDRAWALL, "Offs Ob", 24,51,56,20, &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on its own objectipo");
+ uiDefButBitS(block, TOG, OB_OFFS_PARENT, REDRAWALL, "Offs Par", 82,51,56,20 , &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on the parent");
+ uiDefButBitS(block, TOG, OB_OFFS_PARTICLE, REDRAWALL, "Offs Particle", 140,51,103,20, &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on the particle effect");
uiBlockBeginAlign(block);
uiDefButF(block, NUM, REDRAWALL, "TimeOffset:", 24,17,115,30, &ob->sf, -MAXFRAMEF, MAXFRAMEF, 100, 0, "Specify an offset in frames");
diff --git a/source/blender/src/drawaction.c b/source/blender/src/drawaction.c
index 44a78de6729..8e6b1934f4d 100644
--- a/source/blender/src/drawaction.c
+++ b/source/blender/src/drawaction.c
@@ -78,6 +78,7 @@
#include "BDR_editcurve.h"
#include "BSE_view.h"
+#include "BSE_drawnla.h"
#include "BSE_drawipo.h"
/* 'old' stuff": defines and types, and own include -------------------- */
@@ -360,41 +361,6 @@ int count_action_levels(bAction *act)
return y;
}
- /** Draw a nicely beveled button (in screen space) */
-void draw_bevel_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;
- int i;
-
- glColor3ub(0,0,0);
- glBegin(GL_LINE_LOOP);
- glVertex2i(xmin, ymin);
- glVertex2i(xmax, ymin);
- glVertex2i(xmax, ymax);
- glVertex2i(xmin, ymax);
- glEnd();
-
- 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);
- if (sel) glColor3ub(0xF4, 0xEE, 0x8E);
- else glColor3ub(0xDF, 0xDF, 0xDF);
- glVertex2i(xmin+1, ymax-1);
- glVertex2i(xmin+1, ymin+1);
- glEnd();
-
- if (sel) glColor3ub(0xF1, 0xCA, 0x13);
- else glColor3ub(0xAC, 0xAC, 0xAC);
- glBegin(GL_LINES);
- for (i=xmin+2; i<=xmax-2; i++) {
- glVertex2f(i, ymin+2);
- glVertex2f(i, ymax-1);
- }
- glEnd();
-}
static void draw_channel_strips(SpaceAction *saction)
{
@@ -404,6 +370,7 @@ static void draw_channel_strips(SpaceAction *saction)
bActionChannel *chan;
bConstraintChannel *conchan;
float y;
+ int act_end, dummy;
char col1[3], col2[3];
BIF_GetThemeColor3ubv(TH_SHADE2, col2);
@@ -413,14 +380,21 @@ static void draw_channel_strips(SpaceAction *saction)
if (!act)
return;
- scr_rct.xmin= saction->area->winrct.xmin + ACTWIDTH;
+ scr_rct.xmin= saction->area->winrct.xmin + saction->v2d.mask.xmin;
scr_rct.ymin= saction->area->winrct.ymin + saction->v2d.mask.ymin;
scr_rct.xmax= saction->area->winrct.xmin + saction->v2d.hor.xmax;
scr_rct.ymax= saction->area->winrct.ymin + saction->v2d.mask.ymax;
di= glaBegin2DDraw(&scr_rct, &G.v2d->cur);
+ /* if in NLA there's a strip active, map the view */
+ if (G.saction->pin==0 && OBACT)
+ map_active_strip(di, OBACT, 0);
+
y= count_action_levels(act)*(CHANNELHEIGHT+CHANNELSKIP);
+ /* end of action itself */
+ gla2DDrawTranslatePt(di, calc_action_end(act), 0, &act_end, &dummy);
+
for (chan=act->chanbase.first; chan; chan=chan->next){
int frame1_x, channel_y;
@@ -429,11 +403,11 @@ static void draw_channel_strips(SpaceAction *saction)
glEnable(GL_BLEND);
if (chan->flag & ACHAN_SELECTED) glColor4ub(col1[0], col1[1], col1[2], 0x22);
else glColor4ub(col2[0], col2[1], col2[2], 0x22);
- glRectf(0, channel_y-CHANNELHEIGHT/2, frame1_x, channel_y+CHANNELHEIGHT/2);
+ glRectf(0, channel_y-CHANNELHEIGHT/2, G.v2d->hor.xmax, channel_y+CHANNELHEIGHT/2);
if (chan->flag & ACHAN_SELECTED) glColor4ub(col1[0], col1[1], col1[2], 0x44);
else glColor4ub(col2[0], col2[1], col2[2], 0x44);
- glRectf(frame1_x, channel_y-CHANNELHEIGHT/2, G.v2d->hor.xmax, channel_y+CHANNELHEIGHT/2);
+ glRectf(frame1_x, channel_y-CHANNELHEIGHT/2, act_end, channel_y+CHANNELHEIGHT/2);
glDisable(GL_BLEND);
draw_ipo_channel(di, chan->ipo, 0, y);
@@ -445,14 +419,15 @@ static void draw_channel_strips(SpaceAction *saction)
/* Draw constraint channels */
for (conchan=chan->constraintChannels.first; conchan; conchan=conchan->next){
gla2DDrawTranslatePt(di, 1, y, &frame1_x, &channel_y);
+
glEnable(GL_BLEND);
if (conchan->flag & ACHAN_SELECTED) glColor4ub(col1[0], col1[1], col1[2], 0x22);
else glColor4ub(col2[0], col2[1], col2[2], 0x22);
- glRectf(0, channel_y-CHANNELHEIGHT/2+4, frame1_x, channel_y+CHANNELHEIGHT/2-4);
+ glRectf(0, channel_y-CHANNELHEIGHT/2+4, G.v2d->hor.xmax, channel_y+CHANNELHEIGHT/2-4);
if (conchan->flag & ACHAN_SELECTED) glColor4ub(col1[0], col1[1], col1[2], 0x44);
else glColor4ub(col2[0], col2[1], col2[2], 0x44);
- glRectf(frame1_x, channel_y-CHANNELHEIGHT/2+4, G.v2d->hor.xmax, channel_y+CHANNELHEIGHT/2-4);
+ glRectf(frame1_x, channel_y-CHANNELHEIGHT/2+4, act_end, channel_y+CHANNELHEIGHT/2-4);
glDisable(GL_BLEND);
draw_ipo_channel(di, conchan->ipo, 0, y);
@@ -651,10 +626,8 @@ void drawactionspace(ScrArea *sa, void *spacedata)
* then draw the key frames in the action window
*/
draw_mesh_strips(G.saction, key);
- /*meshactionbuts(G.saction, key);*/
}
-
/* Draw current frame */
glViewport(ofsx+G.v2d->mask.xmin,
ofsy+G.v2d->mask.ymin,
@@ -674,16 +647,20 @@ void drawactionspace(ScrArea *sa, void *spacedata)
if(G.v2d->scroll) drawscroll(0);
}
- /* Draw channel names */
- draw_channel_names();
+ if(G.v2d->mask.xmin!=0) {
+ /* Draw channel names */
+ draw_channel_names();
- if ( key ) {
- /* if there is a mesh with rvk's selected,
- * then draw the key frames in the action window
- */
- meshactionbuts(G.saction, key);
+ if(sa->winx > 50 + NAMEWIDTH + SLIDERWIDTH) {
+ if ( key ) {
+ /* if there is a mesh with rvk's selected,
+ * then draw the key frames in the action window
+ */
+ meshactionbuts(G.saction, key);
+ }
+ }
}
-
+
mywinset(curarea->win); // reset scissor too
myortho2(-0.375, curarea->winx-0.375, -0.375, curarea->winy-0.375);
draw_area_emboss(sa);
@@ -695,11 +672,41 @@ void drawactionspace(ScrArea *sa, void *spacedata)
curarea->win_swap= WIN_BACK_OK;
}
-/* unused and blank
-void draw_channel_name(const char* name, short type, float ypos, int selected)
+
+/** Draw a nicely beveled button (in screen space) */
+static void draw_bevel_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();
+
+ /* interior */
+ if (sel) glColor3ub(0xF1, 0xCA, 0x13);
+ else glColor3ub(0xAC, 0xAC, 0xAC);
+ glRectf(xmin+1, ymin+1, xmax-1, ymax-1);
+
+ /* 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);
+
+ if (sel) glColor3ub(0xF4, 0xEE, 0x8E);
+ else glColor3ub(0xDF, 0xDF, 0xDF);
+ glVertex2i(xmin+1, ymax-1);
+ glVertex2i(xmin+1, ymin+1);
+ glEnd();
}
-*/
static void draw_keylist(gla2DDrawInfo *di, int totvert, BezTriple **blist, float ypos)
{
@@ -712,7 +719,7 @@ static void draw_keylist(gla2DDrawInfo *di, int totvert, BezTriple **blist, floa
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-5, 7, 13, (blist[v]->f2 & 1));
+ draw_bevel_but(sc_x-2, sc_y-7, 7, 13, (blist[v]->f2 & 1));
}
}
}
@@ -770,6 +777,7 @@ void draw_action_channel(gla2DDrawInfo *di, bAction *act, int flags, float ypos)
static BezTriple **ob_to_keylist(Object *ob, int flags, int *totvert)
{
IpoCurve *icu;
+ bConstraintChannel *conchan;
int v, count=0;
BezTriple **list = NULL;
@@ -784,6 +792,12 @@ static BezTriple **ob_to_keylist(Object *ob, int flags, int *totvert)
}
/* Count Constraint Keys */
+ for (conchan=ob->constraintChannels.first; conchan; conchan=conchan->next){
+ if(conchan->ipo)
+ for (icu=conchan->ipo->curve.first; icu; icu=icu->next)
+ count+=icu->totvert;
+ }
+
/* Count object data keys */
/* Build the list */
@@ -792,13 +806,21 @@ static BezTriple **ob_to_keylist(Object *ob, int flags, int *totvert)
count=0;
/* Add object keyframes */
- for (icu=ob->ipo->curve.first; icu; icu=icu->next){
- for (v=0; v<icu->totvert; v++){
- list[count++]=&icu->bezt[v];
+ if(ob->ipo) {
+ for (icu=ob->ipo->curve.first; icu; icu=icu->next){
+ for (v=0; v<icu->totvert; v++){
+ list[count++]=&icu->bezt[v];
+ }
}
+ }
+ /* Add constraint keyframes */
+ for (conchan=ob->constraintChannels.first; conchan; conchan=conchan->next){
+ if(conchan->ipo)
+ for (icu=conchan->ipo->curve.first; icu; icu=icu->next)
+ for (v=0; v<icu->totvert; v++)
+ list[count++]=&icu->bezt[v];
}
- /* Add constraint keyframes */
/* Add object data keyframes */
/* Sort */
@@ -880,13 +902,13 @@ static BezTriple **action_to_keylist(bAction *act, int flags, int *totvert)
if(achan->ipo) {
for (icu=achan->ipo->curve.first; icu; icu=icu->next)
count+=icu->totvert;
-
- /* Count constraint keys */
- for (conchan=achan->constraintChannels.first; conchan; conchan=conchan->next)
+ }
+ /* Count constraint keys */
+ for (conchan=achan->constraintChannels.first; conchan; conchan=conchan->next)
+ if(conchan->ipo)
for (icu=conchan->ipo->curve.first; icu; icu=icu->next)
count+=icu->totvert;
- }
}
/* Build the list */
@@ -895,17 +917,19 @@ static BezTriple **action_to_keylist(bAction *act, int flags, int *totvert)
count=0;
for (achan=act->chanbase.first; achan; achan=achan->next){
- /* Add transformation keys */
- for (icu=achan->ipo->curve.first; icu; icu=icu->next){
- for (v=0; v<icu->totvert; v++)
- list[count++]=&icu->bezt[v];
- }
-
- /* Add constraint keys */
- for (conchan=achan->constraintChannels.first; conchan; conchan=conchan->next){
- for (icu=conchan->ipo->curve.first; icu; icu=icu->next)
+ if(achan->ipo) {
+ /* Add transformation keys */
+ for (icu=achan->ipo->curve.first; icu; icu=icu->next){
for (v=0; v<icu->totvert; v++)
list[count++]=&icu->bezt[v];
+ }
+ }
+ /* Add constraint keys */
+ for (conchan=achan->constraintChannels.first; conchan; conchan=conchan->next){
+ if(conchan->ipo)
+ for (icu=conchan->ipo->curve.first; icu; icu=icu->next)
+ for (v=0; v<icu->totvert; v++)
+ list[count++]=&icu->bezt[v];
}
}
diff --git a/source/blender/src/drawipo.c b/source/blender/src/drawipo.c
index f4e416e4fb5..f7870fda239 100644
--- a/source/blender/src/drawipo.c
+++ b/source/blender/src/drawipo.c
@@ -92,14 +92,15 @@
#define ISPOIN4(a, b, c, d, e) ( (a->b) && (a->c) && (a->d) && (a->e) )
#define IPOBUTX 65
-#define IPOSTEP 35 /* minimum pixels per gridstep */
+ /* minimum pixels per gridstep */
+#define IPOSTEP 35
static float ipogrid_dx, ipogrid_dy, ipogrid_startx, ipogrid_starty;
static int ipomachtx, ipomachty;
-static int vertymin, vertymax, horxmin, horxmax; /* globals om LEFTMOUSE op scrollbar te testen */
+static int vertymin, vertymax, horxmin, horxmax; /* globals to test LEFTMOUSE for scrollbar */
-extern short ACTWIDTH;
+extern short ACTWIDTH; /* this is ugly! */
static void scroll_prstr(float x, float y, float val, char dir, int disptype)
{
@@ -313,7 +314,7 @@ void draw_ipogrid(void)
glRectf(0.0, 0.0, 100.0, 1.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
- else if(ELEM(G.sipo->blocktype, ID_CU, IPO_CO)) {
+ else if(ELEM(G.sipo->blocktype, ID_CU, ID_CO)) {
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glRectf(0.0, 1.0, G.v2d->cur.xmax, 1.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
@@ -594,12 +595,16 @@ void calc_scrollrcts(ScrArea *sa, View2D *v2d, int winx, int winy)
v2d->mask.ymax= winy;
if(sa->spacetype==SPACE_ACTION) {
- v2d->mask.xmin+= ACTWIDTH;
- v2d->hor.xmin+=ACTWIDTH;
+ if(sa->winx > ACTWIDTH+50) {
+ v2d->mask.xmin+= ACTWIDTH;
+ v2d->hor.xmin+=ACTWIDTH;
+ }
}
else if(sa->spacetype==SPACE_NLA){
- v2d->mask.xmin+= NLAWIDTH;
- v2d->hor.xmin+=NLAWIDTH;
+ if(sa->winx > NLAWIDTH+50) {
+ v2d->mask.xmin+= NLAWIDTH;
+ v2d->hor.xmin+=NLAWIDTH;
+ }
}
else if(sa->spacetype==SPACE_IPO) {
v2d->mask.xmax-= IPOBUTX;
@@ -1688,7 +1693,7 @@ void do_ipobuts(unsigned short event)
ei= get_active_editipo();
if(ei) {
if(ei->icu==NULL) {
- ei->icu= get_ipocurve(G.sipo->from, G.sipo->blocktype, ei->adrcode, NULL);
+ ei->icu= verify_ipocurve(G.sipo->from, G.sipo->blocktype, G.sipo->actname, G.sipo->constname, ei->adrcode);
ei->flag |= IPO_SELECT;
ei->icu->flag= ei->flag;
}
@@ -2040,6 +2045,8 @@ int view2dzoom(unsigned short event)
areawinset(curarea->win); /* from buttons */
curarea->head_swap= 0;
getmouseco_areawin(mvalo);
+ mval[0]= mvalo[0];
+ mval[1]= mvalo[1];
while( (get_mbut()&(L_MOUSE|M_MOUSE)) || (event==WHEELUPMOUSE) || (event==WHEELDOWNMOUSE) ) {
@@ -2130,11 +2137,23 @@ int view2dzoom(unsigned short event)
mvalo[1]= mval[1];
}
- G.v2d->cur.xmin+= dx;
- G.v2d->cur.xmax-= dx;
-
- if ELEM5(curarea->spacetype, SPACE_SEQ, SPACE_SOUND, SPACE_ACTION, SPACE_NLA, SPACE_TIME);
+ if( ELEM(curarea->spacetype, SPACE_NLA, SPACE_ACTION) ) {
+ if(mvalo[0] < G.v2d->mask.xmin) {
+ G.v2d->cur.ymin+= dy;
+ G.v2d->cur.ymax-= dy;
+ }
+ else {
+ G.v2d->cur.xmin+= dx;
+ G.v2d->cur.xmax-= dx;
+ }
+ }
+ else if (ELEM3(curarea->spacetype, SPACE_SEQ, SPACE_SOUND, SPACE_TIME)) {
+ G.v2d->cur.xmin+= dx;
+ G.v2d->cur.xmax-= dx;
+ }
else {
+ G.v2d->cur.xmin+= dx;
+ G.v2d->cur.xmax-= dx;
G.v2d->cur.ymin+= dy;
G.v2d->cur.ymax-= dy;
}
@@ -2214,10 +2233,20 @@ int view2dmove(unsigned short event)
if ELEM7(curarea->spacetype, SPACE_IPO, SPACE_SEQ, SPACE_OOPS, SPACE_SOUND, SPACE_ACTION, SPACE_NLA, SPACE_TIME)
{
+
if( BLI_in_rcti(&G.v2d->mask, (int)mvalo[0], (int)mvalo[1]) ) {
facx= (G.v2d->cur.xmax-G.v2d->cur.xmin)/(float)(G.v2d->mask.xmax-G.v2d->mask.xmin);
facy= (G.v2d->cur.ymax-G.v2d->cur.ymin)/(float)(G.v2d->mask.ymax-G.v2d->mask.ymin);
}
+ /* stoopid exception to allow scroll in lefthand side */
+ else if(curarea->spacetype==SPACE_ACTION && BLI_in_rcti(&G.v2d->mask, ACTWIDTH+(int)mvalo[0], (int)mvalo[1]) ) {
+ facx= 0.0f;
+ facy= (G.v2d->cur.ymax-G.v2d->cur.ymin)/(float)(G.v2d->mask.ymax-G.v2d->mask.ymin);
+ }
+ else if(curarea->spacetype==SPACE_NLA && BLI_in_rcti(&G.v2d->mask, NLAWIDTH+(int)mvalo[0], (int)mvalo[1]) ) {
+ facx= 0.0f;
+ facy= (G.v2d->cur.ymax-G.v2d->cur.ymin)/(float)(G.v2d->mask.ymax-G.v2d->mask.ymin);
+ }
else if(IN_2D_VERT_SCROLL((int)mvalo)) {
facy= -(G.v2d->tot.ymax-G.v2d->tot.ymin)/(float)(G.v2d->mask.ymax-G.v2d->mask.ymin);
if(get_mbut() & mousebut) {
diff --git a/source/blender/src/drawnla.c b/source/blender/src/drawnla.c
index 98969f795bf..120ce5c3d8d 100644
--- a/source/blender/src/drawnla.c
+++ b/source/blender/src/drawnla.c
@@ -56,6 +56,8 @@
#include "BLI_blenlib.h"
#include "MEM_guardedalloc.h"
+
+#include "BKE_action.h"
#include "BKE_global.h"
#include "BSE_drawnla.h"
@@ -77,24 +79,16 @@
#include "blendef.h"
#include "mydevice.h"
-/* Local function prototypes */
-static void draw_nlastrips(SpaceNla *snla);
-static void draw_nlatree(void);
-
-int count_nla_levels(void);
-int nla_filter (Base* base, int flags);
-
#define TESTBASE_SAFE(base) ((base)->flag & SELECT)
-/* Implementation */
-static void draw_nlatree(void)
+/* the left hand side with channels only */
+static void draw_nla_channels(void)
{
-
- short ofsx, ofsy = 0;
+ bActionStrip *strip;
Base *base;
+ Object *ob;
float x, y;
- bActionStrip *strip;
- bConstraintChannel *conchan;
+ short ofsx, ofsy = 0;
myortho2(0, NLAWIDTH, G.v2d->cur.ymin, G.v2d->cur.ymax); // Scaling
@@ -111,14 +105,13 @@ static void draw_nlatree(void)
glColor3ub(0x00, 0x00, 0x00);
x = 0.0;
-
y = count_nla_levels();
-
y*= (NLACHANNELHEIGHT+NLACHANNELSKIP);
-
for (base=G.scene->base.first; base; base=base->next){
- if (nla_filter(base, 0)){
+ if (nla_filter(base)) {
+ ob= base->object;
+
BIF_ThemeColorShade(TH_HEADER, 20);
glRectf(x, y-NLACHANNELHEIGHT/2, (float)NLAWIDTH, y+NLACHANNELHEIGHT/2);
@@ -127,63 +120,56 @@ static void draw_nlatree(void)
BIF_ThemeColor(TH_TEXT_HI);
else
BIF_ThemeColor(TH_TEXT);
- glRasterPos2f(x+16, y-4);
+ glRasterPos2f(x+21, y-4);
- BMF_DrawString(G.font, base->object->id.name+2);
+ BMF_DrawString(G.font, ob->id.name+2);
- /* Draw the constraint ipos */
- for (conchan = base->object->constraintChannels.first; conchan; conchan=conchan->next){
- y-=NLACHANNELHEIGHT+NLACHANNELSKIP;
- BIF_ThemeColorShade(TH_HEADER, -30);
+ /* icon to indicate nla or action */
+ if(ob->nlastrips.first && ob->action) {
+ if(ob->nlaflag & OB_NLA_OVERRIDE)
+ BIF_draw_icon(x+5, y-8, ICON_NLA);
+ else
+ BIF_draw_icon(x+5, y-8, ICON_ACTION);
+ }
+ y-=NLACHANNELHEIGHT+NLACHANNELSKIP;
+
+ /* Draw the action timeline */
+ if (ob->action){
+ BIF_ThemeColorShade(TH_HEADER, -20);
glRectf(x+16, y-NLACHANNELHEIGHT/2, (float)NLAWIDTH, y+NLACHANNELHEIGHT/2);
-
- if (conchan->flag & CONSTRAINT_CHANNEL_SELECT)
+
+ if (TESTBASE_SAFE(base))
BIF_ThemeColor(TH_TEXT_HI);
else
BIF_ThemeColor(TH_TEXT);
-
glRasterPos2f(x+32, y-4);
- BMF_DrawString(G.font, conchan->name);
- }
-
- /* Draw the action timeline */
- if (ACTIVE_ARMATURE(base)){
- BIF_draw_icon(x, y-8, ICON_DOWNARROW_HLT);
- y-=NLACHANNELHEIGHT+NLACHANNELSKIP;
+ BMF_DrawString(G.font, ob->action->id.name+2);
- if (base->object->action){
- BIF_ThemeColorShade(TH_HEADER, -30);
- glRectf(x+16, y-NLACHANNELHEIGHT/2, (float)NLAWIDTH, y+NLACHANNELHEIGHT/2);
-
- if (TESTBASE_SAFE(base))
- BIF_ThemeColor(TH_TEXT_HI);
- else
- BIF_ThemeColor(TH_TEXT);
- glRasterPos2f(x+32, y-4);
- BMF_DrawString(G.font, base->object->action->id.name+2);
- }
+ y-=NLACHANNELHEIGHT+NLACHANNELSKIP;
}
- y-=NLACHANNELHEIGHT+NLACHANNELSKIP;
/* Draw the nla strips */
- if (base->object->type==OB_ARMATURE){
- for (strip = base->object->nlastrips.first; strip; strip=strip->next){
- BIF_ThemeColorShade(TH_HEADER, -50);
- glRectf(x+32, y-NLACHANNELHEIGHT/2, (float)NLAWIDTH, y+NLACHANNELHEIGHT/2);
-
- if (TESTBASE_SAFE(base))
- BIF_ThemeColor(TH_TEXT_HI);
- else
- BIF_ThemeColor(TH_TEXT);
-
- // why this test? check freeing mem when deleting strips? (ton)
- if(strip->act) {
- glRasterPos2f(x+48, y-4);
- BMF_DrawString(G.font, strip->act->id.name+2);
-
- y-=(NLACHANNELHEIGHT+NLACHANNELSKIP);
+ for (strip = ob->nlastrips.first; strip; strip=strip->next){
+ BIF_ThemeColorShade(TH_HEADER, -40);
+ glRectf(x+32, y-NLACHANNELHEIGHT/2, (float)NLAWIDTH, y+NLACHANNELHEIGHT/2);
+
+ if (TESTBASE_SAFE(base))
+ BIF_ThemeColor(TH_TEXT_HI);
+ else
+ BIF_ThemeColor(TH_TEXT);
+
+ // why this test? check freeing mem when deleting strips? (ton)
+ if(strip->act) {
+ glRasterPos2f(x+48, y-4);
+ BMF_DrawString(G.font, strip->act->id.name+2);
+
+ if(strip->flag & ACTSTRIP_ACTIVE) {
+ glEnable(GL_BLEND);
+ BIF_draw_icon_blended(x+16, y-8, ICON_DOT, TH_BACK, 0);
+ glDisable(GL_BLEND);
}
}
+ y-=(NLACHANNELHEIGHT+NLACHANNELSKIP);
}
}
}
@@ -191,12 +177,29 @@ static void draw_nlatree(void)
myortho2(0, NLAWIDTH, 0, ( ofsy+G.v2d->mask.ymax)-( ofsy+G.v2d->mask.ymin)); // Scaling
}
-static void draw_nlastrips(SpaceNla *snla)
+void map_active_strip(gla2DDrawInfo *di, Object *ob, int restore)
{
+ static rctf stored;
+
+ if(restore)
+ gla2DSetMap(di, &stored);
+ else {
+ rctf map;
+
+ gla2DGetMap(di, &stored);
+ map= stored;
+ map.xmin= get_action_frame(ob, map.xmin);
+ map.xmax= get_action_frame(ob, map.xmax);
+ gla2DSetMap(di, &map);
+ }
+}
+
+/* the right hand side, with strips and keys */
+static void draw_nla_strips_keys(SpaceNla *snla)
+{
+ Base *base;
rcti scr_rct;
gla2DDrawInfo *di;
- Base *base;
- bConstraintChannel *conchan;
float y;
char col1[3], col2[3];
@@ -205,7 +208,7 @@ static void draw_nlastrips(SpaceNla *snla)
/* Draw strips */
- scr_rct.xmin= snla->area->winrct.xmin + NLAWIDTH;
+ scr_rct.xmin= snla->area->winrct.xmin + snla->v2d.mask.xmin;
scr_rct.ymin= snla->area->winrct.ymin + snla->v2d.mask.ymin;
scr_rct.xmax= snla->area->winrct.xmin + snla->v2d.hor.xmax;
scr_rct.ymax= snla->area->winrct.ymin + snla->v2d.mask.ymax;
@@ -215,13 +218,12 @@ static void draw_nlastrips(SpaceNla *snla)
y*= (NLACHANNELHEIGHT+NLACHANNELSKIP);
for (base=G.scene->base.first; base; base=base->next){
- Object *ob;
+ Object *ob= base->object;
bActionStrip *strip;
int frame1_x, channel_y;
- ob=base->object;
-
- if (nla_filter(base, 0)){
+ if (nla_filter(base)) {
+
/* Draw the field */
glEnable (GL_BLEND);
if (TESTBASE_SAFE(base))
@@ -241,42 +243,14 @@ static void draw_nlastrips(SpaceNla *snla)
glDisable (GL_BLEND);
- /* Draw the ipo */
+ /* Draw the ipo keys */
draw_object_channel(di, ob, 0, y);
- y-=NLACHANNELHEIGHT+NLACHANNELSKIP;
- /* Draw the constraints */
- for (conchan=ob->constraintChannels.first; conchan; conchan=conchan->next){
- glEnable (GL_BLEND);
- if (conchan->flag & CONSTRAINT_CHANNEL_SELECT)
- glColor4ub (col1[0], col1[1], col1[2], 0x22);
- else
- glColor4ub (col2[0], col2[1], col2[2], 0x22);
-
- gla2DDrawTranslatePt(di, 1, y, &frame1_x, &channel_y);
- glRectf(0, channel_y-NLACHANNELHEIGHT/2+4, frame1_x, channel_y+NLACHANNELHEIGHT/2-4);
-
-
- if (conchan->flag & CONSTRAINT_CHANNEL_SELECT)
- glColor4ub (col1[0], col1[1], col1[2], 0x44);
- else
- glColor4ub (col2[0], col2[1], col2[2], 0x44);
- glRectf(frame1_x, channel_y-NLACHANNELHEIGHT/2+4, G.v2d->hor.xmax, channel_y+NLACHANNELHEIGHT/2-4);
-
- glDisable (GL_BLEND);
-
- /* Draw the ipo */
- draw_ipo_channel(di, conchan->ipo, 0, y);
- y-=NLACHANNELHEIGHT+NLACHANNELSKIP;
-
- }
+ y-=NLACHANNELHEIGHT+NLACHANNELSKIP;
}
-
-
-
-
+
/* Draw the action strip */
- if (ACTIVE_ARMATURE(base)){
+ if (ob->action){
/* Draw the field */
glEnable (GL_BLEND);
@@ -284,10 +258,10 @@ static void draw_nlastrips(SpaceNla *snla)
glColor4ub (col1[0], col1[1], col1[2], 0x22);
else
glColor4ub (col2[0], col2[1], col2[2], 0x22);
+
gla2DDrawTranslatePt(di, 1, y, &frame1_x, &channel_y);
glRectf(0, channel_y-NLACHANNELHEIGHT/2+4, frame1_x, channel_y+NLACHANNELHEIGHT/2-4);
-
if (TESTBASE_SAFE(base))
glColor4ub (col1[0], col1[1], col1[2], 0x44);
else
@@ -296,107 +270,108 @@ static void draw_nlastrips(SpaceNla *snla)
glDisable (GL_BLEND);
- /* Draw the action keys */
+ /* Draw the action keys, optionally corrected for active strip */
+ map_active_strip(di, ob, 0);
draw_action_channel(di, ob->action, 0, y);
-
+ map_active_strip(di, ob, 1);
+
y-=NLACHANNELHEIGHT+NLACHANNELSKIP;
}
/* Draw the nla strips */
- if (ob->type==OB_ARMATURE){
- for (strip=ob->nlastrips.first; strip; strip=strip->next){
- int stripstart, stripend;
- int blendstart, blendend;
- unsigned char r, g, b;
-
- /* Draw rect */
- if (strip->flag & ACTSTRIP_SELECT){
- r= 0xff; g= 0xff; b= 0xaa;
- }
- else{
- r= 0xe4; g= 0x9c; b= 0xc6;
- }
-
- glColor4ub (r, g, b, 0xFF);
+ for (strip=ob->nlastrips.first; strip; strip=strip->next){
+ int stripstart, stripend;
+ int blendstart, blendend;
+
+ /* Draw rect */
+ if (strip->flag & ACTSTRIP_SELECT)
+ BIF_ThemeColor(TH_STRIP_SELECT);
+ else
+ BIF_ThemeColor(TH_STRIP);
+
+ gla2DDrawTranslatePt(di, strip->start+strip->blendin, y, &stripstart, &channel_y);
+ gla2DDrawTranslatePt(di, strip->end-strip->blendout, y, &stripend, &channel_y);
+ glRectf(stripstart, channel_y-NLACHANNELHEIGHT/2+3, stripend, channel_y+NLACHANNELHEIGHT/2-3);
+
+ if (strip->flag & ACTSTRIP_SELECT)
+ BIF_ThemeColorShade(TH_STRIP_SELECT, -60);
+ else
+ BIF_ThemeColorShade(TH_STRIP, -60);
+
+ /* Draw blendin */
+ if (strip->blendin>0){
+ glBegin(GL_TRIANGLES);
- gla2DDrawTranslatePt(di, strip->start+strip->blendin, y, &stripstart, &channel_y);
- gla2DDrawTranslatePt(di, strip->end-strip->blendout, y, &stripend, &channel_y);
- glRectf(stripstart, channel_y-NLACHANNELHEIGHT/2+3, stripend, channel_y+NLACHANNELHEIGHT/2-3);
+ gla2DDrawTranslatePt(di, strip->start, y, &blendstart, &channel_y);
+ glVertex2f(blendstart, channel_y-NLACHANNELHEIGHT/2+3);
+ glVertex2f(stripstart, channel_y+NLACHANNELHEIGHT/2-3);
+ glVertex2f(stripstart, channel_y-NLACHANNELHEIGHT/2+3);
- /* Draw blendin */
- if (strip->blendin>0){
- glBegin(GL_TRIANGLES);
-
- gla2DDrawTranslatePt(di, strip->start, y, &blendstart, &channel_y);
-
- glColor4ub (r*0.75, g*0.75, b*0.75, 0xFF);
- glVertex2f(blendstart, channel_y-NLACHANNELHEIGHT/2+3);
- glVertex2f(stripstart, channel_y+NLACHANNELHEIGHT/2-3);
- glVertex2f(stripstart, channel_y-NLACHANNELHEIGHT/2+3);
-
-
- glEnd();
- }
- if (strip->blendout>0){
- glBegin(GL_TRIANGLES);
- gla2DDrawTranslatePt(di, strip->end, y, &blendend, &channel_y);
- glColor4ub (r*0.75, g*0.75, b*0.75, 0xFF);
- glVertex2f(blendend, channel_y-NLACHANNELHEIGHT/2+3);
- glVertex2f(stripend, channel_y+NLACHANNELHEIGHT/2-3);
- glVertex2f(stripend, channel_y-NLACHANNELHEIGHT/2+3);
- glEnd();
- }
- /* Draw border */
- glBegin(GL_LINE_STRIP);
- glColor4f(1, 1, 1, 0.5);
- gla2DDrawTranslatePt(di, strip->start, y, &stripstart, &channel_y);
- gla2DDrawTranslatePt(di, strip->end, y, &stripend, &channel_y);
+ glEnd();
+ }
+ if (strip->blendout>0){
+ glBegin(GL_TRIANGLES);
- glVertex2f(stripstart, channel_y-NLACHANNELHEIGHT/2+3);
- glVertex2f(stripstart, channel_y+NLACHANNELHEIGHT/2-3);
+ gla2DDrawTranslatePt(di, strip->end, y, &blendend, &channel_y);
+
+ glVertex2f(blendend, channel_y-NLACHANNELHEIGHT/2+3);
glVertex2f(stripend, channel_y+NLACHANNELHEIGHT/2-3);
- glColor4f(0, 0, 0, 0.5);
glVertex2f(stripend, channel_y-NLACHANNELHEIGHT/2+3);
- glVertex2f(stripstart, channel_y-NLACHANNELHEIGHT/2+3);
glEnd();
-
- glEnable (GL_BLEND);
+ }
+
+ /* Draw border */
+ glBegin(GL_LINE_STRIP);
+ glColor4f(1, 1, 1, 0.5);
+ 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);
+ 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){
- glColor4ub (r, g, b, 0x55);
-
- glRectf(stripend, channel_y-NLACHANNELHEIGHT/2+4, G.v2d->hor.xmax, channel_y+NLACHANNELHEIGHT/2-2);
- }
+ /* Show strip extension */
+ if (strip->flag & ACTSTRIP_HOLDLASTFRAME){
+ if (strip->flag & ACTSTRIP_SELECT)
+ BIF_ThemeColorShadeAlpha(TH_STRIP_SELECT, 0, -180);
+ else
+ BIF_ThemeColorShadeAlpha(TH_STRIP, 0, -180);
- /* Show repeat */
- if (strip->repeat > 1.0 && !(strip->flag & ACTSTRIP_USESTRIDE)){
- float rep = 1;
- glBegin(GL_LINES);
- while (rep<strip->repeat){
- /* Draw line */
- glColor4f(0, 0, 0, 0.5);
- gla2DDrawTranslatePt(di, strip->start+(rep*((strip->end-strip->start)/strip->repeat)), y, &frame1_x, &channel_y);
- glVertex2f(frame1_x, channel_y-NLACHANNELHEIGHT/2+4);
- glVertex2f(frame1_x, channel_y+NLACHANNELHEIGHT/2-2);
-
- glColor4f(1.0, 1.0, 1.0, 0.5);
- gla2DDrawTranslatePt(di, strip->start+(rep*((strip->end-strip->start)/strip->repeat)), y, &frame1_x, &channel_y);
- glVertex2f(frame1_x+1, channel_y-NLACHANNELHEIGHT/2+4);
- glVertex2f(frame1_x+1, channel_y+NLACHANNELHEIGHT/2-2);
- rep+=1.0;
- }
- glEnd();
+ glRectf(stripend, channel_y-NLACHANNELHEIGHT/2+4, G.v2d->hor.xmax, channel_y+NLACHANNELHEIGHT/2-2);
+ }
+
+ /* Show repeat */
+ if (strip->repeat > 1.0 && !(strip->flag & ACTSTRIP_USESTRIDE)){
+ float rep = 1;
+ glBegin(GL_LINES);
+ while (rep<strip->repeat){
+ /* Draw line */
+ glColor4f(0, 0, 0, 0.5);
+ gla2DDrawTranslatePt(di, strip->start+(rep*((strip->end-strip->start)/strip->repeat)), y, &frame1_x, &channel_y);
+ glVertex2f(frame1_x, channel_y-NLACHANNELHEIGHT/2+4);
+ glVertex2f(frame1_x, channel_y+NLACHANNELHEIGHT/2-2);
+ glColor4f(1.0, 1.0, 1.0, 0.5);
+ gla2DDrawTranslatePt(di, strip->start+(rep*((strip->end-strip->start)/strip->repeat)), y, &frame1_x, &channel_y);
+ glVertex2f(frame1_x+1, channel_y-NLACHANNELHEIGHT/2+4);
+ glVertex2f(frame1_x+1, channel_y+NLACHANNELHEIGHT/2-2);
+ rep+=1.0;
}
- glDisable (GL_BLEND);
+ glEnd();
- y-=(NLACHANNELHEIGHT+NLACHANNELSKIP);
}
+ glDisable (GL_BLEND);
+ y-=(NLACHANNELHEIGHT+NLACHANNELSKIP);
}
}
glaEnd2DDraw(di);
@@ -407,18 +382,16 @@ static void draw_nlastrips(SpaceNla *snla)
#define B_NLA_PANEL 121
-static bActionStrip *get_active_nlastrip(void)
/* For now just returns the first selected strip */
+bActionStrip *get_active_nlastrip(void)
{
Base *base;
bActionStrip *strip;
for (base=G.scene->base.first; base; base=base->next){
- if (nla_filter(base, 0) && base->object->type==OB_ARMATURE){
- for (strip=base->object->nlastrips.first; strip; strip=strip->next){
- if (strip->flag & ACTSTRIP_SELECT)
- return strip;
- }
+ for (strip=base->object->nlastrips.first; strip; strip=strip->next){
+ if (strip->flag & ACTSTRIP_SELECT)
+ return strip;
}
}
@@ -478,30 +451,30 @@ static void nla_panel_properties(short cntrl) // NLA_HANDLER_PROPERTIES
strip = get_active_nlastrip();
if (!strip) return;
- // first labels, for simpler align code :)
+ /* first labels, for simpler align code :) */
uiDefBut(block, LABEL, 0, "Timeline Range:", 10,180,300,19, 0, 0, 0, 0, 0, "");
uiDefBut(block, LABEL, 0, "Action Range:", 10,140,300,19, 0, 0, 0, 0, 0, "");
uiDefBut(block, LABEL, 0, "Blending:", 10,100,300,19, 0, 0, 0, 0, 0, "");
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, 1.0, MAXFRAMEF, 100, 0, "First frame in the timeline");
- uiDefButF(block, NUM, B_REDR, "Strip End:", 160,160,150,19, &strip->end, 1.0, MAXFRAMEF, 100, 0, "Last frame in the timeline");
+ 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");
uiBlockBeginAlign(block);
uiDefButF(block, NUM, B_REDR, "Action Start:", 10,120,150,19, &strip->actstart, 1.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, 1.0, 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, MAXFRAMEF, 100, 0, "Number of frames of ease-in");
- uiDefButF(block, NUM, B_REDR, "Blendout:", 160,80,150,19, &strip->blendout, 0.0, MAXFRAMEF, 100, 0, "Number of frames of ease-out");
+ 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");
uiBlockBeginAlign(block);
- uiDefButF(block, NUM, B_REDR, "Repeat:", 10,40,150,19, &strip->repeat, 0.0001, MAXFRAMEF, 100, 0, "Number of times the action should repeat");
- uiDefButF(block, NUM, B_REDR, "Stride:", 160,40,150,19, &strip->stridelen, 0.0001, MAXFRAMEF, 100, 0, "Distance covered by one complete cycle of the action specified in the Action Range");
+ uiDefButF(block, NUM, B_REDR, "Repeat:", 10,40,150,19, &strip->repeat, 0.0001, 1000.0f, 100, 0, "Number of times the action should repeat");
+ uiDefButF(block, NUM, B_REDR, "Stride:", 160,40,150,19, &strip->stridelen, 0.0001, 1000.0, 100, 0, "Distance covered by one complete cycle of the action specified in the Action Range");
uiBlockBeginAlign(block);
- uiDefButBitS(block, TOG, ACTSTRIP_USESTRIDE, B_REDR, "Use Path", 10,0,100,19, &strip->flag, 0, 0, 0, 0, "Plays action based on path position & stride. Only armatures parented to a path");
+ uiDefButBitS(block, TOG, ACTSTRIP_USESTRIDE, B_REDR, "Use Path", 10,0,100,19, &strip->flag, 0, 0, 0, 0, "Plays action based on path position & stride");
uiDefButBitS(block, TOG, ACTSTRIP_HOLDLASTFRAME, B_REDR, "Hold", 110,0,100,19, &strip->flag, 0, 0, 0, 0, "Toggles whether to continue displaying the last frame past the end of the strip");
uiDefButS(block, TOG, B_REDR, "Add", 210,0,100,19, &strip->mode, 0, 0, 0, 0, "Toggles additive blending mode");
}
@@ -563,8 +536,8 @@ void drawnlaspace(ScrArea *sa, void *spacedata)
calc_ipogrid();
draw_ipogrid();
- /* Draw channel strips */
- draw_nlastrips(G.snla);
+ /* the right hand side, with strips and keys */
+ draw_nla_strips_keys(G.snla);
/* Draw current frame */
glViewport(ofsx+G.v2d->mask.xmin, ofsy+G.v2d->mask.ymin, ( ofsx+G.v2d->mask.xmax-1)-(ofsx+G.v2d->mask.xmin)+1, ( ofsy+G.v2d->mask.ymax-1)-( ofsy+G.v2d->mask.ymin)+1);
@@ -578,10 +551,10 @@ void drawnlaspace(ScrArea *sa, void *spacedata)
myortho2(-0.375, curarea->winx-0.375, -0.375, curarea->winy-0.375);
if(G.v2d->scroll) drawscroll(0);
}
-
- /* Draw channel names */
- draw_nlatree();
-
+ if(G.v2d->mask.xmin!=0) {
+ /* Draw channel names */
+ draw_nla_channels();
+ }
mywinset(curarea->win); // reset scissor too
myortho2(-0.375, sa->winx-0.375, -0.375, sa->winy-0.375);
draw_area_emboss(sa);
@@ -598,48 +571,36 @@ int count_nla_levels(void)
Base *base;
int y=0;
- for (y=0, base=G.scene->base.first; base; base=base->next)
- {
- if (nla_filter(base,0 )){
- /* Ipo */
+ for (y=0, base=G.scene->base.first; base; base=base->next) {
+ if (nla_filter(base)) {
+ /* object level */
y++;
- /* Constraint channels */
- y+=BLI_countlist(&base->object->constraintChannels);
-
- if (base->object->type==OB_ARMATURE){
- /* Action */
- if(base->object->action){
- // bActionChannel *achan;
- y++;
-
- // for (achan=base->object->action->chanbase.first; achan; achan=achan->next){
- // y+=BLI_countlist(&achan->constraintChannels);
- // }
- }
- /* Nla strips */
- y+= BLI_countlist(&base->object->nlastrips);
- }
+
+ if(base->object->action)
+ y++;
+
+ /* Nla strips */
+ y+= BLI_countlist(&base->object->nlastrips);
}
}
return y;
}
-int nla_filter (Base* base, int flags)
+int nla_filter (Base *base)
{
Object *ob = base->object;
+
+ if(ob->action || ob->nlastrips.first)
+ return 1;
- /* Only objects with ipos */
+ /* should become option */
if (ob->ipo)
return 1;
if (ob->constraintChannels.first)
return 1;
- /* Only armatures */
- if (ob->type==OB_ARMATURE)
- return 1;
-
- else return 0;
+ return 0;
}
diff --git a/source/blender/src/drawtime.c b/source/blender/src/drawtime.c
index 00c2e438339..2eb19db36fb 100644
--- a/source/blender/src/drawtime.c
+++ b/source/blender/src/drawtime.c
@@ -255,14 +255,15 @@ static void draw_ob_keys()
/* go through each channel in the action */
for (achan=act->chanbase.first; achan; achan=achan->next){
/* convert the ipo to a list of 'current frame elements' */
-
- elems.first= elems.last= NULL;
- make_cfra_list(achan->ipo, &elems);
-
- col[0] = 0x00; col[1] = 0x82; col[2] = 0x8B;
- draw_key_list(elems, col);
-
- BLI_freelistN(&elems);
+ if(achan->ipo) {
+ elems.first= elems.last= NULL;
+ make_cfra_list(achan->ipo, &elems);
+
+ col[0] = 0x00; col[1] = 0x82; col[2] = 0x8B;
+ draw_key_list(elems, col);
+
+ BLI_freelistN(&elems);
+ }
}
}
diff --git a/source/blender/src/editaction.c b/source/blender/src/editaction.c
index 6dad0f8eb88..44f16abe886 100644
--- a/source/blender/src/editaction.c
+++ b/source/blender/src/editaction.c
@@ -55,6 +55,7 @@
#include "DNA_constraint_types.h"
#include "DNA_key_types.h"
#include "DNA_mesh_types.h"
+#include "DNA_nla_types.h"
#include "DNA_lattice_types.h"
#include "BKE_action.h"
@@ -98,9 +99,7 @@ extern int count_action_levels (bAction *act);
#define BEZSELECTED(bezt) (((bezt)->f1 & 1) || ((bezt)->f2 & 1) || ((bezt)->f3 & 1))
/* Local Function prototypes, are forward needed */
-static void insertactionkey(bAction *act, bActionChannel *achan, bPoseChannel *chan, int adrcode, short makecurve, float time);
static void hilight_channel (bAction *act, bActionChannel *chan, short hilight);
-static void set_action_key_time (bAction *act, bPoseChannel *chan, int adrcode, short makecurve, float time);
static void up_sel_action(void);
static void down_sel_action(void);
@@ -137,6 +136,7 @@ bAction* bake_action_with_client (bAction *act, Object *armob, float tolerance)
bActionChannel *achan;
bAction *temp;
bPoseChannel *pchan;
+ ID *id;
float actlen;
int oldframe;
int curframe;
@@ -144,7 +144,7 @@ bAction* bake_action_with_client (bAction *act, Object *armob, float tolerance)
if (!act)
return NULL;
-
+
arm = get_armature(armob);
if (G.obedit){
@@ -158,7 +158,8 @@ bAction* bake_action_with_client (bAction *act, Object *armob, float tolerance)
}
/* Get a new action */
- result = add_empty_action();
+ result = add_empty_action(ID_PO);
+ id= (ID *)armob;
/* Assign the new action a unique name */
sprintf (newname, "%s.BAKED", act->id.name+2);
@@ -169,7 +170,7 @@ bAction* bake_action_with_client (bAction *act, Object *armob, float tolerance)
oldframe = G.scene->r.cfra;
temp = armob->action;
- armob->action = act;
+ armob->action = result;
for (curframe=1; curframe<ceil(actlen+1); curframe++){
@@ -186,16 +187,16 @@ bAction* bake_action_with_client (bAction *act, Object *armob, float tolerance)
for (pchan=armob->pose->chanbase.first; pchan; pchan=pchan->next){
/* Apply to keys */
- set_action_key_time (result, pchan, AC_QUAT_X, 1, curframe);
- set_action_key_time (result, pchan, AC_QUAT_Y, 1, curframe);
- set_action_key_time (result, pchan, AC_QUAT_Z, 1, curframe);
- set_action_key_time (result, pchan, AC_QUAT_W, 1, curframe);
- set_action_key_time (result, pchan, AC_LOC_X, 1, curframe);
- set_action_key_time (result, pchan, AC_LOC_Y, 1, curframe);
- set_action_key_time (result, pchan, AC_LOC_Z, 1, curframe);
- set_action_key_time (result, pchan, AC_SIZE_X, 1, curframe);
- set_action_key_time (result, pchan, AC_SIZE_Y, 1, curframe);
- set_action_key_time (result, pchan, AC_SIZE_Z, 1, curframe);
+ insertkey(id, ID_AC, pchan->name, NULL, AC_LOC_X);
+ insertkey(id, ID_AC, pchan->name, NULL, AC_LOC_Y);
+ insertkey(id, ID_AC, pchan->name, NULL, AC_LOC_Z);
+ insertkey(id, ID_AC, pchan->name, NULL, AC_QUAT_X);
+ insertkey(id, ID_AC, pchan->name, NULL, AC_QUAT_Y);
+ insertkey(id, ID_AC, pchan->name, NULL, AC_QUAT_Z);
+ insertkey(id, ID_AC, pchan->name, NULL, AC_QUAT_W);
+ insertkey(id, ID_AC, pchan->name, NULL, AC_SIZE_X);
+ insertkey(id, ID_AC, pchan->name, NULL, AC_SIZE_Y);
+ insertkey(id, ID_AC, pchan->name, NULL, AC_SIZE_Z);
}
}
@@ -203,8 +204,10 @@ bAction* bake_action_with_client (bAction *act, Object *armob, float tolerance)
/* Make another pass to ensure all keyframes are set to linear interpolation mode */
for (achan = result->chanbase.first; achan; achan=achan->next){
IpoCurve* icu;
- for (icu = achan->ipo->curve.first; icu; icu=icu->next){
- icu->ipo= IPO_LIN;
+ if(achan->ipo) {
+ for (icu = achan->ipo->curve.first; icu; icu=icu->next){
+ icu->ipo= IPO_LIN;
+ }
}
}
@@ -231,7 +234,6 @@ void select_actionchannel_by_name (bAction *act, char *name, int select)
for (chan = act->chanbase.first; chan; chan=chan->next){
if (!strcmp (chan->name, name)){
- act->achan = chan;
if (select){
chan->flag |= ACHAN_SELECTED;
hilight_channel (act, chan, 1);
@@ -322,25 +324,27 @@ void duplicate_actionchannel_keys(void)
duplicate_ipo_keys(conchan->ipo);
}
- transform_actionchannel_keys ('g');
+ transform_actionchannel_keys ('g', 0);
}
-static bActionChannel *get_nearest_actionchannel_key (float *index, short *sel, bConstraintChannel **rchan){
+static bActionChannel *get_nearest_actionchannel_key (float *index, short *sel, bConstraintChannel **rchan)
+{
bAction *act;
bActionChannel *chan;
IpoCurve *icu;
bActionChannel *firstchan=NULL;
bConstraintChannel *conchan, *firstconchan=NULL;
- int foundsel=0;
+ rctf rectf;
float firstvert=-1, foundx=-1;
- int i;
+ float ymin, ymax, xmin, xmax;
+ int i;
+ int foundsel=0;
short mval[2];
- float ymin, ymax;
- rctf rectf;
+
*index=0;
*rchan=NULL;
- act=G.saction->action; /* We presume that we are only called during a valid action */
+ act= G.saction->action; /* We presume that we are only called during a valid action */
getmouseco_areawin (mval);
@@ -352,16 +356,26 @@ static bActionChannel *get_nearest_actionchannel_key (float *index, short *sel,
ymax = count_action_levels(act) * (CHANNELHEIGHT + CHANNELSKIP);
ymax += CHANNELHEIGHT/2;
+ /* if action is mapped in NLA, it returns a correction */
+ if(G.saction->pin==0 && OBACT) {
+ xmin= get_action_frame(OBACT, rectf.xmin);
+ xmax= get_action_frame(OBACT, rectf.xmax);
+ }
+ else {
+ xmin= rectf.xmin;
+ xmax= rectf.xmax;
+ }
+
*sel=0;
for (chan=act->chanbase.first; chan; chan=chan->next){
/* Check action channel */
ymin= ymax-(CHANNELHEIGHT+CHANNELSKIP);
- if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))){
+ if (!((ymax < rectf.ymin) || (ymin > rectf.ymax)) && chan->ipo){
for (icu=chan->ipo->curve.first; icu; icu=icu->next){
for (i=0; i<icu->totvert; i++){
- if (icu->bezt[i].vec[1][0] > rectf.xmin && icu->bezt[i].vec[1][0] <= rectf.xmax ){
+ if (icu->bezt[i].vec[1][0] > xmin && icu->bezt[i].vec[1][0] <= xmax ){
if (!firstchan){
firstchan=chan;
firstvert=icu->bezt[i].vec[1][0];
@@ -388,10 +402,10 @@ static bActionChannel *get_nearest_actionchannel_key (float *index, short *sel,
/* Check constraint channels */
for (conchan=chan->constraintChannels.first; conchan; conchan=conchan->next){
ymin=ymax-(CHANNELHEIGHT+CHANNELSKIP);
- if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))){
+ if (!((ymax < rectf.ymin) || (ymin > rectf.ymax)) && conchan->ipo) {
for (icu=conchan->ipo->curve.first; icu; icu=icu->next){
for (i=0; i<icu->totvert; i++){
- if (icu->bezt[i].vec[1][0] > rectf.xmin && icu->bezt[i].vec[1][0] <= rectf.xmax ){
+ if (icu->bezt[i].vec[1][0] > xmin && icu->bezt[i].vec[1][0] <= xmax ){
if (!firstchan){
firstchan=chan;
firstconchan=conchan;
@@ -550,13 +564,11 @@ static void mouse_action(int selectmode)
if (chan){
if (selectmode == SELECT_REPLACE) {
- if (sel == 0)
- selectmode = SELECT_ADD;
- else
- selectmode = SELECT_SUBTRACT;
+ selectmode = SELECT_ADD;
+
deselect_actionchannel_keys(act, 0);
deselect_actionchannels(act, 0);
- act->achan = chan;
+
chan->flag |= ACHAN_SELECTED;
hilight_channel (act, chan, 1);
select_poseelement_by_name(chan->name, 1);
@@ -567,7 +579,9 @@ static void mouse_action(int selectmode)
else
select_ipo_key(chan->ipo, selx, selectmode);
- BIF_undo_push("Select Action");
+
+ std_rmouse_transform(transform_actionchannel_keys);
+
allqueue(REDRAWIPO, 0);
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWACTION, 0);
@@ -731,16 +745,17 @@ void borderselect_mesh(Key *key)
/* Lets loop throug the IpoCurves and do borderselect
* on the curves with adrcodes in our selected range.
*/
- for (icu = key->ipo->curve.first; icu ; icu = icu->next) {
- /* lets not deal with the "speed" Ipo
- */
- if (!icu->adrcode) continue;
- if ( (icu->adrcode >= adrcodemin) &&
- (icu->adrcode <= adrcodemax) ) {
- borderselect_icu_key(icu, xmin, xmax, select_function);
+ if(key->ipo) {
+ for (icu = key->ipo->curve.first; icu ; icu = icu->next) {
+ /* lets not deal with the "speed" Ipo
+ */
+ if (!icu->adrcode) continue;
+ if ( (icu->adrcode >= adrcodemin) &&
+ (icu->adrcode <= adrcodemax) ) {
+ borderselect_icu_key(icu, xmin, xmax, select_function);
+ }
}
}
-
/* redraw stuff */
BIF_undo_push("Border select Action Key");
allqueue(REDRAWNLA, 0);
@@ -749,6 +764,23 @@ void borderselect_mesh(Key *key)
}
}
+/* ******************** action API ***************** */
+
+/* generic get current action call, for action window context */
+bAction *ob_get_action(Object *ob)
+{
+ bActionStrip *strip;
+
+ if(ob->action)
+ return ob->action;
+
+ for (strip=ob->nlastrips.first; strip; strip=strip->next){
+ if (strip->flag & ACTSTRIP_SELECT)
+ return strip->act;
+ }
+ return NULL;
+}
+
/* used by ipo, outliner, buttons to find the active channel */
bActionChannel* get_hilighted_action_channel(bAction* action)
{
@@ -766,41 +798,6 @@ bActionChannel* get_hilighted_action_channel(bAction* action)
}
-/* sets action->achan to active channel, also adds if needed */
-void verify_active_action_channel(Object *ob)
-{
- if(ob) {
- bPoseChannel *pchan;
- bActionChannel *achan;
-
- if(ob->action==NULL) return;
-
- pchan= get_active_posechannel(ob);
- if(pchan) {
- /* See if this action channel exists already */
- for (achan=ob->action->chanbase.first; achan; achan=achan->next){
- if (!strcmp (pchan->name, achan->name))
- break;
- }
-
- if (!achan){
- achan = MEM_callocN (sizeof(bActionChannel), "actionChannel");
- strcpy (achan->name, pchan->name);
- BLI_addtail (&ob->action->chanbase, achan);
- }
-
- ob->action->achan= achan;
- ob->action->pchan= pchan;
-
- for (achan=ob->action->chanbase.first; achan; achan=achan->next)
- achan->flag &= ~(ACHAN_SELECTED|ACHAN_HILIGHTED);
-
- ob->action->achan->flag |= ACHAN_SELECTED|ACHAN_HILIGHTED;
-
- }
- }
-}
-
void set_exprap_action(int mode)
{
if(G.saction->action && G.saction->action->id.lib) return;
@@ -808,109 +805,23 @@ void set_exprap_action(int mode)
error ("Not yet implemented!");
}
-void set_action_key (struct bAction *act, struct bPoseChannel *chan, int adrcode, short makecurve)
-{
- set_action_key_time (act, chan, adrcode, makecurve, frame_to_float(CFRA));
-}
-
-static void set_action_key_time (bAction *act, bPoseChannel *chan, int adrcode, short makecurve, float time)
-{
- bActionChannel *achan;
- char ipstr[256];
-
- if (!act)
- return;
-
- if (!chan)
- return;
-
- /* See if this action channel exists already */
- for (achan=act->chanbase.first; achan; achan=achan->next){
- if (!strcmp (chan->name, achan->name))
- break;
- }
-
- if (!achan){
- if (!makecurve)
- return;
- achan = MEM_callocN (sizeof(bActionChannel), "actionChannel");
- strcpy (achan->name, chan->name);
- BLI_addtail (&act->chanbase, achan);
- }
-
- /* Ensure the channel appears selected in the action window */
- /* ton: added flag hilighted, for display in ipowin. dunno what the difference is between select/hilite */
- achan->flag |= ACHAN_SELECTED|ACHAN_HILIGHTED;
-
- /* Ensure this action channel has a valid Ipo */
- if (!achan->ipo){
- sprintf (ipstr, "%s.%s", act->id.name+2, chan->name);
- ipstr[23]=0;
- achan->ipo= add_ipo(ipstr, ID_AC);
- }
-
- insertactionkey(act, achan, chan, adrcode, makecurve, time);
-
-}
-
-static void insertactionkey(bAction *act, bActionChannel *achan, bPoseChannel *chan, int adrcode, short makecurve, float cfra)
+bAction *add_empty_action(int blocktype)
{
- IpoCurve *icu;
- void *poin;
- float curval;
- int type;
- ID *id;
-
- if (!act){
- return;
- }
- if (act->id.lib){
- error ("Can't pose library actions");
- return;
- }
- act->achan=achan;
- act->pchan=chan;
-
- id=(ID*) act;
-
- /* First see if this curve exists */
- if (!makecurve){
- if (!achan->ipo)
- return;
-
- for (icu = achan->ipo->curve.first; icu; icu=icu->next){
- if (icu->adrcode == adrcode)
- break;
- }
- if (!icu)
- return;
- }
-
+ bAction *act;
+ char *str= "Action";
- icu = get_ipocurve (id, GS(id->name), adrcode, achan->ipo);
-
- if(icu) {
- poin= get_ipo_poin(id, icu, &type);
- if(poin) {
- curval= read_ipo_poin(poin, type);
- // cfra= frame_to_float(CFRA);
- insert_vert_ipo(icu, cfra, curval);
- }
- }
+ if(blocktype==ID_OB)
+ str= "ObAction";
+ else if(blocktype==ID_KE)
+ str= "ShapeAction";
-}
-
-bAction *add_empty_action(void)
-{
- bAction *act;
-
- act= alloc_libblock(&G.main->action, ID_AC, "Action");
+ act= alloc_libblock(&G.main->action, ID_AC, str);
act->id.flag |= LIB_FAKEUSER;
act->id.us++;
return act;
}
-void transform_actionchannel_keys(char mode)
+void transform_actionchannel_keys(int mode, int dummy)
{
bAction *act;
TransVert *tv;
@@ -1054,9 +965,13 @@ void transform_actionchannel_keys(char mode)
headerprint(str);
}
- if (G.saction->lock){
- if(ob && ob->pose) {
- DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
+ if (G.saction->lock) {
+ if(ob) {
+ ob->ctime= -1234567.0f;
+ if(ob->pose || ob_get_key(ob))
+ DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
+ else
+ DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
}
force_draw_plus(SPACE_VIEW3D, 0);
}
@@ -1073,8 +988,13 @@ void transform_actionchannel_keys(char mode)
/* Update the curve */
/* Depending on the lock status, draw necessary views */
- if(ob && ob->pose) {
- DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
+ if(ob) {
+ ob->ctime= -1234567.0f;
+
+ if(ob->pose || ob_get_key(ob))
+ DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
+ else
+ DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
}
remake_action_ipos(act);
@@ -1272,7 +1192,6 @@ void transform_meshchannel_keys(char mode, Key *key)
*/
}
-
void deselect_actionchannel_keys (bAction *act, int test)
{
bActionChannel *chan;
@@ -1535,9 +1454,7 @@ static void mouse_actionchannels(bAction *act, short *mval,
* active channel for the action
*/
sel = (chan->flag & ACHAN_SELECTED);
- if ( select_channel(act, chan, selectmode) && !sel ) {
- act->achan = chan;
- }
+ select_channel(act, chan, selectmode);
}
--clickmin;
--clickmax;
@@ -2175,7 +2092,7 @@ void winqreadactionspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
transform_meshchannel_keys('g', key);
}
else if (act) {
- transform_actionchannel_keys ('g');
+ transform_actionchannel_keys ('g', 0);
}
}
break;
@@ -2215,7 +2132,7 @@ void winqreadactionspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
transform_meshchannel_keys('s', key);
}
else if (act) {
- transform_actionchannel_keys ('s');
+ transform_actionchannel_keys ('s', 0);
}
}
break;
@@ -2284,7 +2201,8 @@ void winqreadactionspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
* based on user preference USER_LMOUSESELECT
*/
case LEFTMOUSE:
- if(view2dmove(LEFTMOUSE)); // only checks for sliders
+ if(view2dmove(LEFTMOUSE)) // only checks for sliders
+ break;
else if (mval[0]>ACTWIDTH){
do {
getmouseco_areawin(mval);
@@ -2301,8 +2219,9 @@ void winqreadactionspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
else PIL_sleep_ms(30);
} while(get_mbut() & mousebut);
+ break;
}
- break;
+ /* passed on as selection */
case RIGHTMOUSE:
/* Clicking in the channel area selects the
* channel or constraint channel
diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c
index 301658f5339..59394973d4e 100644
--- a/source/blender/src/editarmature.c
+++ b/source/blender/src/editarmature.c
@@ -2433,7 +2433,7 @@ void armature_bone_rename(bArmature *arm, char *oldnamep, char *newnamep)
act = ob->action;
if (act && !act->id.lib){
/* Find the appropriate channel */
- chan= get_named_actionchannel(act, oldname);
+ chan= get_action_channel(act, oldname);
if(chan) BLI_strncpy(chan->name, newname, MAXBONENAME);
}
diff --git a/source/blender/src/editconstraint.c b/source/blender/src/editconstraint.c
index 5b48986c8fb..bac3099a718 100644
--- a/source/blender/src/editconstraint.c
+++ b/source/blender/src/editconstraint.c
@@ -85,11 +85,11 @@ ListBase *get_active_constraint_channels (Object *ob, int forcevalid)
if (!forcevalid)
return NULL;
- ob->action=add_empty_action();
+ ob->action=add_empty_action(ID_PO);
}
/* Make sure we have an actionchannel */
- achan = get_named_actionchannel(ob->action, pchan->name);
+ achan = get_action_channel(ob->action, pchan->name);
if (!achan){
if (!forcevalid)
return NULL;
@@ -109,7 +109,17 @@ ListBase *get_active_constraint_channels (Object *ob, int forcevalid)
else return NULL;
}
/* else we return object constraints */
- return &ob->constraintChannels;
+ else {
+ if(ob->ipoflag & OB_ACTION_OB) {
+ bActionChannel *achan = get_action_channel(ob->action, "Object");
+ if(achan)
+ return &achan->constraintChannels;
+ else
+ return NULL;
+ }
+
+ return &ob->constraintChannels;
+ }
}
@@ -162,7 +172,7 @@ bConstraintChannel *get_active_constraint_channel(Object *ob)
if(con->flag & CONSTRAINT_ACTIVE)
break;
if(con) {
- bActionChannel *achan = get_named_actionchannel(ob->action, pchan->name);
+ bActionChannel *achan = get_action_channel(ob->action, pchan->name);
if(achan) {
for(chan= achan->constraintChannels.first; chan; chan= chan->next)
if(!strcmp(chan->name, con->name))
@@ -178,10 +188,14 @@ bConstraintChannel *get_active_constraint_channel(Object *ob)
if(con->flag & CONSTRAINT_ACTIVE)
break;
if(con) {
- for(chan= ob->constraintChannels.first; chan; chan= chan->next)
- if(!strcmp(chan->name, con->name))
- break;
- return chan;
+ ListBase *lb= get_active_constraint_channels(ob, 0);
+
+ if(lb) {
+ for(chan= lb->first; chan; chan= chan->next)
+ if(!strcmp(chan->name, con->name))
+ break;
+ return chan;
+ }
}
}
@@ -189,7 +203,6 @@ bConstraintChannel *get_active_constraint_channel(Object *ob)
}
-
bConstraint *add_new_constraint(short type)
{
bConstraint *con;
diff --git a/source/blender/src/editipo.c b/source/blender/src/editipo.c
index cb5988ee16e..d5eb4268367 100644
--- a/source/blender/src/editipo.c
+++ b/source/blender/src/editipo.c
@@ -1,15 +1,12 @@
/**
* $Id$
*
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ * ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -23,11 +20,9 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
- * The Original Code is: all of this file.
+ * Contributor(s): Blender Foundation, 2005. Full recode
*
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * ***** END GPL LICENSE BLOCK *****
*/
@@ -43,10 +38,6 @@
#include <string.h>
#include <math.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#ifndef WIN32
#include <unistd.h>
#else
@@ -81,6 +72,7 @@
#include "BKE_action.h"
#include "BKE_anim.h"
+#include "BKE_constraint.h"
#include "BKE_depsgraph.h"
#include "BKE_global.h"
#include "BKE_group.h"
@@ -118,14 +110,6 @@
#include "blendef.h"
#include "mydevice.h"
-/* forwards */
-#define BEZSELECTED(bezt) (((bezt)->f1 & 1) || ((bezt)->f2 & 1) || ((bezt)->f3 & 1))
-
-#define IPOTHRESH 0.9
-#define ISPOIN(a, b, c) ( (a->b) && (a->c) )
-#define ISPOIN3(a, b, c, d) ( (a->b) && (a->c) && (a->d) )
-#define ISPOIN4(a, b, c, d, e) ( (a->b) && (a->c) && (a->d) && (a->e) )
-
extern int ob_ar[];
extern int ma_ar[];
extern int seq_ar[];
@@ -138,155 +122,12 @@ extern int ac_ar[];
extern int co_ar[];
extern int te_ar[];
-char *ob_ic_names[OB_TOTNAM] = { "LocX", "LocY", "LocZ", "dLocX", "dLocY", "dLocZ",
- "RotX", "RotY", "RotZ", "dRotX", "dRotY", "dRotZ",
- "SizeX", "SizeY", "SizeZ", "dSizeX", "dSizeY", "dSizeZ",
- "Layer", "Time", "ColR", "ColG", "ColB", "ColA",
- "FStreng", "FFall", "RDamp", "Damping", "Perm" };
-
-char *co_ic_names[CO_TOTNAM] = { "Inf" };
-char *mtex_ic_names[TEX_TOTNAM] = { "OfsX", "OfsY", "OfsZ", "SizeX", "SizeY", "SizeZ",
- "texR", "texG", "texB", "DefVar", "Col", "Nor", "Var",
- "Disp" };
-char *tex_ic_names[TE_TOTNAM] = { "NSize", "NDepth", "NType", "Turb", "Vnw1", "Vnw2",
- "Vnw3", "Vnw4", "MinkMExp", "DistM", "ColT", "iScale",
- "DistA", "MgType", "MgH", "Lacu", "Oct", "MgOff",
- "MgGain", "NBase1", "NBase2" };
-char *ma_ic_names[MA_TOTNAM] = { "R", "G", "B", "SpecR", "SpecG", "SpecB", "MirR",
- "MirG", "MirB", "Ref", "Alpha", "Emit", "Amb", "Spec",
- "Hard", "SpTra", "Ior", "Mode", "HaSize", "Translu",
- "RayMir", "FresMir", "FresMirI", "FresTra", "FresTraI",
- "TraGlow" };
-char *seq_ic_names[SEQ_TOTNAM] = { "Fac" };
-char *cu_ic_names[CU_TOTNAM] = { "Speed" };
-char *key_ic_names[KEY_TOTNAM] = { "Speed", "Key 1", "Key 2", "Key 3", "Key 4", "Key 5",
- "Key 6", "Key 7", "Key 8", "Key 9", "Key 10",
- "Key 11", "Key 12", "Key 13", "Key 14", "Key 15",
- "Key 16", "Key 17", "Key 18", "Key 19", "Key 20",
- "Key 21", "Key 22", "Key 23", "Key 24", "Key 25",
- "Key 26", "Key 27", "Key 28", "Key 29", "Key 30",
- "Key 31", "Key 32", "Key 33", "Key 34", "Key 35",
- "Key 36", "Key 37", "Key 38", "Key 39", "Key 40",
- "Key 41", "Key 42", "Key 43", "Key 44", "Key 45",
- "Key 46", "Key 47", "Key 48", "Key 49", "Key 50",
- "Key 51", "Key 52", "Key 53", "Key 54", "Key 55",
- "Key 56", "Key 57", "Key 58", "Key 59", "Key 60",
- "Key 61", "Key 62", "Key 63"};
-char *wo_ic_names[WO_TOTNAM] = { "HorR", "HorG", "HorB", "ZenR", "ZenG", "ZenB", "Expos",
- "Misi", "MisDi", "MisSta", "MisHi", "StarR", "StarB",
- "StarG", "StarDi", "StarSi" };
-char *la_ic_names[LA_TOTNAM] = { "Energ", "R", "G", "B", "Dist", "SpoSi", "SpoBl",
- "Quad1", "Quad2", "HaInt" };
-/* yafray: two curve names added, 'Apert' for aperture, and 'FDist' for focal distance */
-char *cam_ic_names[CAM_TOTNAM] = { "Lens", "ClSta", "ClEnd", "Apert", "FDist" };
-char *snd_ic_names[SND_TOTNAM] = { "Vol", "Pitch", "Pan", "Atten" };
-char *ac_ic_names[AC_TOTNAM] = {"LocX", "LocY", "LocZ", "SizeX", "SizeY",
- "SizeZ", "QuatW", "QuatX", "QuatY", "QuatZ"};
-char *ic_name_empty[1] ={ "" };
-
-char *getname_ac_ei(int nr)
-{
- switch(nr) {
- case AC_LOC_X:
- case AC_LOC_Y:
- case AC_LOC_Z:
- return ac_ic_names[nr-1];
- case AC_SIZE_X:
- case AC_SIZE_Y:
- case AC_SIZE_Z:
- return ac_ic_names[nr-10];
- case AC_QUAT_X:
- case AC_QUAT_Y:
- case AC_QUAT_Z:
- case AC_QUAT_W:
- return ac_ic_names[nr-19];
- default:
- return ic_name_empty[0]; /* empty */
- }
-}
-
-char *getname_co_ei(int nr)
-{
- switch(nr){
- case CO_ENFORCE:
- return co_ic_names[nr-1];
- }
- return ic_name_empty[0];
-}
-
-char *getname_ob_ei(int nr, int colipo)
-{
- if(nr>=OB_LOC_X && nr <= OB_PD_PERM) return ob_ic_names[nr-1];
-
- return ic_name_empty[0];
-}
-
-char *getname_tex_ei(int nr)
-{
- if(nr>=TE_NSIZE && nr<=TE_N_BAS2) return tex_ic_names[nr-1];
-
- return ic_name_empty[0];
-}
-
-char *getname_mtex_ei(int nr)
-{
- if(nr>=MAP_OFS_X && nr<=MAP_DISP) return mtex_ic_names[nr-1];
-
- return ic_name_empty[0];
-}
-
-char *getname_mat_ei(int nr)
-{
- if(nr>=MA_MAP1) return getname_mtex_ei((nr & (MA_MAP1-1)));
- else {
- if(nr>=MA_COL_R && nr<=MA_ADD) return ma_ic_names[nr-1];
- }
- return ic_name_empty[0];
-}
-
-char *getname_world_ei(int nr)
-{
- if(nr>=MA_MAP1) return getname_mtex_ei((nr & (MA_MAP1-1)));
- else {
- if(nr>=WO_HOR_R && nr<=WO_STARSIZE) return wo_ic_names[nr-1];
- }
- return ic_name_empty[0];
-}
-
-char *getname_seq_ei(int nr)
-{
- if(nr == SEQ_FAC1) return seq_ic_names[nr-1];
- return ic_name_empty[0];
-}
-
-char *getname_cu_ei(int nr)
-{
- if(nr==CU_SPEED) return cu_ic_names[nr-1];
- return ic_name_empty[0];
-}
-
-char *getname_la_ei(int nr)
-{
- if(nr>=MA_MAP1) return getname_mtex_ei((nr & (MA_MAP1-1)));
- else {
- if(nr>=LA_ENERGY && nr<=LA_HALOINT) return la_ic_names[nr-1];
- }
- return ic_name_empty[0];
-}
-
-char *getname_cam_ei(int nr)
-{
- /* yafray: curves extended to CAM_YF_FDIST */
- //if(nr>=CAM_LENS && nr<=CAM_END) return cam_ic_names[nr-1];
- if(nr>=CAM_LENS && nr<=CAM_YF_FDIST) return cam_ic_names[nr-1];
- return ic_name_empty[0];
-}
+/* forwards */
+#define BEZSELECTED(bezt) (((bezt)->f1 & 1) || ((bezt)->f2 & 1) || ((bezt)->f3 & 1))
-char *getname_snd_ei(int nr)
-{
- if(nr>=SND_VOLUME && nr<=SND_ATTEN) return snd_ic_names[nr-1];
- return ic_name_empty[0];
-}
+#define IPOTHRESH 0.9
+#define ISPOIN(a, b, c) ( (a->b) && (a->c) )
+#define ISPOIN3(a, b, c, d) ( (a->b) && (a->c) && (a->d) )
/* tests if only one editipo is active */
static void check_active_editipo(void)
@@ -371,78 +212,6 @@ static void set_active_key(int index)
}
}
-void boundbox_ipocurve(IpoCurve *icu)
-{
- BezTriple *bezt;
- float vec[3]={0.0,0.0,0.0};
- float min[3], max[3];
- int a;
-
- if(icu->totvert) {
- INIT_MINMAX(min, max);
-
- if(icu->bezt ) {
- a= icu->totvert;
- bezt= icu->bezt;
- while(a--) {
- if(icu->vartype & IPO_BITS) {
- vec[0]= bezt->vec[1][0];
- vec[1]= 0.0;
- DO_MINMAX(vec, min, max);
-
- vec[1]= 16.0;
- DO_MINMAX(vec, min, max);
- }
- else {
- if(icu->ipo==IPO_BEZ && a!=icu->totvert-1) {
- DO_MINMAX(bezt->vec[0], min, max);
- }
- DO_MINMAX(bezt->vec[1], min, max);
- if(icu->ipo==IPO_BEZ && a!=0) {
- DO_MINMAX(bezt->vec[2], min, max);
- }
- }
-
- bezt++;
- }
- }
- if(min[0]==max[0]) max[0]= (float)(min[0]+1.0);
- if(min[1]==max[1]) max[1]= (float)(min[1]+0.1);
-
- icu->totrct.xmin= min[0];
- icu->totrct.ymin= min[1];
- icu->totrct.xmax= max[0];
- icu->totrct.ymax= max[1];
- }
- else {
- icu->totrct.xmin= icu->totrct.ymin= 0.0;
- icu->totrct.xmax= EFRA;
- icu->totrct.ymax= 1.0;
- }
-}
-
-void boundbox_ipo(Ipo *ipo, rctf *bb)
-{
- IpoCurve *icu;
- int first= 1;
-
- icu= ipo->curve.first;
- while(icu) {
-
- boundbox_ipocurve(icu);
-
- if(first) {
- *bb= icu->totrct;
- first= 0;
- }
- else BLI_union_rctf(bb, &(icu->totrct));
-
- icu= icu->next;
- }
-}
-
-
-
void editipo_changed(SpaceIpo *si, int doredraw)
{
EditIpo *ei;
@@ -544,7 +313,7 @@ void editipo_changed(SpaceIpo *si, int doredraw)
allqueue(REDRAWVIEW3D, 0);
}
else if(si->blocktype==ID_SEQ) clear_last_seq();
- else if(si->blocktype==ID_AC) {
+ else if(si->blocktype==ID_PO) {
Object *ob= OBACT;
if(ob && ob->pose) {
DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
@@ -581,7 +350,7 @@ void scale_editipo(void)
ei= G.sipo->editipo;
if(ei==0) return;
for(a=0; a<G.sipo->totipo; a++, ei++) {
- if ISPOIN(ei, flag & IPO_VISIBLE, icu) {
+ if (ISPOIN(ei, flag & IPO_VISIBLE, icu)) {
bezt= ei->icu->bezt;
b= ei->icu->totvert;
while(b--) {
@@ -607,130 +376,7 @@ void scale_editipo(void)
allqueue(REDRAWIPO, 0);
}
-
-Ipo *get_ipo_to_edit(ID **from)
-{
- Object *ob= OBACT;
-
- *from= 0;
-
-
- if (G.sipo->pin) {
- *from = G.sipo->from;
- return G.sipo->ipo;
- }
-
- if(G.sipo->blocktype==ID_SEQ) {
- extern Sequence *last_seq;
-
- *from= (ID *)last_seq;
- if(last_seq) return last_seq->ipo;
- }
- else if(G.sipo->blocktype==IPO_CO){
- if (ob) {
- bConstraintChannel *chan= get_active_constraint_channel(ob);
- if(chan) {
- *from= (ID*) ob;
- return chan->ipo;
- }
- }
- }
- else if(G.sipo->blocktype==ID_AC) {
- bActionChannel *chan;
- if (ob && ob->action) {
- *from= (ID *) ob->action;
- chan= get_hilighted_action_channel(ob->action);
- if (chan)
- return chan->ipo;
- else
- return NULL;
- }
-
- }
- else if(G.sipo->blocktype==ID_WO) {
- World *wo= G.scene->world;
- *from= (ID *)wo;
- if(wo) return wo->ipo;
- }
- else if(G.sipo->blocktype==ID_OB) {
- if(ob) {
- *from= (ID *)ob;
- return ob->ipo;
- }
- }
- else if(G.sipo->blocktype==ID_TE) {
- if(ob) {
- Tex *tex= give_current_texture(ob, ob->actcol);
- *from= (ID *)tex;
- if(tex) return tex->ipo;
- }
- }
- else if(G.sipo->blocktype==ID_MA) {
- if(ob) {
- Material *ma= give_current_material(ob, ob->actcol);
- *from= (ID *)ma;
- if(ma) return ma->ipo;
- }
- }
- else if(G.sipo->blocktype==ID_KE) {
- if(ob) {
- Key *key= ob_get_key(ob);
- *from= (ID *)key;
- if(key) return key->ipo;
- }
- }
- else if(G.sipo->blocktype==ID_CU) {
- if(ob && ob->type==OB_CURVE) {
- Curve *cu= ob->data;
- *from= (ID *)cu;
- return cu->ipo;
- }
- }
- else if(G.sipo->blocktype==ID_LA) {
- if(ob && ob->type==OB_LAMP) {
- Lamp *la= ob->data;
- *from= (ID *)la;
- return la->ipo;
- }
- }
- else if(G.sipo->blocktype==ID_CA) {
- if(ob && ob->type==OB_CAMERA) {
- Camera *ca= ob->data;
- *from= (ID *)ca;
- if(ca) return ca->ipo;
- }
- }
- else if(G.sipo->blocktype==ID_SO) {
-
-// if (G.buts && G.buts->mainb == BUTS_SOUND) {
-// bSound *sound = G.buts->lockpoin;
-// *from= (ID *)sound;
-// if(sound) return sound->ipo;
-// }
- }
-
- return NULL;
-}
-
-unsigned int ipo_rainbow(int cur, int tot)
-{
- float dfac, fac, sat;
-
- dfac= (float)(1.0/( (float)tot+1.0));
-
- /* this calculation makes 2 or 4 different cycles of rainbow colors */
- if(cur< tot/2) fac= (float)(cur*2.0f*dfac);
- else fac= (float)((cur-tot/2)*2.0f*dfac +dfac);
- if(tot > 32) fac= fac*1.95f;
- if(fac>1.0f) fac-= 1.0f;
-
- if(fac>0.5f && fac<0.8f) sat= 0.4f;
- else sat= 0.5f;
-
- return hsv_to_cpack(fac, sat, 1.0f);
-}
-
-void make_ob_editipo(Object *ob, SpaceIpo *si)
+static void make_ob_editipo(Object *ob, SpaceIpo *si)
{
EditIpo *ei;
int a, len, colipo=0;
@@ -772,8 +418,7 @@ void make_ob_editipo(Object *ob, SpaceIpo *si)
}
}
-
-void make_seq_editipo(SpaceIpo *si)
+static void make_seq_editipo(SpaceIpo *si)
{
EditIpo *ei;
int a;
@@ -801,7 +446,7 @@ void make_seq_editipo(SpaceIpo *si)
}
}
-void make_cu_editipo(SpaceIpo *si)
+static void make_cu_editipo(SpaceIpo *si)
{
EditIpo *ei;
int a;
@@ -829,7 +474,7 @@ void make_cu_editipo(SpaceIpo *si)
}
}
-void make_key_editipo(SpaceIpo *si)
+static void make_key_editipo(SpaceIpo *si)
{
Key *key;
KeyBlock *kb=NULL;
@@ -884,24 +529,7 @@ void make_key_editipo(SpaceIpo *si)
}
}
-int texchannel_to_adrcode(int channel)
-{
- switch(channel) {
- case 0: return MA_MAP1;
- case 1: return MA_MAP2;
- case 2: return MA_MAP3;
- case 3: return MA_MAP4;
- case 4: return MA_MAP5;
- case 5: return MA_MAP6;
- case 6: return MA_MAP7;
- case 7: return MA_MAP8;
- case 8: return MA_MAP9;
- case 9: return MA_MAP10;
- default: return 0;
- }
-}
-
-void make_mat_editipo(SpaceIpo *si)
+static void make_mat_editipo(SpaceIpo *si)
{
EditIpo *ei;
int a, len;
@@ -944,7 +572,7 @@ void make_mat_editipo(SpaceIpo *si)
}
}
-void make_texture_editipo(SpaceIpo *si)
+static void make_texture_editipo(SpaceIpo *si)
{
EditIpo *ei;
int a;
@@ -972,7 +600,7 @@ void make_texture_editipo(SpaceIpo *si)
}
}
-void make_world_editipo(SpaceIpo *si)
+static void make_world_editipo(SpaceIpo *si)
{
EditIpo *ei;
int a, len;
@@ -1016,7 +644,7 @@ void make_world_editipo(SpaceIpo *si)
}
}
-void make_lamp_editipo(SpaceIpo *si)
+static void make_lamp_editipo(SpaceIpo *si)
{
EditIpo *ei;
int a;
@@ -1026,7 +654,6 @@ void make_lamp_editipo(SpaceIpo *si)
si->totipo= LA_TOTIPO;
-
for(a=0; a<LA_TOTIPO; a++) {
name = getname_la_ei(la_ar[a]);
strcpy(ei->name, name);
@@ -1048,7 +675,7 @@ void make_lamp_editipo(SpaceIpo *si)
}
}
-void make_camera_editipo(SpaceIpo *si)
+static void make_camera_editipo(SpaceIpo *si)
{
EditIpo *ei;
int a;
@@ -1075,7 +702,7 @@ void make_camera_editipo(SpaceIpo *si)
}
}
-int make_constraint_editipo(Ipo *ipo, EditIpo **si)
+static int make_constraint_editipo(Ipo *ipo, EditIpo **si)
{
EditIpo *ei;
int a;
@@ -1100,7 +727,8 @@ int make_constraint_editipo(Ipo *ipo, EditIpo **si)
return CO_TOTIPO;
}
-int make_action_editipo(Ipo *ipo, EditIpo **si)
+
+static int make_bone_editipo(Ipo *ipo, EditIpo **si)
{
EditIpo *ei;
int a;
@@ -1126,7 +754,7 @@ int make_action_editipo(Ipo *ipo, EditIpo **si)
return AC_TOTIPO;
}
-void make_sound_editipo(SpaceIpo *si)
+static void make_sound_editipo(SpaceIpo *si)
{
EditIpo *ei;
int a;
@@ -1153,23 +781,24 @@ void make_sound_editipo(SpaceIpo *si)
}
}
-void make_editipo(void)
+/* only called in test_editipo() below */
+static void make_editipo(void)
{
EditIpo *ei;
Object *ob;
- ID *from;
rctf *rf;
int a;
if(G.sipo->editipo)
MEM_freeN(G.sipo->editipo);
+
G.sipo->editipo= NULL;
G.sipo->totipo= 0;
+
+ if(G.sipo->from==NULL) return;
+
ob= OBACT;
- G.sipo->ipo= get_ipo_to_edit(&from);
- G.sipo->from= from;
-
if(G.sipo->ipo) G.sipo->showkey= G.sipo->ipo->showkey;
if(G.sipo->blocktype==ID_SEQ) {
@@ -1226,17 +855,17 @@ void make_editipo(void)
make_sound_editipo(G.sipo);
}
}
- else if(G.sipo->blocktype==IPO_CO){
+ else if(G.sipo->blocktype==ID_CO){
G.sipo->totipo = make_constraint_editipo(G.sipo->ipo, (EditIpo**)&G.sipo->editipo);
if (ob) {
- ob->ipowin= IPO_CO;
+ ob->ipowin= ID_CO;
}
}
- else if(G.sipo->blocktype==ID_AC) {
+ else if(G.sipo->blocktype==ID_PO) {
- G.sipo->totipo = make_action_editipo(G.sipo->ipo, (EditIpo**)&G.sipo->editipo);
+ G.sipo->totipo = make_bone_editipo(G.sipo->ipo, (EditIpo**)&G.sipo->editipo);
if (ob) {
- ob->ipowin= ID_AC;
+ ob->ipowin= ID_PO;
}
}
@@ -1259,73 +888,187 @@ void make_editipo(void)
}
else {
- if(G.sipo->blocktype==ID_OB) {
- G.v2d->cur.xmin= 0.0;
- G.v2d->cur.xmax= EFRA;
- G.v2d->cur.ymin= -5.0;
- G.v2d->cur.ymax= +5.0;
- }
- else if(G.sipo->blocktype==ID_CA) {
- G.v2d->cur.xmin= 0.0;
- G.v2d->cur.xmax= EFRA;
- G.v2d->cur.ymin= 0.0;
- G.v2d->cur.ymax= 100.0;
- }
- else if ELEM5(G.sipo->blocktype, ID_MA, ID_CU, ID_WO, ID_LA, IPO_CO) {
- G.v2d->cur.xmin= (float)-0.1;
- G.v2d->cur.xmax= EFRA;
- G.v2d->cur.ymin= (float)-0.1;
- G.v2d->cur.ymax= (float)+1.1;
- }
- else if(G.sipo->blocktype==ID_TE) {
- G.v2d->cur.xmin= (float)-0.1;
- G.v2d->cur.xmax= EFRA;
- G.v2d->cur.ymin= (float)-0.1;
- G.v2d->cur.ymax= (float)+1.1;
- }
- else if(G.sipo->blocktype==ID_SEQ) {
- G.v2d->cur.xmin= -5.0;
- G.v2d->cur.xmax= 105.0;
- G.v2d->cur.ymin= (float)-0.1;
- G.v2d->cur.ymax= (float)+1.1;
- }
- else if(G.sipo->blocktype==ID_KE) {
- G.v2d->cur.xmin= (float)-0.1;
- G.v2d->cur.xmax= EFRA;
- G.v2d->cur.ymin= (float)-0.1;
- G.v2d->cur.ymax= (float)+2.1;
- }
-
+ ipo_default_v2d_cur(G.sipo->blocktype, &G.v2d->cur);
}
}
+/* evaluates context in the current UI */
+/* blocktype is type of ipo */
+/* from is the base pointer to find data to change (ob in case of action or pose) */
+static void get_ipo_context(short blocktype, ID **from, Ipo **ipo, char *actname, char *constname)
+{
+ Object *ob= OBACT;
+
+ *from= NULL;
+ *ipo= NULL;
+
+ if(blocktype==ID_CO) {
+ if (ob) {
+ bConstraintChannel *chan;
+ bConstraint *con= get_active_constraint(ob);
+
+ if(con) {
+ BLI_strncpy(constname, con->name, 32);
+
+ chan= get_active_constraint_channel(ob);
+ if(chan) {
+ *ipo= chan->ipo;
+ BLI_strncpy(constname, con->name, 32);
+ }
+
+ *from= &ob->id;
+
+ /* set actname if in posemode */
+ if(ob->action) {
+ if(ob->flag & OB_POSEMODE) {
+ bPoseChannel *pchan= get_active_posechannel(ob);
+ if(pchan)
+ BLI_strncpy(actname, pchan->name, 32);
+ }
+ else if(ob->ipoflag & OB_ACTION_OB)
+ strcpy(actname, "Object");
+ }
+ }
+ }
+ }
+ else if(blocktype==ID_PO) {
+ if (ob && ob->action) {
+ bPoseChannel *pchan= get_active_posechannel(ob);
+
+ *from= (ID *)ob;
+ if (pchan) {
+ bActionChannel *achan;
+
+ BLI_strncpy(actname, pchan->name, 32); /* also set when no channel yet */
+
+ achan= get_action_channel(ob->action, pchan->name);
+ if(achan)
+ *ipo= achan->ipo;
+ }
+ }
+
+ }
+ else if(blocktype==ID_OB) {
+ if(ob) {
+ *from= (ID *)ob;
+ if(ob->ipoflag & OB_ACTION_OB) {
+ if (ob->action) {
+ bActionChannel *achan= get_action_channel(ob->action, "Object");
+ if(achan) {
+ *ipo= achan->ipo;
+ BLI_strncpy(actname, achan->name, 32);
+ }
+ }
+ }
+ else {
+ *ipo= ob->ipo;
+ }
+ }
+ }
+ else if(blocktype==ID_SEQ) {
+ extern Sequence *last_seq;
+
+ *from= (ID *)last_seq;
+ if(last_seq) *ipo= last_seq->ipo;
+ }
+ else if(blocktype==ID_WO) {
+ World *wo= G.scene->world;
+ *from= (ID *)wo;
+ if(wo) *ipo= wo->ipo;
+ }
+ else if(blocktype==ID_TE) {
+ if(ob) {
+ Tex *tex= give_current_texture(ob, ob->actcol);
+ *from= (ID *)tex;
+ if(tex) *ipo= tex->ipo;
+ }
+ }
+ else if(blocktype==ID_MA) {
+ if(ob) {
+ Material *ma= give_current_material(ob, ob->actcol);
+ *from= (ID *)ma;
+ if(ma) *ipo= ma->ipo;
+ }
+ }
+ else if(blocktype==ID_KE) {
+ if(ob) {
+ Key *key= ob_get_key(ob);
+ *from= (ID *)key;
+ if(key) *ipo= key->ipo;
+ }
+ }
+ else if(blocktype==ID_CU) {
+ if(ob && ob->type==OB_CURVE) {
+ Curve *cu= ob->data;
+ *from= (ID *)cu;
+ *ipo= cu->ipo;
+ }
+ }
+ else if(blocktype==ID_LA) {
+ if(ob && ob->type==OB_LAMP) {
+ Lamp *la= ob->data;
+ *from= (ID *)la;
+ *ipo= la->ipo;
+ }
+ }
+ else if(blocktype==ID_CA) {
+ if(ob && ob->type==OB_CAMERA) {
+ Camera *ca= ob->data;
+ *from= (ID *)ca;
+ if(ca) *ipo= ca->ipo;
+ }
+ }
+ else if(blocktype==ID_SO) {
+
+ // if (G.buts && G.buts->mainb == BUTS_SOUND) {
+ // bSound *sound = G.buts->lockpoin;
+ // *from= (ID *)sound;
+ // if(sound) *ipo= sound->ipo;
+ // }
+ }
+}
+/* called on each redraw, check if editipo data has to be remade */
void test_editipo(void)
{
- Ipo *ipo;
- ID *from;
+ int doit= 0;
- if(G.sipo->editipo==NULL){
- make_editipo();
+ if(G.sipo->pin==0) {
+ Ipo *ipo;
+ ID *from;
+ char actname[32]="", constname[32]="";
+
+ get_ipo_context(G.sipo->blocktype, &from, &ipo, actname, constname);
+
+ if(G.sipo->ipo != ipo) {
+ G.sipo->ipo= ipo;
+ if(ipo) G.v2d->cur= ipo->cur;
+ doit= 1;
+ }
+ if(G.sipo->from != from) {
+ G.sipo->from= from;
+ doit= 1;
+ }
+ if( strcmp(G.sipo->actname, actname)) {
+ BLI_strncpy(G.sipo->actname, actname, 32);
+ doit= 1;
+ }
+ if( strcmp(G.sipo->constname, constname)) {
+ BLI_strncpy(G.sipo->constname, constname, 32);
+ doit= 1;
+ }
+
+ if(G.sipo->ipo)
+ G.sipo->ipo->cur = G.v2d->cur;
+
}
- else {
- ipo= get_ipo_to_edit(&from);
-
- if(G.sipo->ipo != ipo || G.sipo->from!=from)
- make_editipo();
+ if(G.sipo->editipo==NULL || doit) {
+ make_editipo();
}
-
- if (G.sipo->pin)
- return;
-
-
- if(G.sipo->ipo)
- G.sipo->ipo->cur = G.v2d->cur;
-
}
-/* ****************************************** */
+/* ****************** EditIpo ************************ */
int totipo_edit, totipo_sel, totipo_curve, totipo_vis, totipo_vert, totipo_vertsel, totipo_key, totipo_keysel;
@@ -1426,6 +1169,7 @@ void update_editipo_flags(void)
}
}
+/* sort of enter/leave editmode for curves */
void set_editflag_editipo(void)
{
EditIpo *ei;
@@ -1470,171 +1214,7 @@ void set_editflag_editipo(void)
scrarea_queue_winredraw(curarea);
}
-void ipo_toggle_showkey(void)
-{
- if(G.sipo->showkey) {
- G.sipo->showkey= 0;
- swap_selectall_editipo(); /* sel all */
- }
- else G.sipo->showkey= 1;
- free_ipokey(&G.sipo->ipokey);
- if(G.sipo->ipo) G.sipo->ipo->showkey= G.sipo->showkey;
-
- BIF_undo_push("Toggle show key Ipo");
-}
-
-void swap_selectall_editipo(void)
-{
- Object *ob;
- EditIpo *ei;
- IpoKey *ik;
- BezTriple *bezt;
- int a, b; /* , sel=0; */
-
- get_status_editipo();
-
- if(G.sipo->showkey) {
- ik= G.sipo->ipokey.first;
- while(ik) {
- if(totipo_vertsel) ik->flag &= ~1;
- else ik->flag |= 1;
- ik= ik->next;
- }
- update_editipo_flags();
-
- if(G.sipo->showkey && G.sipo->blocktype==ID_OB ) {
- ob= OBACT;
- if(ob && (ob->ipoflag & OB_DRAWKEY)) draw_object_ext(BASACT);
- }
- }
- else if(totipo_edit==0) {
- ei= G.sipo->editipo;
- if (ei){
- for(a=0; a<G.sipo->totipo; a++) {
- if( ei->flag & IPO_VISIBLE ) {
- if(totipo_sel) ei->flag &= ~IPO_SELECT;
- else ei->flag |= IPO_SELECT;
- }
- ei++;
- }
- update_editipo_flags();
- }
- get_status_editipo();
- }
- else {
- ei= G.sipo->editipo;
- for(a=0; a<G.sipo->totipo; a++) {
- if ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_EDIT, icu ) {
- bezt= ei->icu->bezt;
- if(bezt) {
- b= ei->icu->totvert;
- while(b--) {
- if(totipo_vertsel) {
- bezt->f1= bezt->f2= bezt->f3= 0;
- }
- else {
- bezt->f1= bezt->f2= bezt->f3= 1;
- }
- bezt++;
- }
- }
- }
- ei++;
- }
-
- }
-
- BIF_undo_push("Swap select all Ipo");
- scrarea_queue_winredraw(curarea);
-
-}
-
-void swap_visible_editipo(void)
-{
- EditIpo *ei;
- Object *ob;
- int a; /* , sel=0; */
-
- get_status_editipo();
-
-
- ei= G.sipo->editipo;
- for(a=0; a<G.sipo->totipo; a++) {
- if(totipo_vis==0) {
- if(ei->icu) {
- ei->flag |= IPO_VISIBLE;
- ei->flag |= IPO_SELECT;
- }
- }
- else ei->flag &= ~IPO_VISIBLE;
- ei++;
- }
-
- update_editipo_flags();
-
- if(G.sipo->showkey) {
-
- make_ipokey();
-
- ob= OBACT;
- if(ob && (ob->ipoflag & OB_DRAWKEY)) allqueue(REDRAWVIEW3D, 0);
- }
-
- scrarea_queue_winredraw(curarea);
- BIF_undo_push("Swap Visible Ipo");
-}
-
-void deselectall_editipo(void)
-{
- EditIpo *ei;
- IpoKey *ik;
- BezTriple *bezt;
- int a, b; /* , sel=0; */
-
- get_status_editipo();
-
- if(G.sipo->showkey) {
- ik= G.sipo->ipokey.first;
- while(ik) {
- ik->flag &= ~1;
- ik= ik->next;
- }
- update_editipo_flags();
-
- }
- else if(totipo_edit==0) {
-
- ei= G.sipo->editipo;
- for(a=0; a<G.sipo->totipo; a++) {
- if( ei->flag & IPO_VISIBLE ) {
- ei->flag &= ~IPO_SELECT;
- }
- ei++;
- }
- update_editipo_flags();
- }
- else {
- ei= G.sipo->editipo;
- for(a=0; a<G.sipo->totipo; a++) {
- if ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_EDIT, icu ) {
- if(ei->icu->bezt) {
- bezt= ei->icu->bezt;
- b= ei->icu->totvert;
- while(b--) {
- bezt->f1= bezt->f2= bezt->f3= 0;
- bezt++;
- }
- }
- }
- ei++;
- }
- }
-
- BIF_undo_push("(De)select all Ipo");
- scrarea_queue_winredraw(curarea);
-}
-
-short findnearest_ipovert(IpoCurve **icu, BezTriple **bezt)
+static short findnearest_ipovert(IpoCurve **icu, BezTriple **bezt)
{
/* selected verts get a disadvantage */
/* in icu and (bezt or bp) the nearest is written */
@@ -1651,7 +1231,7 @@ short findnearest_ipovert(IpoCurve **icu, BezTriple **bezt)
ei= G.sipo->editipo;
for(a=0; a<G.sipo->totipo; a++, ei++) {
- if ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_EDIT, icu) {
+ if (ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_EDIT, icu)) {
if(ei->icu->bezt) {
bezt1= ei->icu->bezt;
@@ -1704,55 +1284,192 @@ short findnearest_ipovert(IpoCurve **icu, BezTriple **bezt)
return hpoint;
}
-
-void move_to_frame(void)
+void mouse_select_ipo(void)
{
- EditIpo *ei;
+ Object *ob;
+ Key *key;
+ KeyBlock *kb, *actkb=NULL, *curkb;
+ EditIpo *ei, *actei= 0;
+ IpoCurve *icu;
+ IpoKey *ik, *actik;
BezTriple *bezt;
- ID *id;
- float cfra;
- int a, b;
+ float x, y, dist, mindist;
+ int a, oldflag = 0, hand, ok;
+ short mval[2], xo, yo;
if(G.sipo->editipo==0) return;
-
- ei= G.sipo->editipo;
-
- for(a=0; a<G.sipo->totipo; a++, ei++) {
- if ISPOIN(ei, flag & IPO_VISIBLE, icu) {
- if(G.sipo->showkey || (ei->flag & IPO_EDIT)) {
+
+ get_status_editipo();
+
+ if(G.sipo->showkey) {
+ getmouseco_areawin(mval);
+
+ areamouseco_to_ipoco(G.v2d, mval, &x, &y);
+ actik= 0;
+ mindist= 1000.0;
+ ik= G.sipo->ipokey.first;
+ while(ik) {
+ dist= (float)(fabs(ik->val-x));
+ if(ik->flag & 1) dist+= 1.0;
+ if(dist < mindist) {
+ actik= ik;
+ mindist= dist;
+ }
+ ik= ik->next;
+ }
+ if(actik) {
+ oldflag= actik->flag;
- if(ei->icu->bezt) {
-
- b= ei->icu->totvert;
- bezt= ei->icu->bezt;
- while(b--) {
- if(BEZSELECTED(bezt)) {
-
- cfra= bezt->vec[1][0]/G.scene->r.framelen;
-
- id= G.sipo->from;
- if(id && GS(id->name)==ID_OB ) {
- Object *ob= (Object *)id;
- if(ob->sf!=0.0 && (ob->ipoflag & OB_OFFS_OB) ) {
- cfra+= ob->sf/G.scene->r.framelen;
- }
- }
- CFRA= (short)floor(cfra+0.5);
-
- if(CFRA < 1) CFRA= 1;
- update_for_newframe();
-
- break;
- }
- bezt++;
+ if(G.qual & LR_SHIFTKEY);
+ else deselectall_editipo();
+
+ if(G.qual & LR_SHIFTKEY) {
+ if(oldflag & 1) actik->flag &= ~1;
+ else actik->flag |= 1;
+ }
+ else {
+ actik->flag |= 1;
+ }
+ }
+ }
+ else if(totipo_edit) {
+
+ hand= findnearest_ipovert(&icu, &bezt);
+
+ if(G.qual & LR_SHIFTKEY) {
+ if(bezt) {
+ if(hand==1) {
+ if(BEZSELECTED(bezt)) {
+ bezt->f1= bezt->f2= bezt->f3= 0;
}
+ else {
+ bezt->f1= bezt->f2= bezt->f3= 1;
+ }
+ }
+ else if(hand==0) {
+ if(bezt->f1 & 1) bezt->f1= 0;
+ else bezt->f1= 1;
+ }
+ else {
+ if(bezt->f3 & 1) bezt->f3= 0;
+ else bezt->f3= 1;
}
+ }
+ }
+ else {
+ deselectall_editipo();
+
+ if(bezt) {
+ if(hand==1) {
+ bezt->f1|= 1; bezt->f2|= 1; bezt->f3|= 1;
+ }
+ else if(hand==0) bezt->f1|= 1;
+ else bezt->f3|= 1;
}
}
}
- BIF_undo_push("Set frame to selected Ipo vertex");
+ else {
+
+ /* vertex keys ? */
+ if(G.sipo->blocktype==ID_KE && G.sipo->from) {
+ int i, index= 1;
+
+ key= (Key *)G.sipo->from;
+ ob= OBACT;
+ curkb= BLI_findlink(&key->block, ob->shapenr-1);
+
+ ei= G.sipo->editipo;
+ if(key->type==KEY_NORMAL || (ei->flag & IPO_VISIBLE)) {
+ getmouseco_areawin(mval);
+
+ areamouseco_to_ipoco(G.v2d, mval, &x, &y);
+ /* how much is 20 pixels? */
+ mindist= (float)(20.0*(G.v2d->cur.ymax-G.v2d->cur.ymin)/(float)curarea->winy);
+
+ for(i=1, kb= key->block.first; kb; kb= kb->next, i++) {
+ dist= (float)(fabs(kb->pos-y));
+ if(kb==curkb) dist+= (float)0.01;
+ if(dist < mindist) {
+ actkb= kb;
+ mindist= dist;
+ index= i;
+ }
+ }
+ if(actkb) {
+ ok= TRUE;
+ if(G.obedit && actkb!=curkb) {
+ ok= okee("Copy key after leaving Edit Mode");
+ }
+ if(ok) {
+ /* also does all keypos */
+ deselectall_editipo();
+ set_active_key(index);
+ set_active_editipo(ei+index-1);
+ }
+ }
+ }
+ }
+
+ /* select curve */
+ if(actkb==NULL) {
+ if(totipo_vis==1) {
+ ei= G.sipo->editipo;
+ for(a=0; a<G.sipo->totipo; a++, ei++) {
+ if(ei->icu) {
+ if(ei->flag & IPO_VISIBLE) actei= ei;
+ }
+ }
+ }
+ else if(totipo_vis>1) {
+ actei= select_proj_ipo(0, 0);
+ }
+
+ if(actei) oldflag= actei->flag;
+
+ if(G.qual & LR_SHIFTKEY);
+ else deselectall_editipo();
+
+ if(actei) {
+ if(G.qual & LR_SHIFTKEY) {
+ if(oldflag & IPO_SELECT) actei->flag &= ~IPO_SELECT;
+ else actei->flag |= IPO_SELECT;
+ }
+ else {
+ actei->flag |= IPO_SELECT;
+ }
+ set_active_editipo(actei);
+ }
+ }
+ }
+
+ update_editipo_flags();
+
+ force_draw(0);
+ BIF_undo_push("Select Ipo");
+
+ if(G.sipo->showkey && G.sipo->blocktype==ID_OB) {
+ ob= OBACT;
+ if(ob && (ob->ipoflag & OB_DRAWKEY)) allqueue(REDRAWVIEW3D, 0);
+ }
+
+ getmouseco_areawin(mval);
+ xo= mval[0];
+ yo= mval[1];
+
+ while(get_mbut()&R_MOUSE) {
+ getmouseco_areawin(mval);
+ if(abs(mval[0]-xo)+abs(mval[1]-yo) > 4) {
+
+ if(actkb) move_keys(OBACT);
+ else transform_ipo('g');
+
+ return;
+ }
+ BIF_wait_for_statechange();
+ }
}
+
/* *********************************** */
/* handling of right-hand channel/curve buttons in ipo window */
@@ -1843,203 +1560,189 @@ void do_ipo_selectbuttons(void)
BIF_undo_push("Select Ipo curve");
}
-/* ******************************************* */
-
-EditIpo *get_editipo(void)
-{
- EditIpo *ei;
- int a; /* , sel=0; */
-
- get_status_editipo();
-
- if(totipo_edit>1) {
- return 0;
- }
- if(G.sipo->editipo==0) return 0;
-
- ei= G.sipo->editipo;
- for(a=0; a<G.sipo->totipo; a++) {
- if(ei->flag & IPO_VISIBLE) {
- if( ei->flag & IPO_EDIT ) return ei;
- else if(totipo_vis==1) return ei;
-
- if(ei->flag & IPO_SELECT) {
- if(totipo_sel==1) return ei;
- }
- }
- ei++;
- }
- return 0;
-}
+/* ********************************* Inserting keys ********************************************* */
+/* depending type, it returns ipo, if neded it creates one */
+/* returns either action ipo or "real" ipo */
+/* arguments define full context;
+ - *from has to be set always, to Object in case of Actions
+ - blocktype defines available channels of Ipo struct (blocktype ID_OB can be in action too)
+ - if actname, use this to locate action, and optional constname to find the channel
+*/
-Ipo *get_ipo(ID *from, short type, int make)
+/* note; check header_ipo.c, spaceipo_assign_ipo() too */
+Ipo *verify_ipo(ID *from, short blocktype, char *actname, char *constname)
{
- Object *ob;
- Material *ma;
- Tex *tex;
- Curve *cu;
- Sequence *seq;
- Key *key;
- World *wo;
- Lamp *la;
- Camera *ca;
- Ipo *ipo= NULL;
- bAction *act;
- if(from==NULL) return NULL;
+ if(from==NULL || from->lib) return NULL;
- if( type==ID_OB) {
- ob= (Object *)from;
- if(ob->id.lib) return NULL;
+ /* first check action ipos */
+ if(actname && actname[0]) {
+ Object *ob= (Object *)from;
+ bActionChannel *achan;
- ipo= ob->ipo;
- if(make && ipo==NULL) ipo= ob->ipo= add_ipo("ObIpo", ID_OB);
- }
- else if( type==IPO_CO){
- bConstraintChannel *chan;
+ if(ob->action==NULL)
+ ob->action= add_empty_action(blocktype);
- ob= (Object *)from;
- if(ob->id.lib) return NULL;
+ achan= verify_action_channel(ob->action, actname);
- chan= get_active_constraint_channel(ob);
-
- if (chan){
- ipo= chan->ipo;
- if(make && ipo==NULL) ipo= chan->ipo= add_ipo("CoIpo", IPO_CO);
+ if(achan) {
+ /* constraint exception */
+ if(blocktype==ID_CO) {
+ bConstraintChannel *conchan= verify_constraint_channel(&achan->constraintChannels, constname);
+ if(conchan->ipo==NULL) {
+ conchan->ipo= add_ipo("CoIpo", ID_CO);
+ }
+ return conchan->ipo;
+ }
+ else {
+ if(achan->ipo==NULL) {
+ achan->ipo= add_ipo("ActIpo", blocktype);
+ }
+
+ return achan->ipo;
+ }
}
}
- else if( type==ID_AC) {
- act= (bAction *)from;
- if (act->id.lib) return NULL;
-
- /* weak... the *from pointer has action, ipo doesnt give more context info yet */
- verify_active_action_channel(OBACT);
-
- if (act->achan==NULL)
- return NULL;
+ else {
- ipo= act->achan->ipo;
+ switch(GS(from->name)) {
+ case ID_OB:
+ {
+ Object *ob= (Object *)from;
+ /* constraint exception */
+ if(blocktype==ID_CO) {
+ bConstraintChannel *conchan= verify_constraint_channel(&ob->constraintChannels, constname);
+ if(conchan->ipo==NULL) {
+ conchan->ipo= add_ipo("CoIpo", ID_CO);
+ }
+ return conchan->ipo;
+ }
+ else if(blocktype==ID_OB) {
+ if(ob->ipo==NULL) {
+ ob->ipo= add_ipo("ObIpo", ID_OB);
+ }
+ return ob->ipo;
+ }
+ }
+ break;
+ case ID_MA:
+ {
+ Material *ma= (Material *)from;
- if(make && ipo==NULL) {
- ipo= act->achan->ipo= add_ipo(act->achan->name, ID_AC);
- allspace(REMAKEIPO, 0);
- allqueue(REDRAWIPO, 0);
- allqueue(REDRAWACTION, 0);
- }
- }
- else if( type==ID_MA) {
- ma= (Material *)from;
- if(ma->id.lib) return NULL;
- ipo= ma->ipo;
-
- if(make && ipo==NULL) ipo= ma->ipo= add_ipo("MatIpo", ID_MA);
- }
- else if( type==ID_TE) {
- tex= (Tex *)from;
- if(tex->id.lib) return NULL;
- ipo= tex->ipo;
-
- if(make && ipo==NULL) ipo= tex->ipo= add_ipo("TexIpo", ID_TE);
- }
- else if( type==ID_SEQ) {
- seq= (Sequence *)from;
+ if(ma->ipo==NULL) {
+ ma->ipo= add_ipo("MatIpo", ID_MA);
+ }
+ return ma->ipo;
+ }
+ break;
+ case ID_TE:
+ {
+ Tex *tex= (Tex *)from;
+
+ if(tex->ipo==NULL) {
+ tex->ipo= add_ipo("TexIpo", ID_TE);
+ }
+ return tex->ipo;
+ }
+ break;
+ case ID_SEQ:
+ {
+ Sequence *seq= (Sequence *)from; /* note, sequence is mimicing Id */
+
+ if((seq->type & SEQ_EFFECT)||(seq->type == SEQ_SOUND)) {
+ if(seq->ipo==NULL) {
+ seq->ipo= add_ipo("SeqIpo", ID_SEQ);
+ }
+ return seq->ipo;
+ }
+ }
+ break;
+ case ID_CU:
+ {
+ Curve *cu= (Curve *)from;
+
+ if(cu->ipo==NULL) {
+ cu->ipo= add_ipo("CuIpo", ID_CU);
+ }
+ return cu->ipo;
+ }
+ break;
+ case ID_KE:
+ {
+ Key *key= (Key *)from;
- if((seq->type & SEQ_EFFECT)||(seq->type == SEQ_SOUND)) {
- ipo= seq->ipo;
- if(make && ipo==NULL) ipo= seq->ipo= add_ipo("SeqIpo", ID_SEQ);
+ if(key->ipo==NULL) {
+ key->ipo= add_ipo("KeyIpo", ID_KE);
+ }
+ return key->ipo;
+ }
+ break;
+ case ID_WO:
+ {
+ World *wo= (World *)from;
+
+ if(wo->ipo==NULL) {
+ wo->ipo= add_ipo("WoIpo", ID_WO);
+ }
+ return wo->ipo;
+ }
+ break;
+ case ID_LA:
+ {
+ Lamp *la= (Lamp *)from;
+
+ if(la->ipo==NULL) {
+ la->ipo= add_ipo("LaIpo", ID_LA);
+ }
+ return la->ipo;
+ }
+ break;
+ case ID_CA:
+ {
+ Camera *ca= (Camera *)from;
+
+ if(ca->ipo==NULL) {
+ ca->ipo= add_ipo("CaIpo", ID_CA);
+ }
+ return ca->ipo;
+ }
+ break;
+ case ID_SO:
+ {
+ bSound *snd= (bSound *)from;
+
+ if(snd->ipo==NULL) {
+ snd->ipo= add_ipo("SndIpo", ID_SO);
+ }
+ return snd->ipo;
+ }
}
- else return NULL;
- }
- else if( type==ID_CU) {
- cu= (Curve *)from;
- if(cu->id.lib) return NULL;
- ipo= cu->ipo;
-
- if(make && ipo==NULL) ipo= cu->ipo= add_ipo("CuIpo", ID_CU);
- }
- else if( type==ID_KE) {
- key= (Key *)from;
- if(key->id.lib) return NULL;
- ipo= key->ipo;
-
- if(make && ipo==NULL) ipo= key->ipo= add_ipo("KeyIpo", ID_KE);
}
- else if( type==ID_WO) {
- wo= (World *)from;
- if(wo->id.lib) return NULL;
- ipo= wo->ipo;
-
- if(make && ipo==NULL) ipo= wo->ipo= add_ipo("WoIpo", ID_WO);
- }
- else if( type==ID_LA) {
- la= (Lamp *)from;
- if(la->id.lib) return NULL;
- ipo= la->ipo;
-
- if(make && ipo==NULL) ipo= la->ipo= add_ipo("LaIpo", ID_LA);
- }
- else if( type==ID_CA) {
- ca= (Camera *)from;
- if(ca->id.lib) return NULL;
- ipo= ca->ipo;
-
- if(make && ipo==NULL) ipo= ca->ipo= add_ipo("CaIpo", ID_CA);
- }
- else if( type==ID_SO) {
- bSound *snd= (bSound *)from;
- if(snd->id.lib) return NULL;
- ipo= snd->ipo;
-
- if(make && ipo==NULL) ipo= snd->ipo= add_ipo("SndIpo", ID_SO);
- }
- else return NULL;
- return ipo;
+ return NULL;
}
-
-// this function should not have the G.sipo in it...
-
-IpoCurve *get_ipocurve(ID *from, short type, int adrcode, Ipo *useipo)
+/* returns and creates */
+IpoCurve *verify_ipocurve(ID *from, short blocktype, char *actname, char *constname, int adrcode)
{
- Ipo *ipo= NULL;
- IpoCurve *icu=NULL;
+ Ipo *ipo;
+ IpoCurve *icu= NULL;
/* return 0 if lib */
- /* also test if ipo and ipocurve exist */
-
- if (useipo==NULL) {
- if (G.sipo==NULL || G.sipo->pin==0){
- ipo= get_ipo(from, type, 1); /* 1= make */
- }
- else
- ipo = G.sipo->ipo;
-
- if(G.sipo) {
- if (G.sipo->pin==0) G.sipo->ipo= ipo;
- }
- }
- else
- ipo= useipo;
-
-
- if(ipo && ipo->id.lib==0) {
+ /* creates ipo too */
+ ipo= verify_ipo(from, blocktype, actname, constname);
- icu= ipo->curve.first;
- while(icu) {
+ if(ipo && ipo->id.lib==NULL) {
+
+ for(icu= ipo->curve.first; icu; icu= icu->next) {
if(icu->adrcode==adrcode) break;
- icu= icu->next;
}
- if(icu==0) {
+ if(icu==NULL) {
icu= MEM_callocN(sizeof(IpoCurve), "ipocurve");
-
- icu->flag |= IPO_VISIBLE|IPO_AUTO_HORIZ;
- if (!useipo && G.sipo && G.sipo->pin)
- icu->blocktype = G.sipo->blocktype;
- else
- icu->blocktype= type;
+ icu->flag |= IPO_VISIBLE|IPO_AUTO_HORIZ;
+ icu->blocktype= blocktype;
icu->adrcode= adrcode;
set_icu_vars(icu);
@@ -2047,6 +1750,7 @@ IpoCurve *get_ipocurve(ID *from, short type, int adrcode, Ipo *useipo)
BLI_addtail( &(ipo->curve), icu);
}
}
+
return icu;
}
@@ -2138,17 +1842,19 @@ void add_vert_ipo(void)
if(mval[0]>G.v2d->mask.xmax) return;
- ei= get_editipo();
+ ei= get_active_editipo();
if(ei==0) {
- error("Too many (or no) EditIpos");
+ error("No active Ipo curve");
return;
}
areamouseco_to_ipoco(G.v2d, mval, &x, &y);
if(ei->icu==NULL) {
- if(G.sipo->from)
- ei->icu= get_ipocurve(G.sipo->from, G.sipo->blocktype, ei->adrcode, 0);
+ if(G.sipo->from) {
+ ei->icu= verify_ipocurve(G.sipo->from, G.sipo->blocktype, G.sipo->actname, G.sipo->constname, ei->adrcode);
+ ei->flag |= ei->icu->flag & IPO_AUTO_HORIZ; /* new curve could have been added, weak... */
+ }
}
if(ei->icu==NULL) return;
@@ -2169,6 +1875,591 @@ void add_vert_ipo(void)
BIF_undo_push("Add Ipo vertex");
}
+static void *get_context_ipo_poin(ID *id, int blocktype, char *actname, IpoCurve *icu, int *vartype)
+{
+ if(blocktype==ID_PO) {
+ if(GS(id->name)==ID_OB) {
+ Object *ob= (Object *)id;
+ bPoseChannel *pchan= get_pose_channel(ob->pose, actname);
+
+ *vartype= IPO_FLOAT;
+ return get_pchan_ipo_poin(pchan, icu->adrcode);
+ }
+ return NULL;
+ }
+ else
+ return get_ipo_poin(id, icu, vartype);
+
+}
+
+void insertkey(ID *id, int blocktype, char *actname, char *constname, int adrcode)
+{
+ IpoCurve *icu;
+ Object *ob;
+ void *poin= NULL;
+ float curval, cfra;
+ int vartype;
+
+ icu= verify_ipocurve(id, blocktype, actname, constname, adrcode);
+
+ if(icu) {
+
+ poin= get_context_ipo_poin(id, blocktype, actname, icu, &vartype);
+
+ if(poin) {
+ curval= read_ipo_poin(poin, vartype);
+
+ cfra= frame_to_float(CFRA);
+
+ /* if action is mapped in NLA, it returns a correction */
+ if(actname && actname[0] && GS(id->name)==ID_OB)
+ cfra= get_action_frame((Object *)id, cfra);
+
+ if( GS(id->name)==ID_OB ) {
+ ob= (Object *)id;
+ if(ob->sf!=0.0 && (ob->ipoflag & OB_OFFS_OB) ) {
+ /* actually frametofloat calc again! */
+ cfra-= ob->sf*G.scene->r.framelen;
+ }
+ }
+
+ insert_vert_ipo(icu, cfra, curval);
+ }
+ }
+}
+
+void insertkey_editipo(void)
+{
+ EditIpo *ei;
+ IpoKey *ik;
+ ID *id;
+ float *fp, cfra, *insertvals;
+ int a, nr, ok, tot;
+ short event;
+
+ ei= get_active_editipo();
+ if(ei && ei->icu && ei->icu->driver)
+ event= pupmenu("Insert Curve %t|Default one-to-one mapping %x3");
+ else if(G.sipo->showkey)
+ event= pupmenu("Insert Key Vertices %t|Current Frame %x1|Selected Keys %x2");
+ else
+ event= pupmenu("Insert Key Vertices %t|Current Frame %x1");
+
+ if(event<1) return;
+
+ if(event==3) {
+ IpoDriver *driver= ei->icu->driver;
+
+ if(ei->icu->bezt) MEM_freeN(ei->icu->bezt);
+ ei->icu->totvert= 0;
+ ei->icu->bezt= NULL;
+
+ insert_vert_ipo(ei->icu, 0.0f, 0.0f);
+
+ if(ELEM3(driver->adrcode, OB_ROT_X, OB_ROT_Y, OB_ROT_Z)) {
+ if(ei->disptype==IPO_DISPDEGR)
+ insert_vert_ipo(ei->icu, 18.0f, 18.0f);
+ else
+ insert_vert_ipo(ei->icu, 18.0f, 1.0f);
+ }
+ else
+ insert_vert_ipo(ei->icu, 1.0f, 1.0f);
+
+ ei->flag |= IPO_SELECT|IPO_VISIBLE;
+ ei->icu->flag= ei->flag;
+ ei->icu->extrap= IPO_DIR;
+
+ do_ipo_buttons(B_IPOHOME);
+ }
+ else {
+ ei= G.sipo->editipo;
+ for(nr=0; nr<G.sipo->totipo; nr++, ei++) {
+ if (ISPOIN(ei, flag & IPO_VISIBLE, icu)) {
+
+ ok= 0;
+ if(G.sipo->showkey) ok= 1;
+ else if(ei->flag & IPO_SELECT) ok= 1;
+
+ if(ok) {
+ /* count amount */
+ if(event==1) tot= 1;
+ else {
+ ik= G.sipo->ipokey.first;
+ tot= 0;
+ while(ik) {
+ if(ik->flag & 1) tot++;
+ ik= ik->next;
+ }
+ }
+ if(tot) {
+
+ /* correction for ob timeoffs */
+ cfra= frame_to_float(CFRA);
+ id= G.sipo->from;
+ if(id && GS(id->name)==ID_OB ) {
+ Object *ob= (Object *)id;
+ if(ob->sf!=0.0 && (ob->ipoflag & OB_OFFS_OB) ) {
+ cfra-= ob->sf*G.scene->r.framelen;
+ }
+ }
+ else if(id && GS(id->name)==ID_SEQ) {
+ extern Sequence *last_seq; /* editsequence.c */
+
+ if(last_seq) {
+ cfra= (float)(100.0*(cfra-last_seq->startdisp)/((float)(last_seq->enddisp-last_seq->startdisp)));
+ }
+ }
+
+ insertvals= MEM_mallocN(sizeof(float)*2*tot, "insertkey_editipo");
+ /* make sure icu->curval is correct */
+ calc_ipo(G.sipo->ipo, cfra);
+
+ if(event==1) {
+ insertvals[0]= cfra;
+
+ insertvals[1]= ei->icu->curval;
+ }
+ else {
+ fp= insertvals;
+ ik= G.sipo->ipokey.first;
+ while(ik) {
+ if(ik->flag & 1) {
+ calc_ipo(G.sipo->ipo, ik->val);
+
+ fp[0]= ik->val;
+ fp[1]= ei->icu->curval;
+ fp+= 2;
+ }
+ ik= ik->next;
+ }
+ }
+ fp= insertvals;
+ for(a=0; a<tot; a++, fp+=2) {
+ insert_vert_ipo(ei->icu, fp[0], fp[1]);
+ }
+
+ MEM_freeN(insertvals);
+ calc_ipo(G.sipo->ipo, (float)CFRA);
+ }
+ }
+ }
+ }
+ }
+ BIF_undo_push("Insert Key Ipo");
+ allqueue (REDRAWACTION, 0);
+ allqueue(REDRAWNLA, 0);
+ allqueue(REDRAWIPO, 0);
+ allspace(REMAKEIPO, 0);
+}
+
+
+void common_insertkey(void)
+{
+ Base *base;
+ Object *ob;
+ Material *ma;
+ ID *id;
+ IpoCurve *icu;
+ World *wo;
+ Lamp *la;
+ int tlay, map, event;
+ char menustr[256];
+
+ if(curarea->spacetype==SPACE_IPO) {
+ insertkey_editipo();
+ }
+ else if(curarea->spacetype==SPACE_BUTS) {
+ if(G.buts->mainb==CONTEXT_SHADING) {
+ int tab= G.buts->tab[CONTEXT_SHADING];
+
+ if(tab==TAB_SHADING_MAT) {
+ id= G.buts->lockpoin;
+ ma= G.buts->lockpoin;
+ if(id) {
+ event= pupmenu("Insert Key %t|RGB%x0|Alpha%x1|Halo Size%x2|Mode %x3|All Color%x10|All Mirror%x14|Ofs%x12|Size%x13|All Mapping%x11");
+ if(event== -1) return;
+
+ map= texchannel_to_adrcode(ma->texact);
+
+ if(event==0 || event==10) {
+ insertkey(id, ID_MA, NULL, NULL, MA_COL_R);
+ insertkey(id, ID_MA, NULL, NULL, MA_COL_G);
+ insertkey(id, ID_MA, NULL, NULL, MA_COL_B);
+ }
+ if(event==1 || event==10) {
+ insertkey(id, ID_MA, NULL, NULL, MA_ALPHA);
+ }
+ if(event==2 || event==10) {
+ insertkey(id, ID_MA, NULL, NULL, MA_HASIZE);
+ }
+ if(event==3 || event==10) {
+ insertkey(id, ID_MA, NULL, NULL, MA_MODE);
+ }
+ if(event==10) {
+ insertkey(id, ID_MA, NULL, NULL, MA_SPEC_R);
+ insertkey(id, ID_MA, NULL, NULL, MA_SPEC_G);
+ insertkey(id, ID_MA, NULL, NULL, MA_SPEC_B);
+ insertkey(id, ID_MA, NULL, NULL, MA_REF);
+ insertkey(id, ID_MA, NULL, NULL, MA_EMIT);
+ insertkey(id, ID_MA, NULL, NULL, MA_AMB);
+ insertkey(id, ID_MA, NULL, NULL, MA_SPEC);
+ insertkey(id, ID_MA, NULL, NULL, MA_HARD);
+ insertkey(id, ID_MA, NULL, NULL, MA_MODE);
+ insertkey(id, ID_MA, NULL, NULL, MA_TRANSLU);
+ insertkey(id, ID_MA, NULL, NULL, MA_ADD);
+ }
+ if(event==14) {
+ insertkey(id, ID_MA, NULL, NULL, MA_RAYM);
+ insertkey(id, ID_MA, NULL, NULL, MA_FRESMIR);
+ insertkey(id, ID_MA, NULL, NULL, MA_FRESMIRI);
+ insertkey(id, ID_MA, NULL, NULL, MA_FRESTRA);
+ insertkey(id, ID_MA, NULL, NULL, MA_FRESTRAI);
+ }
+ if(event==12 || event==11) {
+ insertkey(id, ID_MA, NULL, NULL, map+MAP_OFS_X);
+ insertkey(id, ID_MA, NULL, NULL, map+MAP_OFS_Y);
+ insertkey(id, ID_MA, NULL, NULL, map+MAP_OFS_Z);
+ }
+ if(event==13 || event==11) {
+ insertkey(id, ID_MA, NULL, NULL, map+MAP_SIZE_X);
+ insertkey(id, ID_MA, NULL, NULL, map+MAP_SIZE_Y);
+ insertkey(id, ID_MA, NULL, NULL, map+MAP_SIZE_Z);
+ }
+ if(event==11) {
+ insertkey(id, ID_MA, NULL, NULL, map+MAP_R);
+ insertkey(id, ID_MA, NULL, NULL, map+MAP_G);
+ insertkey(id, ID_MA, NULL, NULL, map+MAP_B);
+ insertkey(id, ID_MA, NULL, NULL, map+MAP_DVAR);
+ insertkey(id, ID_MA, NULL, NULL, map+MAP_COLF);
+ insertkey(id, ID_MA, NULL, NULL, map+MAP_NORF);
+ insertkey(id, ID_MA, NULL, NULL, map+MAP_VARF);
+ insertkey(id, ID_MA, NULL, NULL, map+MAP_DISP);
+ }
+ }
+ }
+ else if(tab==TAB_SHADING_WORLD) {
+ id= G.buts->lockpoin;
+ wo= G.buts->lockpoin;
+ if(id) {
+ event= pupmenu("Insert Key %t|Zenith RGB%x0|Horizon RGB%x1|Mist%x2|Stars %x3|Offset%x12|Size%x13");
+ if(event== -1) return;
+
+ map= texchannel_to_adrcode(wo->texact);
+
+ if(event==0) {
+ insertkey(id, ID_WO, NULL, NULL, WO_ZEN_R);
+ insertkey(id, ID_WO, NULL, NULL, WO_ZEN_G);
+ insertkey(id, ID_WO, NULL, NULL, WO_ZEN_B);
+ }
+ if(event==1) {
+ insertkey(id, ID_WO, NULL, NULL, WO_HOR_R);
+ insertkey(id, ID_WO, NULL, NULL, WO_HOR_G);
+ insertkey(id, ID_WO, NULL, NULL, WO_HOR_B);
+ }
+ if(event==2) {
+ insertkey(id, ID_WO, NULL, NULL, WO_MISI);
+ insertkey(id, ID_WO, NULL, NULL, WO_MISTDI);
+ insertkey(id, ID_WO, NULL, NULL, WO_MISTSTA);
+ insertkey(id, ID_WO, NULL, NULL, WO_MISTHI);
+ }
+ if(event==3) {
+ insertkey(id, ID_WO, NULL, NULL, WO_STAR_R);
+ insertkey(id, ID_WO, NULL, NULL, WO_STAR_G);
+ insertkey(id, ID_WO, NULL, NULL, WO_STAR_B);
+ insertkey(id, ID_WO, NULL, NULL, WO_STARDIST);
+ insertkey(id, ID_WO, NULL, NULL, WO_STARSIZE);
+ }
+ if(event==12) {
+ insertkey(id, ID_WO, NULL, NULL, map+MAP_OFS_X);
+ insertkey(id, ID_WO, NULL, NULL, map+MAP_OFS_Y);
+ insertkey(id, ID_WO, NULL, NULL, map+MAP_OFS_Z);
+ }
+ if(event==13) {
+ insertkey(id, ID_WO, NULL, NULL, map+MAP_SIZE_X);
+ insertkey(id, ID_WO, NULL, NULL, map+MAP_SIZE_Y);
+ insertkey(id, ID_WO, NULL, NULL, map+MAP_SIZE_Z);
+ }
+ }
+ }
+ else if(tab==TAB_SHADING_LAMP) {
+ id= G.buts->lockpoin;
+ la= G.buts->lockpoin;
+ if(id) {
+ event= pupmenu("Insert Key %t|RGB%x0|Energy%x1|Spot Size%x2|Offset%x12|Size%x13");
+ if(event== -1) return;
+
+ map= texchannel_to_adrcode(la->texact);
+
+ if(event==0) {
+ insertkey(id, ID_LA, NULL, NULL, LA_COL_R);
+ insertkey(id, ID_LA, NULL, NULL, LA_COL_G);
+ insertkey(id, ID_LA, NULL, NULL, LA_COL_B);
+ }
+ if(event==1) {
+ insertkey(id, ID_LA, NULL, NULL, LA_ENERGY);
+ }
+ if(event==2) {
+ insertkey(id, ID_LA, NULL, NULL, LA_SPOTSI);
+ }
+ if(event==12) {
+ insertkey(id, ID_LA, NULL, NULL, map+MAP_OFS_X);
+ insertkey(id, ID_LA, NULL, NULL, map+MAP_OFS_Y);
+ insertkey(id, ID_LA, NULL, NULL, map+MAP_OFS_Z);
+ }
+ if(event==13) {
+ insertkey(id, ID_LA, NULL, NULL, map+MAP_SIZE_X);
+ insertkey(id, ID_LA, NULL, NULL, map+MAP_SIZE_Y);
+ insertkey(id, ID_LA, NULL, NULL, map+MAP_SIZE_Z);
+ }
+
+ }
+ }
+ }
+ else if(G.buts->mainb==CONTEXT_OBJECT) {
+ ob= OBACT;
+ if(ob && ob->type==OB_MESH) {
+ id= (ID *) (ob);
+ if(id) {
+ event= pupmenu("Insert Key %t|Surface Damping%x0|Random Damping%x1|Permeability%x2|Force Strength%x3|Force Falloff%x4");
+ if(event== -1) return;
+
+ if(event==0) {
+ insertkey(id, ID_OB, NULL, NULL, OB_PD_SDAMP);
+ }
+ if(event==1) {
+ insertkey(id, ID_OB, NULL, NULL, OB_PD_RDAMP);
+ }
+ if(event==2) {
+ insertkey(id, ID_OB, NULL, NULL, OB_PD_PERM);
+ }
+ if(event==3) {
+ insertkey(id, ID_OB, NULL, NULL, OB_PD_FSTR);
+ }
+ if(event==4) {
+ insertkey(id, ID_OB, NULL, NULL, OB_PD_FFALL);
+ }
+
+ }
+ }
+ }
+ else if(G.buts->mainb==CONTEXT_EDITING) {
+ ob= OBACT;
+ if(ob && ob->type==OB_CAMERA) {
+ id= G.buts->lockpoin;
+ if(id) {
+ /* yafray: insert key extended with aperture and focal distance */
+ if (G.scene->r.renderer==R_INTERN)
+ event= pupmenu("Insert Key %t|Lens%x0|Clipping%x1");
+ else
+ event= pupmenu("Insert Key %t|Lens%x0|Clipping%x1|Aperture%x2|FocalDistance%x3");
+ if(event== -1) return;
+
+ if(event==0) {
+ insertkey(id, ID_CA, NULL, NULL, CAM_LENS);
+ }
+ else if(event==1) {
+ insertkey(id, ID_CA, NULL, NULL, CAM_STA);
+ insertkey(id, ID_CA, NULL, NULL, CAM_END);
+ }
+ else if(event==2) {
+ insertkey(id, ID_CA, NULL, NULL, CAM_YF_APERT);
+ }
+ else if(event==3) {
+ insertkey(id, ID_CA, NULL, NULL, CAM_YF_FDIST);
+ }
+ }
+ }
+ }
+ else if(FALSE /* && G.buts->mainb==BUTS_SOUND */) {
+ if(G.ssound) {
+ id= G.buts->lockpoin;
+ if(id) {
+ event= pupmenu("Insert Key %t|Volume%x0|Pitch%x1|Panning%x2|Attennuation%x3");
+ if(event== -1) return;
+
+ if(event==0) {
+ insertkey(id, ID_SO, NULL, NULL, SND_VOLUME);
+ }
+ if(event==1) {
+ insertkey(id, ID_SO, NULL, NULL, SND_PITCH);
+ }
+ if(event==2) {
+ insertkey(id, ID_SO, NULL, NULL, SND_PANNING);
+ }
+ if(event==3) {
+ insertkey(id, ID_SO, NULL, NULL, SND_ATTEN);
+ }
+ }
+ }
+ }
+
+ BIF_undo_push("Insert Key Buttons");
+
+ allqueue(REDRAWACTION, 0);
+ allqueue(REDRAWNLA, 0);
+ allqueue(REDRAWIPO, 0);
+ allspace(REMAKEIPO, 0);
+
+ }
+ else if(curarea->spacetype==SPACE_VIEW3D) {
+ ob= OBACT;
+
+ if (ob && (ob->flag & OB_POSEMODE)) {
+ strcpy(menustr, "Insert Key%t|Loc%x0|Rot%x1|Size%x2|LocRot%x3|LocRotSize%x4|Avail%x9");
+ }
+ else {
+ base= FIRSTBASE;
+ while(base) {
+ if TESTBASELIB(base) break;
+ base= base->next;
+ }
+ if(base==NULL) return;
+
+ strcpy(menustr, "Insert Key%t|Loc%x0|Rot%x1|Size%x2|LocRot%x3|LocRotSize%x4|Layer%x5|Avail%x9");
+ }
+
+ if(ob) {
+ if(ob->type==OB_MESH) strcat(menustr, "| %x6|Mesh%x7");
+ else if(ob->type==OB_LATTICE) strcat(menustr, "| %x6|Lattice%x7");
+ else if(ob->type==OB_CURVE) strcat(menustr, "| %x6|Curve%x7");
+ else if(ob->type==OB_SURF) strcat(menustr, "| %x6|Surface%x7");
+ if(ob->flag & OB_FROMGROUP) strcat(menustr, "| %x6|Entire Group%x10");
+ }
+
+ event= pupmenu(menustr);
+ if(event== -1) return;
+
+ if(event==7) { // ob != NULL
+ insert_shapekey(ob);
+ return;
+ }
+
+ if(event==10) {
+ Group *group= find_group(ob);
+ if(group) {
+ add_group_key(group);
+ allqueue(REDRAWBUTSOBJECT, 0);
+ }
+ }
+
+ if (ob && (ob->flag & OB_POSEMODE)){
+ bPoseChannel *pchan;
+
+ if (ob->action && ob->action->id.lib) {
+ error ("Can't key libactions");
+ return;
+ }
+
+ set_pose_keys(ob); // sets pchan->flag to POSE_KEY if bone selected
+ id= &ob->id;
+ for (pchan=ob->pose->chanbase.first; pchan; pchan=pchan->next) {
+ if (pchan->flag & POSE_KEY){
+ if(event==0 || event==3 ||event==4) {
+ insertkey(id, ID_PO, pchan->name, NULL, AC_LOC_X);
+ insertkey(id, ID_PO, pchan->name, NULL, AC_LOC_Y);
+ insertkey(id, ID_PO, pchan->name, NULL, AC_LOC_Z);
+ }
+ if(event==1 || event==3 ||event==4) {
+ insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_X);
+ insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_Y);
+ insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_Z);
+ insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_W);
+ }
+ if(event==2 || event==4) {
+ insertkey(id, ID_PO, pchan->name, NULL, AC_SIZE_X);
+ insertkey(id, ID_PO, pchan->name, NULL, AC_SIZE_Y);
+ insertkey(id, ID_PO, pchan->name, NULL, AC_SIZE_Z);
+ }
+ if (event==9 && ob->action) {
+ bActionChannel *achan;
+
+ for (achan = ob->action->chanbase.first; achan; achan=achan->next){
+ if (achan->ipo && !strcmp (achan->name, pchan->name)){
+ for (icu = achan->ipo->curve.first; icu; icu=icu->next){
+ insertkey(id, ID_PO, achan->name, NULL, icu->adrcode);
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+ remake_action_ipos(ob->action);
+
+ DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
+
+ allqueue(REDRAWIPO, 0);
+ allqueue(REDRAWACTION, 0);
+ allqueue(REDRAWNLA, 0);
+ }
+ else {
+ base= FIRSTBASE;
+ while(base) {
+ if TESTBASELIB(base) {
+ char *actname= NULL;
+
+ id= (ID *)(base->object);
+
+ if(ob->ipoflag & OB_ACTION_OB)
+ actname= "Object";
+
+ /* all curves in ipo deselect */
+ if(base->object->ipo) {
+ icu= base->object->ipo->curve.first;
+ while(icu) {
+ icu->flag &= ~IPO_SELECT;
+ if(event==9) insertkey(id, ID_OB, actname, NULL, icu->adrcode);
+ icu= icu->next;
+ }
+ }
+
+ if(event==0 || event==3 ||event==4) {
+ insertkey(id, ID_OB, actname, NULL, OB_LOC_X);
+ insertkey(id, ID_OB, actname, NULL, OB_LOC_Y);
+ insertkey(id, ID_OB, actname, NULL, OB_LOC_Z);
+ }
+ if(event==1 || event==3 ||event==4) {
+ insertkey(id, ID_OB, actname, NULL, OB_ROT_X);
+ insertkey(id, ID_OB, actname, NULL, OB_ROT_Y);
+ insertkey(id, ID_OB, actname, NULL, OB_ROT_Z);
+ }
+ if(event==2 || event==4) {
+ insertkey(id, ID_OB, actname, NULL, OB_SIZE_X);
+ insertkey(id, ID_OB, actname, NULL, OB_SIZE_Y);
+ insertkey(id, ID_OB, actname, NULL, OB_SIZE_Z);
+ }
+ if(event==5) {
+ /* remove localview */
+ tlay= base->object->lay;
+ base->object->lay &= 0xFFFFFF;
+ insertkey(id, ID_OB, actname, NULL, OB_LAY);
+ base->object->lay= tlay;
+ }
+ }
+ base= base->next;
+ }
+ }
+
+ if(event==0) BIF_undo_push("Insert Loc Key");
+ else if(event==1) BIF_undo_push("Insert Rot Key");
+ else if(event==2) BIF_undo_push("Insert Size Key");
+ else if(event==3) BIF_undo_push("Insert LocRot Key");
+ else if(event==4) BIF_undo_push("Insert LocRotSize Key");
+ else if(event==5) BIF_undo_push("Insert Layer Key");
+ else if(event==7) BIF_undo_push("Insert Vertex Key");
+ else if(event==9) BIF_undo_push("Insert Avail Key");
+
+ allspace(REMAKEIPO, 0);
+ allqueue(REDRAWIPO, 0);
+ allqueue(REDRAWVIEW3D, 0);
+ allqueue(REDRAWACTION, 0);
+ allqueue(REDRAWNLA, 0);
+ }
+
+}
+
+/* ****************************************************************************** */
+
void add_duplicate_editipo(void)
{
Object *ob;
@@ -2182,7 +2473,7 @@ void add_duplicate_editipo(void)
ei= G.sipo->editipo;
for(a=0; a<G.sipo->totipo; a++, ei++) {
- if ISPOIN3(ei, flag & IPO_VISIBLE, icu, icu->bezt) {
+ if (ISPOIN3(ei, flag & IPO_VISIBLE, icu, icu->bezt)) {
if(G.sipo->showkey || (ei->flag & IPO_EDIT)) {
icu= ei->icu;
@@ -2240,7 +2531,7 @@ void remove_doubles_ipo(void)
ei= G.sipo->editipo;
for(a=0; a<G.sipo->totipo; a++, ei++) {
- if ISPOIN3(ei, flag & IPO_VISIBLE, icu, icu->bezt) {
+ if (ISPOIN3(ei, flag & IPO_VISIBLE, icu, icu->bezt)) {
/* OR the curve is selected OR in editmode OR in keymode */
mode= 0;
@@ -2353,7 +2644,7 @@ void join_ipo(int mode)
/* first: multiple selected verts in 1 curve */
ei= G.sipo->editipo;
for(a=0; a<G.sipo->totipo; a++, ei++) {
- if ISPOIN3(ei, flag & IPO_VISIBLE, icu, icu->bezt) {
+ if (ISPOIN3(ei, flag & IPO_VISIBLE, icu, icu->bezt)) {
if(G.sipo->showkey || (ei->flag & IPO_EDIT)) {
icu= ei->icu;
@@ -2479,7 +2770,7 @@ void ipo_snap(short event)
ei= G.sipo->editipo;
for(b=0; b<G.sipo->totipo; b++, ei++) {
- if ISPOIN3(ei, flag & IPO_VISIBLE, icu, icu->bezt) {
+ if (ISPOIN3(ei, flag & IPO_VISIBLE, icu, icu->bezt)) {
ok2= 0;
if(G.sipo->showkey) ok2= 1;
@@ -2546,717 +2837,8 @@ void ipo_snap(short event)
BIF_undo_push("Snap Ipo");
}
-
-
-void mouse_select_ipo(void)
-{
- Object *ob;
- Key *key;
- KeyBlock *kb, *actkb=NULL, *curkb;
- EditIpo *ei, *actei= 0;
- IpoCurve *icu;
- IpoKey *ik, *actik;
- BezTriple *bezt;
- float x, y, dist, mindist;
- int a, oldflag = 0, hand, ok;
- short mval[2], xo, yo;
-
- if(G.sipo->editipo==0) return;
-
- get_status_editipo();
-
- if(G.sipo->showkey) {
- getmouseco_areawin(mval);
-
- areamouseco_to_ipoco(G.v2d, mval, &x, &y);
- actik= 0;
- mindist= 1000.0;
- ik= G.sipo->ipokey.first;
- while(ik) {
- dist= (float)(fabs(ik->val-x));
- if(ik->flag & 1) dist+= 1.0;
- if(dist < mindist) {
- actik= ik;
- mindist= dist;
- }
- ik= ik->next;
- }
- if(actik) {
- oldflag= actik->flag;
-
- if(G.qual & LR_SHIFTKEY);
- else deselectall_editipo();
-
- if(G.qual & LR_SHIFTKEY) {
- if(oldflag & 1) actik->flag &= ~1;
- else actik->flag |= 1;
- }
- else {
- actik->flag |= 1;
- }
- }
- }
- else if(totipo_edit) {
-
- hand= findnearest_ipovert(&icu, &bezt);
-
- if(G.qual & LR_SHIFTKEY) {
- if(bezt) {
- if(hand==1) {
- if(BEZSELECTED(bezt)) {
- bezt->f1= bezt->f2= bezt->f3= 0;
- }
- else {
- bezt->f1= bezt->f2= bezt->f3= 1;
- }
- }
- else if(hand==0) {
- if(bezt->f1 & 1) bezt->f1= 0;
- else bezt->f1= 1;
- }
- else {
- if(bezt->f3 & 1) bezt->f3= 0;
- else bezt->f3= 1;
- }
- }
- }
- else {
- deselectall_editipo();
-
- if(bezt) {
- if(hand==1) {
- bezt->f1|= 1; bezt->f2|= 1; bezt->f3|= 1;
- }
- else if(hand==0) bezt->f1|= 1;
- else bezt->f3|= 1;
- }
- }
- }
- else {
-
- /* vertex keys ? */
- if(G.sipo->blocktype==ID_KE && G.sipo->from) {
- int i, index= 1;
-
- key= (Key *)G.sipo->from;
- ob= OBACT;
- curkb= BLI_findlink(&key->block, ob->shapenr-1);
-
- ei= G.sipo->editipo;
- if(key->type==KEY_NORMAL || (ei->flag & IPO_VISIBLE)) {
- getmouseco_areawin(mval);
-
- areamouseco_to_ipoco(G.v2d, mval, &x, &y);
- /* how much is 20 pixels? */
- mindist= (float)(20.0*(G.v2d->cur.ymax-G.v2d->cur.ymin)/(float)curarea->winy);
-
- for(i=1, kb= key->block.first; kb; kb= kb->next, i++) {
- dist= (float)(fabs(kb->pos-y));
- if(kb==curkb) dist+= (float)0.01;
- if(dist < mindist) {
- actkb= kb;
- mindist= dist;
- index= i;
- }
- }
- if(actkb) {
- ok= TRUE;
- if(G.obedit && actkb!=curkb) {
- ok= okee("Copy key after leaving Edit Mode");
- }
- if(ok) {
- /* also does all keypos */
- deselectall_editipo();
- set_active_key(index);
- set_active_editipo(ei+index-1);
- }
- }
- }
- }
-
- /* select curve */
- if(actkb==NULL) {
- if(totipo_vis==1) {
- ei= G.sipo->editipo;
- for(a=0; a<G.sipo->totipo; a++, ei++) {
- if(ei->icu) {
- if(ei->flag & IPO_VISIBLE) actei= ei;
- }
- }
- }
- else if(totipo_vis>1) {
- actei= select_proj_ipo(0, 0);
- }
-
- if(actei) oldflag= actei->flag;
-
- if(G.qual & LR_SHIFTKEY);
- else deselectall_editipo();
-
- if(actei) {
- if(G.qual & LR_SHIFTKEY) {
- if(oldflag & IPO_SELECT) actei->flag &= ~IPO_SELECT;
- else actei->flag |= IPO_SELECT;
- }
- else {
- actei->flag |= IPO_SELECT;
- }
- set_active_editipo(actei);
- }
- }
- }
-
- update_editipo_flags();
-
- force_draw(0);
- BIF_undo_push("Select Ipo");
-
- if(G.sipo->showkey && G.sipo->blocktype==ID_OB) {
- ob= OBACT;
- if(ob && (ob->ipoflag & OB_DRAWKEY)) allqueue(REDRAWVIEW3D, 0);
- }
-
- getmouseco_areawin(mval);
- xo= mval[0];
- yo= mval[1];
-
- while(get_mbut()&R_MOUSE) {
- getmouseco_areawin(mval);
- if(abs(mval[0]-xo)+abs(mval[1]-yo) > 4) {
-
- if(actkb) move_keys(OBACT);
- else transform_ipo('g');
-
- return;
- }
- BIF_wait_for_statechange();
- }
-}
-
-static int icu_keys_bezier_loop(IpoCurve *icu,
- int (*bezier_function)(BezTriple *),
- void (ipocurve_function)(struct IpoCurve *icu))
-{
- /* This loops through the beziers in the Ipocurve, and executes
- * the generic user provided 'bezier_function' on each one.
- * Optionally executes the generic function ipocurve_function on the
- * IPO curve after looping (eg. calchandles_ipocurve)
- */
-
- int b;
- BezTriple *bezt;
-
- b = icu->totvert;
- bezt = icu->bezt;
-
- /* if bezier_function has been specified
- * then loop through each bezier executing
- * it.
- */
-
- if (bezier_function != NULL) {
- while(b--) {
- /* exit with return code 1 if the bezier function
- * returns 1 (good for when you are only interested
- * in finding the first bezier that
- * satisfies a condition).
- */
- if (bezier_function(bezt)) return 1;
- bezt++;
- }
- }
-
- /* if ipocurve_function has been specified
- * then execute it
- */
- if (ipocurve_function != NULL)
- ipocurve_function(icu);
-
- return 0;
-
-}
-
-static int ipo_keys_bezier_loop(Ipo *ipo,
- int (*bezier_function)(BezTriple *),
- void (ipocurve_function)(struct IpoCurve *icu))
-{
- /* This loops through the beziers that are attached to
- * the selected keys on the Ipocurves of the Ipo, and executes
- * the generic user provided 'bezier_function' on each one.
- * Optionally executes the generic function ipocurve_function on a
- * IPO curve after looping (eg. calchandles_ipocurve)
- */
-
- IpoCurve *icu;
-
- /* Loop through each curve in the Ipo
- */
- for (icu=ipo->curve.first; icu; icu=icu->next){
- if (icu_keys_bezier_loop(icu,bezier_function, ipocurve_function))
- return 1;
- }
-
- return 0;
-}
-
-static int selected_bezier_loop(int (*looptest)(EditIpo *),
- int (*bezier_function)(BezTriple *),
- void (ipocurve_function)(struct IpoCurve *icu))
-{
- /* This loops through the beziers that are attached to
- * selected keys in editmode in the IPO window, and executes
- * the generic user-provided 'bezier_function' on each one
- * that satisfies the 'looptest' function. Optionally executes
- * the generic function ipocurve_function on a IPO curve
- * after looping (eg. calchandles_ipocurve)
- */
-
- EditIpo *ei;
- BezTriple *bezt;
- int a, b;
-
- /* Get the first Edit Ipo from the selected Ipos
- */
- ei= G.sipo->editipo;
-
- /* Loop throught all of the selected Ipo's
- */
- for(a=0; a<G.sipo->totipo; a++, ei++) {
- /* Do a user provided test on the Edit Ipo
- * to determine whether we want to process it
- */
- if (looptest(ei)) {
- /* Loop through the selected
- * beziers on the Edit Ipo
- */
- bezt = ei->icu->bezt;
- b = ei->icu->totvert;
-
- /* if bezier_function has been specified
- * then loop through each bezier executing
- * it.
- */
- if (bezier_function != NULL) {
- while(b--) {
- /* exit with return code 1 if the bezier function
- * returns 1 (good for when you are only interested
- * in finding the first bezier that
- * satisfies a condition).
- */
- if (bezier_function(bezt)) return 1;
- bezt++;
- }
- }
-
- /* if ipocurve_function has been specified
- * then execute it
- */
- if (ipocurve_function != NULL)
- ipocurve_function(ei->icu);
- }
- /* nufte flourdje zim ploopydu <-- random dutch looking comment ;) */
- /* looks more like russian to me! (ton) */
- }
-
- return 0;
-}
-
-int select_bezier_add(BezTriple *bezt)
-{
- /* Select the bezier triple */
- bezt->f1 |= 1;
- bezt->f2 |= 1;
- bezt->f3 |= 1;
- return 0;
-}
-
-int select_bezier_subtract(BezTriple *bezt)
-{
- /* Deselect the bezier triple */
- bezt->f1 &= ~1;
- bezt->f2 &= ~1;
- bezt->f3 &= ~1;
- return 0;
-}
-
-int select_bezier_invert(BezTriple *bezt)
-{
- /* Invert the selection for the bezier triple */
- bezt->f2 ^= 1;
- if ( bezt->f2 & 1 ) {
- bezt->f1 |= 1;
- bezt->f3 |= 1;
- }
- else {
- bezt->f1 &= ~1;
- bezt->f3 &= ~1;
- }
- return 0;
-}
-
-static int set_bezier_auto(BezTriple *bezt)
-{
- /* Sets the selected bezier handles to type 'auto'
- */
-
- /* is a handle selected? If so
- * set it to type auto
- */
- if(bezt->f1 || bezt->f3) {
- if(bezt->f1) bezt->h1= 1; /* the secret code for auto */
- if(bezt->f3) bezt->h2= 1;
-
- /* if the handles are not of the same type, set them
- * to type free
- */
- if(bezt->h1!=bezt->h2) {
- if ELEM(bezt->h1, HD_ALIGN, HD_AUTO) bezt->h1= HD_FREE;
- if ELEM(bezt->h2, HD_ALIGN, HD_AUTO) bezt->h2= HD_FREE;
- }
- }
- return 0;
-}
-
-static int set_bezier_vector(BezTriple *bezt)
-{
- /* Sets the selected bezier handles to type 'vector'
- */
-
- /* is a handle selected? If so
- * set it to type vector
- */
- if(bezt->f1 || bezt->f3) {
- if(bezt->f1) bezt->h1= 2; /* the code for vector */
- if(bezt->f3) bezt->h2= 2;
-
- /* if the handles are not of the same type, set them
- * to type free
- */
- if(bezt->h1!=bezt->h2) {
- if ELEM(bezt->h1, HD_ALIGN, HD_AUTO) bezt->h1= HD_FREE;
- if ELEM(bezt->h2, HD_ALIGN, HD_AUTO) bezt->h2= HD_FREE;
- }
- }
- return 0;
-}
-
-static int bezier_isfree(BezTriple *bezt)
-{
- /* queries whether the handle should be set
- * to type 'free' (I think)
- */
- if(bezt->f1 && bezt->h1) return 1;
- if(bezt->f3 && bezt->h2) return 1;
- return 0;
-}
-
-static int set_bezier_free(BezTriple *bezt)
-{
- /* Sets selected bezier handles to type 'free'
- */
- if(bezt->f1) bezt->h1= HD_FREE;
- if(bezt->f3) bezt->h2= HD_FREE;
- return 0;
-}
-
-static int set_bezier_align(BezTriple *bezt)
-{
- /* Sets selected bezier handles to type 'align'
- */
- if(bezt->f1) bezt->h1= HD_ALIGN;
- if(bezt->f3) bezt->h2= HD_ALIGN;
- return 0;
-}
-
-static int vis_edit_icu_bez(EditIpo *ei)
-{
- /* A 4 part test for an EditIpo :
- * is it a) visible
- * b) in edit mode
- * c) does it contain an Ipo Curve
- * d) does that ipo curve have a bezier
- *
- * (The reason why I don't just use the macro
- * is I need a pointer to a function.)
- */
- return ISPOIN4(ei, flag & IPO_VISIBLE, flag & IPO_EDIT, icu, icu->bezt);
-}
-
-void select_ipo_bezier_keys(Ipo *ipo, int selectmode)
-{
- /* Select all of the beziers in all
- * of the Ipo curves belonging to the
- * Ipo, using the selection mode.
- */
- switch (selectmode) {
- case SELECT_ADD:
- ipo_keys_bezier_loop(ipo, select_bezier_add, NULL);
- break;
- case SELECT_SUBTRACT:
- ipo_keys_bezier_loop(ipo, select_bezier_subtract, NULL);
- break;
- case SELECT_INVERT:
- ipo_keys_bezier_loop(ipo, select_bezier_invert, NULL);
- break;
- }
-}
-
-void sethandles_ipo_keys(Ipo *ipo, int code)
-{
- /* this function lets you set bezier handles all to
- * one type for some Ipo's (e.g. with hotkeys through
- * the action window).
- */
-
- /* code==1: set autohandle */
- /* code==2: set vectorhandle */
- /* als code==3 (HD_ALIGN) toggelt het, vectorhandles worden HD_FREE */
-
- switch(code) {
- case 1:
- /*** Set to auto ***/
- ipo_keys_bezier_loop(ipo, set_bezier_auto,
- calchandles_ipocurve);
- break;
- case 2:
- /*** Set to vector ***/
- ipo_keys_bezier_loop(ipo, set_bezier_vector,
- calchandles_ipocurve);
- break;
- default:
- if ( ipo_keys_bezier_loop(ipo, bezier_isfree, NULL) ) {
- /*** Set to free ***/
- ipo_keys_bezier_loop(ipo, set_bezier_free,
- calchandles_ipocurve);
- }
- else {
- /*** Set to align ***/
- ipo_keys_bezier_loop(ipo, set_bezier_align,
- calchandles_ipocurve);
- }
- break;
- }
-
-
-}
-
-static void ipo_curves_auto_horiz(void)
-{
- EditIpo *ei;
- int a, set= 1;
-
- ei= G.sipo->editipo;
- for(a=0; a<G.sipo->totipo; a++, ei++) {
- if ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_SELECT, icu)
- if(ei->flag & IPO_AUTO_HORIZ) set= 0;
- }
-
- ei= G.sipo->editipo;
- for(a=0; a<G.sipo->totipo; a++, ei++) {
- if ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_SELECT, icu) {
- if(set) ei->flag |= IPO_AUTO_HORIZ;
- else ei->flag &= ~IPO_AUTO_HORIZ;
- }
- }
- update_editipo_flags();
-}
-
-void sethandles_ipo(int code)
-{
- /* this function lets you set bezier handles all to
- * one type for some selected keys in edit mode in the
- * IPO window (e.g. with hotkeys)
- */
-
- /* code==1: set autohandle */
- /* code==2: set vectorhandle */
- /* als code==3 (HD_ALIGN) toggelt het, vectorhandles worden HD_FREE */
-
- if(G.sipo->ipo && G.sipo->ipo->id.lib) return;
-
- switch(code) {
- case 1:
- /*** Set to auto ***/
- selected_bezier_loop(vis_edit_icu_bez, set_bezier_auto,
- calchandles_ipocurve);
- break;
- case 2:
- /*** Set to vector ***/
- selected_bezier_loop(vis_edit_icu_bez, set_bezier_vector,
- calchandles_ipocurve);
- break;
- case 4:
- /* set to enforce autohandles to be horizontal on extremes */
- ipo_curves_auto_horiz();
-
- break;
- default:
- if (selected_bezier_loop(vis_edit_icu_bez, bezier_isfree, NULL) ) {
- /*** Set to free ***/
- selected_bezier_loop(vis_edit_icu_bez, set_bezier_free,
- calchandles_ipocurve);
- }
- else {
- /*** Set to align ***/
- selected_bezier_loop(vis_edit_icu_bez, set_bezier_align,
- calchandles_ipocurve);
- }
- break;
- }
-
- editipo_changed(G.sipo, 1);
- BIF_undo_push("Set handles Ipo");
-}
-
-
-static void set_ipocurve_constant(struct IpoCurve *icu) {
- /* Sets the type of the IPO curve to constant
- */
- icu->ipo= IPO_CONST;
-}
-
-static void set_ipocurve_linear(struct IpoCurve *icu) {
- /* Sets the type of the IPO curve to linear
- */
- icu->ipo= IPO_LIN;
-}
-
-static void set_ipocurve_bezier(struct IpoCurve *icu) {
- /* Sets the type of the IPO curve to bezier
- */
- icu->ipo= IPO_BEZ;
-}
-
-
-void setipotype_ipo(Ipo *ipo, int code)
-{
- /* Sets the type of the each ipo curve in the
- * Ipo to a value based on the code
- */
- switch (code) {
- case 1:
- ipo_keys_bezier_loop(ipo, NULL, set_ipocurve_constant);
- break;
- case 2:
- ipo_keys_bezier_loop(ipo, NULL, set_ipocurve_linear);
- break;
- case 3:
- ipo_keys_bezier_loop(ipo, NULL, set_ipocurve_bezier);
- break;
- }
-}
-
-void set_ipotype(void)
-{
- EditIpo *ei;
- int a;
- short event;
-
- if(G.sipo->ipo && G.sipo->ipo->id.lib) return;
- if(G.sipo->showkey) return;
- get_status_editipo();
-
- if(G.sipo->blocktype==ID_KE && totipo_edit==0 && totipo_sel==0) {
- Key *key= (Key *)G.sipo->from;
- Object *ob= OBACT;
- KeyBlock *kb;
-
- if(key==NULL) return;
- kb= BLI_findlink(&key->block, ob->shapenr-1);
-
- event= pupmenu("Key Type %t|Linear %x1|Cardinal %x2|B Spline %x3");
- if(event < 1) return;
-
- kb->type= 0;
- if(event==1) kb->type= KEY_LINEAR;
- if(event==2) kb->type= KEY_CARDINAL;
- if(event==3) kb->type= KEY_BSPLINE;
- }
- else {
- event= pupmenu("Ipo Type %t|Constant %x1|Linear %x2|Bezier %x3");
- if(event < 1) return;
-
- ei= G.sipo->editipo;
- for(a=0; a<G.sipo->totipo; a++, ei++) {
- if ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_SELECT, icu) {
- if(event==1) ei->icu->ipo= IPO_CONST;
- else if(event==2) ei->icu->ipo= IPO_LIN;
- else ei->icu->ipo= IPO_BEZ;
- }
- }
- }
- BIF_undo_push("Set ipo type");
- scrarea_queue_winredraw(curarea);
-}
-
-void borderselect_ipo(void)
-{
- EditIpo *ei;
- IpoKey *ik;
- BezTriple *bezt;
- rcti rect;
- rctf rectf;
- int a, b, val;
- short mval[2];
-
- get_status_editipo();
-
- val= get_border(&rect, 3);
-
- if(val) {
- mval[0]= rect.xmin;
- mval[1]= rect.ymin;
- areamouseco_to_ipoco(G.v2d, mval, &rectf.xmin, &rectf.ymin);
- mval[0]= rect.xmax;
- mval[1]= rect.ymax;
- areamouseco_to_ipoco(G.v2d, mval, &rectf.xmax, &rectf.ymax);
-
- if(G.sipo->showkey) {
- ik= G.sipo->ipokey.first;
- while(ik) {
- if(rectf.xmin<ik->val && rectf.xmax>ik->val) {
- if(val==LEFTMOUSE) ik->flag |= 1;
- else ik->flag &= ~1;
- }
- ik= ik->next;
- }
- update_editipo_flags();
- }
- else if(totipo_edit==0) {
- if(rect.xmin<rect.xmax && rect.ymin<rect.ymax)
- select_proj_ipo(&rectf, val);
- }
- else {
-
- ei= G.sipo->editipo;
- for(a=0; a<G.sipo->totipo; a++, ei++) {
- if ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_EDIT, icu) {
- if(ei->icu->bezt) {
- b= ei->icu->totvert;
- bezt= ei->icu->bezt;
- while(b--) {
- int bit= (val==LEFTMOUSE);
-
- if(BLI_in_rctf(&rectf, bezt->vec[0][0], bezt->vec[0][1]))
- bezt->f1 = (bezt->f1&~1) | bit;
- if(BLI_in_rctf(&rectf, bezt->vec[1][0], bezt->vec[1][1]))
- bezt->f2 = (bezt->f2&~1) | bit;
- if(BLI_in_rctf(&rectf, bezt->vec[2][0], bezt->vec[2][1]))
- bezt->f3 = (bezt->f3&~1) | bit;
-
- bezt++;
- }
- }
- }
- }
- }
- BIF_undo_push("Border select Ipo");
- scrarea_queue_winredraw(curarea);
- }
-}
-
/*
- * When deleting an IPO curve from Python, check if the IPO is being
+ * When deleting an IPO curve from Python, check if the Ipo is being
* edited and if so clear the pointer to the old curve.
*/
@@ -3269,7 +2851,7 @@ void del_ipoCurve ( IpoCurve * icu )
for(i=0; i<G.sipo->totipo; i++, ei++) {
if ( ei->icu == icu ) {
ei->flag &= ~(IPO_SELECT | IPO_EDIT);
- ei->icu= 0;
+ ei->icu= NULL;
return;
}
}
@@ -3300,12 +2882,12 @@ void del_ipo(void)
del= 0;
if(G.sipo->showkey==0 && totipo_edit==0) {
- if ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_SELECT, icu) {
+ if (ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_SELECT, icu)) {
del= 1;
}
}
else {
- if ISPOIN(ei, flag & IPO_VISIBLE, icu) {
+ if (ISPOIN(ei, flag & IPO_VISIBLE, icu)) {
if(G.sipo->showkey || (ei->flag & IPO_EDIT)) {
if(ei->icu->bezt) {
bezt= ei->icu->bezt;
@@ -3346,7 +2928,7 @@ void del_ipo(void)
// 2nd round, small parts: just curves
ei= G.sipo->editipo;
for(b=0; b<G.sipo->totipo; b++, ei++) {
- if ISPOIN(ei, flag & IPO_VISIBLE, icu) {
+ if (ISPOIN(ei, flag & IPO_VISIBLE, icu)) {
if(G.sipo->showkey || (ei->flag & IPO_EDIT)) {
event= 0;
@@ -3389,6 +2971,7 @@ void del_ipo(void)
allspace(REMAKEIPO, 0);
}
+/* ******************** copy paste buffer ******************** */
ListBase ipocopybuf={0, 0};
int totipocopybuf=0;
@@ -3418,7 +3001,7 @@ void copy_editipo(void)
ei= G.sipo->editipo;
for(a=0; a<G.sipo->totipo; a++, ei++) {
- if ISPOIN(ei, flag & IPO_VISIBLE, icu) {
+ if (ISPOIN(ei, flag & IPO_VISIBLE, icu)) {
if( (ei->flag & IPO_EDIT) || (ei->flag & IPO_SELECT) ) {
icu= MEM_callocN(sizeof(IpoCurve), "ipocopybuf");
*icu= *(ei->icu);
@@ -3470,7 +3053,7 @@ void paste_editipo(void)
if(ok) {
- ei->icu= get_ipocurve(G.sipo->from, G.sipo->blocktype, ei->adrcode, 0);
+ ei->icu= verify_ipocurve(G.sipo->from, G.sipo->blocktype, G.sipo->actname, G.sipo->constname, ei->adrcode);
if(ei->icu==NULL) return;
if(ei->icu->bezt) MEM_freeN(ei->icu->bezt);
@@ -3498,28 +3081,10 @@ void paste_editipo(void)
}
}
-void set_exprap_ipo(int mode)
-{
- EditIpo *ei;
- int a;
-
- if(G.sipo->ipo && G.sipo->ipo->id.lib) return;
- /* in case of keys: always ok */
+/* *********************** */
- ei= G.sipo->editipo;
- for(a=0; a<G.sipo->totipo; a++, ei++) {
- if ISPOIN(ei, flag & IPO_VISIBLE, icu) {
- if( (ei->flag & IPO_EDIT) || (ei->flag & IPO_SELECT) || (G.sipo->showkey) ) {
- ei->icu->extrap= mode;
- }
- }
- }
- editipo_changed(G.sipo, 1);
- BIF_undo_push("Set extrapolation Ipo");
-}
-
-int find_other_handles(EditIpo *eicur, float ctime, BezTriple **beztar)
+static int find_other_handles(EditIpo *eicur, float ctime, BezTriple **beztar)
{
EditIpo *ei;
BezTriple *bezt;
@@ -3559,7 +3124,7 @@ void set_speed_editipo(float speed)
ei= G.sipo->editipo;
for(a=0; a<G.sipo->totipo; a++, ei++) {
- if ISPOIN(ei, flag & IPO_VISIBLE, icu) {
+ if (ISPOIN(ei, flag & IPO_VISIBLE, icu)) {
bezt= ei->icu->bezt;
totvert= ei->icu->totvert;
@@ -3619,587 +3184,6 @@ void set_speed_editipo(float speed)
}
-void insertkey(ID *id, int adrcode)
-{
- IpoCurve *icu;
- Ipo *ipo;
- Object *ob;
- void *poin;
- float curval, cfra;
- int type;
-
- if(id) {
-
- // this call here, otherwise get_ipocurve gives it from the pinned ipo
- ipo= get_ipo(id, GS(id->name), 1); // 1=make
-
- icu= get_ipocurve(id, GS(id->name), adrcode, ipo);
-
- if(icu) {
- poin= get_ipo_poin(id, icu, &type);
- if(poin) {
- curval= read_ipo_poin(poin, type);
-
- cfra= frame_to_float(CFRA);
-
- if( GS(id->name)==ID_OB ) {
- ob= (Object *)id;
- if(ob->sf!=0.0 && (ob->ipoflag & OB_OFFS_OB) ) {
- /* actually frametofloat calc again! */
- cfra-= ob->sf*G.scene->r.framelen;
- }
- }
-
- insert_vert_ipo(icu, cfra, curval);
- }
- }
- }
-}
-
-void insertkey_editipo(void)
-{
- EditIpo *ei;
- IpoKey *ik;
- ID *id;
- float *fp, cfra, *insertvals;
- int a, nr, ok, tot;
- short event;
-
- ei= get_active_editipo();
- if(ei && ei->icu && ei->icu->driver)
- event= pupmenu("Insert Curve %t|Default one-to-one mapping %x3");
- else if(G.sipo->showkey)
- event= pupmenu("Insert Key Vertices %t|Current Frame %x1|Selected Keys %x2");
- else
- event= pupmenu("Insert Key Vertices %t|Current Frame %x1");
-
- if(event<1) return;
-
- if(event==3) {
- IpoDriver *driver= ei->icu->driver;
-
- if(ei->icu->bezt) MEM_freeN(ei->icu->bezt);
- ei->icu->totvert= 0;
- ei->icu->bezt= NULL;
-
- insert_vert_ipo(ei->icu, 0.0f, 0.0f);
-
- if(ELEM3(driver->adrcode, OB_ROT_X, OB_ROT_Y, OB_ROT_Z)) {
- if(ei->disptype==IPO_DISPDEGR)
- insert_vert_ipo(ei->icu, 18.0f, 18.0f);
- else
- insert_vert_ipo(ei->icu, 18.0f, 1.0f);
- }
- else
- insert_vert_ipo(ei->icu, 1.0f, 1.0f);
-
- ei->flag |= IPO_SELECT|IPO_VISIBLE;
- ei->icu->flag= ei->flag;
- ei->icu->extrap= IPO_DIR;
-
- do_ipo_buttons(B_IPOHOME);
- }
- else {
- ei= G.sipo->editipo;
- for(nr=0; nr<G.sipo->totipo; nr++, ei++) {
- if ISPOIN(ei, flag & IPO_VISIBLE, icu) {
-
- ok= 0;
- if(G.sipo->showkey) ok= 1;
- else if(ei->flag & IPO_SELECT) ok= 1;
-
- if(ok) {
- /* count amount */
- if(event==1) tot= 1;
- else {
- ik= G.sipo->ipokey.first;
- tot= 0;
- while(ik) {
- if(ik->flag & 1) tot++;
- ik= ik->next;
- }
- }
- if(tot) {
-
- /* correction for ob timeoffs */
- cfra= frame_to_float(CFRA);
- id= G.sipo->from;
- if(id && GS(id->name)==ID_OB ) {
- Object *ob= (Object *)id;
- if(ob->sf!=0.0 && (ob->ipoflag & OB_OFFS_OB) ) {
- cfra-= ob->sf*G.scene->r.framelen;
- }
- }
- else if(id && GS(id->name)==ID_SEQ) {
- extern Sequence *last_seq; /* editsequence.c */
-
- if(last_seq) {
- cfra= (float)(100.0*(cfra-last_seq->startdisp)/((float)(last_seq->enddisp-last_seq->startdisp)));
- }
- }
-
- insertvals= MEM_mallocN(sizeof(float)*2*tot, "insertkey_editipo");
- /* make sure icu->curval is correct */
- calc_ipo(G.sipo->ipo, cfra);
-
- if(event==1) {
- insertvals[0]= cfra;
-
- insertvals[1]= ei->icu->curval;
- }
- else {
- fp= insertvals;
- ik= G.sipo->ipokey.first;
- while(ik) {
- if(ik->flag & 1) {
- calc_ipo(G.sipo->ipo, ik->val);
-
- fp[0]= ik->val;
- fp[1]= ei->icu->curval;
- fp+= 2;
- }
- ik= ik->next;
- }
- }
- fp= insertvals;
- for(a=0; a<tot; a++, fp+=2) {
- insert_vert_ipo(ei->icu, fp[0], fp[1]);
- }
-
- MEM_freeN(insertvals);
- calc_ipo(G.sipo->ipo, (float)CFRA);
- }
- }
- }
- }
- }
- BIF_undo_push("Insert Key Ipo");
- allqueue (REDRAWACTION, 0);
- allqueue(REDRAWNLA, 0);
- allqueue(REDRAWIPO, 0);
- allspace(REMAKEIPO, 0);
-}
-
-
-void common_insertkey(void)
-{
- Base *base;
- Object *ob;
- Material *ma;
- ID *id;
- IpoCurve *icu;
- World *wo;
- Lamp *la;
- int tlay, map, event;
- char menustr[256];
-
- if(curarea->spacetype==SPACE_IPO) {
- insertkey_editipo();
- }
- else if(curarea->spacetype==SPACE_BUTS) {
- if(G.buts->mainb==CONTEXT_SHADING) {
- int tab= G.buts->tab[CONTEXT_SHADING];
-
- if(tab==TAB_SHADING_MAT) {
- id= G.buts->lockpoin;
- ma= G.buts->lockpoin;
- if(id) {
- event= pupmenu("Insert Key %t|RGB%x0|Alpha%x1|Halo Size%x2|Mode %x3|All Color%x10|All Mirror%x14|Ofs%x12|Size%x13|All Mapping%x11");
- if(event== -1) return;
-
- map= texchannel_to_adrcode(ma->texact);
-
- if(event==0 || event==10) {
- insertkey(id, MA_COL_R);
- insertkey(id, MA_COL_G);
- insertkey(id, MA_COL_B);
- }
- if(event==1 || event==10) {
- insertkey(id, MA_ALPHA);
- }
- if(event==2 || event==10) {
- insertkey(id, MA_HASIZE);
- }
- if(event==3 || event==10) {
- insertkey(id, MA_MODE);
- }
- if(event==10) {
- insertkey(id, MA_SPEC_R);
- insertkey(id, MA_SPEC_G);
- insertkey(id, MA_SPEC_B);
- insertkey(id, MA_REF);
- insertkey(id, MA_EMIT);
- insertkey(id, MA_AMB);
- insertkey(id, MA_SPEC);
- insertkey(id, MA_HARD);
- insertkey(id, MA_MODE);
- insertkey(id, MA_TRANSLU);
- insertkey(id, MA_ADD);
- }
- if(event==14) {
- insertkey(id, MA_RAYM);
- insertkey(id, MA_FRESMIR);
- insertkey(id, MA_FRESMIRI);
- insertkey(id, MA_FRESTRA);
- insertkey(id, MA_FRESTRAI);
- }
- if(event==12 || event==11) {
- insertkey(id, map+MAP_OFS_X);
- insertkey(id, map+MAP_OFS_Y);
- insertkey(id, map+MAP_OFS_Z);
- }
- if(event==13 || event==11) {
- insertkey(id, map+MAP_SIZE_X);
- insertkey(id, map+MAP_SIZE_Y);
- insertkey(id, map+MAP_SIZE_Z);
- }
- if(event==11) {
- insertkey(id, map+MAP_R);
- insertkey(id, map+MAP_G);
- insertkey(id, map+MAP_B);
- insertkey(id, map+MAP_DVAR);
- insertkey(id, map+MAP_COLF);
- insertkey(id, map+MAP_NORF);
- insertkey(id, map+MAP_VARF);
- insertkey(id, map+MAP_DISP);
- }
- }
- }
- else if(tab==TAB_SHADING_WORLD) {
- id= G.buts->lockpoin;
- wo= G.buts->lockpoin;
- if(id) {
- event= pupmenu("Insert Key %t|Zenith RGB%x0|Horizon RGB%x1|Mist%x2|Stars %x3|Offset%x12|Size%x13");
- if(event== -1) return;
-
- map= texchannel_to_adrcode(wo->texact);
-
- if(event==0) {
- insertkey(id, WO_ZEN_R);
- insertkey(id, WO_ZEN_G);
- insertkey(id, WO_ZEN_B);
- }
- if(event==1) {
- insertkey(id, WO_HOR_R);
- insertkey(id, WO_HOR_G);
- insertkey(id, WO_HOR_B);
- }
- if(event==2) {
- insertkey(id, WO_MISI);
- insertkey(id, WO_MISTDI);
- insertkey(id, WO_MISTSTA);
- insertkey(id, WO_MISTHI);
- }
- if(event==3) {
- insertkey(id, WO_STAR_R);
- insertkey(id, WO_STAR_G);
- insertkey(id, WO_STAR_B);
- insertkey(id, WO_STARDIST);
- insertkey(id, WO_STARSIZE);
- }
- if(event==12) {
- insertkey(id, map+MAP_OFS_X);
- insertkey(id, map+MAP_OFS_Y);
- insertkey(id, map+MAP_OFS_Z);
- }
- if(event==13) {
- insertkey(id, map+MAP_SIZE_X);
- insertkey(id, map+MAP_SIZE_Y);
- insertkey(id, map+MAP_SIZE_Z);
- }
- }
- }
- else if(tab==TAB_SHADING_LAMP) {
- id= G.buts->lockpoin;
- la= G.buts->lockpoin;
- if(id) {
- event= pupmenu("Insert Key %t|RGB%x0|Energy%x1|Spot Size%x2|Offset%x12|Size%x13");
- if(event== -1) return;
-
- map= texchannel_to_adrcode(la->texact);
-
- if(event==0) {
- insertkey(id, LA_COL_R);
- insertkey(id, LA_COL_G);
- insertkey(id, LA_COL_B);
- }
- if(event==1) {
- insertkey(id, LA_ENERGY);
- }
- if(event==2) {
- insertkey(id, LA_SPOTSI);
- }
- if(event==12) {
- insertkey(id, map+MAP_OFS_X);
- insertkey(id, map+MAP_OFS_Y);
- insertkey(id, map+MAP_OFS_Z);
- }
- if(event==13) {
- insertkey(id, map+MAP_SIZE_X);
- insertkey(id, map+MAP_SIZE_Y);
- insertkey(id, map+MAP_SIZE_Z);
- }
-
- }
- }
- }
- else if(G.buts->mainb==CONTEXT_OBJECT) {
- ob= OBACT;
- if(ob && ob->type==OB_MESH) {
- id= (ID *) (ob);
- if(id) {
- event= pupmenu("Insert Key %t|Surface Damping%x0|Random Damping%x1|Permeability%x2|Force Strength%x3|Force Falloff%x4");
- if(event== -1) return;
-
- if(event==0) {
- insertkey(id, OB_PD_SDAMP);
- }
- if(event==1) {
- insertkey(id, OB_PD_RDAMP);
- }
- if(event==2) {
- insertkey(id, OB_PD_PERM);
- }
- if(event==3) {
- insertkey(id, OB_PD_FSTR);
- }
- if(event==4) {
- insertkey(id, OB_PD_FFALL);
- }
-
- }
- }
- }
- else if(G.buts->mainb==CONTEXT_EDITING) {
- ob= OBACT;
- if(ob && ob->type==OB_CAMERA) {
- id= G.buts->lockpoin;
- if(id) {
- /* yafray: insert key extended with aperture and focal distance */
- if (G.scene->r.renderer==R_INTERN)
- event= pupmenu("Insert Key %t|Lens%x0|Clipping%x1");
- else
- event= pupmenu("Insert Key %t|Lens%x0|Clipping%x1|Aperture%x2|FocalDistance%x3");
- if(event== -1) return;
-
- if(event==0) {
- insertkey(id, CAM_LENS);
- }
- else if(event==1) {
- insertkey(id, CAM_STA);
- insertkey(id, CAM_END);
- }
- else if(event==2) {
- insertkey(id, CAM_YF_APERT);
- }
- else if(event==3) {
- insertkey(id, CAM_YF_FDIST);
- }
- }
- }
- }
- else if(FALSE /* && G.buts->mainb==BUTS_SOUND */) {
- if(G.ssound) {
- id= G.buts->lockpoin;
- if(id) {
- event= pupmenu("Insert Key %t|Volume%x0|Pitch%x1|Panning%x2|Attennuation%x3");
- if(event== -1) return;
-
- if(event==0) {
- insertkey(id, SND_VOLUME);
- }
- if(event==1) {
- insertkey(id, SND_PITCH);
- }
- if(event==2) {
- insertkey(id, SND_PANNING);
- }
- if(event==3) {
- insertkey(id, SND_ATTEN);
- }
- }
- }
- }
-
- BIF_undo_push("Insert Key Buttons");
-
- allqueue(REDRAWACTION, 0);
- allqueue(REDRAWNLA, 0);
- allqueue(REDRAWIPO, 0);
- allspace(REMAKEIPO, 0);
-
- }
- else if(curarea->spacetype==SPACE_VIEW3D) {
- ob= OBACT;
-
- if (ob && (ob->flag & OB_POSEMODE)) {
- strcpy(menustr, "Insert Key%t|Loc%x0|Rot%x1|Size%x2|LocRot%x3|LocRotSize%x4|Avail%x9");
- }
- else {
- base= FIRSTBASE;
- while(base) {
- if TESTBASELIB(base) break;
- base= base->next;
- }
- if(base==NULL) return;
-
- strcpy(menustr, "Insert Key%t|Loc%x0|Rot%x1|Size%x2|LocRot%x3|LocRotSize%x4|Layer%x5|Avail%x9");
- }
-
- if(ob) {
- if(ob->type==OB_MESH) strcat(menustr, "| %x6|Mesh%x7");
- else if(ob->type==OB_LATTICE) strcat(menustr, "| %x6|Lattice%x7");
- else if(ob->type==OB_CURVE) strcat(menustr, "| %x6|Curve%x7");
- else if(ob->type==OB_SURF) strcat(menustr, "| %x6|Surface%x7");
- if(ob->flag & OB_FROMGROUP) strcat(menustr, "| %x6|Entire Group%x10");
- }
-
- event= pupmenu(menustr);
- if(event== -1) return;
-
- if(event==7) { // ob != NULL
- insert_shapekey(ob);
- return;
- }
-
- if(event==10) {
- Group *group= find_group(ob);
- if(group) {
- add_group_key(group);
- allqueue(REDRAWBUTSOBJECT, 0);
- }
- }
-
- if (ob && (ob->flag & OB_POSEMODE)){
- bAction *act;
- bPose *pose;
- bPoseChannel *chan;
- bActionChannel *achan;
-
- /* Get action & pose from object */
- act=ob->action;
- pose=ob->pose;
-
- if (!act){
- act= ob->action= add_empty_action();
- /* this sets the non-pinned open ipowindow(s) to show the action curve */
- ob->ipowin= ID_AC;
- allqueue(REDRAWIPO, ob->ipowin);
-
- allqueue(REDRAWACTION, 0);
- allqueue(REDRAWNLA, 0);
- }
- if (!pose){
- error ("No pose!"); /* Should never happen */
- }
-
- if (act->id.lib) {
- error ("Can't key libactions");
- return;
- }
-
- set_pose_keys(ob); // sets chan->flag to POSE_KEY if bone selected
- for (chan=pose->chanbase.first; chan; chan=chan->next) {
- if (chan->flag & POSE_KEY){
- // set_action_key(act, chan);
- if(event==0 || event==3 ||event==4) {
- set_action_key(act, chan, AC_LOC_X, 1);
- set_action_key(act, chan, AC_LOC_Y, 1);
- set_action_key(act, chan, AC_LOC_Z, 1);
- }
- if(event==1 || event==3 ||event==4) {
- set_action_key(act, chan, AC_QUAT_X, 1);
- set_action_key(act, chan, AC_QUAT_Y, 1);
- set_action_key(act, chan, AC_QUAT_Z, 1);
- set_action_key(act, chan, AC_QUAT_W, 1);
- }
- if(event==2 || event==4) {
- set_action_key(act, chan, AC_SIZE_X, 1);
- set_action_key(act, chan, AC_SIZE_Y, 1);
- set_action_key(act, chan, AC_SIZE_Z, 1);
- }
- if (event==9){
- for (achan = act->chanbase.first; achan; achan=achan->next){
- if (achan->ipo && !strcmp (achan->name, chan->name)){
- for (icu = achan->ipo->curve.first; icu; icu=icu->next){
- set_action_key(act, chan, icu->adrcode, 0);
- }
- break;
- }
- }
- }
- }
- remake_action_ipos(act);
- }
-
- DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
-
- allqueue(REDRAWIPO, 0);
- allqueue(REDRAWACTION, 0);
- allqueue(REDRAWNLA, 0);
- }
- else {
- base= FIRSTBASE;
- while(base) {
- if TESTBASELIB(base) {
- id= (ID *)(base->object);
-
- /* all curves in ipo deselect */
- if(base->object->ipo) {
- icu= base->object->ipo->curve.first;
- while(icu) {
- icu->flag &= ~IPO_SELECT;
- if(event==9) insertkey(id, icu->adrcode);
- icu= icu->next;
- }
- }
-
- if(event==0 || event==3 ||event==4) {
- insertkey(id, OB_LOC_X);
- insertkey(id, OB_LOC_Y);
- insertkey(id, OB_LOC_Z);
- }
- if(event==1 || event==3 ||event==4) {
- insertkey(id, OB_ROT_X);
- insertkey(id, OB_ROT_Y);
- insertkey(id, OB_ROT_Z);
- }
- if(event==2 || event==4) {
- insertkey(id, OB_SIZE_X);
- insertkey(id, OB_SIZE_Y);
- insertkey(id, OB_SIZE_Z);
- }
- if(event==5) {
- /* remove localview */
- tlay= base->object->lay;
- base->object->lay &= 0xFFFFFF;
- insertkey(id, OB_LAY);
- base->object->lay= tlay;
- }
- }
- base= base->next;
- }
- }
-
- if(event==0) BIF_undo_push("Insert Loc Key");
- else if(event==1) BIF_undo_push("Insert Rot Key");
- else if(event==2) BIF_undo_push("Insert Size Key");
- else if(event==3) BIF_undo_push("Insert LocRot Key");
- else if(event==4) BIF_undo_push("Insert LocRotSize Key");
- else if(event==5) BIF_undo_push("Insert Layer Key");
- else if(event==7) BIF_undo_push("Insert Vertex Key");
- else if(event==9) BIF_undo_push("Insert Avail Key");
-
- allspace(REMAKEIPO, 0);
- allqueue(REDRAWIPO, 0);
- allqueue(REDRAWVIEW3D, 0);
- allqueue(REDRAWACTION, 0);
- allqueue(REDRAWNLA, 0);
- }
-
-}
-
-
/* **************************************************** */
/* IPOKEY:
@@ -4269,7 +3253,7 @@ void make_ipokey(void)
ei= G.sipo->editipo;
if(ei==0) return;
for(a=0; a<G.sipo->totipo; a++, ei++) {
- if ISPOIN(ei, flag & IPO_VISIBLE, icu) {
+ if (ISPOIN(ei, flag & IPO_VISIBLE, icu)) {
bezt= ei->icu->bezt;
totvert= ei->icu->totvert;
@@ -4324,7 +3308,7 @@ void make_ipokey_transform(Object *ob, ListBase *lb, int sel)
BezTriple *bezt;
int a, adrcode = 0, ok, dloc=0, drot=0, dsize=0;
- if(ob->ipo==0) return;
+ if(ob->ipo==NULL) return;
if(ob->ipo->showkey==0) return;
/* test: are there delta curves? */
@@ -4503,44 +3487,6 @@ void set_ipo_pointers_transob(IpoKey *ik, TransOb *tob)
-void nextkey(ListBase *elems, int dir)
-{
- IpoKey *ik, *previk;
- int totsel;
-
- if(dir==1) ik= elems->last;
- else ik= elems->first;
- previk= 0;
- totsel= 0;
-
- while(ik) {
-
- if(ik->flag) totsel++;
-
- if(previk) {
- if(G.qual & LR_SHIFTKEY) {
- if(ik->flag) previk->flag= 1;
- }
- else previk->flag= ik->flag;
- }
-
- previk= ik;
- if(dir==1) ik= ik->prev;
- else ik= ik->next;
-
- if(G.qual & LR_SHIFTKEY);
- else if(ik==0) previk->flag= 0;
- }
-
- /* when no key select: */
- if(totsel==0) {
- if(dir==1) ik= elems->first;
- else ik= elems->last;
-
- if(ik) ik->flag= 1;
- }
-}
-
static int float_to_frame (float frame)
{
int to= (int) floor(0.5 + frame/G.scene->r.framelen );
@@ -4641,77 +3587,6 @@ void movekey_obipo(int dir) /* only call external from view3d queue */
allspace(REMAKEIPO, 0);
}
-
-void nextkey_ipo(int dir) /* call from ipo queue */
-{
- IpoKey *ik;
- int a;
-
- if(G.sipo->showkey==0) return;
-
- nextkey(&G.sipo->ipokey, dir);
-
- /* copy to beziers */
- ik= G.sipo->ipokey.first;
- while(ik) {
- for(a=0; a<G.sipo->totipo; a++) {
- if(ik->data[a]) ik->data[a]->f1= ik->data[a]->f2= ik->data[a]->f3= ik->flag;
- }
- ik= ik->next;
- }
-
- allqueue(REDRAWNLA, 0);
- allqueue(REDRAWACTION, 0);
- allqueue(REDRAWIPO, 0);
- if(G.sipo->blocktype == ID_OB) allqueue(REDRAWVIEW3D, 0);
-}
-
-void nextkey_obipo(int dir) /* only call external from view3d queue */
-{
- Base *base;
- Object *ob;
- ListBase elems;
- IpoKey *ik;
- int a;
-
- /* problem: this doesnt work when you mix dLoc keys with Loc keys */
-
- base= FIRSTBASE;
- while(base) {
- if TESTBASE(base) {
- ob= base->object;
- if( (ob->ipoflag & OB_DRAWKEY) && ob->ipo && ob->ipo->showkey) {
- elems.first= elems.last= 0;
- make_ipokey_transform(ob, &elems, 0);
-
- if(elems.first) {
-
- nextkey(&elems, dir);
-
- /* copy to beziers */
- ik= elems.first;
- while(ik) {
- for(a=0; a<OB_TOTIPO; a++) {
- if(ik->data[a]) ik->data[a]->f1= ik->data[a]->f2= ik->data[a]->f3= ik->flag;
- }
- ik= ik->next;
- }
-
- free_ipokey(&elems);
- }
- }
- }
-
- base= base->next;
- }
- allqueue(REDRAWNLA, 0);
- allqueue(REDRAWACTION, 0);
- allqueue(REDRAWVIEW3D, 0);
- allspace(REMAKEIPO, 0);
- allqueue(REDRAWIPO, 0);
-}
-
-
/* **************************************************** */
@@ -4725,7 +3600,7 @@ void remake_ipo_transverts(TransVert *transmain, float *dvec, int tot)
ei= G.sipo->editipo;
for(a=0; a<G.sipo->totipo; a++, ei++) {
- if ISPOIN(ei, flag & IPO_VISIBLE, icu) {
+ if (ISPOIN(ei, flag & IPO_VISIBLE, icu)) {
if(ei->icu->bezt) {
sort_time_ipocurve(ei->icu);
@@ -4737,7 +3612,7 @@ void remake_ipo_transverts(TransVert *transmain, float *dvec, int tot)
tv= transmain;
for(a=0; a<G.sipo->totipo; a++, ei++) {
- if ISPOIN(ei, flag & IPO_VISIBLE, icu) {
+ if (ISPOIN(ei, flag & IPO_VISIBLE, icu)) {
if( (ei->flag & IPO_EDIT) || G.sipo->showkey) {
if(ei->icu->bezt) {
bezt= ei->icu->bezt;
@@ -4803,7 +3678,7 @@ void transform_ipo(int mode)
ei= G.sipo->editipo;
for(a=0; a<G.sipo->totipo; a++, ei++) {
- if ISPOIN(ei, flag & IPO_VISIBLE, icu) {
+ if (ISPOIN(ei, flag & IPO_VISIBLE, icu)) {
if( (ei->flag & IPO_EDIT) || G.sipo->showkey) {
@@ -4852,7 +3727,7 @@ void transform_ipo(int mode)
ei= G.sipo->editipo;
for(a=0; a<G.sipo->totipo; a++, ei++) {
- if ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_SELECT, icu) {
+ if (ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_SELECT, icu)) {
if(ei->icu->bezt && ei->icu->ipo==IPO_BEZ) tot+= 3*ei->icu->totvert;
else tot+= ei->icu->totvert;
}
@@ -4863,7 +3738,7 @@ void transform_ipo(int mode)
ei= G.sipo->editipo;
for(a=0; a<G.sipo->totipo; a++, ei++) {
- if ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_SELECT, icu) {
+ if (ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_SELECT, icu)) {
if(ei->icu->bezt) {
bezt= ei->icu->bezt;
@@ -4984,7 +3859,7 @@ void transform_ipo(int mode)
dosort= 0;
ei= G.sipo->editipo;
for(a=0; a<G.sipo->totipo; a++, ei++) {
- if ISPOIN(ei, flag & IPO_VISIBLE, icu) {
+ if (ISPOIN(ei, flag & IPO_VISIBLE, icu)) {
/* watch it: if the time is wrong: do not correct handles */
if (test_time_ipocurve(ei->icu) ) dosort++;
@@ -5009,7 +3884,7 @@ void transform_ipo(int mode)
DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
force_draw_plus(SPACE_VIEW3D, 0);
}
- else if(G.sipo->blocktype==ID_AC) {
+ else if(G.sipo->blocktype==ID_PO) {
Object *ob= OBACT;
if(ob && ob->pose) {
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
@@ -5096,7 +3971,7 @@ void transform_ipo(int mode)
dosort= 0;
ei= G.sipo->editipo;
for(a=0; a<G.sipo->totipo; a++, ei++) {
- if ISPOIN(ei, flag & IPO_VISIBLE, icu) {
+ if (ISPOIN(ei, flag & IPO_VISIBLE, icu)) {
if( (ei->flag & IPO_EDIT) || G.sipo->showkey) {
if( test_time_ipocurve(ei->icu)) {
dosort= 1;
@@ -5110,7 +3985,7 @@ void transform_ipo(int mode)
ei= G.sipo->editipo;
for(a=0; a<G.sipo->totipo; a++, ei++) {
- if ISPOIN(ei, flag & IPO_VISIBLE, icu) {
+ if (ISPOIN(ei, flag & IPO_VISIBLE, icu)) {
if( (ei->flag & IPO_EDIT) || G.sipo->showkey) {
testhandles_ipocurve(ei->icu);
}
@@ -5194,14 +4069,14 @@ void ipo_record(void)
short anim, val, xn, yn, mvalo[2], mval[2];
char str[128];
- if(G.sipo->from==0) return;
+ if(G.sipo->from==NULL) return;
if(SFRA>=EFRA) return;
anim= pupmenu("Record Mouse %t|Still %x1|Play Animation %x2");
if(anim < 1) return;
if(anim!=2) anim= 0;
- ipo= get_ipo(G.sipo->from, G.sipo->blocktype, 1); /* 1= make */
+ ipo= verify_ipo(G.sipo->from, G.sipo->blocktype, G.sipo->actname, G.sipo->constname);
if(G.sipo) G.sipo->ipo= ipo;
ob= OBACT;
@@ -5227,16 +4102,20 @@ void ipo_record(void)
}
/* make curves ready, start values */
- if(ei1->icu==NULL) ei1->icu= get_ipocurve(G.sipo->from, G.sipo->blocktype, ei1->adrcode, 0);
+ if(ei1->icu==NULL)
+ ei1->icu= verify_ipocurve(G.sipo->from, G.sipo->blocktype, G.sipo->actname, G.sipo->constname, ei1->adrcode);
if(ei1->icu==NULL) return;
+
poin= get_ipo_poin(G.sipo->from, ei1->icu, &type);
if(poin) ei1->icu->curval= read_ipo_poin(poin, type);
or1= ei1->icu->curval;
ei1->icu->flag |= IPO_LOCK;
if(ei2) {
- if(ei2->icu==NULL) ei2->icu= get_ipocurve(G.sipo->from, G.sipo->blocktype, ei2->adrcode, 0);
+ if(ei2->icu==NULL)
+ ei1->icu= verify_ipocurve(G.sipo->from, G.sipo->blocktype, G.sipo->actname, G.sipo->constname, ei2->adrcode);
if(ei2->icu==NULL) return;
+
poin= get_ipo_poin(G.sipo->from, ei2->icu, &type);
if(poin) ei2->icu->curval= read_ipo_poin(poin, type);
or2= ei2->icu->curval;
@@ -5396,8 +4275,7 @@ void ipo_record(void)
MEM_freeN(data2);
}
-
-
+/* while transform, update for curves */
void remake_object_ipos(Object *ob)
{
IpoCurve *icu;
@@ -5413,49 +4291,6 @@ void remake_object_ipos(Object *ob)
}
}
-
-int is_ipo_key_selected(Ipo *ipo)
-{
- int i;
- IpoCurve *icu;
-
- if (!ipo)
- return 0;
-
- for (icu=ipo->curve.first; icu; icu=icu->next){
- for (i=0; i<icu->totvert; i++)
- if (BEZSELECTED(&icu->bezt[i]))
- return 1;
- }
-
- return 0;
-}
-
-
-void set_ipo_key_selection(Ipo *ipo, int sel)
-{
- int i;
- IpoCurve *icu;
-
- if (!ipo)
- return;
-
- for (icu=ipo->curve.first; icu; icu=icu->next){
- for (i=0; i<icu->totvert; i++){
- if (sel){
- icu->bezt[i].f1|=1;
- icu->bezt[i].f2|=1;
- icu->bezt[i].f3|=1;
- }
- else{
- icu->bezt[i].f1&=~1;
- icu->bezt[i].f2&=~1;
- icu->bezt[i].f3&=~1;
- }
- }
- }
-}
-
void delete_ipo_keys(Ipo *ipo)
{
IpoCurve *icu, *next;
@@ -5482,27 +4317,6 @@ void delete_ipo_keys(Ipo *ipo)
}
}
-int fullselect_ipo_keys(Ipo *ipo)
-{
- int i;
- IpoCurve *icu;
- int tvtot = 0;
-
- if (!ipo)
- return tvtot;
-
- for (icu=ipo->curve.first; icu; icu=icu->next){
- for (i=0; i<icu->totvert; i++){
- if (icu->bezt[i].f2 & 1){
- tvtot+=3;
- icu->bezt[i].f1 |= 1;
- icu->bezt[i].f3 |= 1;
- }
- }
- }
-
- return tvtot;
-}
int add_trans_ipo_keys(Ipo *ipo, TransVert *tv, int tvtot)
{
@@ -5566,152 +4380,52 @@ void duplicate_ipo_keys(Ipo *ipo)
}
}
-void borderselect_icu_key(IpoCurve *icu, float xmin, float xmax,
- int (*select_function)(BezTriple *))
-{
- /* Selects all bezier triples in the Ipocurve
- * between times xmin and xmax, using the selection
- * function.
- */
-
- int i;
-
- /* loop through all of the bezier triples in
- * the Ipocurve -- if the triple occurs between
- * times xmin and xmax then select it using the selection
- * function
- */
- for (i=0; i<icu->totvert; i++){
- if (icu->bezt[i].vec[1][0] > xmin && icu->bezt[i].vec[1][0] < xmax ){
- select_function(&(icu->bezt[i]));
- }
- }
-}
-
-void borderselect_ipo_key(Ipo *ipo, float xmin, float xmax, int selectmode)
-{
- /* Selects all bezier triples in each Ipocurve of the
- * Ipo between times xmin and xmax, using the selection mode.
- */
-
- IpoCurve *icu;
- int (*select_function)(BezTriple *);
-
- /* If the ipo is no good then return */
- if (!ipo)
- return;
-
- /* Set the selection function based on the
- * selection mode.
- */
- switch(selectmode) {
- case SELECT_ADD:
- select_function = select_bezier_add;
- break;
- case SELECT_SUBTRACT:
- select_function = select_bezier_subtract;
- break;
- case SELECT_INVERT:
- select_function = select_bezier_invert;
- break;
- default:
- return;
- }
-
- /* loop through all of the bezier triples in all
- * of the Ipocurves -- if the triple occurs between
- * times xmin and xmax then select it using the selection
- * function
- */
- for (icu=ipo->curve.first; icu; icu=icu->next){
- borderselect_icu_key(icu, xmin, xmax, select_function);
- }
-}
-
-void select_ipo_key(Ipo *ipo, float selx, int selectmode)
+void move_to_frame(void)
{
- /* Selects all bezier triples in each Ipocurve of the
- * Ipo at time selx, using the selection mode.
- */
- int i;
- IpoCurve *icu;
- int (*select_function)(BezTriple *);
-
- /* If the ipo is no good then return */
- if (!ipo)
- return;
-
- /* Set the selection function based on the
- * selection mode.
- */
- switch(selectmode) {
- case SELECT_ADD:
- select_function = select_bezier_add;
- break;
- case SELECT_SUBTRACT:
- select_function = select_bezier_subtract;
- break;
- case SELECT_INVERT:
- select_function = select_bezier_invert;
- break;
- default:
- return;
- }
-
- /* loop through all of the bezier triples in all
- * of the Ipocurves -- if the triple occurs at
- * time selx then select it using the selection
- * function
- */
- for (icu=ipo->curve.first; icu; icu=icu->next){
- for (i=0; i<icu->totvert; i++){
- if (icu->bezt[i].vec[1][0]==selx){
- select_function(&(icu->bezt[i]));
+ EditIpo *ei;
+ BezTriple *bezt;
+ ID *id;
+ float cfra;
+ int a, b;
+
+ if(G.sipo->editipo==0) return;
+
+ ei= G.sipo->editipo;
+
+ for(a=0; a<G.sipo->totipo; a++, ei++) {
+ if (ISPOIN(ei, flag & IPO_VISIBLE, icu)) {
+ if(G.sipo->showkey || (ei->flag & IPO_EDIT)) {
+
+ if(ei->icu->bezt) {
+
+ b= ei->icu->totvert;
+ bezt= ei->icu->bezt;
+ while(b--) {
+ if(BEZSELECTED(bezt)) {
+
+ cfra= bezt->vec[1][0]/G.scene->r.framelen;
+
+ id= G.sipo->from;
+ if(id && GS(id->name)==ID_OB ) {
+ Object *ob= (Object *)id;
+ if(ob->sf!=0.0 && (ob->ipoflag & OB_OFFS_OB) ) {
+ cfra+= ob->sf/G.scene->r.framelen;
+ }
+ }
+ CFRA= (short)floor(cfra+0.5);
+
+ if(CFRA < 1) CFRA= 1;
+ update_for_newframe();
+
+ break;
+ }
+ bezt++;
+ }
+ }
}
}
}
+ BIF_undo_push("Set frame to selected Ipo vertex");
}
-void select_icu_key(IpoCurve *icu, float selx, int selectmode)
-{
- /* Selects all bezier triples in the Ipocurve
- * at time selx, using the selection mode.
- * This is kind of sloppy the obvious similarities
- * with the above function, forgive me ...
- */
- int i;
- int (*select_function)(BezTriple *);
-
- /* If the icu is no good then return */
- if (!icu)
- return;
-
- /* Set the selection function based on the
- * selection mode.
- */
- switch(selectmode) {
- case SELECT_ADD:
- select_function = select_bezier_add;
- break;
- case SELECT_SUBTRACT:
- select_function = select_bezier_subtract;
- break;
- case SELECT_INVERT:
- select_function = select_bezier_invert;
- break;
- default:
- return;
- }
-
- /* loop through all of the bezier triples in
- * the Ipocurve -- if the triple occurs at
- * time selx then select it using the selection
- * function
- */
- for (i=0; i<icu->totvert; i++){
- if (icu->bezt[i].vec[1][0]==selx){
- select_function(&(icu->bezt[i]));
- }
- }
-}
diff --git a/source/blender/src/editipo_lib.c b/source/blender/src/editipo_lib.c
new file mode 100644
index 00000000000..c3c80c4e238
--- /dev/null
+++ b/source/blender/src/editipo_lib.c
@@ -0,0 +1,309 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation, 2005. Full recode
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/* ********** General calls (minimal dependencies) for editing Ipos in Blender ************* */
+
+#include "BLI_blenlib.h"
+#include "BLI_arithb.h"
+
+#include "DNA_curve_types.h"
+#include "DNA_ipo_types.h"
+#include "DNA_space_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_view3d_types.h"
+
+#include "BKE_global.h"
+#include "BKE_ipo.h"
+#include "BKE_utildefines.h"
+
+#include "BSE_edit.h"
+#include "BSE_editipo_types.h"
+#include "BSE_editipo.h"
+#include "BSE_drawipo.h"
+
+#include "blendef.h"
+#include "mydevice.h"
+
+char *ob_ic_names[OB_TOTNAM] = { "LocX", "LocY", "LocZ", "dLocX", "dLocY", "dLocZ",
+ "RotX", "RotY", "RotZ", "dRotX", "dRotY", "dRotZ",
+ "SizeX", "SizeY", "SizeZ", "dSizeX", "dSizeY", "dSizeZ",
+ "Layer", "Time", "ColR", "ColG", "ColB", "ColA",
+ "FStreng", "FFall", "RDamp", "Damping", "Perm" };
+
+char *co_ic_names[CO_TOTNAM] = { "Inf" };
+char *mtex_ic_names[TEX_TOTNAM] = { "OfsX", "OfsY", "OfsZ", "SizeX", "SizeY", "SizeZ",
+ "texR", "texG", "texB", "DefVar", "Col", "Nor", "Var",
+ "Disp" };
+char *tex_ic_names[TE_TOTNAM] = { "NSize", "NDepth", "NType", "Turb", "Vnw1", "Vnw2",
+ "Vnw3", "Vnw4", "MinkMExp", "DistM", "ColT", "iScale",
+ "DistA", "MgType", "MgH", "Lacu", "Oct", "MgOff",
+ "MgGain", "NBase1", "NBase2" };
+char *ma_ic_names[MA_TOTNAM] = { "R", "G", "B", "SpecR", "SpecG", "SpecB", "MirR",
+ "MirG", "MirB", "Ref", "Alpha", "Emit", "Amb", "Spec",
+ "Hard", "SpTra", "Ior", "Mode", "HaSize", "Translu",
+ "RayMir", "FresMir", "FresMirI", "FresTra", "FresTraI",
+ "TraGlow" };
+char *seq_ic_names[SEQ_TOTNAM] = { "Fac" };
+char *cu_ic_names[CU_TOTNAM] = { "Speed" };
+char *key_ic_names[KEY_TOTNAM] = { "Speed", "Key 1", "Key 2", "Key 3", "Key 4", "Key 5",
+ "Key 6", "Key 7", "Key 8", "Key 9", "Key 10",
+ "Key 11", "Key 12", "Key 13", "Key 14", "Key 15",
+ "Key 16", "Key 17", "Key 18", "Key 19", "Key 20",
+ "Key 21", "Key 22", "Key 23", "Key 24", "Key 25",
+ "Key 26", "Key 27", "Key 28", "Key 29", "Key 30",
+ "Key 31", "Key 32", "Key 33", "Key 34", "Key 35",
+ "Key 36", "Key 37", "Key 38", "Key 39", "Key 40",
+ "Key 41", "Key 42", "Key 43", "Key 44", "Key 45",
+ "Key 46", "Key 47", "Key 48", "Key 49", "Key 50",
+ "Key 51", "Key 52", "Key 53", "Key 54", "Key 55",
+ "Key 56", "Key 57", "Key 58", "Key 59", "Key 60",
+ "Key 61", "Key 62", "Key 63"};
+char *wo_ic_names[WO_TOTNAM] = { "HorR", "HorG", "HorB", "ZenR", "ZenG", "ZenB", "Expos",
+ "Misi", "MisDi", "MisSta", "MisHi", "StarR", "StarB",
+ "StarG", "StarDi", "StarSi" };
+char *la_ic_names[LA_TOTNAM] = { "Energ", "R", "G", "B", "Dist", "SpoSi", "SpoBl",
+ "Quad1", "Quad2", "HaInt" };
+/* yafray: two curve names added, 'Apert' for aperture, and 'FDist' for focal distance */
+char *cam_ic_names[CAM_TOTNAM] = { "Lens", "ClSta", "ClEnd", "Apert", "FDist" };
+char *snd_ic_names[SND_TOTNAM] = { "Vol", "Pitch", "Pan", "Atten" };
+char *ac_ic_names[AC_TOTNAM] = {"LocX", "LocY", "LocZ", "SizeX", "SizeY",
+ "SizeZ", "QuatW", "QuatX", "QuatY", "QuatZ"};
+char *ic_name_empty[1] ={ "" };
+
+char *getname_ac_ei(int nr)
+{
+ switch(nr) {
+ case AC_LOC_X:
+ case AC_LOC_Y:
+ case AC_LOC_Z:
+ return ac_ic_names[nr-1];
+ case AC_SIZE_X:
+ case AC_SIZE_Y:
+ case AC_SIZE_Z:
+ return ac_ic_names[nr-10];
+ case AC_QUAT_X:
+ case AC_QUAT_Y:
+ case AC_QUAT_Z:
+ case AC_QUAT_W:
+ return ac_ic_names[nr-19];
+ default:
+ return ic_name_empty[0]; /* empty */
+ }
+}
+
+char *getname_co_ei(int nr)
+{
+ switch(nr){
+ case CO_ENFORCE:
+ return co_ic_names[nr-1];
+ }
+ return ic_name_empty[0];
+}
+
+char *getname_ob_ei(int nr, int colipo)
+{
+ if(nr>=OB_LOC_X && nr <= OB_PD_PERM) return ob_ic_names[nr-1];
+
+ return ic_name_empty[0];
+}
+
+char *getname_tex_ei(int nr)
+{
+ if(nr>=TE_NSIZE && nr<=TE_N_BAS2) return tex_ic_names[nr-1];
+
+ return ic_name_empty[0];
+}
+
+char *getname_mtex_ei(int nr)
+{
+ if(nr>=MAP_OFS_X && nr<=MAP_DISP) return mtex_ic_names[nr-1];
+
+ return ic_name_empty[0];
+}
+
+char *getname_mat_ei(int nr)
+{
+ if(nr>=MA_MAP1) return getname_mtex_ei((nr & (MA_MAP1-1)));
+ else {
+ if(nr>=MA_COL_R && nr<=MA_ADD) return ma_ic_names[nr-1];
+ }
+ return ic_name_empty[0];
+}
+
+char *getname_world_ei(int nr)
+{
+ if(nr>=MA_MAP1) return getname_mtex_ei((nr & (MA_MAP1-1)));
+ else {
+ if(nr>=WO_HOR_R && nr<=WO_STARSIZE) return wo_ic_names[nr-1];
+ }
+ return ic_name_empty[0];
+}
+
+char *getname_seq_ei(int nr)
+{
+ if(nr == SEQ_FAC1) return seq_ic_names[nr-1];
+ return ic_name_empty[0];
+}
+
+char *getname_cu_ei(int nr)
+{
+ if(nr==CU_SPEED) return cu_ic_names[nr-1];
+ return ic_name_empty[0];
+}
+
+char *getname_la_ei(int nr)
+{
+ if(nr>=MA_MAP1) return getname_mtex_ei((nr & (MA_MAP1-1)));
+ else {
+ if(nr>=LA_ENERGY && nr<=LA_HALOINT) return la_ic_names[nr-1];
+ }
+ return ic_name_empty[0];
+}
+
+char *getname_cam_ei(int nr)
+{
+ /* yafray: curves extended to CAM_YF_FDIST */
+ //if(nr>=CAM_LENS && nr<=CAM_END) return cam_ic_names[nr-1];
+ if(nr>=CAM_LENS && nr<=CAM_YF_FDIST) return cam_ic_names[nr-1];
+ return ic_name_empty[0];
+}
+
+char *getname_snd_ei(int nr)
+{
+ if(nr>=SND_VOLUME && nr<=SND_ATTEN) return snd_ic_names[nr-1];
+ return ic_name_empty[0];
+}
+
+
+void boundbox_ipocurve(IpoCurve *icu)
+{
+ BezTriple *bezt;
+ float vec[3]={0.0,0.0,0.0};
+ float min[3], max[3];
+ int a;
+
+ if(icu->totvert) {
+ INIT_MINMAX(min, max);
+
+ if(icu->bezt ) {
+ a= icu->totvert;
+ bezt= icu->bezt;
+ while(a--) {
+ if(icu->vartype & IPO_BITS) {
+ vec[0]= bezt->vec[1][0];
+ vec[1]= 0.0;
+ DO_MINMAX(vec, min, max);
+
+ vec[1]= 16.0;
+ DO_MINMAX(vec, min, max);
+ }
+ else {
+ if(icu->ipo==IPO_BEZ && a!=icu->totvert-1) {
+ DO_MINMAX(bezt->vec[0], min, max);
+ }
+ DO_MINMAX(bezt->vec[1], min, max);
+ if(icu->ipo==IPO_BEZ && a!=0) {
+ DO_MINMAX(bezt->vec[2], min, max);
+ }
+ }
+
+ bezt++;
+ }
+ }
+ if(min[0]==max[0]) max[0]= (float)(min[0]+1.0);
+ if(min[1]==max[1]) max[1]= (float)(min[1]+0.1);
+
+ icu->totrct.xmin= min[0];
+ icu->totrct.ymin= min[1];
+ icu->totrct.xmax= max[0];
+ icu->totrct.ymax= max[1];
+ }
+ else {
+ icu->totrct.xmin= icu->totrct.ymin= 0.0;
+ icu->totrct.xmax= EFRA;
+ icu->totrct.ymax= 1.0;
+ }
+}
+
+void boundbox_ipo(Ipo *ipo, rctf *bb)
+{
+ IpoCurve *icu;
+ int first= 1;
+
+ icu= ipo->curve.first;
+ while(icu) {
+
+ boundbox_ipocurve(icu);
+
+ if(first) {
+ *bb= icu->totrct;
+ first= 0;
+ }
+ else BLI_union_rctf(bb, &(icu->totrct));
+
+ icu= icu->next;
+ }
+}
+
+
+unsigned int ipo_rainbow(int cur, int tot)
+{
+ float dfac, fac, sat;
+
+ dfac= (float)(1.0/( (float)tot+1.0));
+
+ /* this calculation makes 2 or 4 different cycles of rainbow colors */
+ if(cur< tot/2) fac= (float)(cur*2.0f*dfac);
+ else fac= (float)((cur-tot/2)*2.0f*dfac +dfac);
+ if(tot > 32) fac= fac*1.95f;
+ if(fac>1.0f) fac-= 1.0f;
+
+ if(fac>0.5f && fac<0.8f) sat= 0.4f;
+ else sat= 0.5f;
+
+ return hsv_to_cpack(fac, sat, 1.0f);
+}
+
+/* exported to python, hrms... (ton) */
+int texchannel_to_adrcode(int channel)
+{
+ switch(channel) {
+ case 0: return MA_MAP1;
+ case 1: return MA_MAP2;
+ case 2: return MA_MAP3;
+ case 3: return MA_MAP4;
+ case 4: return MA_MAP5;
+ case 5: return MA_MAP6;
+ case 6: return MA_MAP7;
+ case 7: return MA_MAP8;
+ case 8: return MA_MAP9;
+ case 9: return MA_MAP10;
+ default: return 0;
+ }
+}
+
+
diff --git a/source/blender/src/editipo_mods.c b/source/blender/src/editipo_mods.c
new file mode 100644
index 00000000000..91698300ef5
--- /dev/null
+++ b/source/blender/src/editipo_mods.c
@@ -0,0 +1,1115 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation, 2005. Full recode
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+
+/* ********** Selection and set Handle code for editing Ipos in Blender ************* */
+/*
+ mouse_select_ipo() is in editipo.c
+*/
+
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#ifndef WIN32
+#include <unistd.h>
+#else
+#include <io.h>
+#endif
+
+#include "BLI_blenlib.h"
+#include "BLI_arithb.h"
+
+#include "DNA_curve_types.h"
+#include "DNA_ipo_types.h"
+#include "DNA_key_types.h"
+#include "DNA_object_types.h"
+#include "DNA_space_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_view3d_types.h"
+
+#include "BKE_global.h"
+#include "BKE_ipo.h"
+#include "BKE_utildefines.h"
+
+#include "BIF_interface.h"
+#include "BIF_screen.h"
+#include "BIF_space.h"
+#include "BIF_toolbox.h"
+
+#include "BSE_edit.h"
+#include "BSE_editipo_types.h"
+#include "BSE_editipo.h"
+#include "BSE_drawipo.h"
+#include "BSE_trans_types.h"
+
+#include "BDR_drawobject.h"
+
+#include "blendef.h"
+#include "mydevice.h"
+
+/* copy from editipo.c */
+#define BEZSELECTED(bezt) (((bezt)->f1 & 1) || ((bezt)->f2 & 1) || ((bezt)->f3 & 1))
+
+#define ISPOIN(a, b, c) ( (a->b) && (a->c) )
+#define ISPOIN3(a, b, c, d) ( (a->b) && (a->c) && (a->d) )
+#define ISPOIN4(a, b, c, d, e) ( (a->b) && (a->c) && (a->d) && (a->e) )
+
+extern int totipo_edit, totipo_sel, totipo_vertsel, totipo_vis;
+
+void ipo_toggle_showkey(void)
+{
+ if(G.sipo->showkey) {
+ G.sipo->showkey= 0;
+ swap_selectall_editipo(); /* sel all */
+ }
+ else G.sipo->showkey= 1;
+ free_ipokey(&G.sipo->ipokey);
+ if(G.sipo->ipo) G.sipo->ipo->showkey= G.sipo->showkey;
+
+ BIF_undo_push("Toggle show key Ipo");
+}
+
+void swap_selectall_editipo(void)
+{
+ Object *ob;
+ EditIpo *ei;
+ IpoKey *ik;
+ BezTriple *bezt;
+ int a, b; /* , sel=0; */
+
+ get_status_editipo();
+
+ if(G.sipo->showkey) {
+ ik= G.sipo->ipokey.first;
+ while(ik) {
+ if(totipo_vertsel) ik->flag &= ~1;
+ else ik->flag |= 1;
+ ik= ik->next;
+ }
+ update_editipo_flags();
+
+ if(G.sipo->showkey && G.sipo->blocktype==ID_OB ) {
+ ob= OBACT;
+ if(ob && (ob->ipoflag & OB_DRAWKEY)) draw_object_ext(BASACT);
+ }
+ }
+ else if(totipo_edit==0) {
+ ei= G.sipo->editipo;
+ if (ei){
+ for(a=0; a<G.sipo->totipo; a++) {
+ if( ei->flag & IPO_VISIBLE ) {
+ if(totipo_sel) ei->flag &= ~IPO_SELECT;
+ else ei->flag |= IPO_SELECT;
+ }
+ ei++;
+ }
+ update_editipo_flags();
+ }
+ get_status_editipo();
+ }
+ else {
+ ei= G.sipo->editipo;
+ for(a=0; a<G.sipo->totipo; a++) {
+ if (ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_EDIT, icu )) {
+ bezt= ei->icu->bezt;
+ if(bezt) {
+ b= ei->icu->totvert;
+ while(b--) {
+ if(totipo_vertsel) {
+ bezt->f1= bezt->f2= bezt->f3= 0;
+ }
+ else {
+ bezt->f1= bezt->f2= bezt->f3= 1;
+ }
+ bezt++;
+ }
+ }
+ }
+ ei++;
+ }
+
+ }
+
+ BIF_undo_push("Swap select all Ipo");
+ scrarea_queue_winredraw(curarea);
+
+}
+
+void swap_visible_editipo(void)
+{
+ EditIpo *ei;
+ Object *ob;
+ int a; /* , sel=0; */
+
+ get_status_editipo();
+
+
+ ei= G.sipo->editipo;
+ for(a=0; a<G.sipo->totipo; a++) {
+ if(totipo_vis==0) {
+ if(ei->icu) {
+ ei->flag |= IPO_VISIBLE;
+ ei->flag |= IPO_SELECT;
+ }
+ }
+ else ei->flag &= ~IPO_VISIBLE;
+ ei++;
+ }
+
+ update_editipo_flags();
+
+ if(G.sipo->showkey) {
+
+ make_ipokey();
+
+ ob= OBACT;
+ if(ob && (ob->ipoflag & OB_DRAWKEY)) allqueue(REDRAWVIEW3D, 0);
+ }
+
+ scrarea_queue_winredraw(curarea);
+ BIF_undo_push("Swap Visible Ipo");
+}
+
+void deselectall_editipo(void)
+{
+ EditIpo *ei;
+ IpoKey *ik;
+ BezTriple *bezt;
+ int a, b; /* , sel=0; */
+
+ get_status_editipo();
+
+ if(G.sipo->showkey) {
+ ik= G.sipo->ipokey.first;
+ while(ik) {
+ ik->flag &= ~1;
+ ik= ik->next;
+ }
+ update_editipo_flags();
+
+ }
+ else if(totipo_edit==0) {
+
+ ei= G.sipo->editipo;
+ for(a=0; a<G.sipo->totipo; a++) {
+ if( ei->flag & IPO_VISIBLE ) {
+ ei->flag &= ~IPO_SELECT;
+ }
+ ei++;
+ }
+ update_editipo_flags();
+ }
+ else {
+ ei= G.sipo->editipo;
+ for(a=0; a<G.sipo->totipo; a++) {
+ if (ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_EDIT, icu )) {
+ if(ei->icu->bezt) {
+ bezt= ei->icu->bezt;
+ b= ei->icu->totvert;
+ while(b--) {
+ bezt->f1= bezt->f2= bezt->f3= 0;
+ bezt++;
+ }
+ }
+ }
+ ei++;
+ }
+ }
+
+ BIF_undo_push("(De)select all Ipo");
+ scrarea_queue_winredraw(curarea);
+}
+
+
+static int icu_keys_bezier_loop(IpoCurve *icu,
+ int (*bezier_function)(BezTriple *),
+ void (ipocurve_function)(struct IpoCurve *icu))
+{
+ /* This loops through the beziers in the Ipocurve, and executes
+ * the generic user provided 'bezier_function' on each one.
+ * Optionally executes the generic function ipocurve_function on the
+ * IPO curve after looping (eg. calchandles_ipocurve)
+ */
+
+ int b;
+ BezTriple *bezt;
+
+ b = icu->totvert;
+ bezt = icu->bezt;
+
+ /* if bezier_function has been specified
+ * then loop through each bezier executing
+ * it.
+ */
+
+ if (bezier_function != NULL) {
+ while(b--) {
+ /* exit with return code 1 if the bezier function
+ * returns 1 (good for when you are only interested
+ * in finding the first bezier that
+ * satisfies a condition).
+ */
+ if (bezier_function(bezt)) return 1;
+ bezt++;
+ }
+ }
+
+ /* if ipocurve_function has been specified
+ * then execute it
+ */
+ if (ipocurve_function != NULL)
+ ipocurve_function(icu);
+
+ return 0;
+
+}
+
+static int ipo_keys_bezier_loop(Ipo *ipo,
+ int (*bezier_function)(BezTriple *),
+ void (ipocurve_function)(struct IpoCurve *icu))
+{
+ /* This loops through the beziers that are attached to
+ * the selected keys on the Ipocurves of the Ipo, and executes
+ * the generic user provided 'bezier_function' on each one.
+ * Optionally executes the generic function ipocurve_function on a
+ * IPO curve after looping (eg. calchandles_ipocurve)
+ */
+
+ IpoCurve *icu;
+
+ /* Loop through each curve in the Ipo
+ */
+ for (icu=ipo->curve.first; icu; icu=icu->next){
+ if (icu_keys_bezier_loop(icu,bezier_function, ipocurve_function))
+ return 1;
+ }
+
+ return 0;
+}
+
+static int selected_bezier_loop(int (*looptest)(EditIpo *),
+ int (*bezier_function)(BezTriple *),
+ void (ipocurve_function)(struct IpoCurve *icu))
+{
+ /* This loops through the beziers that are attached to
+ * selected keys in editmode in the IPO window, and executes
+ * the generic user-provided 'bezier_function' on each one
+ * that satisfies the 'looptest' function. Optionally executes
+ * the generic function ipocurve_function on a IPO curve
+ * after looping (eg. calchandles_ipocurve)
+ */
+
+ EditIpo *ei;
+ BezTriple *bezt;
+ int a, b;
+
+ /* Get the first Edit Ipo from the selected Ipos
+ */
+ ei= G.sipo->editipo;
+
+ /* Loop throught all of the selected Ipo's
+ */
+ for(a=0; a<G.sipo->totipo; a++, ei++) {
+ /* Do a user provided test on the Edit Ipo
+ * to determine whether we want to process it
+ */
+ if (looptest(ei)) {
+ /* Loop through the selected
+ * beziers on the Edit Ipo
+ */
+ bezt = ei->icu->bezt;
+ b = ei->icu->totvert;
+
+ /* if bezier_function has been specified
+ * then loop through each bezier executing
+ * it.
+ */
+ if (bezier_function != NULL) {
+ while(b--) {
+ /* exit with return code 1 if the bezier function
+ * returns 1 (good for when you are only interested
+ * in finding the first bezier that
+ * satisfies a condition).
+ */
+ if (bezier_function(bezt)) return 1;
+ bezt++;
+ }
+ }
+
+ /* if ipocurve_function has been specified
+ * then execute it
+ */
+ if (ipocurve_function != NULL)
+ ipocurve_function(ei->icu);
+ }
+ /* nufte flourdje zim ploopydu <-- random dutch looking comment ;) */
+ /* looks more like russian to me! (ton) */
+ }
+
+ return 0;
+}
+
+int select_bezier_add(BezTriple *bezt)
+{
+ /* Select the bezier triple */
+ bezt->f1 |= 1;
+ bezt->f2 |= 1;
+ bezt->f3 |= 1;
+ return 0;
+}
+
+int select_bezier_subtract(BezTriple *bezt)
+{
+ /* Deselect the bezier triple */
+ bezt->f1 &= ~1;
+ bezt->f2 &= ~1;
+ bezt->f3 &= ~1;
+ return 0;
+}
+
+int select_bezier_invert(BezTriple *bezt)
+{
+ /* Invert the selection for the bezier triple */
+ bezt->f2 ^= 1;
+ if ( bezt->f2 & 1 ) {
+ bezt->f1 |= 1;
+ bezt->f3 |= 1;
+ }
+ else {
+ bezt->f1 &= ~1;
+ bezt->f3 &= ~1;
+ }
+ return 0;
+}
+
+static int set_bezier_auto(BezTriple *bezt)
+{
+ /* Sets the selected bezier handles to type 'auto'
+ */
+
+ /* is a handle selected? If so
+ * set it to type auto
+ */
+ if(bezt->f1 || bezt->f3) {
+ if(bezt->f1) bezt->h1= 1; /* the secret code for auto */
+ if(bezt->f3) bezt->h2= 1;
+
+ /* if the handles are not of the same type, set them
+ * to type free
+ */
+ if(bezt->h1!=bezt->h2) {
+ if ELEM(bezt->h1, HD_ALIGN, HD_AUTO) bezt->h1= HD_FREE;
+ if ELEM(bezt->h2, HD_ALIGN, HD_AUTO) bezt->h2= HD_FREE;
+ }
+ }
+ return 0;
+}
+
+static int set_bezier_vector(BezTriple *bezt)
+{
+ /* Sets the selected bezier handles to type 'vector'
+ */
+
+ /* is a handle selected? If so
+ * set it to type vector
+ */
+ if(bezt->f1 || bezt->f3) {
+ if(bezt->f1) bezt->h1= 2; /* the code for vector */
+ if(bezt->f3) bezt->h2= 2;
+
+ /* if the handles are not of the same type, set them
+ * to type free
+ */
+ if(bezt->h1!=bezt->h2) {
+ if ELEM(bezt->h1, HD_ALIGN, HD_AUTO) bezt->h1= HD_FREE;
+ if ELEM(bezt->h2, HD_ALIGN, HD_AUTO) bezt->h2= HD_FREE;
+ }
+ }
+ return 0;
+}
+
+static int bezier_isfree(BezTriple *bezt)
+{
+ /* queries whether the handle should be set
+ * to type 'free' (I think)
+ */
+ if(bezt->f1 && bezt->h1) return 1;
+ if(bezt->f3 && bezt->h2) return 1;
+ return 0;
+}
+
+static int set_bezier_free(BezTriple *bezt)
+{
+ /* Sets selected bezier handles to type 'free'
+ */
+ if(bezt->f1) bezt->h1= HD_FREE;
+ if(bezt->f3) bezt->h2= HD_FREE;
+ return 0;
+}
+
+static int set_bezier_align(BezTriple *bezt)
+{
+ /* Sets selected bezier handles to type 'align'
+ */
+ if(bezt->f1) bezt->h1= HD_ALIGN;
+ if(bezt->f3) bezt->h2= HD_ALIGN;
+ return 0;
+}
+
+static int vis_edit_icu_bez(EditIpo *ei)
+{
+ /* A 4 part test for an EditIpo :
+ * is it a) visible
+ * b) in edit mode
+ * c) does it contain an Ipo Curve
+ * d) does that ipo curve have a bezier
+ *
+ * (The reason why I don't just use the macro
+ * is I need a pointer to a function.)
+ */
+ return (ISPOIN4(ei, flag & IPO_VISIBLE, flag & IPO_EDIT, icu, icu->bezt));
+}
+
+void select_ipo_bezier_keys(Ipo *ipo, int selectmode)
+{
+ /* Select all of the beziers in all
+ * of the Ipo curves belonging to the
+ * Ipo, using the selection mode.
+ */
+ switch (selectmode) {
+ case SELECT_ADD:
+ ipo_keys_bezier_loop(ipo, select_bezier_add, NULL);
+ break;
+ case SELECT_SUBTRACT:
+ ipo_keys_bezier_loop(ipo, select_bezier_subtract, NULL);
+ break;
+ case SELECT_INVERT:
+ ipo_keys_bezier_loop(ipo, select_bezier_invert, NULL);
+ break;
+ }
+}
+
+void sethandles_ipo_keys(Ipo *ipo, int code)
+{
+ /* this function lets you set bezier handles all to
+ * one type for some Ipo's (e.g. with hotkeys through
+ * the action window).
+ */
+
+ /* code==1: set autohandle */
+ /* code==2: set vectorhandle */
+ /* als code==3 (HD_ALIGN) toggelt het, vectorhandles worden HD_FREE */
+
+ switch(code) {
+ case 1:
+ /*** Set to auto ***/
+ ipo_keys_bezier_loop(ipo, set_bezier_auto,
+ calchandles_ipocurve);
+ break;
+ case 2:
+ /*** Set to vector ***/
+ ipo_keys_bezier_loop(ipo, set_bezier_vector,
+ calchandles_ipocurve);
+ break;
+ default:
+ if ( ipo_keys_bezier_loop(ipo, bezier_isfree, NULL) ) {
+ /*** Set to free ***/
+ ipo_keys_bezier_loop(ipo, set_bezier_free,
+ calchandles_ipocurve);
+ }
+ else {
+ /*** Set to align ***/
+ ipo_keys_bezier_loop(ipo, set_bezier_align,
+ calchandles_ipocurve);
+ }
+ break;
+ }
+
+
+}
+
+static void ipo_curves_auto_horiz(void)
+{
+ EditIpo *ei;
+ int a, set= 1;
+
+ ei= G.sipo->editipo;
+ for(a=0; a<G.sipo->totipo; a++, ei++) {
+ if (ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_SELECT, icu))
+ if(ei->flag & IPO_AUTO_HORIZ) set= 0;
+ }
+
+ ei= G.sipo->editipo;
+ for(a=0; a<G.sipo->totipo; a++, ei++) {
+ if (ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_SELECT, icu)) {
+ if(set) ei->flag |= IPO_AUTO_HORIZ;
+ else ei->flag &= ~IPO_AUTO_HORIZ;
+ }
+ }
+ update_editipo_flags();
+}
+
+void sethandles_ipo(int code)
+{
+ /* this function lets you set bezier handles all to
+ * one type for some selected keys in edit mode in the
+ * IPO window (e.g. with hotkeys)
+ */
+
+ /* code==1: set autohandle */
+ /* code==2: set vectorhandle */
+ /* als code==3 (HD_ALIGN) toggelt het, vectorhandles worden HD_FREE */
+
+ if(G.sipo->ipo && G.sipo->ipo->id.lib) return;
+
+ switch(code) {
+ case 1:
+ /*** Set to auto ***/
+ selected_bezier_loop(vis_edit_icu_bez, set_bezier_auto,
+ calchandles_ipocurve);
+ break;
+ case 2:
+ /*** Set to vector ***/
+ selected_bezier_loop(vis_edit_icu_bez, set_bezier_vector,
+ calchandles_ipocurve);
+ break;
+ case 4:
+ /* set to enforce autohandles to be horizontal on extremes */
+ ipo_curves_auto_horiz();
+
+ break;
+ default:
+ if (selected_bezier_loop(vis_edit_icu_bez, bezier_isfree, NULL) ) {
+ /*** Set to free ***/
+ selected_bezier_loop(vis_edit_icu_bez, set_bezier_free,
+ calchandles_ipocurve);
+ }
+ else {
+ /*** Set to align ***/
+ selected_bezier_loop(vis_edit_icu_bez, set_bezier_align,
+ calchandles_ipocurve);
+ }
+ break;
+ }
+
+ editipo_changed(G.sipo, 1);
+ BIF_undo_push("Set handles Ipo");
+}
+
+
+static void set_ipocurve_constant(struct IpoCurve *icu) {
+ /* Sets the type of the IPO curve to constant
+ */
+ icu->ipo= IPO_CONST;
+}
+
+static void set_ipocurve_linear(struct IpoCurve *icu) {
+ /* Sets the type of the IPO curve to linear
+ */
+ icu->ipo= IPO_LIN;
+}
+
+static void set_ipocurve_bezier(struct IpoCurve *icu) {
+ /* Sets the type of the IPO curve to bezier
+ */
+ icu->ipo= IPO_BEZ;
+}
+
+
+void setipotype_ipo(Ipo *ipo, int code)
+{
+ /* Sets the type of the each ipo curve in the
+ * Ipo to a value based on the code
+ */
+ switch (code) {
+ case 1:
+ ipo_keys_bezier_loop(ipo, NULL, set_ipocurve_constant);
+ break;
+ case 2:
+ ipo_keys_bezier_loop(ipo, NULL, set_ipocurve_linear);
+ break;
+ case 3:
+ ipo_keys_bezier_loop(ipo, NULL, set_ipocurve_bezier);
+ break;
+ }
+}
+
+void set_ipotype(void)
+{
+ EditIpo *ei;
+ int a;
+ short event;
+
+ if(G.sipo->ipo && G.sipo->ipo->id.lib) return;
+ if(G.sipo->showkey) return;
+ get_status_editipo();
+
+ if(G.sipo->blocktype==ID_KE && totipo_edit==0 && totipo_sel==0) {
+ Key *key= (Key *)G.sipo->from;
+ Object *ob= OBACT;
+ KeyBlock *kb;
+
+ if(key==NULL) return;
+ kb= BLI_findlink(&key->block, ob->shapenr-1);
+
+ event= pupmenu("Key Type %t|Linear %x1|Cardinal %x2|B Spline %x3");
+ if(event < 1) return;
+
+ kb->type= 0;
+ if(event==1) kb->type= KEY_LINEAR;
+ if(event==2) kb->type= KEY_CARDINAL;
+ if(event==3) kb->type= KEY_BSPLINE;
+ }
+ else {
+ event= pupmenu("Ipo Type %t|Constant %x1|Linear %x2|Bezier %x3");
+ if(event < 1) return;
+
+ ei= G.sipo->editipo;
+ for(a=0; a<G.sipo->totipo; a++, ei++) {
+ if (ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_SELECT, icu)) {
+ if(event==1) ei->icu->ipo= IPO_CONST;
+ else if(event==2) ei->icu->ipo= IPO_LIN;
+ else ei->icu->ipo= IPO_BEZ;
+ }
+ }
+ }
+ BIF_undo_push("Set ipo type");
+ scrarea_queue_winredraw(curarea);
+}
+
+void borderselect_ipo(void)
+{
+ EditIpo *ei;
+ IpoKey *ik;
+ BezTriple *bezt;
+ rcti rect;
+ rctf rectf;
+ int a, b, val;
+ short mval[2];
+
+ get_status_editipo();
+
+ val= get_border(&rect, 3);
+
+ if(val) {
+ mval[0]= rect.xmin;
+ mval[1]= rect.ymin;
+ areamouseco_to_ipoco(G.v2d, mval, &rectf.xmin, &rectf.ymin);
+ mval[0]= rect.xmax;
+ mval[1]= rect.ymax;
+ areamouseco_to_ipoco(G.v2d, mval, &rectf.xmax, &rectf.ymax);
+
+ if(G.sipo->showkey) {
+ ik= G.sipo->ipokey.first;
+ while(ik) {
+ if(rectf.xmin<ik->val && rectf.xmax>ik->val) {
+ if(val==LEFTMOUSE) ik->flag |= 1;
+ else ik->flag &= ~1;
+ }
+ ik= ik->next;
+ }
+ update_editipo_flags();
+ }
+ else if(totipo_edit==0) {
+ if(rect.xmin<rect.xmax && rect.ymin<rect.ymax)
+ select_proj_ipo(&rectf, val);
+ }
+ else {
+
+ ei= G.sipo->editipo;
+ for(a=0; a<G.sipo->totipo; a++, ei++) {
+ if (ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_EDIT, icu)) {
+ if(ei->icu->bezt) {
+ b= ei->icu->totvert;
+ bezt= ei->icu->bezt;
+ while(b--) {
+ int bit= (val==LEFTMOUSE);
+
+ if(BLI_in_rctf(&rectf, bezt->vec[0][0], bezt->vec[0][1]))
+ bezt->f1 = (bezt->f1&~1) | bit;
+ if(BLI_in_rctf(&rectf, bezt->vec[1][0], bezt->vec[1][1]))
+ bezt->f2 = (bezt->f2&~1) | bit;
+ if(BLI_in_rctf(&rectf, bezt->vec[2][0], bezt->vec[2][1]))
+ bezt->f3 = (bezt->f3&~1) | bit;
+
+ bezt++;
+ }
+ }
+ }
+ }
+ }
+ BIF_undo_push("Border select Ipo");
+ scrarea_queue_winredraw(curarea);
+ }
+}
+
+
+
+void nextkey(ListBase *elems, int dir)
+{
+ IpoKey *ik, *previk;
+ int totsel;
+
+ if(dir==1) ik= elems->last;
+ else ik= elems->first;
+ previk= 0;
+ totsel= 0;
+
+ while(ik) {
+
+ if(ik->flag) totsel++;
+
+ if(previk) {
+ if(G.qual & LR_SHIFTKEY) {
+ if(ik->flag) previk->flag= 1;
+ }
+ else previk->flag= ik->flag;
+ }
+
+ previk= ik;
+ if(dir==1) ik= ik->prev;
+ else ik= ik->next;
+
+ if(G.qual & LR_SHIFTKEY);
+ else if(ik==0) previk->flag= 0;
+ }
+
+ /* when no key select: */
+ if(totsel==0) {
+ if(dir==1) ik= elems->first;
+ else ik= elems->last;
+
+ if(ik) ik->flag= 1;
+ }
+}
+
+
+void nextkey_ipo(int dir) /* call from ipo queue */
+{
+ IpoKey *ik;
+ int a;
+
+ if(G.sipo->showkey==0) return;
+
+ nextkey(&G.sipo->ipokey, dir);
+
+ /* copy to beziers */
+ ik= G.sipo->ipokey.first;
+ while(ik) {
+ for(a=0; a<G.sipo->totipo; a++) {
+ if(ik->data[a]) ik->data[a]->f1= ik->data[a]->f2= ik->data[a]->f3= ik->flag;
+ }
+ ik= ik->next;
+ }
+
+ allqueue(REDRAWNLA, 0);
+ allqueue(REDRAWACTION, 0);
+ allqueue(REDRAWIPO, 0);
+ if(G.sipo->blocktype == ID_OB) allqueue(REDRAWVIEW3D, 0);
+}
+
+void nextkey_obipo(int dir) /* only call external from view3d queue */
+{
+ Base *base;
+ Object *ob;
+ ListBase elems;
+ IpoKey *ik;
+ int a;
+
+ /* problem: this doesnt work when you mix dLoc keys with Loc keys */
+
+ base= FIRSTBASE;
+ while(base) {
+ if TESTBASE(base) {
+ ob= base->object;
+ if( (ob->ipoflag & OB_DRAWKEY) && ob->ipo && ob->ipo->showkey) {
+ elems.first= elems.last= 0;
+ make_ipokey_transform(ob, &elems, 0);
+
+ if(elems.first) {
+
+ nextkey(&elems, dir);
+
+ /* copy to beziers */
+ ik= elems.first;
+ while(ik) {
+ for(a=0; a<OB_TOTIPO; a++) {
+ if(ik->data[a]) ik->data[a]->f1= ik->data[a]->f2= ik->data[a]->f3= ik->flag;
+ }
+ ik= ik->next;
+ }
+
+ free_ipokey(&elems);
+ }
+ }
+ }
+
+ base= base->next;
+ }
+ allqueue(REDRAWNLA, 0);
+ allqueue(REDRAWACTION, 0);
+ allqueue(REDRAWVIEW3D, 0);
+ allspace(REMAKEIPO, 0);
+ allqueue(REDRAWIPO, 0);
+}
+
+int is_ipo_key_selected(Ipo *ipo)
+{
+ int i;
+ IpoCurve *icu;
+
+ if (!ipo)
+ return 0;
+
+ for (icu=ipo->curve.first; icu; icu=icu->next){
+ for (i=0; i<icu->totvert; i++)
+ if (BEZSELECTED(&icu->bezt[i]))
+ return 1;
+ }
+
+ return 0;
+}
+
+void set_ipo_key_selection(Ipo *ipo, int sel)
+{
+ int i;
+ IpoCurve *icu;
+
+ if (!ipo)
+ return;
+
+ for (icu=ipo->curve.first; icu; icu=icu->next){
+ for (i=0; i<icu->totvert; i++){
+ if (sel){
+ icu->bezt[i].f1|=1;
+ icu->bezt[i].f2|=1;
+ icu->bezt[i].f3|=1;
+ }
+ else{
+ icu->bezt[i].f1&=~1;
+ icu->bezt[i].f2&=~1;
+ icu->bezt[i].f3&=~1;
+ }
+ }
+ }
+}
+
+int fullselect_ipo_keys(Ipo *ipo)
+{
+ int i;
+ IpoCurve *icu;
+ int tvtot = 0;
+
+ if (!ipo)
+ return tvtot;
+
+ for (icu=ipo->curve.first; icu; icu=icu->next){
+ for (i=0; i<icu->totvert; i++){
+ if (icu->bezt[i].f2 & 1){
+ tvtot+=3;
+ icu->bezt[i].f1 |= 1;
+ icu->bezt[i].f3 |= 1;
+ }
+ }
+ }
+
+ return tvtot;
+}
+
+
+void borderselect_icu_key(IpoCurve *icu, float xmin, float xmax,
+ int (*select_function)(BezTriple *))
+{
+ /* Selects all bezier triples in the Ipocurve
+ * between times xmin and xmax, using the selection
+ * function.
+ */
+
+ int i;
+
+ /* loop through all of the bezier triples in
+ * the Ipocurve -- if the triple occurs between
+ * times xmin and xmax then select it using the selection
+ * function
+ */
+ for (i=0; i<icu->totvert; i++){
+ if (icu->bezt[i].vec[1][0] > xmin && icu->bezt[i].vec[1][0] < xmax ){
+ select_function(&(icu->bezt[i]));
+ }
+ }
+}
+
+void borderselect_ipo_key(Ipo *ipo, float xmin, float xmax, int selectmode)
+{
+ /* Selects all bezier triples in each Ipocurve of the
+ * Ipo between times xmin and xmax, using the selection mode.
+ */
+
+ IpoCurve *icu;
+ int (*select_function)(BezTriple *);
+
+ /* If the ipo is no good then return */
+ if (!ipo)
+ return;
+
+ /* Set the selection function based on the
+ * selection mode.
+ */
+ switch(selectmode) {
+ case SELECT_ADD:
+ select_function = select_bezier_add;
+ break;
+ case SELECT_SUBTRACT:
+ select_function = select_bezier_subtract;
+ break;
+ case SELECT_INVERT:
+ select_function = select_bezier_invert;
+ break;
+ default:
+ return;
+ }
+
+ /* loop through all of the bezier triples in all
+ * of the Ipocurves -- if the triple occurs between
+ * times xmin and xmax then select it using the selection
+ * function
+ */
+ for (icu=ipo->curve.first; icu; icu=icu->next){
+ borderselect_icu_key(icu, xmin, xmax, select_function);
+ }
+}
+
+void select_ipo_key(Ipo *ipo, float selx, int selectmode)
+{
+ /* Selects all bezier triples in each Ipocurve of the
+ * Ipo at time selx, using the selection mode.
+ */
+ int i;
+ IpoCurve *icu;
+ int (*select_function)(BezTriple *);
+
+ /* If the ipo is no good then return */
+ if (!ipo)
+ return;
+
+ /* Set the selection function based on the
+ * selection mode.
+ */
+ switch(selectmode) {
+ case SELECT_ADD:
+ select_function = select_bezier_add;
+ break;
+ case SELECT_SUBTRACT:
+ select_function = select_bezier_subtract;
+ break;
+ case SELECT_INVERT:
+ select_function = select_bezier_invert;
+ break;
+ default:
+ return;
+ }
+
+ /* loop through all of the bezier triples in all
+ * of the Ipocurves -- if the triple occurs at
+ * time selx then select it using the selection
+ * function
+ */
+ for (icu=ipo->curve.first; icu; icu=icu->next){
+ for (i=0; i<icu->totvert; i++){
+ if (icu->bezt[i].vec[1][0]==selx){
+ select_function(&(icu->bezt[i]));
+ }
+ }
+ }
+}
+
+void select_icu_key(IpoCurve *icu, float selx, int selectmode)
+{
+ /* Selects all bezier triples in the Ipocurve
+ * at time selx, using the selection mode.
+ * This is kind of sloppy the obvious similarities
+ * with the above function, forgive me ...
+ */
+ int i;
+ int (*select_function)(BezTriple *);
+
+ /* If the icu is no good then return */
+ if (!icu)
+ return;
+
+ /* Set the selection function based on the
+ * selection mode.
+ */
+ switch(selectmode) {
+ case SELECT_ADD:
+ select_function = select_bezier_add;
+ break;
+ case SELECT_SUBTRACT:
+ select_function = select_bezier_subtract;
+ break;
+ case SELECT_INVERT:
+ select_function = select_bezier_invert;
+ break;
+ default:
+ return;
+ }
+
+ /* loop through all of the bezier triples in
+ * the Ipocurve -- if the triple occurs at
+ * time selx then select it using the selection
+ * function
+ */
+ for (i=0; i<icu->totvert; i++){
+ if (icu->bezt[i].vec[1][0]==selx){
+ select_function(&(icu->bezt[i]));
+ }
+ }
+}
+
+void set_exprap_ipo(int mode)
+{
+ EditIpo *ei;
+ int a;
+
+ if(G.sipo->ipo && G.sipo->ipo->id.lib) return;
+ /* in case of keys: always ok */
+
+ ei= G.sipo->editipo;
+ for(a=0; a<G.sipo->totipo; a++, ei++) {
+ if (ISPOIN(ei, flag & IPO_VISIBLE, icu)) {
+ if( (ei->flag & IPO_EDIT) || (ei->flag & IPO_SELECT) || (G.sipo->showkey) ) {
+ ei->icu->extrap= mode;
+ }
+ }
+ }
+
+ editipo_changed(G.sipo, 1);
+ BIF_undo_push("Set extrapolation Ipo");
+}
+
+
diff --git a/source/blender/src/editkey.c b/source/blender/src/editkey.c
index 345c48d789f..2262d3298cf 100644
--- a/source/blender/src/editkey.c
+++ b/source/blender/src/editkey.c
@@ -96,18 +96,20 @@ float meshslidervals[64] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
-static IpoCurve *get_key_icu(Key *key, int keynum) {
+static IpoCurve *get_key_icu(Key *key, int keynum)
+{
/* return the Ipocurve that has the specified
* keynum as ardcode -- return NULL if no such
* curve exists.
*/
IpoCurve *icu;
+
+ /* why this? (ton) */
if (!(key->ipo)) {
- key->ipo = get_ipo((ID *)key, ID_KE, 1);
+ key->ipo= add_ipo("KeyIpo", ID_KE);
return NULL;
}
-
for (icu = key->ipo->curve.first; icu ; icu = icu->next) {
if (!icu->adrcode) continue;
if (icu->adrcode == keynum) return icu;
@@ -158,7 +160,7 @@ static void rvk_slider_func(void *voidkey, void *voidkeynum)
cfra = frame_to_float(CFRA);
- icu = get_key_icu(key, keynum);
+ icu = verify_ipocurve(&key->id, ID_KE, NULL, NULL, keynum);
if (icu) {
/* if the ipocurve exists, try to get a bezier
@@ -166,12 +168,6 @@ static void rvk_slider_func(void *voidkey, void *voidkeynum)
*/
bezt = get_bezt_icu_time(icu, &cfra, &rvkval);
}
- else {
- /* create an IpoCurve if one doesn't already
- * exist.
- */
- icu = get_ipocurve(key->from, GS(key->from->name), keynum, key->ipo);
- }
/* create the bezier triple if one doesn't exist,
* otherwise modify it's value
diff --git a/source/blender/src/editnla.c b/source/blender/src/editnla.c
index 00cf212e3cb..89479f53d91 100644
--- a/source/blender/src/editnla.c
+++ b/source/blender/src/editnla.c
@@ -40,13 +40,6 @@
#include "PIL_time.h"
-#include "BKE_action.h"
-#include "BKE_global.h"
-#include "BKE_ipo.h"
-#include "BKE_library.h"
-#include "BKE_main.h"
-#include "BKE_nla.h"
-
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
@@ -62,6 +55,14 @@
#include "DNA_nla_types.h"
#include "DNA_constraint_types.h"
+#include "BKE_action.h"
+#include "BKE_depsgraph.h"
+#include "BKE_global.h"
+#include "BKE_ipo.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
+#include "BKE_nla.h"
+
#include "BIF_screen.h"
#include "BIF_interface.h"
#include "BIF_butspace.h"
@@ -98,8 +99,6 @@ static Base *get_nearest_nlastrip (bActionStrip **rstrip, short *sel);
static void mouse_nlachannels(short mval[2]);
static void add_nlablock(short mval[2]);
static void convert_nla(short mval[2]);
-extern int count_nla_levels(void); /* From drawnla.c */
-extern int nla_filter (Base* base, int flags); /* From drawnla.c */
/* ******************** SPACE: NLA ********************** */
@@ -109,31 +108,28 @@ void shift_nlastrips_up(void) {
bActionStrip *strip, *prevstrip;
for (base=G.scene->base.first; base; base=base->next) {
- if (base->object->type == OB_ARMATURE) {
-
- for (strip = base->object->nlastrips.first;
- strip; strip=strip->next){
- if (strip->flag & ACTSTRIP_SELECT) {
- if ( (prevstrip = strip->prev) ) {
- if (prevstrip->prev)
- prevstrip->prev->next = strip;
- if (strip->next)
- strip->next->prev = prevstrip;
- strip->prev = prevstrip->prev;
- prevstrip->next = strip->next;
- strip->next = prevstrip;
- prevstrip->prev = strip;
-
- if (prevstrip == base->object->nlastrips.first)
- base->object->nlastrips.first = strip;
- if (strip == base->object->nlastrips.last)
- base->object->nlastrips.last = prevstrip;
-
- strip = prevstrip;
- }
- else {
- break;
- }
+ for (strip = base->object->nlastrips.first;
+ strip; strip=strip->next){
+ if (strip->flag & ACTSTRIP_SELECT) {
+ if ( (prevstrip = strip->prev) ) {
+ if (prevstrip->prev)
+ prevstrip->prev->next = strip;
+ if (strip->next)
+ strip->next->prev = prevstrip;
+ strip->prev = prevstrip->prev;
+ prevstrip->next = strip->next;
+ strip->next = prevstrip;
+ prevstrip->prev = strip;
+
+ if (prevstrip == base->object->nlastrips.first)
+ base->object->nlastrips.first = strip;
+ if (strip == base->object->nlastrips.last)
+ base->object->nlastrips.last = prevstrip;
+
+ strip = prevstrip;
+ }
+ else {
+ break;
}
}
}
@@ -149,37 +145,35 @@ void shift_nlastrips_down(void) {
bActionStrip *strip, *nextstrip;
for (base=G.scene->base.first; base; base=base->next) {
- if (base->object->type == OB_ARMATURE) {
- for (strip = base->object->nlastrips.last;
- strip; strip=strip->prev){
- if (strip->flag & ACTSTRIP_SELECT) {
- if ( (nextstrip = strip->next) ) {
- if (nextstrip->next)
- nextstrip->next->prev = strip;
- if (strip->prev)
- strip->prev->next = nextstrip;
- strip->next = nextstrip->next;
- nextstrip->prev = strip->prev;
- strip->prev = nextstrip;
- nextstrip->next = strip;
-
- if (nextstrip == base->object->nlastrips.last)
- base->object->nlastrips.last = strip;
- if (strip == base->object->nlastrips.first)
- base->object->nlastrips.first = nextstrip;
-
- strip = nextstrip;
- }
- else {
- break;
- }
+ for (strip = base->object->nlastrips.last;
+ strip; strip=strip->prev){
+ if (strip->flag & ACTSTRIP_SELECT) {
+ if ( (nextstrip = strip->next) ) {
+ if (nextstrip->next)
+ nextstrip->next->prev = strip;
+ if (strip->prev)
+ strip->prev->next = nextstrip;
+ strip->next = nextstrip->next;
+ nextstrip->prev = strip->prev;
+ strip->prev = nextstrip;
+ nextstrip->next = strip;
+
+ if (nextstrip == base->object->nlastrips.last)
+ base->object->nlastrips.last = strip;
+ if (strip == base->object->nlastrips.first)
+ base->object->nlastrips.first = nextstrip;
+
+ strip = nextstrip;
+ }
+ else {
+ break;
}
}
}
}
+
BIF_undo_push("Shift NLA strips");
allqueue (REDRAWNLA, 0);
-
}
void winqreadnlaspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
@@ -267,7 +261,7 @@ void winqreadnlaspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
case GKEY:
if (mval[0]>=NLAWIDTH)
- transform_nlachannel_keys ('g');
+ transform_nlachannel_keys ('g', 0);
update_for_newframe_muted();
break;
@@ -280,7 +274,7 @@ void winqreadnlaspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
case SKEY:
if (mval[0]>=NLAWIDTH)
- transform_nlachannel_keys ('s');
+ transform_nlachannel_keys ('s', 0);
update_for_newframe_muted();
break;
@@ -288,17 +282,17 @@ void winqreadnlaspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
case XKEY:
if (mval[0]>=NLAWIDTH)
delete_nlachannel_keys ();
- else
- delete_nlachannels();
+
update_for_newframe_muted();
break;
-
+
/* LEFTMOUSE and RIGHTMOUSE event codes can be swapped above,
* based on user preference USER_LMOUSESELECT
*/
case LEFTMOUSE:
- if(view2dmove(LEFTMOUSE)); // only checks for sliders
- else if (mval[0]>NLAWIDTH){
+ if(view2dmove(LEFTMOUSE))
+ break; // only checks for sliders
+ else if (mval[0]>=snla->v2d.mask.xmin) {
do {
getmouseco_areawin(mval);
@@ -310,16 +304,16 @@ void winqreadnlaspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if( cfra!=CFRA ) {
CFRA= cfra;
update_for_newframe();
- force_draw_plus(SPACE_VIEW3D, 1);
- force_draw_plus(SPACE_IPO, 1);
+ force_draw_all(0);
}
else PIL_sleep_ms(30);
} while(get_mbut() & mousebut);
+ break;
}
- break;
+ /* else pass on! */
case RIGHTMOUSE:
- if (mval[0]>=NLAWIDTH) {
+ if (mval[0]>=snla->v2d.mask.xmin) {
if(G.qual & LR_SHIFTKEY)
mouse_nla(SELECT_INVERT);
else
@@ -350,6 +344,31 @@ void winqreadnlaspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if(doredraw) scrarea_queue_winredraw(curarea);
}
+static void set_active_strip(Object *ob, bActionStrip *act)
+{
+ bActionStrip *strip;
+
+ for (strip = ob->nlastrips.first; strip; strip=strip->next)
+ strip->flag &= ~ACTSTRIP_ACTIVE;
+
+ if(act) {
+ act->flag |= ACTSTRIP_ACTIVE;
+
+ if(ob->action!=act->act) {
+ if(ob->action) ob->action->id.us--;
+ ob->action= act->act;
+ ob->action->id.us++;
+
+ allqueue(REDRAWIPO, 0);
+ allqueue(REDRAWVIEW3D, 0);
+ allqueue(REDRAWACTION, 0);
+ allqueue(REDRAWNLA, 0);
+ ob->ctime= -1234567.0f; // eveil!
+ DAG_object_flush_update(G.scene, ob, OB_RECALC_OB|OB_RECALC_DATA);
+ }
+ }
+}
+
static void convert_nla(short mval[2])
{
short event;
@@ -358,6 +377,7 @@ static void convert_nla(short mval[2])
float x,y;
int sel=0;
bActionStrip *strip, *nstrip;
+
/* Find out what strip we're over */
ymax = count_nla_levels() * (NLACHANNELSKIP+NLACHANNELHEIGHT);
ymax+= NLACHANNELHEIGHT/2;
@@ -365,74 +385,73 @@ static void convert_nla(short mval[2])
areamouseco_to_ipoco(G.v2d, mval, &x, &y);
for (base=G.scene->base.first; base; base=base->next){
- if (nla_filter(base, 0)){
+ if (nla_filter(base)) {
/* Check object ipo */
- ymin=ymax-(NLACHANNELSKIP+NLACHANNELHEIGHT);
+ ymin= ymax-(NLACHANNELSKIP+NLACHANNELHEIGHT);
if (y>=ymin && y<=ymax)
break;
ymax=ymin;
- if (base->object->type==OB_ARMATURE){
- /* Check action ipo */
+ /* Check action ipo */
+ ymin=ymax-(NLACHANNELSKIP+NLACHANNELHEIGHT);
+ if (y>=ymin && y<=ymax)
+ break;
+ ymax=ymin;
+
+ /* Check nlastrips */
+ for (strip=base->object->nlastrips.first; strip; strip=strip->next){
ymin=ymax-(NLACHANNELSKIP+NLACHANNELHEIGHT);
- if (y>=ymin && y<=ymax)
+ if (y>=ymin && y<=ymax){
+ sel = 1;
break;
- ymax=ymin;
-
- /* Check nlastrips */
- for (strip=base->object->nlastrips.first; strip; strip=strip->next){
- ymin=ymax-(NLACHANNELSKIP+NLACHANNELHEIGHT);
- if (y>=ymin && y<=ymax){
- sel = 1;
- break;
- }
- ymax=ymin;
}
- if (sel)
- break;
+ ymax=ymin;
}
+ if (sel)
+ break;
}
}
if (!base)
return;
- if (base->object->type==OB_ARMATURE){
- event = pupmenu("Convert%t|Action to NLA Strip%x1");
- switch (event){
- case 1:
- if (base->object->action){
- /* Make new actionstrip */
- nstrip = MEM_callocN(sizeof(bActionStrip), "bActionStrip");
-
- deselect_nlachannel_keys(0);
-
- /* Link the action to the nstrip */
- nstrip->act = base->object->action;
- nstrip->actstart = calc_action_start(base->object->action); /* MAKE THIS THE FIRST FRAME OF THE ACTION */
- nstrip->actend = calc_action_end(base->object->action);
- nstrip->start = nstrip->actstart;
- nstrip->end = nstrip->actend;
- nstrip->flag = ACTSTRIP_SELECT;
- nstrip->repeat = 1.0;
-
- BLI_addtail(&base->object->nlastrips, nstrip);
-
- /* Unlink action */
- base->object->action = NULL;
-
- BIF_undo_push("Convert NLA");
- allqueue (REDRAWNLA, 0);
- }
+ event = pupmenu("Convert%t|Action to NLA Strip%x1");
+ switch (event){
+ case 1:
+ if (base->object->action){
+ /* Make new actionstrip */
+ nstrip = MEM_callocN(sizeof(bActionStrip), "bActionStrip");
+ deselect_nlachannel_keys(0);
- break;
- default:
- break;
+ /* Link the action to the nstrip */
+ nstrip->act = base->object->action;
+ nstrip->actstart = calc_action_start(base->object->action); /* MAKE THIS THE FIRST FRAME OF THE ACTION */
+ nstrip->actend = calc_action_end(base->object->action);
+ nstrip->start = nstrip->actstart;
+ nstrip->end = nstrip->actend;
+ nstrip->flag = ACTSTRIP_SELECT;
+ set_active_strip(base->object, nstrip);
+
+ nstrip->repeat = 1.0;
+
+ BLI_addtail(&base->object->nlastrips, nstrip);
+
+ /* Unlink action */
+ base->object->action = NULL;
+
+ BIF_undo_push("Convert NLA");
+ allqueue (REDRAWNLA, 0);
}
+
+
+ break;
+ default:
+ break;
}
}
+
static Base *nla_base=NULL; /* global, bad, bad! put it in nla space later, or recode the 2 functions below (ton) */
static void add_nla_block(short event)
@@ -461,14 +480,17 @@ static void add_nla_block(short event)
/* Link the action to the strip */
strip->act = act;
- strip->actstart = 1.0;
+ strip->actstart = calc_action_start(act);
strip->actend = calc_action_end(act);
- strip->start = G.scene->r.cfra; /* Should be mval[0] */
+ strip->start = G.scene->r.cfra; /* could be mval[0] another time... */
strip->end = strip->start + (strip->actend-strip->actstart);
- if(strip->start<strip->end+2)
+ /* simple prevention of zero strips */
+ if(strip->start>strip->end-2)
strip->end= strip->start+100;
strip->flag = ACTSTRIP_SELECT;
+ set_active_strip(nla_base->object, strip);
+
strip->repeat = 1.0;
act->id.us++;
@@ -492,15 +514,14 @@ static void add_nla_databrowse_callback(unsigned short val)
static void add_nlablock(short mval[2])
{
- /* Make sure we are over an armature */
+ /* Make sure we are over an object with action */
Base *base;
+ rctf rectf;
float ymin, ymax;
float x, y;
- rctf rectf;
short event;
- char *str;
short nr;
- bConstraintChannel *conchan=NULL;
+ char *str;
areamouseco_to_ipoco(G.v2d, mval, &x, &y);
@@ -516,34 +537,22 @@ static void add_nlablock(short mval[2])
for (base=G.scene->base.first; base; base=base->next){
/* Handle object ipo selection */
- if (nla_filter(base, 0)){
+ if (nla_filter(base)) {
/* Area that encloses object name (or ipo) */
ymin=ymax-(NLACHANNELHEIGHT+NLACHANNELSKIP);
- /* Area that encloses constraint channels */
- for (conchan=base->object->constraintChannels.first;
- conchan; conchan=conchan->next){
+ /* Area that encloses action */
+ if (base->object->action)
ymin-=(NLACHANNELHEIGHT+NLACHANNELSKIP);
- }
- if (base->object->type==OB_ARMATURE){
- /* Area that encloses selected action, if
- * present
- */
- if (base->object->action)
- ymin-=(NLACHANNELHEIGHT+NLACHANNELSKIP);
+ /* Area that encloses nla strips */
+ ymin-=(NLACHANNELHEIGHT+NLACHANNELSKIP)*
+ (BLI_countlist(&base->object->nlastrips));
- /* Area that encloses nla strips */
- ymin-=(NLACHANNELHEIGHT+NLACHANNELSKIP)*
- (BLI_countlist(&base->object->nlastrips));
- }
-
- /* Test to see the mouse is in an armature area */
- if (base->object->type==OB_ARMATURE){
- if (!((ymax < rectf.ymin) || (ymin > rectf.ymax)))
- break;
- }
+ /* Test to see the mouse is in an action area */
+ if (!((ymax < rectf.ymin) || (ymin > rectf.ymax)))
+ break;
ymax=ymin;
}
@@ -552,9 +561,9 @@ static void add_nlablock(short mval[2])
/* global... for the call above, because the NLA system seems not to have an 'active strip' stored */
nla_base= base;
- /* Make sure we have an armature */
+ /* Make sure we have an action */
if (!base){
- error ("Not an armature");
+ error ("Object has not an Action");
return;
}
@@ -581,127 +590,83 @@ static void add_nlablock(short mval[2])
*/
}
+/* Left hand side of channels display, selects objects */
static void mouse_nlachannels(short mval[2])
{
- /* Find which strip has been clicked */
-// bActionChannel *chan;
- bConstraintChannel *conchan=NULL;
- bActionStrip *strip;
- float click, x,y;
- int wsize;
- int sel;
+ bActionStrip *strip= NULL;
Base *base;
+ Object *ob=NULL;
+ float x,y;
+ int click, obclick=0;
+ int wsize;
wsize = (count_nla_levels ()*(NLACHANNELHEIGHT+NLACHANNELSKIP));
wsize+= NLACHANNELHEIGHT/2;
- areamouseco_to_ipoco(G.v2d, mval, &x, &y);
- click = ((wsize - y) / (NLACHANNELHEIGHT+NLACHANNELSKIP));
-
+ areamouseco_to_ipoco(G.v2d, mval, &x, &y);
+ click = (int)floor( ((float)wsize - y) / (NLACHANNELHEIGHT+NLACHANNELSKIP));
+
if (click<0)
return;
for (base = G.scene->base.first; base; base=base->next){
- if (nla_filter(base, 0)) {
+ if (nla_filter(base)) {
+ ob= base->object;
+
/* See if this is a base selected */
- if ((int)click==0)
+ if (click==0) {
+ obclick= 1;
break;
-
+ }
click--;
- /* Check for click in a constraint */
- for (conchan=base->object->constraintChannels.first; conchan; conchan=conchan->next){
- if ((int)click==0){
- base=G.scene->base.last;
- break;
- }
- click--;
- }
-
/* See if this is an action */
- if (base->object->type==OB_ARMATURE && base->object->action){
- if ((int)click==0){
- break;
- }
+ if (ob->action){
+ if (click==0) break;
click--;
}
/* See if this is an nla strip */
- for (strip = base->object->nlastrips.first; strip; strip=strip->next){
- if ((int)click==0){
- base=G.scene->base.last;
- break;
+ if(ob->nlastrips.first) {
+ for (strip = ob->nlastrips.first; strip; strip=strip->next){
+ if (click==0) break;
+ click--;
}
- click--;
+ if (strip && click==0) break;
}
}
}
- if (!base && !conchan)
+ if (!base)
return;
- /* Handle constraint strip selection */
- if (conchan){
- if (conchan->flag & CONSTRAINT_CHANNEL_SELECT)
- sel = 0;
- else
- sel =1;
-
- /* Channel names clicking */
- if (G.qual & LR_SHIFTKEY){
- // select_poseelement_by_name(chan->name, !(chan->flag & ACHAN_SELECTED));
- if (conchan->flag & CONSTRAINT_CHANNEL_SELECT){
- conchan->flag &= ~CONSTRAINT_CHANNEL_SELECT;
- // hilight_channel(act, chan, 0);
- }
- else{
- conchan->flag |= CONSTRAINT_CHANNEL_SELECT;
- // hilight_channel(act, chan, 1);
- }
- }
- else{
- deselect_nlachannels (0); // Auto clear
- conchan->flag |= CONSTRAINT_CHANNEL_SELECT;
- // hilight_channel(act, chan, 1);
- // act->achan = chan;
- // select_poseelement_by_name(chan->name, 1);
- }
-
+ /* Handle object strip selection */
+ if (G.qual & LR_SHIFTKEY) {
+ if (base->flag & SELECT) base->flag &= ~SELECT;
+ else base->flag |= SELECT;
+ }
+ else {
+ deselect_nlachannels (0); // Auto clear
+ base->flag |= SELECT;
}
+ ob->flag= base->flag;
- /* Handle object strip selection */
- else if (base) {
-
- /* Choose the mode */
- if (base->flag & SELECT)
- sel = 0;
- else
- sel =1;
-
- /* Channel names clicking */
- if (G.qual & LR_SHIFTKEY) {
- // select_poseelement_by_name(chan->name, !(chan->flag & ACHAN_SELECTED));
- if (base->flag & SELECT) {
- base->flag &= ~SELECT;
- // hilight_channel(act, chan, 0);
- }
- else {
- base->flag |= SELECT;
- // hilight_channel(act, chan, 1);
- }
- }
- else {
- deselect_nlachannels (0); // Auto clear
- base->flag |= SELECT;
- // hilight_channel(act, chan, 1);
- // act->achan = chan;
- // select_poseelement_by_name(chan->name, 1);
- }
-
+ if(base!=BASACT) set_active_base(base);
+
+ /* set action */
+ if(strip)
+ set_active_strip(ob, strip);
+
+ /* override option for NLA */
+ if(obclick && mval[0]<25) {
+ ob->nlaflag ^= OB_NLA_OVERRIDE;
+ ob->ctime= -1234567.0f; // eveil!
+ DAG_object_flush_update(G.scene, ob, OB_RECALC_OB|OB_RECALC_DATA);
}
- allqueue (REDRAWIPO, 0);
- allqueue (REDRAWVIEW3D, 0);
- allqueue (REDRAWACTION, 0);
+
+ allqueue(REDRAWIPO, 0);
+ allqueue(REDRAWVIEW3D, 0);
+ allqueue(REDRAWACTION, 0);
allqueue(REDRAWNLA, 0);
}
@@ -736,7 +701,7 @@ void deselect_nlachannel_keys (int test)
/* Test action ipos */
if (sel){
- if (base->object->type==OB_ARMATURE && base->object->action){
+ if (base->object->action){
for (chan=base->object->action->chanbase.first; chan; chan=chan->next){
if (is_ipo_key_selected(chan->ipo)){
sel=0;
@@ -758,12 +723,10 @@ void deselect_nlachannel_keys (int test)
/* Test NLA strips */
if (sel){
- if (base->object->type==OB_ARMATURE){
- for (strip=base->object->nlastrips.first; strip; strip=strip->next){
- if (strip->flag & ACTSTRIP_SELECT){
- sel = 0;
- break;
- }
+ for (strip=base->object->nlastrips.first; strip; strip=strip->next){
+ if (strip->flag & ACTSTRIP_SELECT){
+ sel = 0;
+ break;
}
}
}
@@ -775,9 +738,9 @@ void deselect_nlachannel_keys (int test)
/* Set the flags */
for (base=G.scene->base.first; base; base=base->next){
+
/* Set the object ipos */
set_ipo_key_selection(base->object->ipo, sel);
-
/* Set the object constraint ipos */
for (conchan=base->object->constraintChannels.first; conchan; conchan=conchan->next){
@@ -785,7 +748,7 @@ void deselect_nlachannel_keys (int test)
}
/* Set the action ipos */
- if (base->object->type==OB_ARMATURE && base->object->action){
+ if (base->object->action){
for (chan=base->object->action->chanbase.first; chan; chan=chan->next){
set_ipo_key_selection(chan->ipo, sel);
/* Set the action constraint ipos */
@@ -795,13 +758,11 @@ void deselect_nlachannel_keys (int test)
}
/* Set the nlastrips */
- if (base->object->type==OB_ARMATURE){
- for (strip=base->object->nlastrips.first; strip; strip=strip->next){
- if (sel)
- strip->flag |= ACTSTRIP_SELECT;
- else
- strip->flag &= ~ACTSTRIP_SELECT;
- }
+ for (strip=base->object->nlastrips.first; strip; strip=strip->next){
+ if (sel)
+ strip->flag |= ACTSTRIP_SELECT;
+ else
+ strip->flag &= ~ACTSTRIP_SELECT;
}
}
}
@@ -821,7 +782,7 @@ static void recalc_all_ipos(void)
}
}
-void transform_nlachannel_keys(char mode)
+void transform_nlachannel_keys(int mode, int dummy)
{
Base *base;
TransVert *tv;
@@ -852,7 +813,7 @@ void transform_nlachannel_keys(char mode)
tvtot+=fullselect_ipo_keys(conchan->ipo);
/* Check action ipos */
- if (base->object->type == OB_ARMATURE && base->object->action){
+ if (base->object->action){
for (chan=base->object->action->chanbase.first; chan; chan=chan->next){
tvtot+=fullselect_ipo_keys(chan->ipo);
@@ -864,11 +825,9 @@ void transform_nlachannel_keys(char mode)
}
/* Check nlastrips */
- if (base->object->type==OB_ARMATURE){
- for (strip=base->object->nlastrips.first; strip; strip=strip->next){
- if (strip->flag & ACTSTRIP_SELECT)
- tvtot+=2;
- }
+ for (strip=base->object->nlastrips.first; strip; strip=strip->next){
+ if (strip->flag & ACTSTRIP_SELECT)
+ tvtot+=2;
}
}
@@ -889,7 +848,7 @@ void transform_nlachannel_keys(char mode)
tvtot=add_trans_ipo_keys(conchan->ipo, tv, tvtot);
/* Manipulate action ipos */
- if (base->object->type==OB_ARMATURE && base->object->action){
+ if (base->object->action){
for (chan=base->object->action->chanbase.first; chan; chan=chan->next){
tvtot=add_trans_ipo_keys(chan->ipo, tv, tvtot);
@@ -1078,19 +1037,17 @@ void delete_nlachannel_keys(void)
delete_ipo_keys(conchan->ipo);
/* Delete NLA strips */
- if (base->object->type==OB_ARMATURE){
- for (strip = base->object->nlastrips.first; strip; strip=nextstrip){
- nextstrip=strip->next;
- if (strip->flag & ACTSTRIP_SELECT){
- free_actionstrip(strip);
- BLI_remlink(&base->object->nlastrips, strip);
- MEM_freeN(strip);
- }
+ for (strip = base->object->nlastrips.first; strip; strip=nextstrip){
+ nextstrip=strip->next;
+ if (strip->flag & ACTSTRIP_SELECT){
+ free_actionstrip(strip);
+ BLI_remlink(&base->object->nlastrips, strip);
+ MEM_freeN(strip);
}
}
/* Delete action ipos */
- if (base->object->type==OB_ARMATURE && base->object->action){
+ if (base->object->action){
for (chan=base->object->action->chanbase.first; chan; chan=chan->next){
delete_ipo_keys(chan->ipo);
/* Delete action constraint keys */
@@ -1125,27 +1082,26 @@ void duplicate_nlachannel_keys(void)
duplicate_ipo_keys(conchan->ipo);
/* Duplicate nla strips */
- if (base->object->type == OB_ARMATURE){
- laststrip = base->object->nlastrips.last;
- for (strip=base->object->nlastrips.first; strip; strip=strip->next){
- if (strip->flag & ACTSTRIP_SELECT){
- bActionStrip *newstrip;
-
- copy_actionstrip(&newstrip, &strip);
-
- BLI_addtail(&base->object->nlastrips, newstrip);
-
- strip->flag &= ~ACTSTRIP_SELECT;
- newstrip->flag |= ACTSTRIP_SELECT;
-
- }
- if (strip==laststrip)
- break;
+ laststrip = base->object->nlastrips.last;
+ for (strip=base->object->nlastrips.first; strip; strip=strip->next){
+ if (strip->flag & ACTSTRIP_SELECT){
+ bActionStrip *newstrip;
+
+ copy_actionstrip(&newstrip, &strip);
+
+ BLI_addtail(&base->object->nlastrips, newstrip);
+
+ strip->flag &= ~ACTSTRIP_SELECT;
+ newstrip->flag |= ACTSTRIP_SELECT;
+ set_active_strip(base->object, newstrip);
+
}
+ if (strip==laststrip)
+ break;
}
/* Duplicate actionchannel keys */
- if (base->object->type == OB_ARMATURE && base->object->action){
+ if (base->object->action){
for (chan=base->object->action->chanbase.first; chan; chan=chan->next){
duplicate_ipo_keys(chan->ipo);
/* Duplicate action constraint keys */
@@ -1156,7 +1112,7 @@ void duplicate_nlachannel_keys(void)
}
BIF_undo_push("Duplicate NLA");
- transform_nlachannel_keys ('g');
+ transform_nlachannel_keys ('g', 0);
}
void borderselect_nla(void)
@@ -1185,66 +1141,67 @@ void borderselect_nla(void)
ymax = count_nla_levels();
ymax*= (NLACHANNELHEIGHT+NLACHANNELSKIP);
-
+ ymax+= (NLACHANNELHEIGHT+NLACHANNELSKIP)/2;
+
for (base=G.scene->base.first; base; base=base->next){
- /* Check object ipos */
- if (nla_filter(base, 0)){
+ if (nla_filter(base)) {
+
ymin=ymax-(NLACHANNELHEIGHT+NLACHANNELSKIP);
+
+ /* Check object ipos */
if (base->object->ipo){
if (!((ymax < rectf.ymin) || (ymin > rectf.ymax)))
borderselect_ipo_key(base->object->ipo, rectf.xmin, rectf.xmax,
selectmode);
}
- ymax=ymin;
-
/* Check object constraint ipos */
for (conchan=base->object->constraintChannels.first; conchan; conchan=conchan->next){
- ymin=ymax-(NLACHANNELHEIGHT+NLACHANNELSKIP);
if (!((ymax < rectf.ymin) || (ymin > rectf.ymax)))
borderselect_ipo_key(conchan->ipo, rectf.xmin, rectf.xmax,
selectmode);
- ymax=ymin;
}
+
+ ymax=ymin;
/* Check action ipos */
- if (ACTIVE_ARMATURE(base)){
+ if (base->object->action){
+ bActionChannel *chan;
+ float xmin, xmax;
+
ymin=ymax-(NLACHANNELHEIGHT+NLACHANNELSKIP);
- if (base->object->action){
- bActionChannel *chan;
-
- if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))){
- for (chan=base->object->action->chanbase.first; chan; chan=chan->next){
- borderselect_ipo_key(chan->ipo, rectf.xmin, rectf.xmax,
- selectmode);
- /* Check action constraint ipos */
- for (conchan=chan->constraintChannels.first; conchan; conchan=conchan->next)
- borderselect_ipo_key(conchan->ipo, rectf.xmin, rectf.xmax,
- selectmode);
- }
+
+ /* if action is mapped in NLA, it returns a correction */
+ xmin= get_action_frame(base->object, rectf.xmin);
+ xmax= get_action_frame(base->object, rectf.xmax);
+
+ if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))){
+ for (chan=base->object->action->chanbase.first; chan; chan=chan->next){
+ borderselect_ipo_key(chan->ipo, xmin, xmax, selectmode);
+ /* Check action constraint ipos */
+ for (conchan=chan->constraintChannels.first; conchan; conchan=conchan->next)
+ borderselect_ipo_key(conchan->ipo, xmin, xmax, selectmode);
}
}
+
ymax=ymin;
- } /* End of if armature */
+ } /* End of if action */
/* Skip nlastrips */
- if (base->object->type==OB_ARMATURE){
- for (strip=base->object->nlastrips.first; strip; strip=strip->next){
- ymin=ymax-(NLACHANNELHEIGHT+NLACHANNELSKIP);
- //
- if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))){
- if (!((rectf.xmax<strip->start) || (rectf.xmin>strip->end))){
- if (val==1)
- strip->flag |= ACTSTRIP_SELECT;
- else
- strip->flag &= ~ACTSTRIP_SELECT;
- }
+ for (strip=base->object->nlastrips.first; strip; strip=strip->next){
+ ymin=ymax-(NLACHANNELHEIGHT+NLACHANNELSKIP);
+ //
+ if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))){
+ if (!((rectf.xmax<strip->start) || (rectf.xmin>strip->end))){
+ if (val==1)
+ strip->flag |= ACTSTRIP_SELECT;
+ else
+ strip->flag &= ~ACTSTRIP_SELECT;
}
-
- ymax=ymin;
}
+
+ ymax=ymin;
}
-
- } /* End of object filter */
+ }
}
BIF_undo_push("Border select NLA");
allqueue(REDRAWNLA, 0);
@@ -1253,22 +1210,25 @@ void borderselect_nla(void)
}
}
+/* right hand side of window, does ipokeys, actionkeys or strips */
static void mouse_nla(int selectmode)
{
- short sel;
- float selx;
- short mval[2];
Base *base;
bAction *act;
bActionChannel *chan;
bActionStrip *rstrip;
bConstraintChannel *conchan;
+ float selx;
+ short mval[2];
+ short sel, isdone=0;
getmouseco_areawin (mval);
- /* Try object ipo selection */
+ /* Try object ipo or ob-constraint ipo selection */
base= get_nearest_nlachannel_ob_key(&selx, &sel);
if (base) {
+ isdone= 1;
+
if (selectmode == SELECT_REPLACE){
deselect_nlachannel_keys(0);
selectmode = SELECT_ADD;
@@ -1279,71 +1239,66 @@ static void mouse_nla(int selectmode)
/* Try object constraint selection */
for (conchan=base->object->constraintChannels.first; conchan; conchan=conchan->next)
select_ipo_key(conchan->ipo, selx, selectmode);
-
-
- BIF_undo_push("Select NLA");
- allqueue(REDRAWIPO, 0);
- allqueue(REDRAWVIEW3D, 0);
- allqueue(REDRAWNLA, 0);
- return;
}
-
- /* Try action ipo selection */
- act= get_nearest_nlachannel_ac_key(&selx, &sel);
- if (act) {
- if (selectmode == SELECT_REPLACE){
- deselect_nlachannel_keys(0);
- selectmode = SELECT_ADD;
+ else {
+ /* Try action ipo selection */
+ act= get_nearest_nlachannel_ac_key(&selx, &sel);
+ if (act) {
+ isdone= 1;
+
+ if (selectmode == SELECT_REPLACE){
+ deselect_nlachannel_keys(0);
+ selectmode = SELECT_ADD;
+ }
+
+ for (chan=act->chanbase.first; chan; chan=chan->next) {
+ select_ipo_key(chan->ipo, selx, selectmode);
+ /* Try action constraint selection */
+ for (conchan=chan->constraintChannels.first; conchan; conchan=conchan->next)
+ select_ipo_key(conchan->ipo, selx, selectmode);
+ }
}
-
- for (chan=act->chanbase.first; chan; chan=chan->next) {
- select_ipo_key(chan->ipo, selx, selectmode);
- /* Try action constraint selection */
- for (conchan=chan->constraintChannels.first; conchan; conchan=conchan->next)
- select_ipo_key(conchan->ipo, selx, selectmode);
+ else {
+
+ /* Try nla strip selection */
+ base= get_nearest_nlastrip(&rstrip, &sel);
+ if (base){
+ isdone= 1;
+
+ if (!(G.qual & LR_SHIFTKEY)){
+ deselect_nlachannel_keys(0);
+ sel = 0;
+ }
+
+ if (sel)
+ rstrip->flag &= ~ACTSTRIP_SELECT;
+ else
+ rstrip->flag |= ACTSTRIP_SELECT;
+
+ set_active_strip(base->object, rstrip);
+ }
}
-
- BIF_undo_push("Select NLA");
- allqueue(REDRAWIPO, 0);
- allqueue(REDRAWVIEW3D, 0);
- allqueue(REDRAWNLA, 0);
- return;
}
- /* Try nla strip selection */
- base= get_nearest_nlastrip(&rstrip, &sel);
- if (base){
- if (!(G.qual & LR_SHIFTKEY)){
- deselect_nlachannel_keys(0);
- sel = 0;
- }
+ if(isdone) {
+ std_rmouse_transform(transform_nlachannel_keys);
- if (sel)
- rstrip->flag &= ~ACTSTRIP_SELECT;
- else
- rstrip->flag |= ACTSTRIP_SELECT;
-
- BIF_undo_push("Select NLA");
allqueue(REDRAWIPO, 0);
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWNLA, 0);
- return;
-
}
-
}
-static Base *get_nearest_nlastrip (bActionStrip **rstrip, short *sel)
/* This function is currently more complicated than it seems like it should be.
* However, this will be needed once the nla strip timeline is more complex */
+static Base *get_nearest_nlastrip (bActionStrip **rstrip, short *sel)
{
Base *base, *firstbase=NULL;
- short mval[2];
- short foundsel = 0;
+ bActionStrip *strip, *firststrip=NULL, *foundstrip=NULL;
rctf rectf;
float ymin, ymax;
- bActionStrip *strip, *firststrip=NULL, *foundstrip=NULL;
- bConstraintChannel *conchan=NULL;
+ short mval[2];
+ short foundsel = 0;
getmouseco_areawin (mval);
@@ -1358,48 +1313,42 @@ static Base *get_nearest_nlastrip (bActionStrip **rstrip, short *sel)
ymax+= NLACHANNELHEIGHT/2;
for (base = G.scene->base.first; base; base=base->next){
- if (nla_filter(base, 0)){
+ if (nla_filter(base)) {
+
/* Skip object ipos */
- // if (base->object->ipo)
ymax-=(NLACHANNELHEIGHT+NLACHANNELSKIP);
- /* Skip constraint channels */
- for (conchan=base->object->constraintChannels.first;
- conchan; conchan=conchan->next){
+ /* Skip action ipos */
+ if (base->object->action)
ymax-=(NLACHANNELHEIGHT+NLACHANNELSKIP);
- }
-
- if (base->object->type==OB_ARMATURE){
- /* Skip action ipos */
- if (base->object->action)
- ymax-=(NLACHANNELHEIGHT+NLACHANNELSKIP);
- for (strip=base->object->nlastrips.first; strip; strip=strip->next){
- ymin=ymax-(NLACHANNELHEIGHT+NLACHANNELSKIP);
- /* Do Ytest */
- if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))){
- /* Do XTest */
- if (!((rectf.xmax<strip->start) || (rectf.xmin>strip->end))){
- if (!firstbase){
- firstbase=base;
- firststrip=strip;
- *sel = strip->flag & ACTSTRIP_SELECT;
- }
-
- if (strip->flag & ACTSTRIP_SELECT){
- if (!foundsel){
- foundsel=1;
- foundstrip = strip;
- }
- }
- else if (foundsel && strip != foundstrip){
- *rstrip=strip;
- *sel = 0;
- return base;
+
+ /* the strips */
+ for (strip=base->object->nlastrips.first; strip; strip=strip->next){
+ ymin=ymax-(NLACHANNELHEIGHT+NLACHANNELSKIP);
+ /* Do Ytest */
+ if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))){
+ /* Do XTest */
+ if (!((rectf.xmax<strip->start) || (rectf.xmin>strip->end))){
+ if (!firstbase){
+ firstbase=base;
+ firststrip=strip;
+ *sel = strip->flag & ACTSTRIP_SELECT;
+ }
+
+ if (strip->flag & ACTSTRIP_SELECT){
+ if (!foundsel){
+ foundsel=1;
+ foundstrip = strip;
}
}
+ else if (foundsel && strip != foundstrip){
+ *rstrip=strip;
+ *sel = 0;
+ return base;
+ }
}
- ymax=ymin;
}
+ ymax=ymin;
}
}
}
@@ -1414,7 +1363,7 @@ static Base *get_nearest_nlachannel_ob_key (float *index, short *sel)
Base *firstbase=NULL;
bConstraintChannel *conchan;
int foundsel=0;
- float firstvert=-1, foundx=-1;
+ float firstvertx=-1, foundx=-1;
int i;
short mval[2];
float ymin, ymax;
@@ -1438,9 +1387,11 @@ static Base *get_nearest_nlachannel_ob_key (float *index, short *sel)
*sel=0;
for (base=G.scene->base.first; base; base=base->next){
- /* Handle object ipo selection */
- if (nla_filter(base, 0)){
+ if (nla_filter(base)) {
+
ymin=ymax-(NLACHANNELHEIGHT+NLACHANNELSKIP);
+
+ /* Handle object ipo selection */
if (base->object->ipo){
if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))){
for (icu=base->object->ipo->curve.first; icu; icu=icu->next){
@@ -1448,7 +1399,7 @@ static Base *get_nearest_nlachannel_ob_key (float *index, short *sel)
if (icu->bezt[i].vec[1][0] > rectf.xmin && icu->bezt[i].vec[1][0] <= rectf.xmax ){
if (!firstbase){
firstbase=base;
- firstvert=icu->bezt[i].vec[1][0];
+ firstvertx=icu->bezt[i].vec[1][0];
*sel = icu->bezt[i].f2 & 1;
}
@@ -1468,19 +1419,15 @@ static Base *get_nearest_nlachannel_ob_key (float *index, short *sel)
}
}
}
-
- ymax=ymin;
-
/* Handle object constraint ipos */
for (conchan=base->object->constraintChannels.first; conchan; conchan=conchan->next){
- ymin=ymax-(NLACHANNELHEIGHT+NLACHANNELSKIP);
- if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))){
+ if ( !((ymax < rectf.ymin) || (ymin > rectf.ymax)) && conchan->ipo){
for (icu=conchan->ipo->curve.first; icu; icu=icu->next){
for (i=0; i<icu->totvert; i++){
if (icu->bezt[i].vec[1][0] > rectf.xmin && icu->bezt[i].vec[1][0] <= rectf.xmax ){
if (!firstbase){
firstbase=base;
- firstvert=icu->bezt[i].vec[1][0];
+ firstvertx=icu->bezt[i].vec[1][0];
*sel = icu->bezt[i].f2 & 1;
}
@@ -1499,21 +1446,20 @@ static Base *get_nearest_nlachannel_ob_key (float *index, short *sel)
}
}
}
- ymax=ymin;
}
+ ymax=ymin;
+
/* Skip action ipos */
- if (ACTIVE_ARMATURE(base)){
+ if (base->object->action){
ymax-=(NLACHANNELHEIGHT+NLACHANNELSKIP);
}
/* Skip nlastrips */
- if (base->object->type==OB_ARMATURE){
- ymax-=(NLACHANNELHEIGHT+NLACHANNELSKIP)*BLI_countlist(&base->object->nlastrips);
- }
+ ymax-=(NLACHANNELHEIGHT+NLACHANNELSKIP)*BLI_countlist(&base->object->nlastrips);
}
}
- *index=firstvert;
+ *index=firstvertx;
return firstbase;
}
@@ -1522,14 +1468,14 @@ static bAction *get_nearest_nlachannel_ac_key (float *index, short *sel)
Base *base;
IpoCurve *icu;
bAction *firstact=NULL;
- int foundsel=0;
+ bActionChannel *chan;
+ bConstraintChannel *conchan;
+ rctf rectf;
float firstvert=-1, foundx=-1;
+ float ymin, ymax, xmin, xmax;
int i;
+ int foundsel=0;
short mval[2];
- float ymin, ymax;
- rctf rectf;
- bActionChannel *chan;
- bConstraintChannel *conchan;
*index=0;
@@ -1550,47 +1496,55 @@ static bAction *get_nearest_nlachannel_ac_key (float *index, short *sel)
for (base=G.scene->base.first; base; base=base->next){
/* Handle object ipo selection */
- if (nla_filter(base, 0)){
- /* Skip object ipo */
+ if (nla_filter(base)) {
+
+ /* Skip object ipo and ob-constraint ipo */
ymin=ymax-(NLACHANNELHEIGHT+NLACHANNELSKIP);
ymax=ymin;
/* Handle action ipos */
- if (ACTIVE_ARMATURE(base)){
+ if (base->object->action){
+ bAction *act= base->object->action;
+
+ /* if action is mapped in NLA, it returns a correction */
+ xmin= get_action_frame(base->object, rectf.xmin);
+ xmax= get_action_frame(base->object, rectf.xmax);
+
ymin=ymax-(NLACHANNELHEIGHT+NLACHANNELSKIP);
if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))){
- for (chan=base->object->action->chanbase.first; chan; chan=chan->next){
- for (icu=chan->ipo->curve.first; icu; icu=icu->next){
- for (i=0; i<icu->totvert; i++){
- if (icu->bezt[i].vec[1][0] > rectf.xmin && icu->bezt[i].vec[1][0] <= rectf.xmax ){
- if (!firstact){
- firstact=base->object->action;
- firstvert=icu->bezt[i].vec[1][0];
- *sel = icu->bezt[i].f2 & 1;
- }
-
- if (icu->bezt[i].f2 & 1){
- if (!foundsel){
- foundsel=1;
- foundx = icu->bezt[i].vec[1][0];
+ for (chan=act->chanbase.first; chan; chan=chan->next){
+ if(chan->ipo) {
+ for (icu=chan->ipo->curve.first; icu; icu=icu->next){
+ for (i=0; i<icu->totvert; i++){
+ if (icu->bezt[i].vec[1][0] > xmin && icu->bezt[i].vec[1][0] <= xmax ){
+ if (!firstact){
+ firstact= act;
+ firstvert=icu->bezt[i].vec[1][0];
+ *sel = icu->bezt[i].f2 & 1;
+ }
+
+ if (icu->bezt[i].f2 & 1){
+ if (!foundsel){
+ foundsel=1;
+ foundx = icu->bezt[i].vec[1][0];
+ }
+ }
+ else if (foundsel && icu->bezt[i].vec[1][0] != foundx){
+ *index=icu->bezt[i].vec[1][0];
+ *sel = 0;
+ return act;
}
- }
- else if (foundsel && icu->bezt[i].vec[1][0] != foundx){
- *index=icu->bezt[i].vec[1][0];
- *sel = 0;
- return base->object->action;
}
}
}
}
-
for (conchan=chan->constraintChannels.first; conchan; conchan=conchan->next){
ymin=ymax-(NLACHANNELHEIGHT+NLACHANNELSKIP);
- if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))){
+ if ( !((ymax < rectf.ymin) || (ymin > rectf.ymax)) && conchan->ipo){
for (icu=conchan->ipo->curve.first; icu; icu=icu->next){
for (i=0; i<icu->totvert; i++){
- if (icu->bezt[i].vec[1][0] > rectf.xmin && icu->bezt[i].vec[1][0] <= rectf.xmax ){
+ if (icu->bezt[i].vec[1][0] > xmin && icu->bezt[i].vec[1][0] <= xmax ){
if (!firstact){
firstact=base->object->action;
firstvert=icu->bezt[i].vec[1][0];
@@ -1622,9 +1576,7 @@ static bAction *get_nearest_nlachannel_ac_key (float *index, short *sel)
}
/* Skip nlastrips */
- if (base->object->type==OB_ARMATURE){
- ymax-=(NLACHANNELHEIGHT+NLACHANNELSKIP)*BLI_countlist(&base->object->nlastrips);
- }
+ ymax-=(NLACHANNELHEIGHT+NLACHANNELSKIP)*BLI_countlist(&base->object->nlastrips);
}
}
@@ -1632,73 +1584,10 @@ static bAction *get_nearest_nlachannel_ac_key (float *index, short *sel)
return firstact;
}
-void clever_numbuts_nla(void){
- bActionStrip *strip=NULL;
- int but=0;
-
- /* Determine if an nla strip has been selected */
- //strip = get_active_nlastrip();
- if (!strip)
- return;
-
- add_numbut(but++, LABEL, "Timeline Range:", 1.0, MAXFRAMEF, 0, 0);
- add_numbut(but++, NUM|FLO, "Strip Start:", 1.0, MAXFRAMEF, &strip->start, "First frame in the timeline");
- add_numbut(but++, NUM|FLO, "Strip End:", 1.0, MAXFRAMEF, &strip->end, "Last frame in the timeline");
- add_numbut(but++, LABEL, "Action Range:", 1.0, MAXFRAMEF, 0, 0);
- add_numbut(but++, NUM|FLO, "Action Start:", 1.0, MAXFRAMEF, &strip->actstart, "First frame of the action to map to the playrange");
- add_numbut(but++, NUM|FLO, "Action End:", 1.0, MAXFRAMEF, &strip->actend, "Last frame of the action to map to the playrange");
- add_numbut(but++, LABEL, "Blending:", 1.0, MAXFRAMEF, 0, 0);
- add_numbut(but++, NUM|FLO, "Blend In:", 0.0, MAXFRAMEF, &strip->blendin, "Number of frames of ease-in");
- add_numbut(but++, NUM|FLO, "Blend Out:", 0.0, MAXFRAMEF, &strip->blendout, "Number of frames of ease-out");
- add_numbut(but++, LABEL, "Options:", 1.0, MAXFRAMEF, 0, 0);
- add_numbut(but++, NUM|FLO, "Repeat:", 0.0001, MAXFRAMEF, &strip->repeat, "Number of times the action should repeat");
- add_numbut(but++, NUM|FLO, "Stride:", 0.0001, MAXFRAMEF, &strip->stridelen, "Distance covered by one complete cycle of the action specified in the Action Range");
- {
- /* STUPID HACK BECAUSE NUMBUTS ARE BROKEN WITH MULTIPLE TOGGLES */
- short hold= (strip->flag & ACTSTRIP_HOLDLASTFRAME) ? 1 : 0;
- short frompath=(strip->flag & ACTSTRIP_USESTRIDE) ? 1 : 0;
-
- add_numbut(but++, TOG|SHO, "Use Path", 0, 0, &frompath, "Plays action based on position on path & stride length. Only valid for armatures that are parented to a path");
- add_numbut(but++, TOG|SHO, "Hold", 0, 0, &hold, "Toggles whether or not to continue displaying the last frame past the end of the strip");
- add_numbut(but++, TOG|SHO, "Add", 0, 0, &strip->mode, "Toggles additive blending mode");
-
- do_clever_numbuts("Action", but, REDRAW);
-
- /* STUPID HACK BECAUSE NUMBUTS ARE BROKEN WITH MULTIPLE TOGGLES */
- if (hold) strip->flag |= ACTSTRIP_HOLDLASTFRAME;
- else strip->flag &= ~ACTSTRIP_HOLDLASTFRAME;
-
- if (frompath) strip->flag |= ACTSTRIP_USESTRIDE;
- else strip->flag &= ~ACTSTRIP_USESTRIDE;
-
- }
-
- if (strip->end<strip->start)
- strip->end=strip->start;
-
-
- if (strip->blendin>(strip->end-strip->start))
- strip->blendin = strip->end-strip->start;
-
- if (strip->blendout>(strip->end-strip->start))
- strip->blendout = strip->end-strip->start;
-
- if (strip->blendin > (strip->end-strip->start-strip->blendout))
- strip->blendin = (strip->end-strip->start-strip->blendout);
-
- if (strip->blendout > (strip->end-strip->start-strip->blendin))
- strip->blendout = (strip->end-strip->start-strip->blendin);
-
-
- update_for_newframe_muted();
- allqueue (REDRAWNLA, 0);
- allqueue (REDRAWVIEW3D, 0);
-}
-
-void deselect_nlachannels(int test){
- int sel = 1;
+void deselect_nlachannels(int test)
+{
Base *base;
- bConstraintChannel *conchan;
+ int sel = 1;
if (test){
for (base=G.scene->base.first; base; base=base->next){
@@ -1707,15 +1596,6 @@ void deselect_nlachannels(int test){
sel=0;
break;
}
-
- /* Check constraint flags for previous selection */
- for (conchan=base->object->constraintChannels.first; conchan; conchan=conchan->next){
- if (conchan->flag & CONSTRAINT_CHANNEL_SELECT){
- sel=0;
- base = G.scene->base.last;
- break;
- }
- }
}
}
else
@@ -1724,56 +1604,12 @@ void deselect_nlachannels(int test){
/* Select objects */
for (base=G.scene->base.first; base; base=base->next){
if (sel){
- if (nla_filter(base, 0))
+ if (nla_filter(base))
base->flag |= SELECT;
}
else
base->flag &= ~SELECT;
-
- /* Select constraint channels */
- for (conchan=base->object->constraintChannels.first; conchan; conchan=conchan->next){
- if (sel){
- if (nla_filter(base, 0))
- conchan->flag |= CONSTRAINT_CHANNEL_SELECT;
- }
- else
- conchan->flag &= ~CONSTRAINT_CHANNEL_SELECT;
- }
+
+ base->object->flag= base->flag;
}
}
-
-void delete_nlachannels(void){
- Base *base;
- bConstraintChannel *conchan, *nextchan;
- int sel=0;
-
- /* See if there is anything selected */
- for (base = G.scene->base.first; base && (!sel); base=base->next){
- /* Check constraints */
- for (conchan=base->object->constraintChannels.first; conchan; conchan=conchan->next){
- if (conchan->flag & CONSTRAINT_CHANNEL_SELECT){
- sel = 1;
- break;
- }
- }
- }
-
- if (!sel)
- return;
-
- if (okee ("Delete selected channels")){
- for (base=G.scene->base.first; base; base=base->next){
- for (conchan=base->object->constraintChannels.first; conchan; conchan=nextchan){
- nextchan = conchan->next;
-
- if (conchan->flag & CONSTRAINT_CHANNEL_SELECT){
- if (conchan->ipo)
- conchan->ipo->id.us--;
- BLI_freelinkN(&base->object->constraintChannels, conchan);
- }
- }
- }
- BIF_undo_push("Delete NLA channels");
-
- }
-}
diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c
index f5521bbf8ee..d46c06bd4b9 100644
--- a/source/blender/src/editobject.c
+++ b/source/blender/src/editobject.c
@@ -181,6 +181,7 @@ void add_object_draw(int type) /* for toolbox or menus, only non-editmode stuff
if ELEM3(curarea->spacetype, SPACE_VIEW3D, SPACE_BUTS, SPACE_INFO) {
if (G.obedit) exit_editmode(2); // freedata, and undo
ob= add_object(type);
+ set_active_base(BASACT);
base_init_from_view3d(BASACT, G.vd);
/* only undo pushes on objects without editmode... */
@@ -3541,8 +3542,10 @@ void std_rmouse_transform(void (*xf_func)(int, int))
PIL_sleep_ms(10);
timer++;
if(timer>=10*U.tb_rightmouse) {
- toolbox_n();
- return;
+ if(curarea->spacetype==SPACE_VIEW3D) {
+ toolbox_n();
+ return;
+ }
}
}
}
diff --git a/source/blender/src/editview.c b/source/blender/src/editview.c
index 3bab4124201..7f45e353ecd 100644
--- a/source/blender/src/editview.c
+++ b/source/blender/src/editview.c
@@ -1041,11 +1041,13 @@ void set_active_base(Base *base)
set_active_group();
/* signal to ipo */
- if (base) {
- allqueue(REDRAWIPO, base->object->ipowin);
- allqueue(REDRAWACTION, 0);
- allqueue(REDRAWNLA, 0);
- }
+ allqueue(REDRAWIPO, base->object->ipowin);
+ allqueue(REDRAWACTION, 0);
+ allqueue(REDRAWNLA, 0);
+
+ /* signal to action */
+ select_actionchannel_by_name(base->object->action, "Object", 1);
+
/* disable temporal locks */
for(tbase=FIRSTBASE; tbase; tbase= tbase->next) {
if(base!=tbase && (tbase->object->shapeflag & OB_SHAPE_TEMPLOCK)) {
diff --git a/source/blender/src/glutil.c b/source/blender/src/glutil.c
index a9b42e35b7e..16571fbec95 100644
--- a/source/blender/src/glutil.c
+++ b/source/blender/src/glutil.c
@@ -377,6 +377,28 @@ struct gla2DDrawInfo {
float wo_to_sc[2];
};
+void gla2DGetMap(gla2DDrawInfo *di, rctf *rect)
+{
+ *rect= di->world_rect;
+}
+
+void gla2DSetMap(gla2DDrawInfo *di, rctf *rect)
+{
+ int sc_w, sc_h;
+ float wo_w, wo_h;
+
+ di->world_rect= *rect;
+
+ sc_w= (di->screen_rect.xmax-di->screen_rect.xmin);
+ sc_h= (di->screen_rect.ymax-di->screen_rect.ymin);
+ wo_w= (di->world_rect.xmax-di->world_rect.xmin);
+ wo_h= (di->world_rect.ymax-di->world_rect.ymin);
+
+ di->wo_to_sc[0]= sc_w/wo_w;
+ di->wo_to_sc[1]= sc_h/wo_h;
+}
+
+
gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect)
{
gla2DDrawInfo *di= MEM_mallocN(sizeof(*di), "gla2DDrawInfo");
diff --git a/source/blender/src/header_action.c b/source/blender/src/header_action.c
index 216309ceb94..49f5ee3fd0d 100644
--- a/source/blender/src/header_action.c
+++ b/source/blender/src/header_action.c
@@ -395,7 +395,7 @@ static void do_action_keymenu_transformmenu(void *arg, int event)
transform_meshchannel_keys('g', key);
}
else if (act) {
- transform_actionchannel_keys ('g');
+ transform_actionchannel_keys ('g', 0);
}
break;
case ACTMENU_KEY_TRANSFORM_SCALE:
@@ -403,7 +403,7 @@ static void do_action_keymenu_transformmenu(void *arg, int event)
transform_meshchannel_keys('s', key);
}
else if (act) {
- transform_actionchannel_keys ('s');
+ transform_actionchannel_keys ('s', 0);
}
break;
}
@@ -743,30 +743,24 @@ void action_buttons(void)
uiBlockSetEmboss(block, UI_EMBOSS);
- // object action is allowed to be zero!
- /* (ton) commented out below line, since people can apparently link Action to any object (mesh) and
- not unlink anymore when theres a mesh key. Needs to be rethought this stuff! */
- //if (!get_action_mesh_key()) {
-
- /* NAME ETC */
- ob=OBACT;
- from = (ID*) ob;
+ /* NAME ETC */
+ ob=OBACT;
+ from = (ID*) ob;
- xco= std_libbuttons(block, xco, 0, B_ACTPIN, &G.saction->pin,
- B_ACTIONBROWSE, (ID*)G.saction->action,
- from, &(G.saction->actnr), B_ACTALONE,
- B_ACTLOCAL, B_ACTIONDELETE, 0, 0);
+ xco= std_libbuttons(block, xco, 0, B_ACTPIN, &G.saction->pin,
+ B_ACTIONBROWSE, (ID*)G.saction->action,
+ from, &(G.saction->actnr), B_ACTALONE,
+ B_ACTLOCAL, B_ACTIONDELETE, 0, 0);
- /* Draw action baker */
- xco+= 8;
-
- uiDefBut(block, BUT, B_ACTBAKE,
- "Bake", xco, 0, 64, YIC, 0, 0, 0, 0, 0,
- "Create an action with the constraint effects "
- "converted into Ipo keys");
- xco+=64;
+ /* Draw action baker */
+ xco+= 8;
+
+ uiDefBut(block, BUT, B_ACTBAKE,
+ "Bake", xco, 0, 64, YIC, 0, 0, 0, 0, 0,
+ "Create an action with the constraint effects "
+ "converted into Ipo keys");
+ xco+=64;
- //}
uiClearButLock();
/* draw LOCK */
diff --git a/source/blender/src/header_ipo.c b/source/blender/src/header_ipo.c
index 4d4a7d25e4b..44e9ddf6425 100644
--- a/source/blender/src/header_ipo.c
+++ b/source/blender/src/header_ipo.c
@@ -43,34 +43,47 @@
#include <config.h>
#endif
-#include "DNA_ID.h"
+#include "DNA_action_types.h"
+#include "DNA_camera_types.h"
#include "DNA_curve_types.h"
+#include "DNA_constraint_types.h"
+#include "DNA_ID.h"
+#include "DNA_ipo_types.h"
#include "DNA_key_types.h"
+#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
-#include "DNA_ipo_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
+#include "DNA_texture_types.h"
#include "DNA_space_types.h"
+#include "DNA_sequence_types.h"
+#include "DNA_sound_types.h"
+#include "DNA_world_types.h"
-#include "BIF_interface.h"
-#include "BIF_mainqueue.h"
-#include "BIF_resources.h"
-#include "BIF_screen.h"
-#include "BIF_space.h"
-
+#include "BKE_action.h"
+#include "BKE_constraint.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_texture.h"
#include "BKE_utildefines.h"
+
#include "BLI_blenlib.h"
+
#include "BSE_drawipo.h"
#include "BSE_editipo_types.h"
#include "BSE_edit.h"
#include "BSE_editipo.h"
#include "BSE_headerbuttons.h"
+#include "BIF_editaction.h"
+#include "BIF_interface.h"
+#include "BIF_mainqueue.h"
+#include "BIF_resources.h"
+#include "BIF_screen.h"
+#include "BIF_space.h"
+
#include "nla.h"
#include "blendef.h"
@@ -79,6 +92,154 @@
static int viewmovetemp = 0;
extern int totipo_edit, totipo_sel;
+/* headerbutton call, assuming full context is set */
+/* it aligns with editipo.c, verify_ipo */
+void spaceipo_assign_ipo(SpaceIpo *si, Ipo *ipo)
+{
+ if(si->from==NULL || si->from->lib) return;
+
+ if(ipo) ipo->id.us++;
+
+ /* first check action ipos */
+ if(si->actname && si->actname[0]) {
+ Object *ob= (Object *)si->from;
+ bActionChannel *achan;
+
+ if(ob->action) {
+ achan= get_action_channel(ob->action, si->actname);
+
+ if(achan) {
+ /* constraint exception */
+ if(si->blocktype==ID_CO) {
+ bConstraintChannel *conchan= get_constraint_channel(&achan->constraintChannels, si->constname);
+ if(conchan) {
+ if(conchan->ipo)
+ conchan->ipo->id.us--;
+ conchan->ipo= ipo;
+ }
+ }
+ else {
+ if(achan->ipo)
+ achan->ipo->id.us--;
+ achan->ipo= ipo;
+ }
+ }
+ }
+ }
+ else {
+ switch(GS(si->from->name)) {
+ case ID_OB:
+ {
+ Object *ob= (Object *)si->from;
+ /* constraint exception */
+ if(si->blocktype==ID_CO) {
+ bConstraintChannel *conchan= get_constraint_channel(&ob->constraintChannels, si->constname);
+ if(conchan) {
+ if(conchan->ipo)
+ conchan->ipo->id.us--;
+ conchan->ipo= ipo;
+ }
+ }
+ else if(si->blocktype==ID_OB) {
+ if(ob->ipo)
+ ob->ipo->id.us--;
+ ob->ipo= ipo;
+ }
+ }
+ break;
+ case ID_MA:
+ {
+ Material *ma= (Material *)si->from;
+
+ if(ma->ipo)
+ ma->ipo->id.us--;
+ ma->ipo= ipo;
+ }
+ break;
+ case ID_TE:
+ {
+ Tex *tex= (Tex *)si->from;
+
+ if(tex->ipo)
+ tex->ipo->id.us--;
+ tex->ipo= ipo;
+ }
+ break;
+ case ID_SEQ:
+ {
+ Sequence *seq= (Sequence *)si->from; /* note, sequence is mimicing Id */
+
+ if((seq->type & SEQ_EFFECT)||(seq->type == SEQ_SOUND)) {
+ if(seq->ipo)
+ seq->ipo->id.us--;
+ seq->ipo= ipo;
+ }
+ }
+ break;
+ case ID_CU:
+ {
+ Curve *cu= (Curve *)si->from;
+
+ if(cu->ipo)
+ cu->ipo->id.us--;
+ cu->ipo= ipo;
+ }
+ break;
+ case ID_KE:
+ {
+ Key *key= (Key *)si->from;
+
+ if(key->ipo)
+ key->ipo->id.us--;
+ key->ipo= ipo;
+ }
+ break;
+ case ID_WO:
+ {
+ World *wo= (World *)si->from;
+
+ if(wo->ipo)
+ wo->ipo->id.us--;
+ wo->ipo= ipo;
+ }
+ break;
+ case ID_LA:
+ {
+ Lamp *la= (Lamp *)si->from;
+
+ if(la->ipo)
+ la->ipo->id.us--;
+ la->ipo= ipo;
+ }
+ break;
+ case ID_CA:
+ {
+ Camera *ca= (Camera *)si->from;
+
+ if(ca->ipo)
+ ca->ipo->id.us--;
+ ca->ipo= ipo;
+ }
+ break;
+ case ID_SO:
+ {
+ bSound *snd= (bSound *)si->from;
+
+ if(snd->ipo)
+ snd->ipo->id.us--;
+ snd->ipo= ipo;
+ }
+ }
+ }
+
+ allqueue(REDRAWVIEW3D, 0);
+ allqueue(REDRAWIPO, 0);
+ allqueue(REDRAWACTION, 0);
+ allqueue(REDRAWNLA, 0);
+ allqueue(REDRAWBUTSALL, 0);
+
+}
+
static void do_ipo_editmenu_transformmenu(void *arg, int event)
{
@@ -203,7 +364,7 @@ static uiBlock *ipo_editmenu_keymenu(void *arg_unused)
block= uiNewBlock(&curarea->uiblocks, "ipo_editmenu_keymenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
uiBlockSetButmFunc(block, do_ipo_editmenu_keymenu, NULL);
- ei = get_editipo();
+ ei = get_active_editipo();
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Linear", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Cardinal", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
@@ -475,10 +636,10 @@ static void do_ipo_viewmenu(void *arg, int event)
case 5:
mainqenter(PADMINUS,1);
break;
- case 6: /* Play Back Animation */
+ case 6: /* Play Animation */
play_anim(0);
break;
- case 7: /* Play Back Animation in All */
+ case 7: /* Play Animation in All */
play_anim(1);
break;
case 8:
@@ -493,7 +654,7 @@ static uiBlock *ipo_viewmenu(void *arg_unused)
EditIpo *ei;
short yco= 0, menuwidth=120;
- ei = get_editipo();
+ ei = get_active_editipo();
block= uiNewBlock(&curarea->uiblocks, "ipo_viewmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
uiBlockSetButmFunc(block, do_ipo_viewmenu, NULL);
@@ -512,9 +673,9 @@ static uiBlock *ipo_viewmenu(void *arg_unused)
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
- uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Back Animation|Alt A", 0, yco-=20,
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Animation|Alt A", 0, yco-=20,
menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
- uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Back Animation in 3D View|Alt Shift A", 0, yco-=20,
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Animation in 3D View|Alt Shift A", 0, yco-=20,
menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
@@ -582,6 +743,7 @@ static uiBlock *ipo_selectmenu(void *arg_unused)
static char *ipo_modeselect_pup(void)
{
+ Object *ob= OBACT;
static char string[1024];
char tmpstr[1024];
char formatstring[1024];
@@ -590,12 +752,12 @@ static char *ipo_modeselect_pup(void)
strcpy(formatstring, "|%s %%x%d %%i%d");
- if(OBACT) {
+ if(ob) {
sprintf(tmpstr,formatstring,"Object",ID_OB, ICON_OBJECT);
strcat(string,tmpstr);
}
- if(OBACT && give_current_material(OBACT, OBACT->actcol)) { // check for material
+ if(ob && give_current_material(ob, ob->actcol)) { // check for material
sprintf(tmpstr,formatstring,"Material",ID_MA, ICON_MATERIAL);
strcat(string,tmpstr);
}
@@ -605,37 +767,37 @@ static char *ipo_modeselect_pup(void)
strcat(string,tmpstr);
}
- if(OBACT && OBACT->type==OB_CURVE) {
+ if(ob && ob->type==OB_CURVE) {
sprintf(tmpstr,formatstring,"Path",ID_CU, ICON_CURVE);
strcat(string,tmpstr);
}
- if(OBACT && OBACT->type==OB_CAMERA) {
+ if(ob && ob->type==OB_CAMERA) {
sprintf(tmpstr,formatstring,"Camera",ID_CA, ICON_CAMERA);
strcat(string,tmpstr);
}
- if(OBACT && OBACT->type==OB_LAMP) {
+ if(ob && ob->type==OB_LAMP) {
sprintf(tmpstr,formatstring,"Lamp",ID_LA, ICON_LAMP);
strcat(string,tmpstr);
}
- if(OBACT && give_current_texture(OBACT, OBACT->actcol)) {
+ if(ob && give_current_texture(ob, ob->actcol)) {
sprintf(tmpstr,formatstring,"Texture",ID_TE, ICON_TEXTURE);
strcat(string,tmpstr);
}
- if(OBACT){
- if ELEM4(OBACT->type, OB_MESH, OB_CURVE, OB_SURF, OB_LATTICE) {
+ if(ob){
+ if ELEM4(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_LATTICE) {
sprintf(tmpstr,formatstring,"Shape",ID_KE, ICON_EDIT);
strcat(string,tmpstr);
}
- if (OBACT->action){
- sprintf(tmpstr,formatstring,"Action",ID_AC, ICON_ACTION);
+ if (ob->type==OB_ARMATURE){
+ sprintf(tmpstr,formatstring,"Pose",ID_PO, ICON_POSE_HLT);
strcat(string,tmpstr);
}
#ifdef __CON_IPO
- sprintf(tmpstr,formatstring,"Constraint",IPO_CO, ICON_CONSTRAINT);
+ sprintf(tmpstr,formatstring,"Constraint",ID_CO, ICON_CONSTRAINT);
strcat(string,tmpstr);
#endif
}
@@ -652,6 +814,7 @@ void do_ipo_buttons(short event)
EditIpo *ei;
View2D *v2d;
rcti rect;
+ Object *ob= OBACT;
float xmin, ymin, dx, dy;
int a, val, first;
short mval[2];
@@ -744,10 +907,9 @@ void do_ipo_buttons(short event)
set_exprap_ipo(IPO_CYCLX);
break;
case B_IPOMAIN:
- make_editipo();
scrarea_queue_winredraw(curarea);
scrarea_queue_headredraw(curarea);
-
+ if(ob) ob->ipowin= G.sipo->blocktype;
break;
case B_IPOSHOWKEY:
/* reverse value because of winqread */
@@ -762,7 +924,53 @@ void do_ipo_buttons(short event)
view2dzoom(event);
scrarea_queue_headredraw(curarea);
break;
-
+ case B_IPO_ACTION_OB:
+ if(ob && G.sipo->from && G.sipo->pin==0) {
+ if(ob->ipoflag & OB_ACTION_OB) { /* check if channel exists, and flip ipo link */
+ bActionChannel *achan;
+
+ if(ob->action==NULL)
+ ob->action= add_empty_action(ID_OB);
+ achan= verify_action_channel(ob->action, "Object");
+ if(achan->ipo==NULL && ob->ipo) {
+ achan->ipo= ob->ipo;
+ ob->ipo= NULL;
+ }
+
+ /* object constraints */
+ if(ob->constraintChannels.first) {
+ free_constraint_channels(&achan->constraintChannels);
+ achan->constraintChannels= ob->constraintChannels;
+ ob->constraintChannels.first= ob->constraintChannels.last= NULL;
+ }
+ }
+ else if(ob->action) {
+ bActionChannel *achan= get_action_channel(ob->action, "Object");
+ if(achan) {
+
+ if(achan->ipo && ob->ipo==NULL) {
+ ob->ipo= achan->ipo;
+ achan->ipo= NULL;
+ }
+
+ /* object constraints */
+ if(achan->constraintChannels.first) {
+ free_constraint_channels(&ob->constraintChannels);
+ ob->constraintChannels= achan->constraintChannels;
+ achan->constraintChannels.first= achan->constraintChannels.last= NULL;
+ }
+ }
+ }
+ allqueue(REDRAWVIEW3D, 0);
+ allqueue(REDRAWIPO, 0);
+ allqueue(REDRAWACTION, 0);
+ allqueue(REDRAWOOPS, 0);
+ allqueue(REDRAWNLA, 0);
+ }
+ break;
+ case B_IPO_ACTION_KEY:
+
+ break;
}
}
@@ -770,7 +978,6 @@ void ipo_buttons(void)
{
Object *ob;
EditIpo *ei;
- ID *id, *from;
uiBlock *block;
short xco,xmax;
char naam[20];
@@ -807,7 +1014,7 @@ void ipo_buttons(void)
if((curarea->flag & HEADER_NO_PULLDOWN)==0) {
uiBlockSetEmboss(block, UI_EMBOSSP);
- ei = get_editipo();
+ ei = get_active_editipo();
xmax= GetButStringLength("View");
uiDefPulldownBut(block,ipo_viewmenu, NULL, "View", xco, -2, xmax-3, 24, "");
@@ -836,10 +1043,45 @@ void ipo_buttons(void)
/* end of pull down menus */
uiBlockSetEmboss(block, UI_EMBOSS);
- /* mainmenu, only when data is there and no pin */
+ ob= OBACT;
+
+ /* action switch option, only when active object is there and no pin */
uiSetButLock(G.sipo->pin, "Can't change because of pinned data");
- ob= OBACT;
+ /* define whether ipos are on Object or on action */
+ if(ob) {
+ static short fake1= 1;
+
+ uiBlockBeginAlign(block);
+
+ if(G.sipo->blocktype==ID_OB) {
+ uiDefIconButBitS(block, TOG, OB_ACTION_OB, B_IPO_ACTION_OB, ICON_ACTION, xco,0,XIC,YIC, &(ob->ipoflag), 0, 0, 0, 0, "Sets Ipo to be included in an Action or not");
+ xco+= XIC;
+ }
+ else if(G.sipo->blocktype==ID_KE) {
+ uiDefIconButBitS(block, TOG, OB_ACTION_KEY, B_IPO_ACTION_KEY, ICON_ACTION, xco,0,XIC,YIC, &(ob->ipoflag), 0, 0, 0, 0, "Sets Ipo to be included in an Action or not");
+ xco+= XIC;
+ }
+ else if(G.sipo->blocktype==ID_CO) {
+
+ if(G.sipo->from && G.sipo->actname[0]==0)
+ uiDefIconButBitS(block, TOG, OB_ACTION_OB, B_IPO_ACTION_OB, ICON_ACTION, xco,0,XIC,YIC, &(ob->ipoflag), 0, 0, 0, 0, "Sets Ipo to be included in an Action or not");
+ else {
+ uiSetButLock(1, "Pose Constraint Ipo cannot be switched");
+ uiDefIconButS(block, TOG, 1, ICON_ACTION, xco,0,XIC,YIC, &fake1, 0, 0, 0, 0, "Ipo is connected to Pose Action");
+ }
+ xco+= XIC;
+ }
+ else if(G.sipo->blocktype==ID_PO) { /* only to indicate we have action ipos */
+ uiSetButLock(1, "Pose Action Ipo cannot be switched");
+ uiDefIconButS(block, TOG, 1, ICON_ACTION, xco,0,XIC,YIC, &fake1, 0, 0, 0, 0, "Ipo is connected to Pose Action");
+ xco+= XIC;
+ }
+ uiClearButLock();
+ }
+
+ /* mainmenu, only when data is there and no pin */
+ uiSetButLock(G.sipo->pin, "Can't change because of pinned data");
if (G.sipo->blocktype == ID_OB)
icon = ICON_OBJECT;
@@ -855,9 +1097,9 @@ void ipo_buttons(void)
icon = ICON_LAMP;
else if (G.sipo->blocktype == ID_KE)
icon = ICON_EDIT;
- else if (G.sipo->blocktype == ID_AC)
- icon = ICON_ACTION;
- else if (G.sipo->blocktype == IPO_CO)
+ else if (G.sipo->blocktype == ID_PO)
+ icon = ICON_POSE_HLT;
+ else if (G.sipo->blocktype == ID_CO)
icon = ICON_CONSTRAINT;
else if (G.sipo->blocktype == ID_SEQ)
icon = ICON_SEQUENCE;
@@ -882,25 +1124,22 @@ void ipo_buttons(void)
xco-= 4;
}
+ uiBlockEndAlign(block);
+
uiClearButLock();
- /* NAME ETC */
- id= (ID *)get_ipo_to_edit(&from);
-
- xco= std_libbuttons(block, (short)(xco+1.5*XIC), 0, B_IPOPIN, &G.sipo->pin, B_IPOBROWSE, (ID*)G.sipo->ipo, from, &(G.sipo->menunr), B_IPOALONE, B_IPOLOCAL, B_IPODELETE, 0, B_KEEPDATA);
-
- uiSetButLock(id && id->lib, "Can't edit library data");
+ xco= std_libbuttons(block, (short)(xco+1.5*XIC), 0, B_IPOPIN, &G.sipo->pin, B_IPOBROWSE, (ID*)G.sipo->ipo, G.sipo->from, &(G.sipo->menunr), B_IPOALONE, B_IPOLOCAL, B_IPODELETE, 0, B_KEEPDATA);
/* COPY PASTE */
xco-= XIC/2;
if(curarea->headertype==HEADERTOP) {
uiDefIconBut(block, BUT, B_IPOCOPY, ICON_COPYUP, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Copies the selected curves to the buffer");
- uiSetButLock(id && id->lib, "Can't edit library data");
+ uiSetButLock(G.sipo->ipo && G.sipo->ipo->id.lib, "Can't edit library data");
uiDefIconBut(block, BUT, B_IPOPASTE, ICON_PASTEUP, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Pastes the curves from the buffer");
}
else {
uiDefIconBut(block, BUT, B_IPOCOPY, ICON_COPYDOWN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Copies the selected curves to the buffer");
- uiSetButLock(id && id->lib, "Can't edit library data");
+ uiSetButLock(G.sipo->ipo && G.sipo->ipo->id.lib, "Can't edit library data");
uiDefIconBut(block, BUT, B_IPOPASTE, ICON_PASTEDOWN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Pastes the curves from the buffer");
}
xco+=XIC/2;
diff --git a/source/blender/src/header_nla.c b/source/blender/src/header_nla.c
index a255247c221..d0139b82992 100644
--- a/source/blender/src/header_nla.c
+++ b/source/blender/src/header_nla.c
@@ -207,11 +207,11 @@ static void do_nla_strip_transformmenu(void *arg, int event)
{
switch(event) {
case 0: /* grab/move */
- transform_nlachannel_keys ('g');
+ transform_nlachannel_keys ('g', 0);
update_for_newframe_muted();
break;
case 1: /* scale */
- transform_nlachannel_keys ('s');
+ transform_nlachannel_keys ('s', 0);
update_for_newframe_muted();
break;
}
diff --git a/source/blender/src/headerbuttons.c b/source/blender/src/headerbuttons.c
index b8555f9df43..f51830a56e5 100644
--- a/source/blender/src/headerbuttons.c
+++ b/source/blender/src/headerbuttons.c
@@ -634,14 +634,12 @@ void do_global_buttons(unsigned short event)
Ipo *ipo;
Lamp *la;
World *wrld;
- Sequence *seq;
bAction *act;
- ID *id, *idtest, *from;
+ ID *id, *idtest, *from=NULL;
ScrArea *sa;
int nr= 1;
char buf[FILE_MAXDIR+FILE_MAXFILE];
-
ob= OBACT;
id= NULL; /* id at null for texbrowse */
@@ -966,7 +964,7 @@ void do_global_buttons(unsigned short event)
if (act)
idtest= (ID *)copy_action(act);
else
- idtest=(ID *)add_empty_action();
+ idtest=(ID *)add_empty_action(ob->type==OB_ARMATURE?ID_PO:ID_OB);
idtest->us--;
}
@@ -992,9 +990,10 @@ void do_global_buttons(unsigned short event)
break;
case B_IPOBROWSE:
- ipo= get_ipo_to_edit(&from);
+ ipo= G.sipo->ipo;
+ from= G.sipo->from;
id= (ID *)ipo;
- if(from==0) return;
+ if(from==NULL) return;
if(G.sipo->menunr== -2) {
activate_databrowse((ID *)G.sipo->ipo, ID_IP, GS(from->name), B_IPOBROWSE, &G.sipo->menunr, do_global_buttons);
@@ -1026,13 +1025,10 @@ void do_global_buttons(unsigned short event)
if(idtest==0) {
if(ipo) idtest= (ID *)copy_ipo(ipo);
else {
- nr= GS(from->name);
- if(nr==ID_OB){
- if (G.sipo->blocktype==IPO_CO)
- idtest= (ID *)add_ipo("CoIpo", IPO_CO); /* constraint channel is no ID data... */
- else
- idtest= (ID *)add_ipo("ObIpo", nr);
- }
+ nr= G.sipo->blocktype;
+ if(nr==ID_OB) idtest= (ID *)add_ipo("ObIpo", ID_OB);
+ else if(nr==ID_CO) idtest= (ID *)add_ipo("CoIpo", ID_CO);
+ else if(nr==ID_PO) idtest= (ID *)add_ipo("ActIpo", nr);
else if(nr==ID_MA) idtest= (ID *)add_ipo("MatIpo", nr);
else if(nr==ID_TE) idtest= (ID *)add_ipo("TexIpo", nr);
else if(nr==ID_SEQ) idtest= (ID *)add_ipo("MatSeq", nr);
@@ -1042,136 +1038,26 @@ void do_global_buttons(unsigned short event)
else if(nr==ID_LA) idtest= (ID *)add_ipo("LaIpo", nr);
else if(nr==ID_CA) idtest= (ID *)add_ipo("CaIpo", nr);
else if(nr==ID_SO) idtest= (ID *)add_ipo("SndIpo", nr);
- else if(nr==ID_AC) idtest= (ID *)add_ipo("ActIpo", nr);
else error("Warn bugtracker!");
}
idtest->us--;
}
if(idtest!=id && from) {
- ipo= (Ipo *)idtest;
-
- if (ipo->blocktype==IPO_CO){
- bConstraintChannel *chan= get_active_constraint_channel((Object*)from);
- if(chan) {
- chan->ipo = ipo;
- id_us_plus(idtest);
- allqueue(REDRAWVIEW3D, 0);
- allqueue(REDRAWACTION, 0);
- allqueue(REDRAWNLA, 0);
- }
- }
- else if(ipo->blocktype==ID_OB) {
- ( (Object *)from)->ipo= ipo;
- id_us_plus(idtest);
- allqueue(REDRAWVIEW3D, 0);
- }
- else if(ipo->blocktype==ID_AC) {
- bActionChannel *chan;
- chan = get_hilighted_action_channel ((bAction*)from);
- if (!chan){
- error ("Create an action channel first");
- return;
- }
- chan->ipo=ipo;
- id_us_plus(idtest);
- allqueue(REDRAWNLA, 0);
- allqueue(REDRAWACTION, 0);
- }
- else if(ipo->blocktype==ID_MA) {
- ( (Material *)from)->ipo= ipo;
- id_us_plus(idtest);
- allqueue(REDRAWBUTSSHADING, 0);
- }
- else if(ipo->blocktype==ID_TE) {
- ( (Tex *)from)->ipo= ipo;
- id_us_plus(idtest);
- allqueue(REDRAWBUTSSHADING, 0);
- }
- else if(ipo->blocktype==ID_SEQ) {
- seq= (Sequence *)from;
- if((seq->type & SEQ_EFFECT)||(seq->type == SEQ_SOUND)) {
- id_us_plus(idtest);
- seq->ipo= ipo;
- }
- }
- else if(ipo->blocktype==ID_CU) {
- ( (Curve *)from)->ipo= ipo;
- id_us_plus(idtest);
- allqueue(REDRAWVIEW3D, 0);
- }
- else if(ipo->blocktype==ID_KE) {
- ( (Key *)from)->ipo= ipo;
-
- id_us_plus(idtest);
- allqueue(REDRAWVIEW3D, 0);
-
- }
- else if(ipo->blocktype==ID_WO) {
- ( (World *)from)->ipo= ipo;
- id_us_plus(idtest);
- allqueue(REDRAWBUTSSHADING, 0);
- }
- else if(ipo->blocktype==ID_LA) {
- ( (Lamp *)from)->ipo= ipo;
- id_us_plus(idtest);
- allqueue(REDRAWBUTSSHADING, 0);
- }
- else if(ipo->blocktype==ID_CA) {
- ( (Camera *)from)->ipo= ipo;
- id_us_plus(idtest);
- allqueue(REDRAWBUTSEDIT, 0);
- }
- else if(ipo->blocktype==ID_SO) {
- ( (bSound *)from)->ipo= ipo;
- id_us_plus(idtest);
- allqueue(REDRAWBUTSEDIT, 0);
- }
- else
- printf("error in browse ipo \n");
-
- if(id) id->us--;
-
+ spaceipo_assign_ipo(G.sipo, (Ipo *)idtest);
+
BIF_undo_push("Browse Ipo");
- scrarea_queue_winredraw(curarea);
- scrarea_queue_headredraw(curarea);
- allqueue(REDRAWIPO, 0);
}
}
break;
case B_IPODELETE:
- ipo= get_ipo_to_edit(&from);
- if(from==0) return;
+ ipo= G.sipo->ipo;
+ from= G.sipo->from;
- ipo->id.us--;
-
- if(ipo->blocktype==ID_OB) ( (Object *)from)->ipo= NULL;
- else if(ipo->blocktype==ID_MA) ( (Material *)from)->ipo= NULL;
- else if(ipo->blocktype==ID_TE) ( (Tex *)from)->ipo= NULL;
- else if(ipo->blocktype==ID_SEQ) ( (Sequence *)from)->ipo= NULL;
- else if(ipo->blocktype==ID_CU) ( (Curve *)from)->ipo= NULL;
- else if(ipo->blocktype==ID_KE) ( (Key *)from)->ipo= NULL;
- else if(ipo->blocktype==ID_WO) ( (World *)from)->ipo= NULL;
- else if(ipo->blocktype==ID_LA) ( (Lamp *)from)->ipo= NULL;
- else if(ipo->blocktype==ID_WO) ( (World *)from)->ipo= NULL;
- else if(ipo->blocktype==ID_CA) ( (Camera *)from)->ipo= NULL;
- else if(ipo->blocktype==ID_SO) ( (bSound *)from)->ipo= NULL;
- else if(ipo->blocktype==ID_AC) {
- bAction *act = (bAction*) from;
- bActionChannel *chan =
- get_hilighted_action_channel((bAction*)from);
- BLI_freelinkN (&act->chanbase, chan);
- }
- else if(ipo->blocktype==IPO_CO) {
- bConstraintChannel *chan= get_active_constraint_channel((Object*)from);
- if(chan) chan->ipo= NULL;
- }
- else error("Warn bugtracker!");
+ spaceipo_assign_ipo(G.sipo, NULL);
editipo_changed(G.sipo, 1); /* doredraw */
+
BIF_undo_push("Unlink Ipo");
- allqueue(REDRAWIPO, 0);
- allqueue(REDRAWNLA, 0);
- allqueue (REDRAWACTION, 0);
break;
case B_WORLDBROWSE:
@@ -1616,6 +1502,8 @@ void do_global_buttons(unsigned short event)
scrarea_queue_headredraw(curarea);
allqueue(REDRAWINFO, 1);
allqueue(REDRAWOOPS, 1);
+ allqueue(REDRAWACTION, 1);
+ allqueue(REDRAWNLA, 1);
/* name scene also in set PUPmenu */
allqueue(REDRAWBUTSALL, 0);
allqueue(REDRAWHEADERS, 0);
@@ -1973,9 +1861,10 @@ void do_global_buttons2(short event)
break;
case B_IPOALONE:
- ipo= get_ipo_to_edit(&idfrom);
+ ipo= G.sipo->ipo;
+ idfrom= G.sipo->from;
- if(idfrom && idfrom->lib==0) {
+ if(idfrom && idfrom->lib==NULL) {
if(ipo->id.us>1) {
if(okee("Single user")) {
if(ipo->blocktype==ID_OB) ((Object *)idfrom)->ipo= copy_ipo(ipo);
@@ -1990,7 +1879,7 @@ void do_global_buttons2(short event)
else if(ipo->blocktype==ID_SO) ((bSound *)idfrom)->ipo= copy_ipo(ipo);
else if(ipo->blocktype==ID_AC)
get_hilighted_action_channel((bAction *)idfrom)->ipo= copy_ipo(ipo);
- else if(ipo->blocktype==IPO_CO)
+ else if(ipo->blocktype==ID_CO)
get_active_constraint_channel((Object*)idfrom)->ipo= copy_ipo(ipo);
else error("Warn bugtracker!");
@@ -2001,7 +1890,8 @@ void do_global_buttons2(short event)
}
break;
case B_IPOLOCAL:
- ipo= get_ipo_to_edit(&idfrom);
+ ipo= G.sipo->ipo;
+ idfrom= G.sipo->from;
if(idfrom && idfrom->lib==0) {
if(ipo->id.lib) {
diff --git a/source/blender/src/poseobject.c b/source/blender/src/poseobject.c
index 8481f569e70..827882c5204 100644
--- a/source/blender/src/poseobject.c
+++ b/source/blender/src/poseobject.c
@@ -70,6 +70,7 @@
#include "BDR_editobject.h"
#include "BSE_edit.h"
+#include "BSE_editipo.h"
#include "mydevice.h"
#include "blendef.h"
@@ -493,7 +494,6 @@ void paste_posebuf (int flip)
Object *ob= OBACT;
bPoseChannel *chan, *pchan;
float eul[4];
- int newchan = 0;
char name[32];
if (!ob || !ob->pose)
@@ -533,22 +533,23 @@ void paste_posebuf (int flip)
}
if (G.flags & G_RECORDKEYS){
+ ID *id= &ob->id;
/* Set keys on pose */
if (chan->flag & POSE_ROT){
- set_action_key(ob->action, pchan, AC_QUAT_X, newchan);
- set_action_key(ob->action, pchan, AC_QUAT_Y, newchan);
- set_action_key(ob->action, pchan, AC_QUAT_Z, newchan);
- set_action_key(ob->action, pchan, AC_QUAT_W, newchan);
+ insertkey(id, ID_AC, chan->name, NULL, AC_QUAT_X);
+ insertkey(id, ID_AC, chan->name, NULL, AC_QUAT_Y);
+ insertkey(id, ID_AC, chan->name, NULL, AC_QUAT_Z);
+ insertkey(id, ID_AC, chan->name, NULL, AC_QUAT_W);
}
if (chan->flag & POSE_SIZE){
- set_action_key(ob->action, pchan, AC_SIZE_X, newchan);
- set_action_key(ob->action, pchan, AC_SIZE_Y, newchan);
- set_action_key(ob->action, pchan, AC_SIZE_Z, newchan);
+ insertkey(id, ID_AC, chan->name, NULL, AC_SIZE_X);
+ insertkey(id, ID_AC, chan->name, NULL, AC_SIZE_Y);
+ insertkey(id, ID_AC, chan->name, NULL, AC_SIZE_Z);
}
if (chan->flag & POSE_LOC){
- set_action_key(ob->action, pchan, AC_LOC_X, newchan);
- set_action_key(ob->action, pchan, AC_LOC_Y, newchan);
- set_action_key(ob->action, pchan, AC_LOC_Z, newchan);
+ insertkey(id, ID_AC, pchan->name, NULL, AC_LOC_X);
+ insertkey(id, ID_AC, pchan->name, NULL, AC_LOC_Y);
+ insertkey(id, ID_AC, pchan->name, NULL, AC_LOC_Z);
}
}
}
diff --git a/source/blender/src/resources.c b/source/blender/src/resources.c
index b9c47d99775..84e9359e7b9 100644
--- a/source/blender/src/resources.c
+++ b/source/blender/src/resources.c
@@ -812,7 +812,11 @@ char *BIF_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
cp= ts->bone_solid; break;
case TH_BONE_POSE:
cp= ts->bone_pose; break;
-
+ case TH_STRIP:
+ cp= ts->strip; break;
+ case TH_STRIP_SELECT:
+ cp= ts->strip_select; break;
+
case TH_SYNTAX_B:
cp= ts->syntaxb; break;
case TH_SYNTAX_V:
@@ -962,6 +966,8 @@ void BIF_InitTheme(void)
SETCOL(btheme->tnla.shade1, 172, 172, 172, 255); // sliders
SETCOL(btheme->tnla.shade2, 84, 44, 31, 100); // bar
SETCOL(btheme->tnla.hilite, 17, 27, 60, 100); // bar
+ SETCOL(btheme->tnla.strip_select, 0xff, 0xff, 0xaa, 255);
+ SETCOL(btheme->tnla.strip, 0xe4, 0x9c, 0xc6, 255);
/* space seq */
btheme->tseq= btheme->tv3d;
@@ -1088,6 +1094,8 @@ char *BIF_ThemeColorsPup(int spacetype)
sprintf(str, "View Sliders %%x%d|", TH_SHADE1); strcat(cp, str);
sprintf(str, "Bars %%x%d|", TH_SHADE2); strcat(cp, str);
sprintf(str, "Bars selected %%x%d|", TH_HILITE); strcat(cp, str);
+ sprintf(str, "Strips %%x%d|", TH_STRIP); strcat(cp, str);
+ sprintf(str, "Strips selected %%x%d|", TH_STRIP_SELECT); strcat(cp, str);
}
else if(spacetype==SPACE_ACTION) {
//sprintf(str, "Panel %%x%d|", TH_PANEL); strcat(cp, str);
diff --git a/source/blender/src/space.c b/source/blender/src/space.c
index cab768e8b0f..550327c1fbd 100644
--- a/source/blender/src/space.c
+++ b/source/blender/src/space.c
@@ -2521,7 +2521,7 @@ void drawinfospace(ScrArea *sa, void *spacedata)
uiDefButBitI(block, TOGN, USER_TRACKBALL, B_DRAWINFO, "Turntable",
(xpos+edgsp+mpref+(2*spref)+(3*midsp)+(mpref/2)),y3,(mpref/2),buth,
&(U.flag), 0, 0, 0, 0,
- "Allow the view to tumble freely when orbiting with the Middle Mouse Button");
+ "Use fixed up axis for orbiting with Middle Mouse Button");
uiBlockSetCol(block, TH_AUTO); /* end color */
uiDefButBitI(block, TOG, USER_AUTOPERSP, B_DRAWINFO, "Auto Perspective",
(xpos+edgsp+mpref+(2*spref)+(3*midsp)),y2,(mpref/2),buth,
@@ -4639,7 +4639,7 @@ void allqueue(unsigned short event, short val)
scrarea_queue_headredraw(sa);
if(val) {
si= sa->spacedata.first;
- if (si->pin==0)
+ if (si->pin==0)
si->blocktype= val;
}
}
diff --git a/source/blender/src/transform_conversions.c b/source/blender/src/transform_conversions.c
index fbbea6a76fd..bb6543267ab 100755
--- a/source/blender/src/transform_conversions.c
+++ b/source/blender/src/transform_conversions.c
@@ -1627,24 +1627,24 @@ void special_aftertrans_update(TransInfo *t)
pose= ob->pose;
if (!act)
- act= ob->action= add_empty_action();
+ act= ob->action= add_empty_action(ID_PO);
set_pose_keys(ob); // sets chan->flag to POSE_KEY if bone selected
for (pchan=pose->chanbase.first; pchan; pchan=pchan->next){
if (pchan->flag & POSE_KEY){
- set_action_key(act, pchan, AC_QUAT_X, 1);
- set_action_key(act, pchan, AC_QUAT_Y, 1);
- set_action_key(act, pchan, AC_QUAT_Z, 1);
- set_action_key(act, pchan, AC_QUAT_W, 1);
-
- set_action_key(act, pchan, AC_SIZE_X, 1);
- set_action_key(act, pchan, AC_SIZE_Y, 1);
- set_action_key(act, pchan, AC_SIZE_Z, 1);
-
- set_action_key(act, pchan, AC_LOC_X, 1);
- set_action_key(act, pchan, AC_LOC_Y, 1);
- set_action_key(act, pchan, AC_LOC_Z, 1);
+ insertkey(&act->id, ID_AC, pchan->name, NULL, AC_SIZE_X);
+ insertkey(&act->id, ID_AC, pchan->name, NULL, AC_SIZE_Y);
+ insertkey(&act->id, ID_AC, pchan->name, NULL, AC_SIZE_Z);
+
+ insertkey(&act->id, ID_AC, pchan->name, NULL, AC_QUAT_W);
+ insertkey(&act->id, ID_AC, pchan->name, NULL, AC_QUAT_X);
+ insertkey(&act->id, ID_AC, pchan->name, NULL, AC_QUAT_Y);
+ insertkey(&act->id, ID_AC, pchan->name, NULL, AC_QUAT_Z);
+
+ insertkey(&act->id, ID_AC, pchan->name, NULL, AC_LOC_X);
+ insertkey(&act->id, ID_AC, pchan->name, NULL, AC_LOC_Y);
+ insertkey(&act->id, ID_AC, pchan->name, NULL, AC_LOC_Z);
}
}
@@ -1679,18 +1679,18 @@ void special_aftertrans_update(TransInfo *t)
/* Set autokey if necessary */
if ((G.flags & G_RECORDKEYS) && (!cancelled) && (base->flag & SELECT)){
+ /* note, here we have to do context still */
+ insertkey(&base->object->id, ID_OB, NULL, NULL, OB_ROT_X);
+ insertkey(&base->object->id, ID_OB, NULL, NULL, OB_ROT_Y);
+ insertkey(&base->object->id, ID_OB, NULL, NULL, OB_ROT_Z);
- insertkey(&base->object->id, OB_ROT_X);
- insertkey(&base->object->id, OB_ROT_Y);
- insertkey(&base->object->id, OB_ROT_Z);
-
- insertkey(&base->object->id, OB_LOC_X);
- insertkey(&base->object->id, OB_LOC_Y);
- insertkey(&base->object->id, OB_LOC_Z);
+ insertkey(&base->object->id, ID_OB, NULL, NULL, OB_LOC_X);
+ insertkey(&base->object->id, ID_OB, NULL, NULL, OB_LOC_Y);
+ insertkey(&base->object->id, ID_OB, NULL, NULL, OB_LOC_Z);
- insertkey(&base->object->id, OB_SIZE_X);
- insertkey(&base->object->id, OB_SIZE_Y);
- insertkey(&base->object->id, OB_SIZE_Z);
+ insertkey(&base->object->id, ID_OB, NULL, NULL, OB_SIZE_X);
+ insertkey(&base->object->id, ID_OB, NULL, NULL, OB_SIZE_Y);
+ insertkey(&base->object->id, ID_OB, NULL, NULL, OB_SIZE_Z);
remake_object_ipos (ob);
allqueue(REDRAWIPO, 0);
diff --git a/source/blender/src/usiblender.c b/source/blender/src/usiblender.c
index af0e1bd79a0..f60737aa200 100644
--- a/source/blender/src/usiblender.c
+++ b/source/blender/src/usiblender.c
@@ -238,6 +238,17 @@ static void init_userdef_file(void)
}
}
}
+ if (G.main->versionfile <= 238) {
+ bTheme *btheme;
+ /* bone colors */
+ for(btheme= U.themes.first; btheme; btheme= btheme->next) {
+ /* check for alpha==0 is safe, then color was never set */
+ if(btheme->tnla.strip[3]==0) {
+ SETCOL(btheme->tnla.strip_select, 0xff, 0xff, 0xaa, 255);
+ SETCOL(btheme->tnla.strip, 0xe4, 0x9c, 0xc6, 255);
+ }
+ }
+ }
if (U.undosteps==0) U.undosteps=32;