Fix #114588: Graph Editor increment snap not working #114607

Merged
Christoph Lendenfeld merged 2 commits from ChrisLend/blender:fix_graph_editor_snapping into blender-v4.0-release 2023-11-09 14:38:37 +01:00
2 changed files with 19 additions and 17 deletions

View File

@ -644,18 +644,6 @@ static bool fcu_test_selected(FCurve *fcu)
return false;
}
static void invert_snap(eSnapMode &snap_mode)
{
if (snap_mode & SCE_SNAP_TO_FRAME) {
snap_mode &= ~SCE_SNAP_TO_FRAME;
snap_mode |= SCE_SNAP_TO_SECOND;
}
else if (snap_mode & SCE_SNAP_TO_SECOND) {
snap_mode &= ~SCE_SNAP_TO_SECOND;
snap_mode |= SCE_SNAP_TO_FRAME;
}
}
/* This function is called on recalc_data to apply the transforms applied
* to the transdata on to the actual keyframe data
*/
@ -668,10 +656,6 @@ static void flushTransGraphData(TransInfo *t)
eSnapMode snap_mode = t->tsnap.mode;
if (t->modifiers & MOD_SNAP_INVERT) {
invert_snap(snap_mode);
}
TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
/* flush to 2d vector from internally used 3d vector */
for (a = 0,

View File

@ -129,10 +129,28 @@ bool validSnap(const TransInfo *t)
void transform_snap_flag_from_modifiers_set(TransInfo *t)
{
if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_ACTION, SPACE_NLA)) {
if (ELEM(t->spacetype, SPACE_ACTION, SPACE_NLA)) {
/* Those space-types define their own invert behavior instead of toggling it on/off. */
return;
}
if (t->spacetype == SPACE_GRAPH) {
nathanvegdahl marked this conversation as resolved Outdated

Style: I would make this an else if. Or perhaps even better, make the whole thing a switch.

Never mind. Apparently else after a return is considered bad style in Blender, even in cases like this.

~~Style: I would make this an `else if`. Or perhaps even better, make the whole thing a switch.~~ Never mind. Apparently `else` after a return is considered bad style in Blender, even in cases like this.
/* This is to stay consistent with the behavior from 3.6. */
if (t->modifiers & MOD_SNAP_INVERT) {
t->tsnap.mode |= SCE_SNAP_TO_INCREMENT;
}
else {
t->tsnap.mode &= ~SCE_SNAP_TO_INCREMENT;
}
/* In 3.6 when snapping was disabled, pressing the invert button would turn on snapping.
* But it wouldn't turn it off when it was enabled. */
if ((t->modifiers & MOD_SNAP) || (t->modifiers & MOD_SNAP_INVERT)) {
t->tsnap.flag |= SCE_SNAP;
}
else {
t->tsnap.flag &= ~SCE_SNAP;
}
return;
}
SET_FLAG_FROM_TEST(t->tsnap.flag,
(((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP) ||
((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP_INVERT)),