Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform.h
| Show All 30 Lines | |||||
| #include "DNA_listBase.h" | #include "DNA_listBase.h" | ||||
| #include "DNA_object_enums.h" | #include "DNA_object_enums.h" | ||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "transform_data.h" | #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/ | /** \name Types/ | ||||
| * \{ */ | * \{ */ | ||||
| struct ARegion; | struct ARegion; | ||||
| struct Depsgraph; | struct Depsgraph; | ||||
| struct NumInput; | struct NumInput; | ||||
| struct Object; | struct Object; | ||||
| struct RNG; | struct RNG; | ||||
| struct ReportList; | struct ReportList; | ||||
| struct Scene; | struct Scene; | ||||
| struct ScrArea; | struct ScrArea; | ||||
| struct SnapObjectContext; | struct SnapObjectContext; | ||||
| struct TransDataContainer; | struct TransDataContainer; | ||||
| struct TransInfo; | struct TransInfo; | ||||
| struct TransSnap; | struct TransSnap; | ||||
| struct TransformOrientation; | struct TransformOrientation; | ||||
| struct ViewLayer; | struct ViewLayer; | ||||
| struct bContext; | struct bContext; | ||||
| struct wmEvent; | struct wmEvent; | ||||
| struct wmKeyConfig; | struct wmKeyConfig; | ||||
| struct wmKeyMap; | struct wmKeyMap; | ||||
| struct wmTimer; | struct wmTimer; | ||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Enums | |||||
| * \{ */ | |||||
| /** #TransInfo.redraw */ | /** #TransInfo.redraw */ | ||||
| typedef enum { | typedef enum { | ||||
| TREDRAW_NOTHING = 0, | TREDRAW_NOTHING = 0, | ||||
| TREDRAW_HARD = 1, | TREDRAW_HARD = 1, | ||||
| TREDRAW_SOFT = 2, | TREDRAW_SOFT = 2, | ||||
| } eRedrawFlag; | } eRedrawFlag; | ||||
| /** #TransInfo.state */ | |||||
| typedef enum { | |||||
| TRANS_STARTING = 0, | |||||
| TRANS_RUNNING = 1, | |||||
| TRANS_CONFIRM = 2, | |||||
| TRANS_CANCEL = 3, | |||||
| } eTransState; | |||||
| /** \} */ | |||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Flags | |||||
| * \{ */ | |||||
| /** #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, | |||||
| } eTransFlag; | |||||
| /** #TransInfo.modifiers */ | |||||
| typedef enum { | |||||
| MOD_CONSTRAINT_SELECT = 1 << 0, | |||||
| MOD_CONSTRAINT_PLANE = 1 << 1, | |||||
| MOD_PRECISION = 1 << 2, | |||||
| MOD_SNAP = 1 << 3, | |||||
| MOD_SNAP_INVERT = 1 << 4, | |||||
| MOD_FORCE_SNAP = MOD_SNAP | (1 << 5), | |||||
| MOD_EDIT_BASEPOINT = 1 << 6, | |||||
| } eTransModifiers; | |||||
| /** #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, | |||||
| } eTrasHelpLine; | |||||
| /** #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, | |||||
| } eTrasConMode; | |||||
| /** #TransSnap.status */ | |||||
| typedef enum { | |||||
| SNAP_FORCED = 1 << 0, | |||||
| TARGET_INIT = 1 << 1, | |||||
| POINT_INIT = 1 << 2, | |||||
| MULTI_POINTS = 1 << 3, | |||||
| } eTrasSnapStatus; | |||||
| /** \} */ | |||||
| typedef struct TransSnapPoint { | typedef struct TransSnapPoint { | ||||
| struct TransSnapPoint *next, *prev; | struct TransSnapPoint *next, *prev; | ||||
| float co[3]; | float co[3]; | ||||
| } TransSnapPoint; | } TransSnapPoint; | ||||
| typedef struct TransSnap { | typedef struct TransSnap { | ||||
| short mode; | short mode; | ||||
| short target; | short target; | ||||
| short modePoint; | short modePoint; | ||||
| short modeSelect; | short modeSelect; | ||||
| bool align; | bool align; | ||||
| bool project; | bool project; | ||||
| bool snap_self; | bool snap_self; | ||||
| bool peel; | bool peel; | ||||
| bool use_backface_culling; | bool use_backface_culling; | ||||
| char status; | eTrasSnapStatus status; | ||||
| /* Snapped Element Type (currently for objects only). */ | /* Snapped Element Type (currently for objects only). */ | ||||
| char snapElem; | char snapElem; | ||||
| /** snapping from this point (in global-space). */ | /** snapping from this point (in global-space). */ | ||||
| float snapPoint[3]; | |||||
| /** to this point (in global-space). */ | |||||
| float snapTarget[3]; | float snapTarget[3]; | ||||
| /** to this point (in global-space). */ | |||||
| float snapPoint[3]; | |||||
| float snapNormal[3]; | float snapNormal[3]; | ||||
| char snapNodeBorder; | char snapNodeBorder; | ||||
| ListBase points; | ListBase points; | ||||
| TransSnapPoint *selectedPoint; | TransSnapPoint *selectedPoint; | ||||
| double last; | double last; | ||||
| void (*applySnap)(struct TransInfo *, float *); | void (*applySnap)(struct TransInfo *, float *); | ||||
| void (*calcSnap)(struct TransInfo *, float *); | void (*calcSnap)(struct TransInfo *, float *); | ||||
| void (*targetSnap)(struct TransInfo *); | void (*targetSnap)(struct TransInfo *); | ||||
| Show All 15 Lines | typedef struct TransCon { | ||||
| /** Description of the constraint for header_print. */ | /** Description of the constraint for header_print. */ | ||||
| char text[50]; | char text[50]; | ||||
| /** Projection constraint matrix (same as #imtx with some axis == 0). */ | /** Projection constraint matrix (same as #imtx with some axis == 0). */ | ||||
| float pmtx[3][3]; | float pmtx[3][3]; | ||||
| /** Initial mouse value for visual calculation | /** Initial mouse value for visual calculation | ||||
| * the one in #TransInfo is not guarantee to stay the same (Rotates change it). */ | * the one in #TransInfo is not guarantee to stay the same (Rotates change it). */ | ||||
| int imval[2]; | int imval[2]; | ||||
| /** Mode flags of the constraint. */ | /** Mode flags of the constraint. */ | ||||
| int mode; | eTrasConMode mode; | ||||
| void (*drawExtra)(struct TransInfo *t); | void (*drawExtra)(struct TransInfo *t); | ||||
| /* Note: if 'tc' is NULL, 'td' must also be NULL. | /* Note: if 'tc' is NULL, 'td' must also be NULL. | ||||
| * For constraints that needs to draw differently from the other | * For constraints that needs to draw differently from the other | ||||
| * uses this instead of the generic draw function. */ | * uses this instead of the generic draw function. */ | ||||
| /** Apply function pointer for linear vectorial transformation | /** Apply function pointer for linear vectorial transformation | ||||
| * The last three parameters are pointers to the in/out/printable vectors. */ | * The last three parameters are pointers to the in/out/printable vectors. */ | ||||
| ▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | typedef struct TransInfo { | ||||
| /** Combine length of all #TransDataContainer.data_len | /** Combine length of all #TransDataContainer.data_len | ||||
| * Use to check if nothing is selected or if we have a single selection. */ | * Use to check if nothing is selected or if we have a single selection. */ | ||||
| int data_len_all; | int data_len_all; | ||||
| /** Current mode. */ | /** Current mode. */ | ||||
| int mode; | int mode; | ||||
| /** Generic flags for special behaviors. */ | /** Generic flags for special behaviors. */ | ||||
| int flag; | eTransFlag flag; | ||||
| /** Special modifiers, by function, not key. */ | /** Special modifiers, by function, not key. */ | ||||
| int modifiers; | eTransModifiers modifiers; | ||||
| /** Current state (running, canceled. */ | /** Current state (running, canceled. */ | ||||
| short state; | eTransState state; | ||||
| /** Current context/options for transform. */ | /** Current context/options for transform. */ | ||||
| int options; | int options; | ||||
| void (*transform)(struct TransInfo *, const int[2]); | void (*transform)(struct TransInfo *, const int[2]); | ||||
| /** Transform function pointer. */ | /** Transform function pointer. */ | ||||
| eRedrawFlag (*handleEvent)(struct TransInfo *, const struct wmEvent *); | eRedrawFlag (*handleEvent)(struct TransInfo *, const struct wmEvent *); | ||||
| /* event handler function pointer RETURN 1 if redraw is needed */ | /* event handler function pointer RETURN 1 if redraw is needed */ | ||||
| /** transformed constraint. */ | /** transformed constraint. */ | ||||
| TransCon con; | TransCon con; | ||||
| Show All 36 Lines | typedef struct TransInfo { | ||||
| /** access G.vd from other space types. */ | /** access G.vd from other space types. */ | ||||
| float persmat[4][4]; | float persmat[4][4]; | ||||
| float persinv[4][4]; | float persinv[4][4]; | ||||
| short persp; | short persp; | ||||
| short around; | short around; | ||||
| /** space-type where transforming is. */ | /** space-type where transforming is. */ | ||||
| char spacetype; | char spacetype; | ||||
| /** Choice of custom cursor with or without a help line from the gizmo to the mouse position. */ | /** Choice of custom cursor with or without a help line from the gizmo to the mouse position. */ | ||||
| char helpline; | eTrasHelpLine helpline; | ||||
| /** Avoid looking inside #TransDataContainer.obedit. */ | /** Avoid looking inside #TransDataContainer.obedit. */ | ||||
| short obedit_type; | short obedit_type; | ||||
| /** translation, to show for widget. */ | /** translation, to show for widget. */ | ||||
| float vec[3]; | float vec[3]; | ||||
| /** Rotate/re-scale, to show for widget. */ | /** Rotate/re-scale, to show for widget. */ | ||||
| float mat[3][3]; | float mat[3][3]; | ||||
| ▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | typedef struct TransInfo { | ||||
| /** Typically for mode settings. */ | /** Typically for mode settings. */ | ||||
| TransCustomDataContainer custom; | TransCustomDataContainer custom; | ||||
| } TransInfo; | } 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 | /** \name Keymap Modal Items | ||||
| * | * | ||||
| * \note these values are saved in key-map files, do not change then but just add new ones. | * \note these values are saved in key-map files, do not change then but just add new ones. | ||||
| * \{ */ | * \{ */ | ||||
| enum { | enum { | ||||
| TFM_MODAL_CANCEL = 1, | TFM_MODAL_CANCEL = 1, | ||||
| TFM_MODAL_CONFIRM = 2, | TFM_MODAL_CONFIRM = 2, | ||||
| Show All 27 Lines | enum { | ||||
| /** For analog input, like track-pad. */ | /** For analog input, like track-pad. */ | ||||
| TFM_MODAL_PROPSIZE = 26, | TFM_MODAL_PROPSIZE = 26, | ||||
| /** Node editor insert offset (also called auto-offset) direction toggle. */ | /** Node editor insert offset (also called auto-offset) direction toggle. */ | ||||
| TFM_MODAL_INSERTOFS_TOGGLE_DIR = 27, | TFM_MODAL_INSERTOFS_TOGGLE_DIR = 27, | ||||
| TFM_MODAL_AUTOCONSTRAINT = 28, | TFM_MODAL_AUTOCONSTRAINT = 28, | ||||
| TFM_MODAL_AUTOCONSTRAINTPLANE = 29, | TFM_MODAL_AUTOCONSTRAINTPLANE = 29, | ||||
| TFM_MODAL_EDIT_SNAPWITH = 30, | |||||
| }; | }; | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Public Transform API | /** \name Public Transform API | ||||
| * \{ */ | * \{ */ | ||||
| ▲ Show 20 Lines • Show All 157 Lines • Show Last 20 Lines | |||||