|
Blender
V2.59
|
00001 /* 00002 * $Id: transform.h 39156 2011-08-07 17:01:44Z merwin $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00021 * All rights reserved. 00022 * 00023 * The Original Code is: all of this file. 00024 * 00025 * Contributor(s): none yet. 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 00035 #ifndef TRANSFORM_H 00036 #define TRANSFORM_H 00037 00038 #include "ED_transform.h" 00039 #include "ED_numinput.h" 00040 00041 #include "DNA_listBase.h" 00042 00043 #include "BLI_editVert.h" 00044 00045 /* ************************** Types ***************************** */ 00046 00047 struct TransInfo; 00048 struct TransData; 00049 struct TransformOrientation; 00050 struct TransSnap; 00051 struct NumInput; 00052 struct Object; 00053 struct View3D; 00054 struct ScrArea; 00055 struct Scene; 00056 struct bPose; 00057 struct bConstraint; 00058 struct BezTriple; 00059 struct wmOperatorType; 00060 struct wmOperator; 00061 struct wmWindowManager; 00062 struct wmKeyMap; 00063 struct wmKeyConfig; 00064 struct bContext; 00065 struct wmEvent; 00066 struct wmTimer; 00067 struct ARegion; 00068 struct ReportList; 00069 00070 /* 00071 The ctrl value has different meaning: 00072 0 : No value has been typed 00073 00074 otherwise, |value| - 1 is where the cursor is located after the period 00075 Positive : number is positive 00076 Negative : number is negative 00077 */ 00078 00079 typedef struct TransSnapPoint { 00080 struct TransSnapPoint *next,*prev; 00081 float co[3]; 00082 } TransSnapPoint; 00083 00084 typedef struct TransSnap { 00085 short mode; 00086 short target; 00087 short modePoint; 00088 short modeSelect; 00089 short align; 00090 char project; 00091 char snap_self; 00092 short peel; 00093 short status; 00094 float snapPoint[3]; /* snapping from this point */ 00095 float snapTarget[3]; /* to this point */ 00096 float snapNormal[3]; 00097 float snapTangent[3]; 00098 ListBase points; 00099 float dist; // Distance from snapPoint to snapTarget 00100 double last; 00101 void (*applySnap)(struct TransInfo *, float *); 00102 void (*calcSnap)(struct TransInfo *, float *); 00103 void (*targetSnap)(struct TransInfo *); 00104 float (*distance)(struct TransInfo *, float p1[3], float p2[3]); // Get the transform distance between two points (used by Closest snap) 00105 } TransSnap; 00106 00107 typedef struct TransCon { 00108 short orientation; 00109 char text[50]; /* Description of the Constraint for header_print */ 00110 float mtx[3][3]; /* Matrix of the Constraint space */ 00111 float imtx[3][3]; /* Inverse Matrix of the Constraint space */ 00112 float pmtx[3][3]; /* Projection Constraint Matrix (same as imtx with some axis == 0) */ 00113 float center[3]; /* transformation center to define where to draw the view widget 00114 ALWAYS in global space. Unlike the transformation center */ 00115 int imval[2]; /* initial mouse value for visual calculation */ 00116 /* the one in TransInfo is not garanty to stay the same (Rotates change it) */ 00117 int mode; /* Mode flags of the Constraint */ 00118 void (*drawExtra)(struct TransInfo *); 00119 /* For constraints that needs to draw differently from the other 00120 uses this instead of the generic draw function */ 00121 void (*applyVec)(struct TransInfo *, struct TransData *, float *, float *, float *); 00122 /* Apply function pointer for linear vectorial transformation */ 00123 /* The last three parameters are pointers to the in/out/printable vectors */ 00124 void (*applySize)(struct TransInfo *, struct TransData *, float [3][3]); 00125 /* Apply function pointer for size transformation */ 00126 void (*applyRot)(struct TransInfo *, struct TransData *, float [3], float *); 00127 /* Apply function pointer for rotation transformation */ 00128 } TransCon; 00129 00130 typedef struct TransDataExtension { 00131 float drot[3]; /* Initial object drot */ 00132 // float drotAngle; /* Initial object drotAngle, TODO: not yet implimented */ 00133 // float drotAxis[3]; /* Initial object drotAxis, TODO: not yet implimented */ 00134 float dquat[4]; /* Initial object dquat */ 00135 float dsize[3]; /* Initial object dsize */ 00136 float *rot; /* Rotation of the data to transform (Faculative) */ 00137 float irot[3]; /* Initial rotation */ 00138 float *quat; /* Rotation quaternion of the data to transform (Faculative) */ 00139 float iquat[4]; /* Initial rotation quaternion */ 00140 float *rotAngle; /* Rotation angle of the data to transform (Faculative) */ 00141 float irotAngle; /* Initial rotation angle */ 00142 float *rotAxis; /* Rotation axis of the data to transform (Faculative) */ 00143 float irotAxis[4]; /* Initial rotation axis */ 00144 float *size; /* Size of the data to transform (Faculative) */ 00145 float isize[3]; /* Initial size */ 00146 float obmat[4][4]; /* Object matrix */ 00147 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 */ 00148 int rotOrder; /* rotation mode, as defined in eRotationModes (DNA_action_types.h) */ 00149 } TransDataExtension; 00150 00151 typedef struct TransData2D { 00152 float loc[3]; /* Location of data used to transform (x,y,0) */ 00153 float *loc2d; /* Pointer to real 2d location of data */ 00154 00155 float *h1, *h2; /* Pointer to handle locations, if handles aren't being moved independantly*/ 00156 float ih1[2], ih2[2]; 00157 } TransData2D; 00158 00159 /* we need to store 2 handles for each transdata incase the other handle wasnt selected */ 00160 typedef struct TransDataCurveHandleFlags { 00161 char ih1, ih2; 00162 char *h1, *h2; 00163 } TransDataCurveHandleFlags; 00164 00165 /* for sequencer transform */ 00166 typedef struct TransDataSeq { 00167 struct Sequence *seq; 00168 int flag; /* a copy of seq->flag that may be modified for nested strips */ 00169 int start_offset; /* use this so we can have transform data at the strips start, but apply correctly to the start frame */ 00170 short sel_flag; /* one of SELECT, SEQ_LEFTSEL and SEQ_RIGHTSEL */ 00171 00172 } TransDataSeq; 00173 00174 /* for NLA transform (stored in td->extra pointer) */ 00175 typedef struct TransDataNla { 00176 ID *id; /* ID-block NLA-data is attached to */ 00177 00178 struct NlaTrack *oldTrack; /* Original NLA-Track that the strip belongs to */ 00179 struct NlaTrack *nlt; /* Current NLA-Track that the strip belongs to */ 00180 00181 struct NlaStrip *strip; /* NLA-strip this data represents */ 00182 00183 /* dummy values for transform to write in - must have 3 elements... */ 00184 float h1[3]; /* start handle */ 00185 float h2[3]; /* end handle */ 00186 00187 int trackIndex; /* index of track that strip is currently in */ 00188 int handle; /* handle-index: 0 for dummy entry, -1 for start, 1 for end, 2 for both ends */ 00189 } TransDataNla; 00190 00191 struct LinkNode; 00192 struct EditEdge; 00193 struct EditVert; 00194 struct GHash; 00195 typedef struct TransDataSlideUv { 00196 float origuv[2]; 00197 float *uv_up, *uv_down; 00198 //float *fuv[4]; 00199 struct LinkNode *fuv_list; 00200 } TransDataSlideUv; 00201 00202 typedef struct TransDataSlideVert { 00203 struct EditEdge *up, *down; 00204 struct EditVert origvert; 00205 } TransDataSlideVert; 00206 00207 typedef struct SlideData { 00208 TransDataSlideUv *slideuv, *suv_last; 00209 int totuv, uvlay_tot; 00210 struct GHash *vhash, **uvhash; 00211 struct EditVert *nearest; 00212 struct LinkNode *edgelist, *vertlist; 00213 int start[2], end[2]; 00214 } SlideData; 00215 00216 typedef struct TransData { 00217 float dist; /* Distance needed to affect element (for Proportionnal Editing) */ 00218 float rdist; /* Distance to the nearest element (for Proportionnal Editing) */ 00219 float factor; /* Factor of the transformation (for Proportionnal Editing) */ 00220 float *loc; /* Location of the data to transform */ 00221 float iloc[3]; /* Initial location */ 00222 float *val; /* Value pointer for special transforms */ 00223 float ival; /* Old value*/ 00224 float center[3]; /* Individual data center */ 00225 float mtx[3][3]; /* Transformation matrix from data space to global space */ 00226 float smtx[3][3]; /* Transformation matrix from global space to data space */ 00227 float axismtx[3][3];/* Axis orientation matrix of the data */ 00228 struct Object *ob; 00229 struct bConstraint *con; /* for objects/bones, the first constraint in its constraint stack */ 00230 TransDataExtension *ext; /* for objects, poses. 1 single malloc per TransInfo! */ 00231 TransDataCurveHandleFlags *hdata; /* for curves, stores handle flags for modification/cancel */ 00232 void *extra; /* extra data (mirrored element pointer, in editmode mesh to EditVert) (editbone for roll fixing) (...) */ 00233 int flag; /* Various flags */ 00234 short protectflag; /* If set, copy of Object or PoseChannel protection */ 00235 } TransData; 00236 00237 typedef struct MouseInput { 00238 void (*apply)(struct TransInfo *, struct MouseInput *, const int [2], float [3]); 00239 void (*post)(struct TransInfo *, float [3]); 00240 00241 int imval[2]; /* initial mouse position */ 00242 char precision; 00243 int precision_mval[2]; /* mouse position when precision key was pressed */ 00244 int center[2]; 00245 float factor; 00246 void *data; /* additional data, if needed by the particular function */ 00247 } MouseInput; 00248 00249 typedef struct TransInfo { 00250 int mode; /* current mode */ 00251 int flag; /* generic flags for special behaviors */ 00252 int modifiers; /* special modifiers, by function, not key */ 00253 short state; /* current state (running, canceled,...)*/ 00254 int options; /* current context/options for transform */ 00255 float val; /* init value for some transformations (and rotation angle) */ 00256 float fac; /* factor for distance based transform */ 00257 int (*transform)(struct TransInfo *, const int *); 00258 /* transform function pointer */ 00259 int (*handleEvent)(struct TransInfo *, struct wmEvent *); 00260 /* event handler function pointer RETURN 1 if redraw is needed */ 00261 int total; /* total number of transformed data */ 00262 TransData *data; /* transformed data (array) */ 00263 TransDataExtension *ext; /* transformed data extension (array) */ 00264 TransData2D *data2d; /* transformed data for 2d (array) */ 00265 TransCon con; /* transformed constraint */ 00266 TransSnap tsnap; 00267 NumInput num; /* numerical input */ 00268 MouseInput mouse; /* mouse input */ 00269 char redraw; /* redraw flag */ 00270 float prop_size; /* proportional circle radius */ 00271 char proptext[20]; /* proportional falloff text */ 00272 float center[3]; /* center of transformation */ 00273 int center2d[2]; /* center in screen coordinates */ 00274 int imval[2]; /* initial mouse position */ 00275 short event_type; /* event->type used to invoke transform */ 00276 short idx_max; /* maximum index on the input vector */ 00277 float snap[3]; /* Snapping Gears */ 00278 char frame_side; /* Mouse side of the cfra, 'L', 'R' or 'B' */ 00279 00280 float viewmat[4][4]; /* copy from G.vd, prevents feedback, */ 00281 float viewinv[4][4]; /* and to make sure we don't have to */ 00282 float persmat[4][4]; /* access G.vd from other space types */ 00283 float persinv[4][4]; 00284 short persp; 00285 short around; 00286 char spacetype; /* spacetype where transforming is */ 00287 char helpline; /* helpline modes (not to be confused with hotline) */ 00288 00289 float vec[3]; /* translation, to show for widget */ 00290 float mat[3][3]; /* rot/rescale, to show for widget */ 00291 00292 char *undostr; /* if set, uses this string for undo */ 00293 float spacemtx[3][3]; /* orientation matrix of the current space */ 00294 char spacename[32]; /* name of the current space */ 00295 00296 struct Object *poseobj; /* if t->flag & T_POSE, this denotes pose object */ 00297 00298 void *customData; /* Per Transform custom data */ 00299 void (*customFree)(struct TransInfo *); /* if a special free function is needed */ 00300 00301 /*************** NEW STUFF *********************/ 00302 short launch_event; /* event type used to launch transform */ 00303 00304 short current_orientation; 00305 short twtype; /* backup from view3d, to restore on end */ 00306 00307 short prop_mode; 00308 00309 short mirror; 00310 00311 float values[4]; 00312 float auto_values[4]; 00313 float axis[3]; 00314 float axis_orig[3]; /* TransCon can change 'axis', store the original value here */ 00315 00316 void *view; 00317 struct bContext *context; /* Only valid (non null) during an operator called function. */ 00318 struct ScrArea *sa; 00319 struct ARegion *ar; 00320 struct Scene *scene; 00321 struct ToolSettings *settings; 00322 struct wmTimer *animtimer; 00323 int mval[2]; /* current mouse position */ 00324 struct Object *obedit; 00325 void *draw_handle_apply; 00326 void *draw_handle_view; 00327 void *draw_handle_pixel; 00328 void *draw_handle_cursor; 00329 } TransInfo; 00330 00331 00332 /* ******************** Macros & Prototypes *********************** */ 00333 00334 /* transinfo->state */ 00335 #define TRANS_STARTING 0 00336 #define TRANS_RUNNING 1 00337 #define TRANS_CONFIRM 2 00338 #define TRANS_CANCEL 3 00339 00340 /* transinfo->redraw */ 00341 #define TREDRAW_NOTHING 0 00342 #define TREDRAW_HARD 1 00343 #define TREDRAW_SOFT 2 00344 00345 00346 /* transinfo->flag */ 00347 #define T_OBJECT (1 << 0) 00348 #define T_EDIT (1 << 1) 00349 #define T_POSE (1 << 2) 00350 #define T_TEXTURE (1 << 3) 00351 #define T_CAMERA (1 << 4) 00352 // trans on points, having no rotation/scale 00353 #define T_POINTS (1 << 6) 00354 // for manipulator exceptions, like scaling using center point, drawing help lines 00355 #define T_USES_MANIPULATOR (1 << 7) 00356 00357 /* restrictions flags */ 00358 #define T_ALL_RESTRICTIONS ((1 << 8)|(1 << 9)|(1 << 10)) 00359 #define T_NO_CONSTRAINT (1 << 8) 00360 #define T_NULL_ONE (1 << 9) 00361 #define T_NO_ZERO (1 << 10) 00362 00363 #define T_PROP_EDIT (1 << 11) 00364 #define T_PROP_CONNECTED (1 << 12) 00365 00366 #define T_V3D_ALIGN (1 << 14) 00367 /* for 2d views like uv or ipo */ 00368 #define T_2D_EDIT (1 << 15) 00369 #define T_CLIP_UV (1 << 16) 00370 00371 #define T_FREE_CUSTOMDATA (1 << 17) 00372 /* auto-ik is on */ 00373 #define T_AUTOIK (1 << 18) 00374 00375 #define T_MIRROR (1 << 19) 00376 00377 #define T_AUTOVALUES (1 << 20) 00378 00379 /* to specificy if we save back settings at the end */ 00380 #define T_MODAL (1 << 21) 00381 00382 /* no retopo */ 00383 #define T_NO_PROJECT (1 << 22) 00384 00385 #define T_RELEASE_CONFIRM (1 << 23) 00386 00387 /* TransInfo->modifiers */ 00388 #define MOD_CONSTRAINT_SELECT 0x01 00389 #define MOD_PRECISION 0x02 00390 #define MOD_SNAP 0x04 00391 #define MOD_SNAP_INVERT 0x08 00392 #define MOD_CONSTRAINT_PLANE 0x10 00393 00394 00395 /* ******************************************************************************** */ 00396 00397 /* transinfo->helpline */ 00398 #define HLP_NONE 0 00399 #define HLP_SPRING 1 00400 #define HLP_ANGLE 2 00401 #define HLP_HARROW 3 00402 #define HLP_VARROW 4 00403 #define HLP_TRACKBALL 5 00404 00405 /* transinfo->con->mode */ 00406 #define CON_APPLY 1 00407 #define CON_AXIS0 2 00408 #define CON_AXIS1 4 00409 #define CON_AXIS2 8 00410 #define CON_SELECT 16 00411 #define CON_NOFLIP 32 /* does not reorient vector to face viewport when on */ 00412 #define CON_USER 64 00413 00414 /* transdata->flag */ 00415 #define TD_SELECTED 1 00416 #define TD_ACTIVE (1 << 1) 00417 #define TD_NOACTION (1 << 2) 00418 #define TD_USEQUAT (1 << 3) 00419 #define TD_NOTCONNECTED (1 << 4) 00420 #define TD_SINGLESIZE (1 << 5) /* used for scaling of MetaElem->rad */ 00421 /*#define TD_TIMEONLY (1 << 8) */ /*UNUSED*/ 00422 #define TD_NOCENTER (1 << 9) 00423 #define TD_NO_EXT (1 << 10) /* ext abused for particle key timing */ 00424 #define TD_SKIP (1 << 11) /* don't transform this data */ 00425 #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 */ 00426 #define TD_NO_LOC (1 << 13) /* when this is set, don't apply translation changes to this element */ 00427 #define TD_NOTIMESNAP (1 << 14) /* for Graph Editor autosnap, indicates that point should not undergo autosnapping */ 00428 #define TD_INTVALUES (1 << 15) /* for Graph Editor - curves that can only have int-values need their keyframes tagged with this */ 00429 #define TD_MIRROR_EDGE (1 << 16) /* For editmode mirror, clamp to x = 0 */ 00430 #define TD_MOVEHANDLE1 (1 << 17) /* For fcurve handles, move them along with their keyframes */ 00431 #define TD_MOVEHANDLE2 (1 << 18) 00432 #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. */ 00433 #define TD_PBONE_LOCAL_MTX_C (1 << 20) /* same as above but for a child bone */ 00434 00435 /* transsnap->status */ 00436 #define SNAP_FORCED 1 00437 #define TARGET_INIT 2 00438 #define POINT_INIT 4 00439 #define MULTI_POINTS 8 00440 00441 void TRANSFORM_OT_transform(struct wmOperatorType *ot); 00442 00443 int initTransform(struct bContext *C, struct TransInfo *t, struct wmOperator *op, struct wmEvent *event, int mode); 00444 void saveTransform(struct bContext *C, struct TransInfo *t, struct wmOperator *op); 00445 int transformEvent(TransInfo *t, struct wmEvent *event); 00446 void transformApply(struct bContext *C, TransInfo *t); 00447 int transformEnd(struct bContext *C, TransInfo *t); 00448 00449 void setTransformViewMatrices(TransInfo *t); 00450 void convertViewVec(TransInfo *t, float *vec, int dx, int dy); 00451 void projectIntView(TransInfo *t, float *vec, int *adr); 00452 void projectFloatView(TransInfo *t, float *vec, float *adr); 00453 00454 void applyAspectRatio(TransInfo *t, float *vec); 00455 void removeAspectRatio(TransInfo *t, float *vec); 00456 00457 void initWarp(TransInfo *t); 00458 int handleEventWarp(TransInfo *t, struct wmEvent *event); 00459 int Warp(TransInfo *t, const int mval[2]); 00460 00461 void initShear(TransInfo *t); 00462 int handleEventShear(TransInfo *t, struct wmEvent *event); 00463 int Shear(TransInfo *t, const int mval[2]); 00464 00465 void initResize(TransInfo *t); 00466 int Resize(TransInfo *t, const int mval[2]); 00467 00468 void initTranslation(TransInfo *t); 00469 int Translation(TransInfo *t, const int mval[2]); 00470 00471 void initToSphere(TransInfo *t); 00472 int ToSphere(TransInfo *t, const int mval[2]); 00473 00474 void initRotation(TransInfo *t); 00475 int Rotation(TransInfo *t, const int mval[2]); 00476 00477 void initShrinkFatten(TransInfo *t); 00478 int ShrinkFatten(TransInfo *t, const int mval[2]); 00479 00480 void initTilt(TransInfo *t); 00481 int Tilt(TransInfo *t, const int mval[2]); 00482 00483 void initCurveShrinkFatten(TransInfo *t); 00484 int CurveShrinkFatten(TransInfo *t, const int mval[2]); 00485 00486 void initTrackball(TransInfo *t); 00487 int Trackball(TransInfo *t, const int mval[2]); 00488 00489 void initPushPull(TransInfo *t); 00490 int PushPull(TransInfo *t, const int mval[2]); 00491 00492 void initBevel(TransInfo *t); 00493 int handleEventBevel(TransInfo *t, struct wmEvent *event); 00494 int Bevel(TransInfo *t, const int mval[2]); 00495 00496 void initBevelWeight(TransInfo *t); 00497 int BevelWeight(TransInfo *t, const int mval[2]); 00498 00499 void initCrease(TransInfo *t); 00500 int Crease(TransInfo *t, const int mval[2]); 00501 00502 void initBoneSize(TransInfo *t); 00503 int BoneSize(TransInfo *t, const int mval[2]); 00504 00505 void initBoneEnvelope(TransInfo *t); 00506 int BoneEnvelope(TransInfo *t, const int mval[2]); 00507 00508 void initBoneRoll(TransInfo *t); 00509 int BoneRoll(TransInfo *t, const int mval[2]); 00510 00511 void initEdgeSlide(TransInfo *t); 00512 int EdgeSlide(TransInfo *t, const int mval[2]); 00513 00514 void initTimeTranslate(TransInfo *t); 00515 int TimeTranslate(TransInfo *t, const int mval[2]); 00516 00517 void initTimeSlide(TransInfo *t); 00518 int TimeSlide(TransInfo *t, const int mval[2]); 00519 00520 void initTimeScale(TransInfo *t); 00521 int TimeScale(TransInfo *t, const int mval[2]); 00522 00523 void initBakeTime(TransInfo *t); 00524 int BakeTime(TransInfo *t, const int mval[2]); 00525 00526 void initMirror(TransInfo *t); 00527 int Mirror(TransInfo *t, const int mval[2]); 00528 00529 void initAlign(TransInfo *t); 00530 int Align(TransInfo *t, const int mval[2]); 00531 00532 void initSeqSlide(TransInfo *t); 00533 int SeqSlide(TransInfo *t, const int mval[2]); 00534 00535 void drawPropCircle(const struct bContext *C, TransInfo *t); 00536 00537 struct wmKeyMap *transform_modal_keymap(struct wmKeyConfig *keyconf); 00538 00539 00540 /*********************** transform_conversions.c ********** */ 00541 struct ListBase; 00542 00543 void flushTransGPactionData(TransInfo *t); 00544 void flushTransGraphData(TransInfo *t); 00545 void remake_graph_transdata(TransInfo *t, struct ListBase *anim_data); 00546 void flushTransUVs(TransInfo *t); 00547 void flushTransParticles(TransInfo *t); 00548 int clipUVTransform(TransInfo *t, float *vec, int resize); 00549 void flushTransNodes(TransInfo *t); 00550 void flushTransSeq(TransInfo *t); 00551 00552 /*********************** exported from transform_manipulator.c ********** */ 00553 int gimbal_axis(struct Object *ob, float gmat[][3]); /* return 0 when no gimbal for selection */ 00554 int calc_manipulator_stats(const struct bContext *C); 00555 00556 /*********************** TransData Creation and General Handling *********** */ 00557 void createTransData(struct bContext *C, TransInfo *t); 00558 void sort_trans_data_dist(TransInfo *t); 00559 void add_tdi_poin(float *poin, float *old, float delta); 00560 void special_aftertrans_update(struct bContext *C, TransInfo *t); 00561 00562 void transform_autoik_update(TransInfo *t, short mode); 00563 00564 int count_set_pose_transflags(int *out_mode, short around, struct Object *ob); 00565 00566 /* auto-keying stuff used by special_aftertrans_update */ 00567 void autokeyframe_ob_cb_func(struct bContext *C, struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode); 00568 void autokeyframe_pose_cb_func(struct bContext *C, struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode, short targetless_ik); 00569 00570 /*********************** Constraints *****************************/ 00571 00572 void drawConstraint(TransInfo *t); 00573 00574 void getConstraintMatrix(TransInfo *t); 00575 void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[]); 00576 void setLocalConstraint(TransInfo *t, int mode, const char text[]); 00577 void setUserConstraint(TransInfo *t, short orientation, int mode, const char text[]); 00578 00579 void constraintNumInput(TransInfo *t, float vec[3]); 00580 00581 int isLockConstraint(TransInfo *t); 00582 int getConstraintSpaceDimension(TransInfo *t); 00583 char constraintModeToChar(TransInfo *t); 00584 00585 void startConstraint(TransInfo *t); 00586 void stopConstraint(TransInfo *t); 00587 00588 void initSelectConstraint(TransInfo *t, float mtx[3][3]); 00589 void selectConstraint(TransInfo *t); 00590 void postSelectConstraint(TransInfo *t); 00591 00592 void setNearestAxis(TransInfo *t); 00593 00594 /*********************** Snapping ********************************/ 00595 00596 typedef enum { 00597 NO_GEARS = 0, 00598 BIG_GEARS = 1, 00599 SMALL_GEARS = 2 00600 } GearsType; 00601 00602 void snapGrid(TransInfo *t, float *val); 00603 void snapGridAction(TransInfo *t, float *val, GearsType action); 00604 00605 int activeSnap(TransInfo *t); 00606 int validSnap(TransInfo *t); 00607 00608 void initSnapping(struct TransInfo *t, struct wmOperator *op); 00609 void applyProject(TransInfo *t); 00610 void applySnapping(TransInfo *t, float *vec); 00611 void resetSnapping(TransInfo *t); 00612 int handleSnapping(TransInfo *t, struct wmEvent *event); 00613 void drawSnapping(const struct bContext *C, TransInfo *t); 00614 int usingSnappingNormal(TransInfo *t); 00615 int validSnappingNormal(TransInfo *t); 00616 00617 void getSnapPoint(TransInfo *t, float vec[3]); 00618 void addSnapPoint(TransInfo *t); 00619 void removeSnapPoint(TransInfo *t); 00620 00621 /********************** Mouse Input ******************************/ 00622 00623 typedef enum { 00624 INPUT_NONE, 00625 INPUT_VECTOR, 00626 INPUT_SPRING, 00627 INPUT_SPRING_FLIP, 00628 INPUT_ANGLE, 00629 INPUT_TRACKBALL, 00630 INPUT_HORIZONTAL_RATIO, 00631 INPUT_HORIZONTAL_ABSOLUTE, 00632 INPUT_VERTICAL_RATIO, 00633 INPUT_VERTICAL_ABSOLUTE, 00634 INPUT_CUSTOM_RATIO 00635 } MouseInputMode; 00636 00637 void initMouseInput(TransInfo *t, MouseInput *mi, int center[2], int mval[2]); 00638 void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode); 00639 int handleMouseInput(struct TransInfo *t, struct MouseInput *mi, struct wmEvent *event); 00640 void applyMouseInput(struct TransInfo *t, struct MouseInput *mi, const int mval[2], float output[3]); 00641 00642 void setCustomPoints(TransInfo *t, MouseInput *mi, int start[2], int end[2]); 00643 void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *, float [3])); 00644 00645 /*********************** Generics ********************************/ 00646 00647 int initTransInfo(struct bContext *C, TransInfo *t, struct wmOperator *op, struct wmEvent *event); 00648 void postTrans (struct bContext *C, TransInfo *t); 00649 void resetTransRestrictions(TransInfo *t); 00650 00651 void drawLine(TransInfo *t, float *center, float *dir, char axis, short options); 00652 00653 TransDataCurveHandleFlags *initTransDataCurveHandes(TransData *td, struct BezTriple *bezt); 00654 00655 /* DRAWLINE options flags */ 00656 #define DRAWLIGHT 1 00657 00658 void applyTransObjects(TransInfo *t); 00659 void restoreTransObjects(TransInfo *t); 00660 void restoreTransNodes(TransInfo *t); 00661 void recalcData(TransInfo *t); 00662 00663 void calculateCenter(TransInfo *t); 00664 void calculateCenter2D(TransInfo *t); 00665 void calculateCenterBound(TransInfo *t); 00666 void calculateCenterMedian(TransInfo *t); 00667 void calculateCenterCursor(TransInfo *t); 00668 00669 void calculateCenterCursor2D(TransInfo *t); 00670 void calculatePropRatio(TransInfo *t); 00671 00672 void getViewVector(TransInfo *t, float coord[3], float vec[3]); 00673 00674 /*********************** Transform Orientations ******************************/ 00675 00676 void initTransformOrientation(struct bContext *C, TransInfo *t); 00677 00678 struct TransformOrientation *createObjectSpace(struct bContext *C, struct ReportList *reports, char *name, int overwrite); 00679 struct TransformOrientation *createMeshSpace(struct bContext *C, struct ReportList *reports, char *name, int overwrite); 00680 struct TransformOrientation *createBoneSpace(struct bContext *C, struct ReportList *reports, char *name, int overwrite); 00681 00682 /* Those two fill in mat and return non-zero on success */ 00683 int createSpaceNormal(float mat[3][3], float normal[3]); 00684 int createSpaceNormalTangent(float mat[3][3], float normal[3], float tangent[3]); 00685 00686 struct TransformOrientation *addMatrixSpace(struct bContext *C, float mat[3][3], char name[], int overwrite); 00687 int addObjectSpace(struct bContext *C, struct Object *ob); 00688 void applyTransformOrientation(const struct bContext *C, float mat[3][3], char *name); 00689 00690 #define ORIENTATION_NONE 0 00691 #define ORIENTATION_NORMAL 1 00692 #define ORIENTATION_VERT 2 00693 #define ORIENTATION_EDGE 3 00694 #define ORIENTATION_FACE 4 00695 00696 int getTransformOrientation(const struct bContext *C, float normal[3], float plane[3], int activeOnly); 00697 00698 void freeSlideVerts(TransInfo *t); 00699 00700 #endif