184
183
fcu = MEM_callocN(sizeof(FCurve), "FCurve");
186
185
fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED);
187
if (act->curves.first == NULL)
186
if (BLI_listbase_is_empty(&act->curves))
188
187
fcu->flag |= FCURVE_ACTIVE; /* first one added active */
190
189
/* store path - make copy, and store that */
232
static void update_autoflags_fcurve_direct(FCurve *fcu, PropertyRNA *prop)
234
/* set additional flags for the F-Curve (i.e. only integer values) */
235
fcu->flag &= ~(FCURVE_INT_VALUES | FCURVE_DISCRETE_VALUES);
236
switch (RNA_property_type(prop)) {
241
/* do integer (only 'whole' numbers) interpolation between all points */
242
fcu->flag |= FCURVE_INT_VALUES;
245
/* do 'discrete' (i.e. enum, boolean values which cannot take any intermediate
246
* values at all) interpolation between all points
247
* - however, we must also ensure that evaluated values are only integers still
249
fcu->flag |= (FCURVE_DISCRETE_VALUES | FCURVE_INT_VALUES);
254
/* Update integer/discrete flags of the FCurve (used when creating/inserting keyframes,
255
* but also through RNA when editing an ID prop, see T37103).
257
void update_autoflags_fcurve(FCurve *fcu, bContext *C, ReportList *reports, PointerRNA *ptr)
261
int old_flag = fcu->flag;
263
if ((ptr->id.data == NULL) && (ptr->data == NULL)) {
264
BKE_report(reports, RPT_ERROR, "No RNA pointer available to retrieve values for this fcurve");
268
/* try to get property we should be affecting */
269
if (RNA_path_resolve_property(ptr, fcu->rna_path, &tmp_ptr, &prop) == false) {
270
/* property not found... */
271
const char *idname = (ptr->id.data) ? ((ID *)ptr->id.data)->name : TIP_("<No ID pointer>");
273
BKE_reportf(reports, RPT_ERROR,
274
"Could not update flags for this fcurve, as RNA path is invalid for the given ID "
275
"(ID = %s, path = %s)",
276
idname, fcu->rna_path);
280
update_autoflags_fcurve_direct(fcu, prop);
282
if (old_flag != fcu->flag) {
283
/* Same as if keyframes had been changed */
284
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
232
288
/* ************************************************** */
233
289
/* KEYFRAME INSERTION */
722
778
rotmode = ob->rotmode;
724
780
else if (ptr->type == &RNA_PoseBone) {
725
Object *ob = (Object *)ptr->id.data; /* we assume that this is always set, and is an object */
726
781
bPoseChannel *pchan = (bPoseChannel *)ptr->data;
728
/* Although it is not strictly required for this particular space conversion,
729
* arg1 must not be null, as there is a null check for the other conversions to
730
* be safe. Therefore, the active object is passed here, and in many cases, this
731
* will be what owns the pose-channel that is getting this anyway.
733
copy_m4_m4(tmat, pchan->pose_mat);
734
BKE_constraint_mat_convertspace(ob, pchan, tmat, CONSTRAINT_SPACE_POSE, CONSTRAINT_SPACE_LOCAL);
783
BKE_armature_mat_pose_to_bone(pchan, pchan->pose_mat, tmat);
735
784
rotmode = pchan->rotmode;
737
786
/* Loc code is specific... */
838
/* set additional flags for the F-Curve (i.e. only integer values) */
839
fcu->flag &= ~(FCURVE_INT_VALUES | FCURVE_DISCRETE_VALUES);
840
switch (RNA_property_type(prop)) {
845
/* do integer (only 'whole' numbers) interpolation between all points */
846
fcu->flag |= FCURVE_INT_VALUES;
849
/* do 'discrete' (i.e. enum, boolean values which cannot take any intermediate
850
* values at all) interpolation between all points
851
* - however, we must also ensure that evaluated values are only integers still
853
fcu->flag |= (FCURVE_DISCRETE_VALUES | FCURVE_INT_VALUES);
887
update_autoflags_fcurve_direct(fcu, prop);
857
889
/* obtain value to give keyframe */
858
890
if ( (flag & INSERTKEY_MATRIX) &&
1101
1133
if (BKE_fcurve_is_protected(fcu)) {
1102
1134
BKE_reportf(reports, RPT_WARNING,
1103
"not deleting keyframe for locked F-Curve '%s' for %s '%s'",
1135
"Not deleting keyframe for locked F-Curve '%s' for %s '%s'",
1104
1136
fcu->rna_path, BKE_idcode_to_name(GS(id->name)), id->name + 2);
1218
1250
ScrArea *sa = CTX_wm_area(C);
1219
1251
Scene *scene = CTX_data_scene(C);
1220
SpaceOops *so = CTX_wm_space_outliner(C);
1222
1253
/* if no area or active scene */
1223
1254
if (ELEM(NULL, sa, scene))
1226
/* if Outliner, don't allow in some views */
1228
if (ELEM5(so->outlinevis, SO_GROUPS, SO_LIBRARIES, SO_SEQUENCE, SO_USERDEF, SO_KEYMAP)) {
1233
/* TODO: checks for other space types can be added here */
1235
1257
/* should be fine */
1477
1499
static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op))
1501
bool changed = false;
1479
1503
CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
1481
1505
/* just those in active action... */
1515
1539
/* delete F-Curve completely */
1516
1540
if (can_delete) {
1517
1541
ANIM_fcurve_delete_from_animdata(NULL, adt, fcu);
1542
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
1523
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
1551
return OPERATOR_CANCELLED;
1527
1554
/* send updates */
1528
1555
WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL);
1571
1598
if (BKE_fcurve_is_protected(fcu)) {
1572
1599
BKE_reportf(op->reports, RPT_WARNING,
1573
"not deleting keyframe for locked F-Curve '%s', object '%s'",
1600
"Not deleting keyframe for locked F-Curve '%s', object '%s'",
1574
1601
fcu->rna_path, id->name + 2);
1623
1650
float cfra = (float)CFRA;
1624
1651
short success = 0;
1625
int a, index, length, all = RNA_boolean_get(op->ptr, "all");
1652
int a, index, length;
1653
const bool all = RNA_boolean_get(op->ptr, "all");
1626
1654
short flag = 0;
1628
1656
/* flags for inserting keyframes */
1714
1742
float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
1715
1743
short success = 0;
1716
int a, index, length, all = RNA_boolean_get(op->ptr, "all");
1744
int a, index, length;
1745
const bool all = RNA_boolean_get(op->ptr, "all");
1718
1747
/* try to insert keyframe using property retrieved from UI */
1719
1748
uiContextActiveProperty(C, &ptr, &prop, &index);
1782
1811
PropertyRNA *prop = NULL;
1784
1813
short success = 0;
1785
int a, index, length, all = RNA_boolean_get(op->ptr, "all");
1814
int a, index, length;
1815
const bool all = RNA_boolean_get(op->ptr, "all");
1787
1817
/* try to insert keyframe using property retrieved from UI */
1788
1818
uiContextActiveProperty(C, &ptr, &prop, &index);
1871
1901
/* --------------- API/Per-Datablock Handling ------------------- */
1873
1903
/* Checks if some F-Curve has a keyframe for a given frame */
1874
short fcurve_frame_has_keyframe(FCurve *fcu, float frame, short filter)
1904
bool fcurve_frame_has_keyframe(FCurve *fcu, float frame, short filter)
1876
1906
/* quick sanity check */
1877
1907
if (ELEM(NULL, fcu, fcu->bezt))
1941
1971
/* try shapekey keyframes (if available, and allowed by filter) */
1942
if (!(filter & ANIMFILTER_KEYS_LOCAL) && !(filter & ANIMFILTER_KEYS_NOSKEY) ) {
1972
if (!(filter & ANIMFILTER_KEYS_LOCAL) && !(filter & ANIMFILTER_KEYS_NOSKEY)) {
1943
1973
Key *key = BKE_key_from_object(ob);
1945
1975
/* shapekeys can have keyframes ('Relative Shape Keys')
1957
1987
/* try materials */
1958
if (!(filter & ANIMFILTER_KEYS_LOCAL) && !(filter & ANIMFILTER_KEYS_NOMAT) ) {
1988
if (!(filter & ANIMFILTER_KEYS_LOCAL) && !(filter & ANIMFILTER_KEYS_NOMAT)) {
1959
1989
/* if only active, then we can skip a lot of looping */
1960
1990
if (filter & ANIMFILTER_KEYS_ACTIVE) {
1961
1991
Material *ma = give_current_material(ob, (ob->actcol + 1));