Fix #110108: NLA absolute snapping #111984

Merged
Christoph Lendenfeld merged 9 commits from ChrisLend/blender:fix_nla_marker_snap into main 2023-09-15 09:52:48 +02:00
1 changed files with 8 additions and 6 deletions
Showing only changes of commit a5f3817961 - Show all commits

View File

@ -662,18 +662,20 @@ static void snap_transform_data(TransInfo *t, TransDataContainer *tc)
}
float offset = 0;
float closest_snap_offset = FLT_MAX;
float smallest_snap_delta = FLT_MAX;
/* In order to move the strip in a block and not each end individually,
* find the minimal snap offset first and then shift the whole strip by that amount. */
for (int i = 0; i < tc->data_len; i++) {
TransData td = tc->data[i];
float snap_value;
transform_snap_anim_flush_data(t, &td, snap_mode, &snap_value);
/* In order to move the strip in a block and not each end individually, find the minimal snap
* offset and shift the whole strip by that amount. */
const float snap_offset = *td.loc - snap_value;
if (fabs(snap_offset) < fabs(closest_snap_offset)) {
/* The snap_delta measures how far from the unsnapped position the value has moved. */

Minor: first line in comment is a little long.

/* In order to move the strip in a block and not each end individually,
 * find the minimal snap offset and shift the whole strip by that amount. */

Might read better.

Minor: first line in comment is a little long. ``` /* In order to move the strip in a block and not each end individually, * find the minimal snap offset and shift the whole strip by that amount. */ ``` Might read better.
const float snap_delta = *td.loc - snap_value;
if (fabs(snap_delta) < fabs(smallest_snap_delta)) {
offset = snap_value - td.iloc[0];
closest_snap_offset = snap_offset;
smallest_snap_delta = snap_delta;
}
}