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