Fix #122490: Snapping with free handles doesn't move the handles

When snapping keyframes in the Graph Editor, handles
that were set to free didn't move.

The issue was that the snapping code didn't set the handle position.
Instead it relied on the handle recalculation (`calchandleNurb_intern`) to do the job.
That code doesn't affect free handles though.

The fix is to also offset the handles in the snapping code. The handle recalculation
will still run for all the other handle types so that behavior isn't expected to change.

This does NOT change the behavior of bezier snapping in the 3D viewport.

Pull Request: https://projects.blender.org/blender/blender/pulls/123173
This commit is contained in:
Christoph Lendenfeld
2024-06-18 16:00:37 +02:00
committed by Christoph Lendenfeld
parent 979e142965
commit 1070ae46fa

View File

@@ -846,7 +846,7 @@ void bezt_remap_times(KeyframeEditData *ked, BezTriple *bezt)
static short snap_bezier_nearest(KeyframeEditData * /*ked*/, BezTriple *bezt)
{
if (bezt->f2 & SELECT) {
bezt->vec[1][0] = float(floorf(bezt->vec[1][0] + 0.5f));
BKE_fcurve_keyframe_move_time_with_handles(bezt, floorf(bezt->vec[1][0] + 0.5f));
}
return 0;
}
@@ -858,7 +858,7 @@ static short snap_bezier_nearestsec(KeyframeEditData *ked, BezTriple *bezt)
const float secf = float(FPS);
if (bezt->f2 & SELECT) {
bezt->vec[1][0] = float(floorf(bezt->vec[1][0] / secf + 0.5f)) * secf;
BKE_fcurve_keyframe_move_time_with_handles(bezt, floorf(bezt->vec[1][0] / secf + 0.5f) * secf);
}
return 0;
}
@@ -868,7 +868,7 @@ static short snap_bezier_cframe(KeyframeEditData *ked, BezTriple *bezt)
{
const Scene *scene = ked->scene;
if (bezt->f2 & SELECT) {
bezt->vec[1][0] = float(scene->r.cfra);
BKE_fcurve_keyframe_move_time_with_handles(bezt, float(scene->r.cfra));
}
return 0;
}
@@ -877,7 +877,8 @@ static short snap_bezier_cframe(KeyframeEditData *ked, BezTriple *bezt)
static short snap_bezier_nearmarker(KeyframeEditData *ked, BezTriple *bezt)
{
if (bezt->f2 & SELECT) {
bezt->vec[1][0] = float(ED_markers_find_nearest_marker_time(&ked->list, bezt->vec[1][0]));
BKE_fcurve_keyframe_move_time_with_handles(
bezt, float(ED_markers_find_nearest_marker_time(&ked->list, bezt->vec[1][0])));
}
return 0;
}
@@ -902,7 +903,7 @@ static short snap_bezier_horizontal(KeyframeEditData * /*ked*/, BezTriple *bezt)
static short snap_bezier_time(KeyframeEditData *ked, BezTriple *bezt)
{
if (bezt->f2 & SELECT) {
bezt->vec[1][0] = ked->f1;
BKE_fcurve_keyframe_move_time_with_handles(bezt, ked->f1);
}
return 0;
}
@@ -911,7 +912,7 @@ static short snap_bezier_time(KeyframeEditData *ked, BezTriple *bezt)
static short snap_bezier_value(KeyframeEditData *ked, BezTriple *bezt)
{
if (bezt->f2 & SELECT) {
bezt->vec[1][1] = ked->f1;
BKE_fcurve_keyframe_move_value_with_handles(bezt, ked->f1);
}
return 0;
}