Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenkernel/intern/fcurve.c10
-rw-r--r--source/blender/editors/animation/keyframing.c3
-rw-r--r--source/blender/makesdna/DNA_anim_types.h3
3 files changed, 13 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index d2a9064a373..d57ef45107c 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -839,6 +839,8 @@ bool BKE_fcurve_calc_range(
*/
void BKE_fcurve_active_keyframe_set(FCurve *fcu, const BezTriple *active_bezt)
{
+ /* The active keyframe should always be selected. */
+ BLI_assert(active_bezt->f2 & SELECT);
fcu->active_keyframe_index = (active_bezt == NULL) ? FCURVE_ACTIVE_KEYFRAME_NONE :
active_bezt - fcu->bezt;
}
@@ -850,12 +852,18 @@ int BKE_fcurve_active_keyframe_index(const FCurve *fcu)
{
const int active_keyframe_index = fcu->active_keyframe_index;
- /* Sanity checks. */
+ /* Array access boundary checks. */
if ((fcu->bezt == NULL) || (active_keyframe_index >= fcu->totvert) ||
(active_keyframe_index < 0)) {
return FCURVE_ACTIVE_KEYFRAME_NONE;
}
+ const BezTriple *active_bezt = &fcu->bezt[active_keyframe_index];
+ if ((active_bezt->f2 & SELECT) == 0) {
+ /* The active keyframe should always be selected. If it's not selected, it can't be active. */
+ return FCURVE_ACTIVE_KEYFRAME_NONE;
+ }
+
return active_keyframe_index;
}
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index c2a772604f2..967ca13c17d 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -605,8 +605,7 @@ int insert_vert_fcurve(
/* add temp beztriple to keyframes */
a = insert_bezt_fcurve(fcu, &beztr, flag);
-
- fcu->active_keyframe_index = a;
+ BKE_fcurve_active_keyframe_set(fcu, &fcu->bezt[a]);
/* what if 'a' is a negative index?
* for now, just exit to prevent any segfaults
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index f17d8b84790..1a74166da31 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -593,6 +593,9 @@ typedef struct FCurve {
/**
* Index of active keyframe in #bezt for numerical editing in the interface. A value of
* #FCURVE_ACTIVE_KEYFRAME_NONE indicates that the FCurve has no active keyframe.
+ *
+ * Do not access directly, use #BKE_fcurve_active_keyframe_index() and
+ * #BKE_fcurve_active_keyframe_set() instead.
*/
int active_keyframe_index;