Merge remote-tracking branch 'origin/blender-v2.91-release'

This commit is contained in:
Sybren A. Stüvel
2020-11-10 14:02:28 +01:00

View File

@@ -841,11 +841,23 @@ bool BKE_fcurve_calc_range(
*/
void BKE_fcurve_active_keyframe_set(FCurve *fcu, const BezTriple *active_bezt)
{
if (active_bezt == NULL) {
fcu->active_keyframe_index = FCURVE_ACTIVE_KEYFRAME_NONE;
return;
}
/* Gracefully handle out-of-bounds pointers. Ideally this would do a BLI_assert() as well, but
* then the unit tests would break in debug mode. */
ptrdiff_t offset = active_bezt - fcu->bezt;
if (offset < 0 || offset >= fcu->totvert) {
fcu->active_keyframe_index = FCURVE_ACTIVE_KEYFRAME_NONE;
return;
}
/* The active keyframe should always be selected. */
BLI_assert((active_bezt == NULL) ||
((active_bezt->f1 | active_bezt->f2 | active_bezt->f3) & SELECT));
fcu->active_keyframe_index = (active_bezt == NULL) ? FCURVE_ACTIVE_KEYFRAME_NONE :
active_bezt - fcu->bezt;
BLI_assert(BEZT_ISSEL_ANY(active_bezt));
fcu->active_keyframe_index = (int)offset;
}
/**