Cleanup: Rearrange and name the enums and flags used in the transform code

Simple change that shows all the enums used in the transform code and helps
to better understand the role of the members of the struct TransInfo.

It also allows the IDE to show the name of the value represented by the
member instead of a number that needs to be consulted.

Differential Revision: https://developer.blender.org/D10312
This commit is contained in:
Germano Cavalcante 2021-02-03 19:25:16 -03:00
parent dfa3e0d9b5
commit bc56c12770
5 changed files with 261 additions and 249 deletions

View File

@ -40,7 +40,7 @@ void transform_operatortypes(void);
/* ******************** Macros & Prototypes *********************** */
/* MODE AND NUMINPUT FLAGS */
enum TfmMode {
typedef enum {
TFM_INIT = -1,
TFM_DUMMY,
TFM_TRANSLATION,
@ -77,24 +77,7 @@ enum TfmMode {
TFM_BONE_ENVELOPE_DIST,
TFM_NORMAL_ROTATION,
TFM_GPENCIL_OPACITY,
};
/* TRANSFORM CONTEXTS */
#define CTX_NONE 0
#define CTX_TEXTURE (1 << 0)
#define CTX_EDGE (1 << 1)
#define CTX_NO_PET (1 << 2)
#define CTX_NO_MIRROR (1 << 3)
#define CTX_AUTOCONFIRM (1 << 4)
#define CTX_MOVIECLIP (1 << 6)
#define CTX_MASK (1 << 7)
#define CTX_PAINT_CURVE (1 << 8)
#define CTX_GPENCIL_STROKES (1 << 9)
#define CTX_CURSOR (1 << 10)
/** When transforming object's, adjust the object data so it stays in the same place. */
#define CTX_OBMODE_XFORM_OBDATA (1 << 11)
/** Transform object parents without moving their children. */
#define CTX_OBMODE_XFORM_SKIP_CHILDREN (1 << 12)
} eTfmMode;
/* Standalone call to get the transformation center corresponding to the current situation
* returns 1 if successful, 0 otherwise (usually means there's no selection)

View File

@ -36,6 +36,11 @@
#include "transform_data.h"
/* use node center for transform instead of upper-left corner.
* disabled since it makes absolute snapping not work so nicely
*/
// #define USE_NODE_CENTER
/* -------------------------------------------------------------------- */
/** \name Types/
* \{ */
@ -60,6 +65,133 @@ struct wmKeyMap;
struct wmOperator;
struct wmTimer;
/** \} */
/* -------------------------------------------------------------------- */
/** \name Enums and Flags
* \{ */
/** #TransInfo.options */
typedef enum {
CTX_NONE = 0,
CTX_TEXTURE = (1 << 0),
CTX_EDGE = (1 << 1),
CTX_NO_PET = (1 << 2),
CTX_NO_MIRROR = (1 << 3),
CTX_AUTOCONFIRM = (1 << 4),
CTX_MOVIECLIP = (1 << 6),
CTX_MASK = (1 << 7),
CTX_PAINT_CURVE = (1 << 8),
CTX_GPENCIL_STROKES = (1 << 9),
CTX_CURSOR = (1 << 10),
/** When transforming object's, adjust the object data so it stays in the same place. */
CTX_OBMODE_XFORM_OBDATA = (1 << 11),
/** Transform object parents without moving their children. */
CTX_OBMODE_XFORM_SKIP_CHILDREN = (1 << 12),
} eTContext;
/** #TransInfo.flag */
typedef enum {
T_OBJECT = 1 << 0,
/** \note We could remove 'T_EDIT' and use 'obedit_type', for now ensure they're in sync. */
T_EDIT = 1 << 1,
T_POSE = 1 << 2,
T_TEXTURE = 1 << 3,
/** Transforming the 3d view. */
T_CAMERA = 1 << 4,
/** Transforming the 3D cursor. */
T_CURSOR = 1 << 5,
/** Transform points, having no rotation/scale. */
T_POINTS = 1 << 6,
/** restrictions flags */
T_NO_CONSTRAINT = 1 << 7,
T_NULL_ONE = 1 << 8,
T_NO_ZERO = 1 << 9,
T_ALL_RESTRICTIONS = T_NO_CONSTRAINT | T_NULL_ONE | T_NO_ZERO,
T_PROP_EDIT = 1 << 10,
T_PROP_CONNECTED = 1 << 11,
T_PROP_PROJECTED = 1 << 12,
T_PROP_EDIT_ALL = T_PROP_EDIT | T_PROP_CONNECTED | T_PROP_PROJECTED,
T_V3D_ALIGN = 1 << 13,
/** For 2D views such as UV or f-curve. */
T_2D_EDIT = 1 << 14,
T_CLIP_UV = 1 << 15,
/** Auto-IK is on. */
T_AUTOIK = 1 << 16,
/** Don't use mirror even if the data-block option is set. */
T_NO_MIRROR = 1 << 17,
/** To indicate that the value set in the `value` parameter is the final
* value of the transformation, modified only by the constrain. */
T_INPUT_IS_VALUES_FINAL = 1 << 18,
/** To specify if we save back settings at the end. */
T_MODAL = 1 << 19,
/** No re-topology (projection). */
T_NO_PROJECT = 1 << 20,
T_RELEASE_CONFIRM = 1 << 21,
/** Alternative transformation. used to add offset to tracking markers. */
T_ALT_TRANSFORM = 1 << 22,
/** #TransInfo.center has been set, don't change it. */
T_OVERRIDE_CENTER = 1 << 23,
T_MODAL_CURSOR_SET = 1 << 24,
T_CLNOR_REBUILD = 1 << 25,
/** Merges unselected into selected after transforming (runs after transforming). */
T_AUTOMERGE = 1 << 26,
/** Runs auto-merge & splits. */
T_AUTOSPLIT = 1 << 27,
} eTFlag;
/** #TransInfo.modifiers */
typedef enum {
MOD_CONSTRAINT_SELECT = 1 << 0,
MOD_PRECISION = 1 << 1,
MOD_SNAP = 1 << 2,
MOD_SNAP_INVERT = 1 << 3,
MOD_CONSTRAINT_PLANE = 1 << 4,
} eTModifier;
/** #TransSnap.status */
typedef enum {
SNAP_FORCED = 1 << 0,
TARGET_INIT = 1 << 1,
POINT_INIT = 1 << 2,
MULTI_POINTS = 1 << 3,
} eTSnap;
/** #TransCon.mode, #TransInfo.con.mode */
typedef enum {
/** When set constraints are in use. */
CON_APPLY = 1 << 0,
/** These are only used for modal execution. */
CON_AXIS0 = 1 << 1,
CON_AXIS1 = 1 << 2,
CON_AXIS2 = 1 << 3,
CON_SELECT = 1 << 4,
/** Does not reorient vector to face viewport when on. */
CON_NOFLIP = 1 << 5,
CON_USER = 1 << 6,
} eTConstraint;
/** #TransInfo.state */
typedef enum {
TRANS_STARTING = 0,
TRANS_RUNNING = 1,
TRANS_CONFIRM = 2,
TRANS_CANCEL = 3,
} eTState;
/** #TransInfo.redraw */
typedef enum {
TREDRAW_NOTHING = 0,
@ -67,6 +199,95 @@ typedef enum {
TREDRAW_SOFT = 2,
} eRedrawFlag;
/** #TransInfo.helpline */
typedef enum {
HLP_NONE = 0,
HLP_SPRING = 1,
HLP_ANGLE = 2,
HLP_HARROW = 3,
HLP_VARROW = 4,
HLP_CARROW = 5,
HLP_TRACKBALL = 6,
} eTHelpline;
typedef enum {
TC_NONE = 0,
TC_ACTION_DATA,
TC_POSE,
TC_ARMATURE_VERTS,
TC_CURSOR_IMAGE,
TC_CURSOR_VIEW3D,
TC_CURVE_VERTS,
TC_GRAPH_EDIT_DATA,
TC_GPENCIL,
TC_LATTICE_VERTS,
TC_MASKING_DATA,
TC_MBALL_VERTS,
TC_MESH_VERTS,
TC_MESH_EDGES,
TC_MESH_SKIN,
TC_MESH_UV,
TC_NLA_DATA,
TC_NODE_DATA,
TC_OBJECT,
TC_OBJECT_TEXSPACE,
TC_PAINT_CURVE_VERTS,
TC_PARTICLE_VERTS,
TC_SCULPT,
TC_SEQ_DATA,
TC_TRACKING_DATA,
} eTConvertType;
/** \} */
/* -------------------------------------------------------------------- */
/** \name Keymap Modal Items
*
* \note these values are saved in key-map files, do not change then but just add new ones.
* \{ */
enum {
TFM_MODAL_CANCEL = 1,
TFM_MODAL_CONFIRM = 2,
TFM_MODAL_TRANSLATE = 3,
TFM_MODAL_ROTATE = 4,
TFM_MODAL_RESIZE = 5,
TFM_MODAL_SNAP_INV_ON = 6,
TFM_MODAL_SNAP_INV_OFF = 7,
TFM_MODAL_SNAP_TOGGLE = 8,
TFM_MODAL_AXIS_X = 9,
TFM_MODAL_AXIS_Y = 10,
TFM_MODAL_AXIS_Z = 11,
TFM_MODAL_PLANE_X = 12,
TFM_MODAL_PLANE_Y = 13,
TFM_MODAL_PLANE_Z = 14,
TFM_MODAL_CONS_OFF = 15,
TFM_MODAL_ADD_SNAP = 16,
TFM_MODAL_REMOVE_SNAP = 17,
/* 18 and 19 used by number-input, defined in `ED_numinput.h`. */
// NUM_MODAL_INCREMENT_UP = 18,
// NUM_MODAL_INCREMENT_DOWN = 19,
TFM_MODAL_PROPSIZE_UP = 20,
TFM_MODAL_PROPSIZE_DOWN = 21,
TFM_MODAL_AUTOIK_LEN_INC = 22,
TFM_MODAL_AUTOIK_LEN_DEC = 23,
TFM_MODAL_EDGESLIDE_UP = 24,
TFM_MODAL_EDGESLIDE_DOWN = 25,
/** For analog input, like track-pad. */
TFM_MODAL_PROPSIZE = 26,
/** Node editor insert offset (also called auto-offset) direction toggle. */
TFM_MODAL_INSERTOFS_TOGGLE_DIR = 27,
TFM_MODAL_AUTOCONSTRAINT = 28,
TFM_MODAL_AUTOCONSTRAINTPLANE = 29,
};
/** \} */
typedef struct TransSnapPoint {
struct TransSnapPoint *next, *prev;
float co[3];
@ -82,7 +303,7 @@ typedef struct TransSnap {
bool snap_self;
bool peel;
bool use_backface_culling;
char status;
eTSnap status;
/* Snapped Element Type (currently for objects only). */
char snapElem;
/** snapping from this point (in global-space). */
@ -120,7 +341,7 @@ typedef struct TransCon {
* the one in #TransInfo is not guarantee to stay the same (Rotates change it). */
int imval[2];
/** Mode flags of the constraint. */
int mode;
eTConstraint mode;
void (*drawExtra)(struct TransInfo *t);
/* Note: if 'tc' is NULL, 'td' must also be NULL.
@ -266,37 +487,45 @@ typedef struct TransInfo {
TransDataContainer *data_container;
int data_container_len;
/** #eTransConvertType
* TODO: It should be a member of #TransDataContainer. */
int data_type;
/** Combine length of all #TransDataContainer.data_len
* Use to check if nothing is selected or if we have a single selection. */
int data_len_all;
/** Current mode. */
int mode;
/** Generic flags for special behaviors. */
int flag;
/** Special modifiers, by function, not key. */
int modifiers;
/** Current state (running, canceled. */
short state;
/** TODO: It should be a member of #TransDataContainer. */
eTConvertType data_type;
/** Current context/options for transform. */
int options;
void (*transform)(struct TransInfo *, const int[2]);
/** Transform function pointer. */
eRedrawFlag (*handleEvent)(struct TransInfo *, const struct wmEvent *);
/* event handler function pointer RETURN 1 if redraw is needed */
/** transformed constraint. */
TransCon con;
TransSnap tsnap;
/** numerical input. */
NumInput num;
/** mouse input. */
MouseInput mouse;
/** redraw flag. */
eTContext options;
/** Generic flags for special behaviors. */
eTFlag flag;
/** Special modifiers, by function, not key. */
eTModifier modifiers;
/** Current state (running, canceled. */
eTState state;
/** Redraw flag. */
eRedrawFlag redraw;
/** Choice of custom cursor with or without a help line from the gizmo to the mouse position. */
eTHelpline helpline;
/** Current mode. */
eTfmMode mode;
/** Main transform mode function. */
void (*transform)(struct TransInfo *, const int[2]);
/* Event handler function that determines whether the viewport needs to be redrawn. */
eRedrawFlag (*handleEvent)(struct TransInfo *, const struct wmEvent *);
/** Constraint Data. */
TransCon con;
/** Snap Data. */
TransSnap tsnap;
/** Numerical input. */
NumInput num;
/** Mouse input. */
MouseInput mouse;
/** proportional circle radius. */
float prop_size;
/** proportional falloff text. */
@ -333,8 +562,6 @@ typedef struct TransInfo {
short around;
/** space-type where transforming is. */
char spacetype;
/** Choice of custom cursor with or without a help line from the gizmo to the mouse position. */
char helpline;
/** Avoid looking inside #TransDataContainer.obedit. */
short obedit_type;
@ -421,178 +648,6 @@ typedef struct TransInfo {
/** \} */
/* -------------------------------------------------------------------- */
/** \name Flags
* \{ */
/** #TransInfo.state */
enum {
TRANS_STARTING = 0,
TRANS_RUNNING = 1,
TRANS_CONFIRM = 2,
TRANS_CANCEL = 3,
};
/** #TransInfo.flag */
enum {
T_OBJECT = 1 << 0,
/** \note We could remove 'T_EDIT' and use 'obedit_type', for now ensure they're in sync. */
T_EDIT = 1 << 1,
T_POSE = 1 << 2,
T_TEXTURE = 1 << 3,
/** Transforming the 3d view. */
T_CAMERA = 1 << 4,
/** Transforming the 3D cursor. */
T_CURSOR = 1 << 5,
/** Transform points, having no rotation/scale. */
T_POINTS = 1 << 6,
/** restrictions flags */
T_NO_CONSTRAINT = 1 << 7,
T_NULL_ONE = 1 << 8,
T_NO_ZERO = 1 << 9,
T_ALL_RESTRICTIONS = T_NO_CONSTRAINT | T_NULL_ONE | T_NO_ZERO,
T_PROP_EDIT = 1 << 10,
T_PROP_CONNECTED = 1 << 11,
T_PROP_PROJECTED = 1 << 12,
T_PROP_EDIT_ALL = T_PROP_EDIT | T_PROP_CONNECTED | T_PROP_PROJECTED,
T_V3D_ALIGN = 1 << 13,
/** For 2D views such as UV or f-curve. */
T_2D_EDIT = 1 << 14,
T_CLIP_UV = 1 << 15,
/** Auto-IK is on. */
T_AUTOIK = 1 << 16,
/** Don't use mirror even if the data-block option is set. */
T_NO_MIRROR = 1 << 17,
/** To indicate that the value set in the `value` parameter is the final
* value of the transformation, modified only by the constrain. */
T_INPUT_IS_VALUES_FINAL = 1 << 18,
/** To specify if we save back settings at the end. */
T_MODAL = 1 << 19,
/** No re-topology (projection). */
T_NO_PROJECT = 1 << 20,
T_RELEASE_CONFIRM = 1 << 21,
/** Alternative transformation. used to add offset to tracking markers. */
T_ALT_TRANSFORM = 1 << 22,
/** #TransInfo.center has been set, don't change it. */
T_OVERRIDE_CENTER = 1 << 23,
T_MODAL_CURSOR_SET = 1 << 24,
T_CLNOR_REBUILD = 1 << 25,
/** Merges unselected into selected after transforming (runs after transforming). */
T_AUTOMERGE = 1 << 26,
/** Runs auto-merge & splits. */
T_AUTOSPLIT = 1 << 27,
};
/** #TransInfo.modifiers */
enum {
MOD_CONSTRAINT_SELECT = 1 << 0,
MOD_PRECISION = 1 << 1,
MOD_SNAP = 1 << 2,
MOD_SNAP_INVERT = 1 << 3,
MOD_CONSTRAINT_PLANE = 1 << 4,
};
/* use node center for transform instead of upper-left corner.
* disabled since it makes absolute snapping not work so nicely
*/
// #define USE_NODE_CENTER
/** #TransInfo.helpline */
enum {
HLP_NONE = 0,
HLP_SPRING = 1,
HLP_ANGLE = 2,
HLP_HARROW = 3,
HLP_VARROW = 4,
HLP_CARROW = 5,
HLP_TRACKBALL = 6,
};
/** #TransCon.mode, #TransInfo.con.mode */
enum {
/** When set constraints are in use. */
CON_APPLY = 1 << 0,
/** These are only used for modal execution. */
CON_AXIS0 = 1 << 1,
CON_AXIS1 = 1 << 2,
CON_AXIS2 = 1 << 3,
CON_SELECT = 1 << 4,
/** Does not reorient vector to face viewport when on. */
CON_NOFLIP = 1 << 5,
CON_USER = 1 << 6,
};
/** #TransSnap.status */
enum {
SNAP_FORCED = 1 << 0,
TARGET_INIT = 1 << 1,
POINT_INIT = 1 << 2,
MULTI_POINTS = 1 << 3,
};
/** \} */
/* -------------------------------------------------------------------- */
/** \name Keymap Modal Items
*
* \note these values are saved in key-map files, do not change then but just add new ones.
* \{ */
enum {
TFM_MODAL_CANCEL = 1,
TFM_MODAL_CONFIRM = 2,
TFM_MODAL_TRANSLATE = 3,
TFM_MODAL_ROTATE = 4,
TFM_MODAL_RESIZE = 5,
TFM_MODAL_SNAP_INV_ON = 6,
TFM_MODAL_SNAP_INV_OFF = 7,
TFM_MODAL_SNAP_TOGGLE = 8,
TFM_MODAL_AXIS_X = 9,
TFM_MODAL_AXIS_Y = 10,
TFM_MODAL_AXIS_Z = 11,
TFM_MODAL_PLANE_X = 12,
TFM_MODAL_PLANE_Y = 13,
TFM_MODAL_PLANE_Z = 14,
TFM_MODAL_CONS_OFF = 15,
TFM_MODAL_ADD_SNAP = 16,
TFM_MODAL_REMOVE_SNAP = 17,
/* 18 and 19 used by number-input, defined in `ED_numinput.h`. */
// NUM_MODAL_INCREMENT_UP = 18,
// NUM_MODAL_INCREMENT_DOWN = 19,
TFM_MODAL_PROPSIZE_UP = 20,
TFM_MODAL_PROPSIZE_DOWN = 21,
TFM_MODAL_AUTOIK_LEN_INC = 22,
TFM_MODAL_AUTOIK_LEN_DEC = 23,
TFM_MODAL_EDGESLIDE_UP = 24,
TFM_MODAL_EDGESLIDE_DOWN = 25,
/** For analog input, like track-pad. */
TFM_MODAL_PROPSIZE = 26,
/** Node editor insert offset (also called auto-offset) direction toggle. */
TFM_MODAL_INSERTOFS_TOGGLE_DIR = 27,
TFM_MODAL_AUTOCONSTRAINT = 28,
TFM_MODAL_AUTOCONSTRAINTPLANE = 29,
};
/** \} */
/* -------------------------------------------------------------------- */
/** \name Public Transform API
* \{ */

View File

@ -981,7 +981,7 @@ void createTransData(bContext *C, TransInfo *t)
t->data_len_all = -1;
eTransConvertType convert_type = TC_NONE;
eTConvertType convert_type = TC_NONE;
/* if tests must match recalcData for correct updates */
if (t->options & CTX_CURSOR) {

View File

@ -52,34 +52,6 @@ int transform_convert_sequencer_get_snap_bound(TransInfo *t);
void transform_convert_sequencer_channel_clamp(TransInfo *t);
/********************* intern **********************/
typedef enum eTransConvertType {
TC_NONE = 0,
TC_ACTION_DATA,
TC_POSE,
TC_ARMATURE_VERTS,
TC_CURSOR_IMAGE,
TC_CURSOR_VIEW3D,
TC_CURVE_VERTS,
TC_GRAPH_EDIT_DATA,
TC_GPENCIL,
TC_LATTICE_VERTS,
TC_MASKING_DATA,
TC_MBALL_VERTS,
TC_MESH_VERTS,
TC_MESH_EDGES,
TC_MESH_SKIN,
TC_MESH_UV,
TC_NLA_DATA,
TC_NODE_DATA,
TC_OBJECT,
TC_OBJECT_TEXSPACE,
TC_PAINT_CURVE_VERTS,
TC_PARTICLE_VERTS,
TC_SCULPT,
TC_SEQ_DATA,
TC_TRACKING_DATA,
} eTransConvertType;
/* transform_convert.c */
bool transform_mode_use_local_origins(const TransInfo *t);
void transform_around_single_fallback_ex(TransInfo *t, int data_len_all);

View File

@ -211,6 +211,8 @@ void transform_draw_cursor_draw(bContext *UNUSED(C), int x, int y, void *customd
drawArrow(pos_id, DOWN);
break;
}
case HLP_NONE:
break;
}
GPU_matrix_pop();