2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): none yet.
25 * ***** END GPL LICENSE BLOCK *****
28 /** \file blender/editors/transform/transform.h
29 * \ingroup edtransform
33 #ifndef __TRANSFORM_H__
34 #define __TRANSFORM_H__
36 #include "ED_transform.h"
37 #include "ED_numinput.h"
38 #include "ED_view3d.h"
40 #include "DNA_listBase.h"
42 /* ************************** Types ***************************** */
46 struct TransformOrientation;
62 struct SnapObjectContext;
64 /* transinfo->redraw */
71 typedef struct TransSnapPoint {
72 struct TransSnapPoint *next, *prev;
76 typedef struct TransSnap {
85 bool snap_spatial_grid;
87 float snapPoint[3]; /* snapping from this point (in global-space)*/
88 float snapTarget[3]; /* to this point (in global-space)*/
92 TransSnapPoint *selectedPoint;
94 void (*applySnap)(struct TransInfo *, float *);
95 void (*calcSnap)(struct TransInfo *, float *);
96 void (*targetSnap)(struct TransInfo *);
98 * Get the transform distance between two points (used by Closest snap)
100 * \note Return value can be anything,
101 * where the smallest absolute value defines whats closest.
103 float (*distance)(struct TransInfo *, const float p1[3], const float p2[3]);
106 * Re-usable snap context data.
108 struct SnapObjectContext *object_context;
111 typedef struct TransCon {
112 short orientation; /**/
113 char text[50]; /* Description of the Constraint for header_print */
114 float mtx[3][3]; /* Matrix of the Constraint space */
115 float imtx[3][3]; /* Inverse Matrix of the Constraint space */
116 float pmtx[3][3]; /* Projection Constraint Matrix (same as imtx with some axis == 0) */
117 int imval[2]; /* initial mouse value for visual calculation */
118 /* the one in TransInfo is not garanty to stay the same (Rotates change it) */
119 int mode; /* Mode flags of the Constraint */
120 void (*drawExtra)(struct TransInfo *t);
121 /* For constraints that needs to draw differently from the other
122 * uses this instead of the generic draw function */
123 void (*applyVec)(struct TransInfo *t, struct TransData *td, const float in[3], float out[3], float pvec[3]);
124 /* Apply function pointer for linear vectorial transformation */
125 /* The last three parameters are pointers to the in/out/printable vectors */
126 void (*applySize)(struct TransInfo *t, struct TransData *td, float smat[3][3]);
127 /* Apply function pointer for size transformation */
128 void (*applyRot)(struct TransInfo *t, struct TransData *td, float vec[3], float *angle);
129 /* Apply function pointer for rotation transformation */
132 typedef struct TransDataExtension {
133 float drot[3]; /* Initial object drot */
134 // float drotAngle; /* Initial object drotAngle, TODO: not yet implemented */
135 // float drotAxis[3]; /* Initial object drotAxis, TODO: not yet implemented */
136 float dquat[4]; /* Initial object dquat */
137 float dscale[3]; /* Initial object dscale */
138 float *rot; /* Rotation of the data to transform */
139 float irot[3]; /* Initial rotation */
140 float *quat; /* Rotation quaternion of the data to transform */
141 float iquat[4]; /* Initial rotation quaternion */
142 float *rotAngle; /* Rotation angle of the data to transform */
143 float irotAngle; /* Initial rotation angle */
144 float *rotAxis; /* Rotation axis of the data to transform */
145 float irotAxis[4]; /* Initial rotation axis */
146 float *size; /* Size of the data to transform */
147 float isize[3]; /* Initial size */
148 float obmat[4][4]; /* Object matrix */
149 float l_smtx[3][3]; /* use instead of td->smtx, It is the same but without the 'bone->bone_mat', see TD_PBONE_LOCAL_MTX_C */
150 float r_mtx[3][3]; /* The rotscale matrix of pose bone, to allow using snap-align in translation mode,
151 * when td->mtx is the loc pose bone matrix (and hence can't be used to apply rotation in some cases,
152 * namely when a bone is in "NoLocal" or "Hinge" mode)... */
153 float r_smtx[3][3]; /* Invers of previous one. */
154 int rotOrder; /* rotation mode, as defined in eRotationModes (DNA_action_types.h) */
155 float oloc[3], orot[3], oquat[4], orotAxis[3], orotAngle; /* Original object transformation used for rigid bodies */
156 } TransDataExtension;
158 typedef struct TransData2D {
159 float loc[3]; /* Location of data used to transform (x,y,0) */
160 float *loc2d; /* Pointer to real 2d location of data */
162 float *h1, *h2; /* Pointer to handle locations, if handles aren't being moved independently */
163 float ih1[2], ih2[2];
166 /* we need to store 2 handles for each transdata in case the other handle wasnt selected */
167 typedef struct TransDataCurveHandleFlags {
170 } TransDataCurveHandleFlags;
172 /* for sequencer transform */
173 typedef struct TransDataSeq {
174 struct Sequence *seq;
175 int flag; /* a copy of seq->flag that may be modified for nested strips */
176 int start_offset; /* use this so we can have transform data at the strips start, but apply correctly to the start frame */
177 short sel_flag; /* one of SELECT, SEQ_LEFTSEL and SEQ_RIGHTSEL */
181 typedef struct TransSeq {
188 /* for NLA transform (stored in td->extra pointer) */
189 typedef struct TransDataNla {
190 ID *id; /* ID-block NLA-data is attached to */
192 struct NlaTrack *oldTrack; /* Original NLA-Track that the strip belongs to */
193 struct NlaTrack *nlt; /* Current NLA-Track that the strip belongs to */
195 struct NlaStrip *strip; /* NLA-strip this data represents */
197 /* dummy values for transform to write in - must have 3 elements... */
198 float h1[3]; /* start handle */
199 float h2[3]; /* end handle */
201 int trackIndex; /* index of track that strip is currently in */
202 int handle; /* handle-index: 0 for dummy entry, -1 for start, 1 for end, 2 for both ends */
208 /* header of TransDataEdgeSlideVert, TransDataEdgeSlideEdge */
209 typedef struct TransDataGenericSlideVert {
211 struct LinkNode **cd_loop_groups;
213 } TransDataGenericSlideVert;
215 typedef struct TransDataEdgeSlideVert {
216 /* TransDataGenericSlideVert */
218 struct LinkNode **cd_loop_groups;
224 struct BMVert *v_side[2];
226 /* add origvert.co to get the original locations */
227 float dir_side[2][3];
230 } TransDataEdgeSlideVert;
233 /* store original data so we can correct UV's and similar when sliding */
234 typedef struct SlideOrigData {
235 /* flag that is set when origfaces is initialized */
237 int cd_loop_mdisp_offset;
239 struct GHash *origverts; /* map {BMVert: TransDataGenericSlideVert} */
240 struct GHash *origfaces;
241 struct BMesh *bm_origfaces;
243 struct MemArena *arena;
244 /* number of math BMLoop layers */
245 int layer_math_map_num;
246 /* array size of 'layer_math_map_num'
247 * maps TransDataVertSlideVert.cd_group index to absolute CustomData layer index */
250 /* array of slide vert data especially for mirror verts */
251 TransDataGenericSlideVert *sv_mirror;
255 typedef struct EdgeSlideData {
256 TransDataEdgeSlideVert *sv;
259 int mval_start[2], mval_end[2];
260 struct BMEditMesh *em;
262 SlideOrigData orig_data;
271 /** when un-clamped - use this index: #TransDataEdgeSlideVert.dir_side */
272 int curr_side_unclamp;
276 typedef struct TransDataVertSlideVert {
277 /* TransDataGenericSlideVert */
279 struct LinkNode **cd_loop_groups;
283 float (*co_link_orig_3d)[3];
286 } TransDataVertSlideVert;
288 typedef struct VertSlideData {
289 TransDataVertSlideVert *sv;
292 struct BMEditMesh *em;
294 SlideOrigData orig_data;
303 /* result of ED_view3d_ob_project_mat_get */
304 float proj_mat[4][4];
307 typedef struct BoneInitData {
308 struct EditBone *bone;
318 typedef struct TransData {
319 float dist; /* Distance needed to affect element (for Proportionnal Editing) */
320 float rdist; /* Distance to the nearest element (for Proportionnal Editing) */
321 float factor; /* Factor of the transformation (for Proportionnal Editing) */
322 float *loc; /* Location of the data to transform */
323 float iloc[3]; /* Initial location */
324 float *val; /* Value pointer for special transforms */
325 float ival; /* Old value*/
326 float center[3]; /* Individual data center */
327 float mtx[3][3]; /* Transformation matrix from data space to global space */
328 float smtx[3][3]; /* Transformation matrix from global space to data space */
329 float axismtx[3][3];/* Axis orientation matrix of the data */
331 struct bConstraint *con; /* for objects/bones, the first constraint in its constraint stack */
332 TransDataExtension *ext; /* for objects, poses. 1 single malloc per TransInfo! */
333 TransDataCurveHandleFlags *hdata; /* for curves, stores handle flags for modification/cancel */
334 void *extra; /* extra data (mirrored element pointer, in editmode mesh to BMVert) (editbone for roll fixing) (...) */
335 int flag; /* Various flags */
336 short protectflag; /* If set, copy of Object or PoseChannel protection */
339 typedef struct MouseInput {
340 void (*apply)(struct TransInfo *t, struct MouseInput *mi, const double mval[2], float output[3]);
341 void (*post)(struct TransInfo *t, float values[3]);
343 int imval[2]; /* initial mouse position */
345 float precision_factor;
348 void *data; /* additional data, if needed by the particular function */
351 * Use virtual cursor, which takes precision into account
352 * keeping track of the cursors 'virtual' location,
353 * to avoid jumping values when its toggled.
355 * This works well for scaling drag motion,
356 * but not for rotating around a point (rotaton needs its own custom accumulator)
358 bool use_virtual_mval;
365 typedef struct TransCustomData {
367 void (*free_cb)(struct TransInfo *, struct TransCustomData *);
368 unsigned int use_free : 1;
371 typedef struct TransCenterData {
372 float local[3], global[3];
373 unsigned int is_set : 1;
376 typedef struct TransInfo {
377 int mode; /* current mode */
378 int flag; /* generic flags for special behaviors */
379 int modifiers; /* special modifiers, by function, not key */
380 short state; /* current state (running, canceled,...)*/
381 int options; /* current context/options for transform */
382 float val; /* init value for some transformations (and rotation angle) */
383 void (*transform)(struct TransInfo *, const int[2]);
384 /* transform function pointer */
385 eRedrawFlag (*handleEvent)(struct TransInfo *, const struct wmEvent *);
386 /* event handler function pointer RETURN 1 if redraw is needed */
387 int total; /* total number of transformed data */
388 TransData *data; /* transformed data (array) */
389 TransDataExtension *ext; /* transformed data extension (array) */
390 TransData2D *data2d; /* transformed data for 2d (array) */
391 TransCon con; /* transformed constraint */
393 NumInput num; /* numerical input */
394 MouseInput mouse; /* mouse input */
395 eRedrawFlag redraw; /* redraw flag */
396 float prop_size; /* proportional circle radius */
397 char proptext[20]; /* proportional falloff text */
398 float aspect[3]; /* spaces using non 1:1 aspect, (uv's, f-curve, movie-clip... etc)
399 * use for conversion and snapping. */
400 float center[3]; /* center of transformation (in local-space) */
401 float center_global[3]; /* center of transformation (in global-space) */
402 float center2d[2]; /* center in screen coordinates */
403 /* Lazy initialize center data for when we need other center values.
404 * V3D_AROUND_ACTIVE + 1 (static assert checks this) */
405 TransCenterData center_cache[5];
406 short idx_max; /* maximum index on the input vector */
407 float snap[3]; /* Snapping Gears */
408 float snap_spatial[3]; /* Spatial snapping gears(even when rotating, scaling... etc) */
409 char frame_side; /* Mouse side of the cfra, 'L', 'R' or 'B' */
411 float viewmat[4][4]; /* copy from G.vd, prevents feedback, */
412 float viewinv[4][4]; /* and to make sure we don't have to */
413 float persmat[4][4]; /* access G.vd from other space types */
417 char spacetype; /* spacetype where transforming is */
418 char helpline; /* helpline modes (not to be confused with hotline) */
420 float vec[3]; /* translation, to show for widget */
421 float mat[3][3]; /* rot/rescale, to show for widget */
423 float spacemtx[3][3]; /* orientation matrix of the current space */
424 char spacename[64]; /* name of the current space, MAX_NAME */
426 struct Object *poseobj; /* if t->flag & T_POSE, this denotes pose object */
429 * Rule of thumb for choosing between mode/type:
430 * - If transform mode uses the data, assign to `mode`
431 * (typically in transform.c).
432 * - If conversion uses the data as an extension to the #TransData, assign to `type`
433 * (typically in transform_conversion.c).
436 /* owned by the mode (grab, scale, bend... )*/
438 TransCustomData mode, first_elem;
440 /* owned by the type (mesh, armature, nla...) */
441 TransCustomData type;
443 #define TRANS_CUSTOM_DATA_ELEM_MAX (sizeof(((TransInfo *)NULL)->custom) / sizeof(TransCustomData))
445 /*************** NEW STUFF *********************/
446 short launch_event; /* event type used to launch transform */
448 short current_orientation;
449 short twtype; /* backup from view3d, to restore on end */
456 float auto_values[4];
458 float axis_orig[3]; /* TransCon can change 'axis', store the original value here */
460 bool remove_on_cancel; /* remove elements if operator is canceled */
463 struct bContext *context; /* Only valid (non null) during an operator called function. */
467 struct ToolSettings *settings;
468 struct wmTimer *animtimer;
469 struct wmKeyMap *keymap; /* so we can do lookups for header text */
470 struct ReportList *reports; /* assign from the operator, or can be NULL */
471 int mval[2]; /* current mouse position */
472 float zfac; /* use for 3d view */
473 struct Object *obedit;
474 float obedit_mat[3][3]; /* normalized editmode matrix (T_EDIT only) */
475 void *draw_handle_apply;
476 void *draw_handle_view;
477 void *draw_handle_pixel;
478 void *draw_handle_cursor;
482 /* ******************** Macros & Prototypes *********************** */
484 /* transinfo->state */
485 #define TRANS_STARTING 0
486 #define TRANS_RUNNING 1
487 #define TRANS_CONFIRM 2
488 #define TRANS_CANCEL 3
490 /* transinfo->flag */
491 #define T_OBJECT (1 << 0)
492 #define T_EDIT (1 << 1)
493 #define T_POSE (1 << 2)
494 #define T_TEXTURE (1 << 3)
495 /* transforming the camera while in camera view */
496 #define T_CAMERA (1 << 4)
497 // trans on points, having no rotation/scale
498 #define T_POINTS (1 << 6)
499 // for manipulator exceptions, like scaling using center point, drawing help lines
500 #define T_USES_MANIPULATOR (1 << 7)
502 /* restrictions flags */
503 #define T_ALL_RESTRICTIONS ((1 << 8)|(1 << 9)|(1 << 10))
504 #define T_NO_CONSTRAINT (1 << 8)
505 #define T_NULL_ONE (1 << 9)
506 #define T_NO_ZERO (1 << 10)
508 #define T_PROP_EDIT (1 << 11)
509 #define T_PROP_CONNECTED (1 << 12)
510 #define T_PROP_PROJECTED (1 << 25)
511 #define T_PROP_EDIT_ALL (T_PROP_EDIT | T_PROP_CONNECTED | T_PROP_PROJECTED)
513 #define T_V3D_ALIGN (1 << 14)
514 /* for 2d views like uv or ipo */
515 #define T_2D_EDIT (1 << 15)
516 #define T_CLIP_UV (1 << 16)
519 #define T_AUTOIK (1 << 18)
521 #define T_MIRROR (1 << 19)
523 #define T_AUTOVALUES (1 << 20)
525 /* to specificy if we save back settings at the end */
526 #define T_MODAL (1 << 21)
529 #define T_NO_PROJECT (1 << 22)
531 #define T_RELEASE_CONFIRM (1 << 23)
533 /* alternative transformation. used to add offset to tracking markers */
534 #define T_ALT_TRANSFORM (1 << 24)
536 /** #TransInfo.center has been set, don't change it. */
537 #define T_OVERRIDE_CENTER (1 << 25)
539 /* TransInfo->modifiers */
540 #define MOD_CONSTRAINT_SELECT 0x01
541 #define MOD_PRECISION 0x02
542 #define MOD_SNAP 0x04
543 #define MOD_SNAP_INVERT 0x08
544 #define MOD_CONSTRAINT_PLANE 0x10
546 /* use node center for transform instead of upper-left corner.
547 * disabled since it makes absolute snapping not work so nicely
549 // #define USE_NODE_CENTER
552 /* ******************************************************************************** */
554 /* transinfo->helpline */
560 #define HLP_TRACKBALL 5
562 /* transinfo->con->mode */
567 #define CON_SELECT 16
568 #define CON_NOFLIP 32 /* does not reorient vector to face viewport when on */
571 /* transdata->flag */
572 #define TD_SELECTED 1
573 #define TD_NOACTION (1 << 2)
574 #define TD_USEQUAT (1 << 3)
575 #define TD_NOTCONNECTED (1 << 4)
576 #define TD_SINGLESIZE (1 << 5) /* used for scaling of MetaElem->rad */
577 #define TD_INDIVIDUAL_SCALE (1 << 8) /* Scale relative to individual element center */
578 #define TD_NOCENTER (1 << 9)
579 #define TD_NO_EXT (1 << 10) /* ext abused for particle key timing */
580 #define TD_SKIP (1 << 11) /* don't transform this data */
581 #define TD_BEZTRIPLE (1 << 12) /* if this is a bez triple, we need to restore the handles, if this is set transdata->misc.hdata needs freeing */
582 #define TD_NO_LOC (1 << 13) /* when this is set, don't apply translation changes to this element */
583 #define TD_NOTIMESNAP (1 << 14) /* for Graph Editor autosnap, indicates that point should not undergo autosnapping */
584 #define TD_INTVALUES (1 << 15) /* for Graph Editor - curves that can only have int-values need their keyframes tagged with this */
585 #define TD_MIRROR_EDGE (1 << 16) /* For editmode mirror, clamp to x = 0 */
586 #define TD_MOVEHANDLE1 (1 << 17) /* For fcurve handles, move them along with their keyframes */
587 #define TD_MOVEHANDLE2 (1 << 18)
588 #define TD_PBONE_LOCAL_MTX_P (1 << 19) /* exceptional case with pose bone rotating when a parent bone has 'Local Location' option enabled and rotating also transforms it. */
589 #define TD_PBONE_LOCAL_MTX_C (1 << 20) /* same as above but for a child bone */
591 /* transsnap->status */
592 #define SNAP_FORCED 1
593 #define TARGET_INIT 2
595 #define MULTI_POINTS 8
597 /* Hard min/max for proportional size. */
598 #define T_PROP_SIZE_MIN 1e-6f
599 #define T_PROP_SIZE_MAX 1e12f
601 bool initTransform(struct bContext *C, struct TransInfo *t, struct wmOperator *op, const struct wmEvent *event, int mode);
602 void saveTransform(struct bContext *C, struct TransInfo *t, struct wmOperator *op);
603 int transformEvent(TransInfo *t, const struct wmEvent *event);
604 void transformApply(struct bContext *C, TransInfo *t);
605 int transformEnd(struct bContext *C, TransInfo *t);
607 void setTransformViewMatrices(TransInfo *t);
608 void setTransformViewAspect(TransInfo *t, float r_aspect[3]);
609 void convertViewVec(TransInfo *t, float r_vec[3], double dx, double dy);
610 void projectIntViewEx(TransInfo *t, const float vec[3], int adr[2], const eV3DProjTest flag);
611 void projectIntView(TransInfo *t, const float vec[3], int adr[2]);
612 void projectFloatViewEx(TransInfo *t, const float vec[3], float adr[2], const eV3DProjTest flag);
613 void projectFloatView(TransInfo *t, const float vec[3], float adr[2]);
615 void applyAspectRatio(TransInfo *t, float vec[2]);
616 void removeAspectRatio(TransInfo *t, float vec[2]);
618 void drawPropCircle(const struct bContext *C, TransInfo *t);
620 struct wmKeyMap *transform_modal_keymap(struct wmKeyConfig *keyconf);
623 /*********************** transform_conversions.c ********** */
626 void flushTransIntFrameActionData(TransInfo *t);
627 void flushTransGraphData(TransInfo *t);
628 void remake_graph_transdata(TransInfo *t, struct ListBase *anim_data);
629 void flushTransUVs(TransInfo *t);
630 void flushTransParticles(TransInfo *t);
631 bool clipUVTransform(TransInfo *t, float vec[2], const bool resize);
632 void clipUVData(TransInfo *t);
633 void flushTransNodes(TransInfo *t);
634 void flushTransSeq(TransInfo *t);
635 void flushTransTracking(TransInfo *t);
636 void flushTransMasking(TransInfo *t);
637 void flushTransPaintCurve(TransInfo *t);
638 void restoreBones(TransInfo *t);
640 /*********************** exported from transform_manipulator.c ********** */
641 bool gimbal_axis(struct Object *ob, float gmat[3][3]); /* return 0 when no gimbal for selection */
643 /*********************** TransData Creation and General Handling *********** */
644 void createTransData(struct bContext *C, TransInfo *t);
645 void sort_trans_data_dist(TransInfo *t);
646 void special_aftertrans_update(struct bContext *C, TransInfo *t);
647 int special_transform_moving(TransInfo *t);
649 void transform_autoik_update(TransInfo *t, short mode);
650 bool transdata_check_local_islands(TransInfo *t, short around);
652 int count_set_pose_transflags(int *out_mode, short around, struct Object *ob);
654 /* auto-keying stuff used by special_aftertrans_update */
655 void autokeyframe_ob_cb_func(
656 struct bContext *C, struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode);
657 void autokeyframe_pose_cb_func(
658 struct bContext *C, struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode, short targetless_ik);
660 /*********************** Constraints *****************************/
662 void drawConstraint(TransInfo *t);
664 void getConstraintMatrix(TransInfo *t);
665 void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[]);
666 void setAxisMatrixConstraint(TransInfo *t, int mode, const char text[]);
667 void setLocalConstraint(TransInfo *t, int mode, const char text[]);
668 void setUserConstraint(TransInfo *t, short orientation, int mode, const char text[]);
670 void constraintNumInput(TransInfo *t, float vec[3]);
672 bool isLockConstraint(TransInfo *t);
673 int getConstraintSpaceDimension(TransInfo *t);
674 char constraintModeToChar(TransInfo *t);
676 void startConstraint(TransInfo *t);
677 void stopConstraint(TransInfo *t);
679 void initSelectConstraint(TransInfo *t, float mtx[3][3]);
680 void selectConstraint(TransInfo *t);
681 void postSelectConstraint(TransInfo *t);
683 void setNearestAxis(TransInfo *t);
685 /*********************** Snapping ********************************/
693 void snapGridIncrement(TransInfo *t, float *val);
694 void snapGridIncrementAction(TransInfo *t, float *val, GearsType action);
696 void snapSequenceBounds(TransInfo *t, const int mval[2]);
698 bool activeSnap(TransInfo *t);
699 bool validSnap(TransInfo *t);
701 void initSnapping(struct TransInfo *t, struct wmOperator *op);
702 void freeSnapping(struct TransInfo *t);
703 void applyProject(TransInfo *t);
704 void applyGridAbsolute(TransInfo *t);
705 void applySnapping(TransInfo *t, float *vec);
706 void resetSnapping(TransInfo *t);
707 eRedrawFlag handleSnapping(TransInfo *t, const struct wmEvent *event);
708 void drawSnapping(const struct bContext *C, TransInfo *t);
709 bool usingSnappingNormal(TransInfo *t);
710 bool validSnappingNormal(TransInfo *t);
712 void getSnapPoint(TransInfo *t, float vec[3]);
713 void addSnapPoint(TransInfo *t);
714 eRedrawFlag updateSelectedSnapPoint(TransInfo *t);
715 void removeSnapPoint(TransInfo *t);
717 /********************** Mouse Input ******************************/
728 INPUT_HORIZONTAL_RATIO,
729 INPUT_HORIZONTAL_ABSOLUTE,
730 INPUT_VERTICAL_RATIO,
731 INPUT_VERTICAL_ABSOLUTE,
733 INPUT_CUSTOM_RATIO_FLIP,
736 void initMouseInput(TransInfo *t, MouseInput *mi, const float center[2], const int mval[2], const bool precision);
737 void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode);
738 eRedrawFlag handleMouseInput(struct TransInfo *t, struct MouseInput *mi, const struct wmEvent *event);
739 void applyMouseInput(struct TransInfo *t, struct MouseInput *mi, const int mval[2], float output[3]);
741 void setCustomPoints(TransInfo *t, MouseInput *mi, const int start[2], const int end[2]);
742 void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *t, float values[3]));
744 /*********************** Generics ********************************/
746 void initTransInfo(struct bContext *C, TransInfo *t, struct wmOperator *op, const struct wmEvent *event);
747 void postTrans(struct bContext *C, TransInfo *t);
748 void resetTransModal(TransInfo *t);
749 void resetTransRestrictions(TransInfo *t);
751 void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis, short options);
753 /* DRAWLINE options flags */
756 void applyTransObjects(TransInfo *t);
757 void restoreTransObjects(TransInfo *t);
758 void recalcData(TransInfo *t);
760 void calculateCenter2D(TransInfo *t);
761 void calculateCenterGlobal(
762 TransInfo *t, const float center_local[3],
763 float r_center_global[3]);
765 const TransCenterData *transformCenter_from_type(TransInfo *t, int around);
766 void calculateCenter(TransInfo *t);
768 /* API functions for getting center points */
769 void calculateCenterBound(TransInfo *t, float r_center[3]);
770 void calculateCenterMedian(TransInfo *t, float r_center[3]);
771 void calculateCenterCursor(TransInfo *t, float r_center[3]);
772 void calculateCenterCursor2D(TransInfo *t, float r_center[2]);
773 void calculateCenterCursorGraph2D(TransInfo *t, float r_center[2]);
774 bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3]);
776 void calculatePropRatio(TransInfo *t);
778 void getViewVector(TransInfo *t, float coord[3], float vec[3]);
780 void transform_data_ext_rotate(TransData *td, float mat[3][3], bool use_drot);
782 /*********************** Transform Orientations ******************************/
784 void initTransformOrientation(struct bContext *C, TransInfo *t);
786 /* Those two fill in mat and return non-zero on success */
787 bool createSpaceNormal(float mat[3][3], const float normal[3]);
788 bool createSpaceNormalTangent(float mat[3][3], const float normal[3], const float tangent[3]);
790 struct TransformOrientation *addMatrixSpace(struct bContext *C, float mat[3][3],
791 const char *name, const bool overwrite);
792 bool applyTransformOrientation(const struct bContext *C, float mat[3][3], char r_name[64], int index);
794 #define ORIENTATION_NONE 0
795 #define ORIENTATION_NORMAL 1
796 #define ORIENTATION_VERT 2
797 #define ORIENTATION_EDGE 3
798 #define ORIENTATION_FACE 4
800 int getTransformOrientation_ex(const struct bContext *C, float normal[3], float plane[3], const short around);
801 int getTransformOrientation(const struct bContext *C, float normal[3], float plane[3]);
803 void freeEdgeSlideTempFaces(EdgeSlideData *sld);
804 void freeEdgeSlideVerts(TransInfo *t, TransCustomData *custom_data);
805 void projectEdgeSlideData(TransInfo *t, bool is_final);
807 void freeVertSlideTempFaces(VertSlideData *sld);
808 void freeVertSlideVerts(TransInfo *t, TransCustomData *custom_data);
809 void projectVertSlideData(TransInfo *t, bool is_final);
812 /* TODO. transform_queries.c */
813 bool checkUseAxisMatrix(TransInfo *t);
815 #define TRANSFORM_DIST_MAX_PX 1000.0f
816 #define TRANSFORM_SNAP_MAX_PX 100.0f
817 #define TRANSFORM_DIST_INVALID -FLT_MAX