113
111
pchan->flag |= POSE_SIZE;
115
113
/* store current transforms */
116
// TODO: store axis-angle too?
117
VECCOPY(pfl->oldloc, pchan->loc);
118
VECCOPY(pfl->oldrot, pchan->eul);
119
VECCOPY(pfl->oldscale, pchan->size);
120
QUATCOPY(pfl->oldquat, pchan->quat);
114
copy_v3_v3(pfl->oldloc, pchan->loc);
115
copy_v3_v3(pfl->oldrot, pchan->eul);
116
copy_v3_v3(pfl->oldscale, pchan->size);
117
copy_qt_qt(pfl->oldquat, pchan->quat);
118
copy_v3_v3(pfl->oldaxis, pchan->rotAxis);
119
pfl->oldangle = pchan->rotAngle;
121
/* make copy of custom properties */
122
if (pchan->prop && (transFlags & ACT_TRANS_PROP))
123
pfl->oldprops = IDP_CopyProperty(pchan->prop);
125
128
/* get sets of F-Curves providing transforms for the bones in the Pose */
126
// TODO: separate the inner workings out to another helper func, since we need option of whether to take selected or visible bones...
127
129
void poseAnim_mapping_get (bContext *C, ListBase *pfLinks, Object *ob, bAction *act)
129
131
/* for each Pose-Channel which gets affected, get the F-Curves for that channel
186
205
bPoseChannel *pchan= pfl->pchan;
188
207
/* just copy all the values over regardless of whether they changed or not */
189
// TODO; include axis-angle here too?
190
VECCOPY(pchan->loc, pfl->oldloc);
191
VECCOPY(pchan->eul, pfl->oldrot);
192
VECCOPY(pchan->size, pfl->oldscale);
193
QUATCOPY(pchan->quat, pfl->oldquat);
208
copy_v3_v3(pchan->loc, pfl->oldloc);
209
copy_v3_v3(pchan->eul, pfl->oldrot);
210
copy_v3_v3(pchan->size, pfl->oldscale);
211
copy_qt_qt(pchan->quat, pfl->oldquat);
212
copy_v3_v3(pchan->rotAxis, pfl->oldaxis);
213
pchan->rotAngle = pfl->oldangle;
215
/* just overwrite values of properties from the stored copies (there should be some) */
217
IDP_SyncGroupValues(pfl->pchan->prop, pfl->oldprops);
197
221
/* perform autokeyframing after changes were made + confirmed */
198
222
void poseAnim_mapping_autoKeyframe (bContext *C, Scene *scene, Object *ob, ListBase *pfLinks, float cframe)
200
static short keyingsets_need_init = 1;
201
static KeyingSet *ks_loc = NULL;
202
static KeyingSet *ks_rot = NULL;
203
static KeyingSet *ks_scale = NULL;
205
/* get keyingsets the first time this is run?
206
* NOTE: it should be safe to store these static, since they're currently builtin ones
207
* but maybe later this may change, in which case this code needs to be revised!
209
if (keyingsets_need_init) {
210
ks_loc= ANIM_builtin_keyingset_get_named(NULL, "Location");
211
ks_rot= ANIM_builtin_keyingset_get_named(NULL, "Rotation");
212
ks_scale= ANIM_builtin_keyingset_get_named(NULL, "Scaling");
214
keyingsets_need_init = 0;
217
224
/* insert keyframes as necessary if autokeyframing */
218
225
if (autokeyframe_cfra_can_key(scene, &ob->id)) {
226
KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID);
227
ListBase dsources = {NULL, NULL};
219
228
tPChanFCurveLink *pfl;
221
/* iterate over each pose-channel affected, applying the changes */
230
/* iterate over each pose-channel affected, tagging bones to be keyed */
231
/* XXX: here we already have the information about what transforms exist, though
232
* it might be easier to just overwrite all using normal mechanisms
222
234
for (pfl= pfLinks->first; pfl; pfl= pfl->next) {
223
ListBase dsources = {NULL, NULL};
224
235
bPoseChannel *pchan= pfl->pchan;
226
/* add datasource override for the PoseChannel so KeyingSet will do right thing */
237
/* add datasource override for the PoseChannel, to be used later */
227
238
ANIM_relative_keyingset_add_source(&dsources, &ob->id, &RNA_PoseBone, pchan);
230
* - these keyingsets here use dsources, since we need to specify exactly which keyframes get affected
232
if (pchan->flag & POSE_LOC)
233
ANIM_apply_keyingset(C, &dsources, NULL, ks_loc, MODIFYKEY_MODE_INSERT, cframe);
234
if (pchan->flag & POSE_ROT)
235
ANIM_apply_keyingset(C, &dsources, NULL, ks_rot, MODIFYKEY_MODE_INSERT, cframe);
236
if (pchan->flag & POSE_SIZE)
237
ANIM_apply_keyingset(C, &dsources, NULL, ks_scale, MODIFYKEY_MODE_INSERT, cframe);
239
/* free the temp info */
240
BLI_freelistN(&dsources);
240
/* clear any unkeyed tags */
242
pchan->bone->flag &= ~BONE_UNKEYED;
245
/* insert keyframes for all relevant bones in one go */
246
ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cframe);
247
BLI_freelistN(&dsources);
250
* - only do this if keyframes should have been added
251
* - do not calculate unless there are paths already to update...
253
if (C && (ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS)) {
254
//ED_pose_clear_paths(C, ob); // XXX for now, don't need to clear
255
ED_pose_recalculate_paths(scene, ob);