Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform.h
| Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
| #include "DNA_listBase.h" | #include "DNA_listBase.h" | ||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| /* ************************** Types ***************************** */ | /* ************************** Types ***************************** */ | ||||
| struct Depsgraph; | struct Depsgraph; | ||||
| struct TransInfo; | struct TransInfo; | ||||
| struct TransHandle; | |||||
| struct TransData; | struct TransData; | ||||
| struct TransformOrientation; | struct TransformOrientation; | ||||
| struct TransSnap; | struct TransSnap; | ||||
| struct NumInput; | struct NumInput; | ||||
| struct Object; | struct Object; | ||||
| struct View3D; | struct View3D; | ||||
| struct ScrArea; | struct ScrArea; | ||||
| struct Scene; | struct Scene; | ||||
| ▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | typedef struct TransSnap { | ||||
| void (*calcSnap)(struct TransInfo *, float *); | void (*calcSnap)(struct TransInfo *, float *); | ||||
| void (*targetSnap)(struct TransInfo *); | void (*targetSnap)(struct TransInfo *); | ||||
| /** | /** | ||||
| * Get the transform distance between two points (used by Closest snap) | * Get the transform distance between two points (used by Closest snap) | ||||
| * | * | ||||
| * \note Return value can be anything, | * \note Return value can be anything, | ||||
| * where the smallest absolute value defines whats closest. | * where the smallest absolute value defines whats closest. | ||||
| */ | */ | ||||
| float (*distance)(struct TransInfo *, const float p1[3], const float p2[3]); | float (*distance)(struct TransInfo *t, const float p1[3], const float p2[3]); | ||||
| /** | /** | ||||
| * Re-usable snap context data. | * Re-usable snap context data. | ||||
| */ | */ | ||||
| struct SnapObjectContext *object_context; | struct SnapObjectContext *object_context; | ||||
| } TransSnap; | } TransSnap; | ||||
| typedef struct TransCon { | typedef struct TransCon { | ||||
| short orientation; /**/ | short orientation; /**/ | ||||
| char text[50]; /* Description of the Constraint for header_print */ | char text[50]; /* Description of the Constraint for header_print */ | ||||
| float mtx[3][3]; /* Matrix of the Constraint space */ | float mtx[3][3]; /* Matrix of the Constraint space */ | ||||
| float imtx[3][3]; /* Inverse Matrix of the Constraint space */ | float imtx[3][3]; /* Inverse Matrix of the Constraint space */ | ||||
| float pmtx[3][3]; /* Projection Constraint Matrix (same as imtx with some axis == 0) */ | float pmtx[3][3]; /* Projection Constraint Matrix (same as imtx with some axis == 0) */ | ||||
| int imval[2]; /* initial mouse value for visual calculation */ | int imval[2]; /* initial mouse value for visual calculation */ | ||||
| /* the one in TransInfo is not garanty to stay the same (Rotates change it) */ | /* the one in TransInfo is not garanty to stay the same (Rotates change it) */ | ||||
| int mode; /* Mode flags of the Constraint */ | int mode; /* Mode flags of the Constraint */ | ||||
| void (*drawExtra)(struct TransInfo *t); | void (*drawExtra)(struct TransInfo *t); | ||||
| /* Note: if 'th' 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 */ | ||||
| void (*applyVec)(struct TransInfo *t, struct TransData *td, const float in[3], float out[3], float pvec[3]); | void (*applyVec)(struct TransInfo *t, struct TransHandle *th, struct TransData *td, const float in[3], float out[3], float pvec[3]); | ||||
| /* 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 */ | ||||
| void (*applySize)(struct TransInfo *t, struct TransData *td, float smat[3][3]); | void (*applySize)(struct TransInfo *t, struct TransHandle *th, struct TransData *td, float smat[3][3]); | ||||
| /* Apply function pointer for size transformation */ | /* Apply function pointer for size transformation */ | ||||
| void (*applyRot)(struct TransInfo *t, struct TransData *td, float vec[3], float *angle); | void (*applyRot)(struct TransInfo *t, struct TransHandle *th, struct TransData *td, float vec[3], float *angle); | ||||
| /* Apply function pointer for rotation transformation */ | /* Apply function pointer for rotation transformation */ | ||||
| } TransCon; | } TransCon; | ||||
| typedef struct TransDataExtension { | typedef struct TransDataExtension { | ||||
| float drot[3]; /* Initial object drot */ | float drot[3]; /* Initial object drot */ | ||||
| // float drotAngle; /* Initial object drotAngle, TODO: not yet implemented */ | // float drotAngle; /* Initial object drotAngle, TODO: not yet implemented */ | ||||
| // float drotAxis[3]; /* Initial object drotAxis, TODO: not yet implemented */ | // float drotAxis[3]; /* Initial object drotAxis, TODO: not yet implemented */ | ||||
| float dquat[4]; /* Initial object dquat */ | float dquat[4]; /* Initial object dquat */ | ||||
| ▲ Show 20 Lines • Show All 227 Lines • ▼ Show 20 Lines | |||||
| typedef struct TransCustomData { | typedef struct TransCustomData { | ||||
| void *data; | void *data; | ||||
| void (*free_cb)(struct TransInfo *, struct TransCustomData *); | void (*free_cb)(struct TransInfo *, struct TransCustomData *); | ||||
| unsigned int use_free : 1; | unsigned int use_free : 1; | ||||
| } TransCustomData; | } TransCustomData; | ||||
| typedef struct TransCenterData { | typedef struct TransCenterData { | ||||
| float local[3], global[3]; | float global[3]; | ||||
| unsigned int is_set : 1; | unsigned int is_set : 1; | ||||
| } TransCenterData; | } TransCenterData; | ||||
| typedef struct TransHandle { | |||||
| /* Use for cases we care about the active, eg: active vert of active mesh. | |||||
| * if set this will _always_ be the first item in the array. */ | |||||
| bool is_active; | |||||
| TransData *data; /* transformed data (array) */ | |||||
| TransDataExtension *ext; /* transformed data extension (array) */ | |||||
| TransData2D *data2d; /* transformed data for 2d (array) */ | |||||
| int total; /* total number of transformed data */ | |||||
| struct Object *obedit; | |||||
| float obedit_mat[3][3]; /* normalized editmode matrix (T_EDIT only) */ | |||||
| struct Object *poseobj; /* if t->flag & T_POSE, this denotes pose object */ | |||||
| /* center of transformation (in local-space) */ | |||||
| float center_local[3]; | |||||
| /** | |||||
| * Rule of thumb for choosing between mode/type: | |||||
| * - If transform mode uses the data, assign to `mode` | |||||
| * (typically in transform.c). | |||||
| * - If conversion uses the data as an extension to the #TransData, assign to `type` | |||||
| * (typically in transform_conversion.c). | |||||
| */ | |||||
| struct { | |||||
| /* owned by the mode (grab, scale, bend... )*/ | |||||
| union { | |||||
| TransCustomData mode, first_elem; | |||||
| }; | |||||
| TransCustomData type; | |||||
| } custom; | |||||
| #define TRANS_CUSTOM_DATA_ELEM_MAX (sizeof(((TransHandle *)NULL)->custom) / sizeof(TransCustomData)) | |||||
| } TransHandle; | |||||
| typedef struct TransInfo { | typedef struct TransInfo { | ||||
| TransHandle *thand; | |||||
| int thand_len; | |||||
| int total_all_handle; | |||||
| int mode; /* current mode */ | int mode; /* current mode */ | ||||
| int flag; /* generic flags for special behaviors */ | int flag; /* generic flags for special behaviors */ | ||||
| int modifiers; /* special modifiers, by function, not key */ | int modifiers; /* special modifiers, by function, not key */ | ||||
| short state; /* current state (running, canceled,...)*/ | short state; /* current state (running, canceled,...)*/ | ||||
| int options; /* current context/options for transform */ | int options; /* current context/options for transform */ | ||||
| float val; /* init value for some transformations (and rotation angle) */ | float val; /* init value for some transformations (and rotation angle) */ | ||||
| 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 */ | ||||
| int total; /* total number of transformed data */ | |||||
| TransData *data; /* transformed data (array) */ | |||||
| TransDataExtension *ext; /* transformed data extension (array) */ | |||||
| TransData2D *data2d; /* transformed data for 2d (array) */ | |||||
| TransCon con; /* transformed constraint */ | TransCon con; /* transformed constraint */ | ||||
| TransSnap tsnap; | TransSnap tsnap; | ||||
| NumInput num; /* numerical input */ | NumInput num; /* numerical input */ | ||||
| MouseInput mouse; /* mouse input */ | MouseInput mouse; /* mouse input */ | ||||
| eRedrawFlag redraw; /* redraw flag */ | eRedrawFlag redraw; /* redraw flag */ | ||||
| float prop_size; /* proportional circle radius */ | float prop_size; /* proportional circle radius */ | ||||
| char proptext[20]; /* proportional falloff text */ | char proptext[20]; /* proportional falloff text */ | ||||
| float aspect[3]; /* spaces using non 1:1 aspect, (uv's, f-curve, movie-clip... etc) | float aspect[3]; /* spaces using non 1:1 aspect, (uv's, f-curve, movie-clip... etc) | ||||
| * use for conversion and snapping. */ | * use for conversion and snapping. */ | ||||
| float center[3]; /* center of transformation (in local-space) */ | |||||
| float center_global[3]; /* center of transformation (in global-space) */ | float center_global[3]; /* center of transformation (in global-space) */ | ||||
| float center2d[2]; /* center in screen coordinates */ | float center2d[2]; /* center in screen coordinates */ | ||||
| /* Lazy initialize center data for when we need other center values. | /* Lazy initialize center data for when we need other center values. | ||||
| * V3D_AROUND_ACTIVE + 1 (static assert checks this) */ | * V3D_AROUND_ACTIVE + 1 (static assert checks this) */ | ||||
| TransCenterData center_cache[5]; | TransCenterData center_cache[5]; | ||||
| short idx_max; /* maximum index on the input vector */ | short idx_max; /* maximum index on the input vector */ | ||||
| float snap[3]; /* Snapping Gears */ | float snap[3]; /* Snapping Gears */ | ||||
| float snap_spatial[3]; /* Spatial snapping gears(even when rotating, scaling... etc) */ | float snap_spatial[3]; /* Spatial snapping gears(even when rotating, scaling... etc) */ | ||||
| char frame_side; /* Mouse side of the cfra, 'L', 'R' or 'B' */ | char frame_side; /* Mouse side of the cfra, 'L', 'R' or 'B' */ | ||||
| float viewmat[4][4]; /* copy from G.vd, prevents feedback, */ | float viewmat[4][4]; /* copy from G.vd, prevents feedback, */ | ||||
| float viewinv[4][4]; /* and to make sure we don't have to */ | float viewinv[4][4]; /* and to make sure we don't have to */ | ||||
| float persmat[4][4]; /* access G.vd from other space types */ | float persmat[4][4]; /* access G.vd from other space types */ | ||||
| float persinv[4][4]; | float persinv[4][4]; | ||||
| short persp; | short persp; | ||||
| short around; | short around; | ||||
| char spacetype; /* spacetype where transforming is */ | char spacetype; /* spacetype where transforming is */ | ||||
| char helpline; /* helpline modes (not to be confused with hotline) */ | char helpline; /* helpline modes (not to be confused with hotline) */ | ||||
| short obedit_type; /* Avoid looking inside TransHandle obedit. */ | |||||
| float vec[3]; /* translation, to show for widget */ | float vec[3]; /* translation, to show for widget */ | ||||
| float mat[3][3]; /* rot/rescale, to show for widget */ | float mat[3][3]; /* rot/rescale, to show for widget */ | ||||
| float spacemtx[3][3]; /* orientation matrix of the current space */ | float spacemtx[3][3]; /* orientation matrix of the current space */ | ||||
| char spacename[64]; /* name of the current space, MAX_NAME */ | char spacename[64]; /* name of the current space, MAX_NAME */ | ||||
| struct Object *poseobj; /* if t->flag & T_POSE, this denotes pose object */ | |||||
| /** | |||||
| * Rule of thumb for choosing between mode/type: | |||||
| * - If transform mode uses the data, assign to `mode` | |||||
| * (typically in transform.c). | |||||
| * - If conversion uses the data as an extension to the #TransData, assign to `type` | |||||
| * (typically in transform_conversion.c). | |||||
| */ | |||||
| struct { | |||||
| /* owned by the mode (grab, scale, bend... )*/ | |||||
| union { | |||||
| TransCustomData mode, first_elem; | |||||
| }; | |||||
| /* owned by the type (mesh, armature, nla...) */ | |||||
| TransCustomData type; | |||||
| } custom; | |||||
| #define TRANS_CUSTOM_DATA_ELEM_MAX (sizeof(((TransInfo *)NULL)->custom) / sizeof(TransCustomData)) | |||||
| /*************** NEW STUFF *********************/ | /*************** NEW STUFF *********************/ | ||||
| short launch_event; /* event type used to launch transform */ | short launch_event; /* event type used to launch transform */ | ||||
| short current_orientation; | short current_orientation; | ||||
| TransformOrientation *custom_orientation; /* this gets used when current_orientation is V3D_MANIP_CUSTOM */ | TransformOrientation *custom_orientation; /* this gets used when current_orientation is V3D_MANIP_CUSTOM */ | ||||
| short twtype; /* backup from view3d, to restore on end */ | short twtype; /* backup from view3d, to restore on end */ | ||||
| short prop_mode; | short prop_mode; | ||||
| Show All 17 Lines | typedef struct TransInfo { | ||||
| struct ViewLayer *view_layer; | struct ViewLayer *view_layer; | ||||
| struct RenderEngineType *engine_type; | struct RenderEngineType *engine_type; | ||||
| struct ToolSettings *settings; | struct ToolSettings *settings; | ||||
| struct wmTimer *animtimer; | struct wmTimer *animtimer; | ||||
| struct wmKeyMap *keymap; /* so we can do lookups for header text */ | struct wmKeyMap *keymap; /* so we can do lookups for header text */ | ||||
| struct ReportList *reports; /* assign from the operator, or can be NULL */ | struct ReportList *reports; /* assign from the operator, or can be NULL */ | ||||
| int mval[2]; /* current mouse position */ | int mval[2]; /* current mouse position */ | ||||
| float zfac; /* use for 3d view */ | float zfac; /* use for 3d view */ | ||||
| struct Object *obedit; | |||||
| float obedit_mat[3][3]; /* normalized editmode matrix (T_EDIT only) */ | |||||
| void *draw_handle_apply; | void *draw_handle_apply; | ||||
| void *draw_handle_view; | void *draw_handle_view; | ||||
| void *draw_handle_pixel; | void *draw_handle_pixel; | ||||
| void *draw_handle_cursor; | void *draw_handle_cursor; | ||||
| } TransInfo; | } TransInfo; | ||||
| /* ******************** Macros & Prototypes *********************** */ | /* ******************** Macros & Prototypes *********************** */ | ||||
| ▲ Show 20 Lines • Show All 271 Lines • ▼ Show 20 Lines | |||||
| /* DRAWLINE options flags */ | /* DRAWLINE options flags */ | ||||
| #define DRAWLIGHT 1 | #define DRAWLIGHT 1 | ||||
| void applyTransObjects(TransInfo *t); | void applyTransObjects(TransInfo *t); | ||||
| void restoreTransObjects(TransInfo *t); | void restoreTransObjects(TransInfo *t); | ||||
| void recalcData(TransInfo *t); | void recalcData(TransInfo *t); | ||||
| void calculateCenter2D(TransInfo *t); | void calculateCenter2D(TransInfo *t); | ||||
| void calculateCenterGlobal( | void calculateCenterLocal(TransInfo *t, const float center_global[3]); | ||||
| TransInfo *t, const float center_local[3], | |||||
| float r_center_global[3]); | |||||
| const TransCenterData *transformCenter_from_type(TransInfo *t, int around); | const TransCenterData *transformCenter_from_type(TransInfo *t, int around); | ||||
| void calculateCenter(TransInfo *t); | void calculateCenter(TransInfo *t); | ||||
| /* API functions for getting center points */ | /* API functions for getting center points */ | ||||
| void calculateCenterBound(TransInfo *t, float r_center[3]); | void calculateCenterBound(TransInfo *t, float r_center[3]); | ||||
| void calculateCenterMedian(TransInfo *t, float r_center[3]); | void calculateCenterMedian(TransInfo *t, float r_center[3]); | ||||
| void calculateCenterCursor(TransInfo *t, float r_center[3]); | void calculateCenterCursor(TransInfo *t, float r_center[3]); | ||||
| Show All 39 Lines | |||||
| /* TODO. transform_queries.c */ | /* TODO. transform_queries.c */ | ||||
| bool checkUseAxisMatrix(TransInfo *t); | bool checkUseAxisMatrix(TransInfo *t); | ||||
| #define TRANSFORM_DIST_MAX_PX 1000.0f | #define TRANSFORM_DIST_MAX_PX 1000.0f | ||||
| #define TRANSFORM_SNAP_MAX_PX 100.0f | #define TRANSFORM_SNAP_MAX_PX 100.0f | ||||
| #define TRANSFORM_DIST_INVALID -FLT_MAX | #define TRANSFORM_DIST_INVALID -FLT_MAX | ||||
| /* Temp macros. */ | |||||
| /* This is to be replaced, just to get things compiling early on. */ | |||||
| #define THAND_FIRST_EVIL(t) (&(t)->thand[0]) | |||||
| #define THAND_FIRST_OK(t) (&(t)->thand[0]) | |||||
| /* For cases we _know_ there is only one handle. */ | |||||
| #define THAND_FIRST_SINGLE(t) (BLI_assert((t)->thand_len == 1), (&(t)->thand[0])) | |||||
| #define FOREACH_THAND(t, th) \ | |||||
| for (TransHandle *th = t->thand, *th_end = t->thand + t->thand_len; th != th_end; th++) | |||||
| #define FOREACH_THAND_INDEX(t, th, i) \ | |||||
| for (TransHandle *th = ((i = 0), t->thand), *th_end = t->thand + t->thand_len; th != th_end; th++, i++) | |||||
| #endif | #endif | ||||