Another painful editing issue solved!

Adding Ipos on a Constraint just was working totally insane. Here's how
it works now in the constraint Panel:

- Button "Show" will make the IpoWindow show the Constraint Ipo
 (it didn't before, when IpoWindow was not set to correct mode)

- Button "Key" will insert a key point on current frame (and show it in
  IpoWindow)

Note that both options will create an Action too, if not existed yet.
So, without opening an IpoWindow you can already animate Constraints.
(Todo: use the auto key option to always insert on changing slider)

And; selecting a Bone will update the Constraint IpoWindow too. Note
however, that when theres multiple Constraint Ipos on a Bone, it only
shows the first... will solve that later.
This commit is contained in:
Ton Roosendaal 2005-08-22 21:58:55 +00:00
parent 931d0fc235
commit 50315dc100
3 changed files with 77 additions and 18 deletions

@ -140,23 +140,13 @@ float prlen=0.0;
/* ********************* CONSTRAINT ***************************** */
#if 0
static void add_influence_key_to_constraint_func (void *arg1v, void *unused)
{
bConstraint *con = arg1v;
add_influence_key_to_constraint(con);
}
#endif
static void activate_constraint_ipo_func (void *arg1v, void *unused)
{
Object *ob= OBACT;
bConstraint *con = arg1v;
bConstraintChannel *chan;
ListBase *conbase;
get_constraint_client(NULL, NULL, NULL);
conbase = get_constraint_client_channels(1);
if (!conbase)
@ -177,12 +167,61 @@ static void activate_constraint_ipo_func (void *arg1v, void *unused)
}
/* Make this the active channel */
OBACT->activecon = chan;
allqueue(REDRAWIPO, 0);
ob->activecon = chan;
/* make sure ipowin shows it */
ob->ipowin= IPO_CO;
allqueue(REDRAWIPO, IPO_CO);
allqueue(REDRAWNLA, 0);
}
static void add_influence_key_to_constraint_func (void *arg1v, void *unused)
{
Object *ob= OBACT;
bConstraint *con = arg1v;
bConstraintChannel *chan;
ListBase *conbase;
IpoCurve *icu;
conbase = get_constraint_client_channels(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 = add_new_constraint_channel(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);
insert_vert_ipo(icu, CFRA, con->enforce);
/* Make this the active channel */
ob->activecon = chan;
/* make sure ipowin shows it */
ob->ipowin= IPO_CO;
allqueue(REDRAWIPO, IPO_CO);
allspace(REMAKEIPO, 0);
allqueue(REDRAWNLA, 0);
BIF_undo_push("Insert Influence Key");
}
static void del_constraint_func (void *arg1v, void *arg2v)
{
bConstraint *con= arg1v;
@ -760,14 +799,16 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
}
if (con->type!=CONSTRAINT_TYPE_NULL) {
uiDefButF(block, NUMSLI, B_CONSTRAINT_REDRAW, "Influence ", *xco+17, *yco, 197, 19, &(con->enforce), 0.0, 1.0, 0.0, 0.0, "Amount of influence this constraint will have on the final solution");
but = uiDefBut(block, BUT, B_CONSTRAINT_REDRAW, "Edit", *xco+215, *yco, 41, 19, 0, 0.0, 1.0, 0.0, 0.0, "Show this constraint's ipo in the object's Ipo window");
uiBlockBeginAlign(block);
uiDefButF(block, NUMSLI, B_CONSTRAINT_REDRAW, "Influence ", *xco, *yco, 197, 20, &(con->enforce), 0.0, 1.0, 0.0, 0.0, "Amount of influence this constraint will have on the final solution");
but = uiDefBut(block, BUT, B_CONSTRAINT_REDRAW, "Show", *xco+200, *yco, 45, 20, 0, 0.0, 1.0, 0.0, 0.0, "Show this constraint's ipo in the object's Ipo window");
/* If this is on an object, add the constraint to the object */
uiButSetFunc (but, activate_constraint_ipo_func, con, NULL);
/* If this is on a bone, add the constraint to the action (if any) */
//but = uiDefBut(block, BUT, B_CONSTRAINT_REDRAW, "Key", *xco+227, *yco, 41, 20, 0, 0.0, 1.0, 0.0, 0.0, "Add an influence keyframe to the constraint");
but = uiDefBut(block, BUT, B_CONSTRAINT_REDRAW, "Key", *xco+245, *yco, 40, 20, 0, 0.0, 1.0, 0.0, 0.0, "Add an influence keyframe to the constraint");
/* Add a keyframe to the influence IPO */
//uiButSetFunc (but, add_influence_key_to_constraint_func, con, NULL);
uiButSetFunc (but, add_influence_key_to_constraint_func, con, NULL);
uiBlockEndAlign(block);
(*yco)-=24;
} else {
(*yco)-=3;

@ -1847,6 +1847,23 @@ int do_pose_selectbuffer(Base *base, unsigned int *buffer, short hits)
select_actionchannel_by_name(ob->action, nearBone->name, 1);
}
}
/* signal update to ipo window */
if(ob->ipowin==IPO_CO) {
bConstraintChannel *chan;
ListBase *conbase;
conbase = get_constraint_client_channels(0);
if (conbase) {
for(chan= conbase->first; chan; chan= chan->next) {
if(chan->ipo)
break;
}
/* Make this the active channel */
ob->activecon = chan;
}
else ob->activecon = NULL;
}
/* in weightpaint we select the associated vertex group too */
if(G.f & G_WEIGHTPAINT) {

@ -129,6 +129,7 @@ ListBase *get_constraint_client_channels (int forcevalid)
return &achan->constraintChannels;
}
else return NULL;
}
/* else we return object constraints */
return &ob->constraintChannels;