Fix wrong Anim Auto-Snap Ctrl toggle

This was not working like elsewhere in both NLA and Graph Editor
(meaning that when snapping was already enabled, {key Ctrl} during
transform did not disable it).

Now use getAnimEdit_SnapMode() for this in NLA and GE as well.

Maniphest Tasks: T87173

Differential Revision: https://developer.blender.org/D12244
This commit is contained in:
Philipp Oeser 2021-08-17 15:10:50 +02:00
parent f8dd0080a9
commit 0246128b7f
Notes: blender-bot 2023-02-13 19:03:52 +01:00
Referenced by issue #87173, Some Auto-Snap options in animation editors don't work correctly
2 changed files with 9 additions and 6 deletions

View File

@ -41,6 +41,7 @@
#include "transform.h"
#include "transform_convert.h"
#include "transform_mode.h"
typedef struct TransDataGraph {
float unit_scale;
@ -656,7 +657,6 @@ static bool fcu_test_selected(FCurve *fcu)
*/
static void flushTransGraphData(TransInfo *t)
{
SpaceGraph *sipo = (SpaceGraph *)t->area->spacedata.first;
TransData *td;
TransData2D *td2d;
TransDataGraph *tdg;
@ -680,7 +680,8 @@ static void flushTransGraphData(TransInfo *t)
* - Don't do this when canceling, or else these changes won't go away.
*/
if ((t->state != TRANS_CANCEL) && (td->flag & TD_NOTIMESNAP) == 0) {
switch (sipo->autosnap) {
const short autosnap = getAnimEdit_SnapMode(t);
switch (autosnap) {
case SACTSNAP_FRAME: /* snap to nearest frame */
td2d->loc[0] = floor((double)td2d->loc[0] + 0.5);
break;
@ -714,9 +715,9 @@ static void flushTransGraphData(TransInfo *t)
*
* \note We don't do this when canceling transforms, or else these changes don't go away.
*/
if ((t->state != TRANS_CANCEL) && (td->flag & TD_NOTIMESNAP) == 0 &&
ELEM(sipo->autosnap, SACTSNAP_STEP, SACTSNAP_TSTEP)) {
switch (sipo->autosnap) {
if ((t->state != TRANS_CANCEL) && (td->flag & TD_NOTIMESNAP) == 0) {
const short autosnap = getAnimEdit_SnapMode(t);
switch (autosnap) {
case SACTSNAP_STEP: /* frame step */
td2d->loc2d[0] = floor((double)td2d->loc[0] + 0.5);
td->loc[0] = floor((double)td->loc[0] + 0.5);

View File

@ -42,6 +42,7 @@
#include "transform.h"
#include "transform_convert.h"
#include "transform_mode.h"
/** Used for NLA transform (stored in #TransData.extra pointer). */
typedef struct TransDataNla {
@ -411,7 +412,8 @@ void recalcData_nla(TransInfo *t)
* NOTE: only do this when transform is still running, or we can't restore
*/
if (t->state != TRANS_CANCEL) {
switch (snla->autosnap) {
const short autosnap = getAnimEdit_SnapMode(t);
switch (autosnap) {
case SACTSNAP_FRAME: /* snap to nearest frame */
case SACTSNAP_STEP: /* frame step - this is basically the same,
* since we don't have any remapping going on */