IpoWindow, Action curve update.

When no Ipo existed yet for an Action Channel (Bone), you could not add
curves with CTRL+click or Drivers. This was due to antique action code
state... it's still messy, no time for big cleanup here yet. At least
this works now. :)

(Also: removed test prints of previous commit)
This commit is contained in:
Ton Roosendaal 2005-10-03 13:03:25 +00:00
parent 1c72a19fd8
commit 45edb9cecb
6 changed files with 60 additions and 16 deletions

@ -96,6 +96,8 @@ struct bAction *add_empty_action(void);
void winqreadactionspace(struct ScrArea *sa, void *spacedata, struct BWinEvent *evt);
struct bAction *bake_action_with_client (struct bAction *act, struct Object *arm, float tolerance);
void verify_active_action_channel(struct Object *ob);
void remake_action_ipos(struct bAction *act);

@ -692,7 +692,6 @@ static void initparts(void)
pa->x+= 2;
pa->y+= 2;
}
printf("part %d %d\n", pa->x, pa->y);
BLI_addtail(&R.parts, pa);
}
else MEM_freeN(pa);
@ -720,7 +719,6 @@ static void addparttorect(Part *pa)
int y, heigth, len, copylen;
/* calc the right offset in rects, zbuffer cannot exist... */
printf("add part %d %d\n", pa->x, pa->y);
if(pa->rect==NULL) return;
rtp= pa->rect;

@ -1375,7 +1375,7 @@ static void editing_panel_modifiers(Object *ob)
uiDefBlockBut(block, modifiers_add_menu, ob, "Add Modifier", 0, 190, 130, 20, "Add a new modifier");
sprintf(str, "To: %s", ob->id.name+2);
uiDefBut(block, LABEL, 1, str, 140, 190, 140, 20, NULL, 0.0, 0.0, 0, 0, "Object whose modifier stack is being edited");
uiDefBut(block, LABEL, 1, str, 140, 190, 150, 20, NULL, 0.0, 0.0, 0, 0, "Object whose modifier stack is being edited");
xco = 0;
yco = 160;

@ -1685,7 +1685,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, 0);
ei->icu= get_ipocurve(G.sipo->from, G.sipo->blocktype, ei->adrcode, NULL);
ei->flag |= IPO_SELECT;
ei->icu->flag= ei->flag;
}

@ -766,6 +766,41 @@ 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;

@ -338,10 +338,13 @@ static void set_active_editipo(EditIpo *actei)
EditIpo *get_active_editipo(void)
{
EditIpo *ei= G.sipo->editipo;
EditIpo *ei;
int a;
for(a=0; a<G.sipo->totipo; a++, ei++)
if(G.sipo==NULL)
return NULL;
for(a=0, ei=G.sipo->editipo; a<G.sipo->totipo; a++, ei++)
if(ei->flag & IPO_ACTIVE)
return ei;
@ -635,16 +638,14 @@ Ipo *get_ipo_to_edit(ID **from)
}
else if(G.sipo->blocktype==ID_AC) {
bActionChannel *chan;
if (ob && ob->action){
if (ob && ob->action) {
*from= (ID *) ob->action;
chan= get_hilighted_action_channel(ob->action);
if (chan)
return chan->ipo;
else{
*from = NULL;
else
return NULL;
}
}
}
}
else if(G.sipo->blocktype==ID_WO) {
@ -1909,12 +1910,22 @@ Ipo *get_ipo(ID *from, short type, int make)
}
else if( type==ID_AC) {
act= (bAction *)from;
if (!act->achan) return NULL;
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;
ipo= act->achan->ipo;
/* This should never happen */
if(make && ipo==NULL) ipo= act->achan->ipo= add_ipo("AcIpo", ID_AC);
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;
@ -1998,13 +2009,11 @@ IpoCurve *get_ipocurve(ID *from, short type, int adrcode, Ipo *useipo)
/* 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;