Bugfix #21234: Autokey "insert only available" userpref inserts keys for all bones in an armature
-- Bugfix: When autokey is enabled, notifiers to refresh the animation editors *after* transforms finished for objects were missing. While I understand the need to limit these to not doing this during transform, after transform, this lead to lag/inconsistent UI problems. -- * Added 'Damped Track' Option to 'Make Track' Operator * Improved the code of the 'Clear Track' operator to include other types of tracking constraint too
This commit is contained in:
@@ -873,16 +873,18 @@ static int object_track_clear_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
|
||||
bConstraint *con, *pcon;
|
||||
|
||||
/* remove track-object for old track */
|
||||
ob->track= NULL;
|
||||
ob->recalc |= OB_RECALC;
|
||||
|
||||
/* also remove all Track To constraints
|
||||
* TODO:
|
||||
* - do we only want to do the last instance (use 1 as last arg instead)
|
||||
* - also, what about other forms of tracking?
|
||||
*/
|
||||
remove_constraints_type(&ob->constraints, CONSTRAINT_TYPE_TRACKTO, 0);
|
||||
/* also remove all tracking constraints */
|
||||
for (con= ob->constraints.last; con; con= pcon) {
|
||||
pcon= con->prev;
|
||||
if (ELEM3(con->type, CONSTRAINT_TYPE_TRACKTO, CONSTRAINT_TYPE_LOCKTRACK, CONSTRAINT_TYPE_DAMPTRACK))
|
||||
remove_constraint(&ob->constraints, con);
|
||||
}
|
||||
|
||||
if(type == 1)
|
||||
ED_object_apply_obmat(ob);
|
||||
@@ -918,9 +920,10 @@ void OBJECT_OT_track_clear(wmOperatorType *ot)
|
||||
/************************** Make Track Operator *****************************/
|
||||
|
||||
static EnumPropertyItem prop_make_track_types[] = {
|
||||
{1, "TRACKTO", 0, "TrackTo Constraint", ""},
|
||||
{2, "LOCKTRACK", 0, "LockTrack Constraint", ""},
|
||||
{3, "OLDTRACK", 0, "Old Track", ""},
|
||||
{1, "DAMPTRACK", 0, "Damped Track Constraint", ""},
|
||||
{2, "TRACKTO", 0, "Track To Constraint", ""},
|
||||
{3, "LOCKTRACK", 0, "Lock Track Constraint", ""},
|
||||
{4, "OLDTRACK", 0, "Old Track", ""},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -932,6 +935,25 @@ static int track_set_exec(bContext *C, wmOperator *op)
|
||||
int type= RNA_enum_get(op->ptr, "type");
|
||||
|
||||
if(type == 1) {
|
||||
bConstraint *con;
|
||||
bDampTrackConstraint *data;
|
||||
|
||||
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
|
||||
if(ob!=obact) {
|
||||
con = add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_DAMPTRACK);
|
||||
|
||||
data = con->data;
|
||||
data->tar = obact;
|
||||
ob->recalc |= OB_RECALC;
|
||||
|
||||
/* Lamp and Camera track differently by default */
|
||||
if (ob->type == OB_LAMP || ob->type == OB_CAMERA)
|
||||
data->trackflag = TRACK_nZ;
|
||||
}
|
||||
}
|
||||
CTX_DATA_END;
|
||||
}
|
||||
else if(type == 2) {
|
||||
bConstraint *con;
|
||||
bTrackToConstraint *data;
|
||||
|
||||
@@ -952,7 +974,7 @@ static int track_set_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
CTX_DATA_END;
|
||||
}
|
||||
else if(type == 2) {
|
||||
else if(type == 3) {
|
||||
bConstraint *con;
|
||||
bLockTrackConstraint *data;
|
||||
|
||||
|
||||
@@ -307,8 +307,10 @@ static void viewRedrawForce(const bContext *C, TransInfo *t)
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
|
||||
|
||||
/* for realtime animation record - send notifiers recognised by animation editors */
|
||||
// XXX: is this notifier a lame duck?
|
||||
if ((t->animtimer) && IS_AUTOKEY_ON(t->scene))
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, NULL);
|
||||
|
||||
}
|
||||
else if (t->spacetype == SPACE_ACTION) {
|
||||
//SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
|
||||
@@ -342,6 +344,12 @@ static void viewRedrawPost(TransInfo *t)
|
||||
{
|
||||
ED_area_headerprint(t->sa, NULL);
|
||||
|
||||
if(t->spacetype == SPACE_VIEW3D) {
|
||||
/* if autokeying is enabled, send notifiers that keyframes were added */
|
||||
if (IS_AUTOKEY_ON(t->scene))
|
||||
WM_main_add_notifier(NC_ANIMATION|ND_KEYFRAME_EDIT, NULL);
|
||||
}
|
||||
|
||||
#if 0 // TRANSFORM_FIX_ME
|
||||
if(t->spacetype==SPACE_VIEW3D) {
|
||||
allqueue(REDRAWBUTSOBJECT, 0);
|
||||
|
||||
@@ -4607,8 +4607,20 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o
|
||||
/* only insert into available channels? */
|
||||
else if (IS_AUTOKEY_FLAG(INSERTAVAIL)) {
|
||||
if (act) {
|
||||
for (fcu= act->curves.first; fcu; fcu= fcu->next)
|
||||
insert_keyframe(id, act, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
|
||||
for (fcu= act->curves.first; fcu; fcu= fcu->next) {
|
||||
/* only insert keyframes for this F-Curve if it affects the current bone */
|
||||
if (strstr(fcu->rna_path, "bones")) {
|
||||
char *pchanName= BLI_getQuotedStr(fcu->rna_path, "bones[");
|
||||
|
||||
/* only if bone name matches too...
|
||||
* NOTE: this will do constraints too, but those are ok to do here too?
|
||||
*/
|
||||
if (pchanName && strcmp(pchanName, pchan->name) == 0)
|
||||
insert_keyframe(id, act, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
|
||||
|
||||
if (pchanName) MEM_freeN(pchanName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* only insert keyframe if needed? */
|
||||
|
||||
@@ -955,6 +955,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
|
||||
t->animtimer= CTX_wm_screen(C)->animtimer;
|
||||
|
||||
/* turn manipulator off during transform */
|
||||
// FIXME: but don't do this when USING the manipulator...
|
||||
if (t->flag & T_MODAL) {
|
||||
t->twtype = v3d->twtype;
|
||||
v3d->twtype = 0;
|
||||
|
||||
Reference in New Issue
Block a user