diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-05-13 07:56:51 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-05-13 07:56:51 +0300 |
commit | 59c6487e9314dd43003af1a018fc092b041e7e10 (patch) | |
tree | de8cc7dd06b875d174cb79cad7558874c8bffa5e /source/blender/editors/transform/transform.c | |
parent | 7a56d31af3523081e33a67d7aea11314c37c7104 (diff) | |
parent | b99d064e9142b2e9d790731f4c4c6c107ca43696 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/editors/transform/transform.c')
-rw-r--r-- | source/blender/editors/transform/transform.c | 452 |
1 files changed, 226 insertions, 226 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 632779d50a4..405c6213017 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -652,7 +652,7 @@ static void viewRedrawForce(const bContext *C, TransInfo *t) static void viewRedrawPost(bContext *C, TransInfo *t) { ED_area_headerprint(t->sa, NULL); - + if (t->spacetype == SPACE_VIEW3D) { /* if autokeying is enabled, send notifiers that keyframes were added */ if (IS_AUTOKEY_ON(t->scene)) @@ -664,12 +664,12 @@ static void viewRedrawPost(bContext *C, TransInfo *t) { WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL); } - + /* XXX temp, first hack to get auto-render in compositor work (ton) */ WM_event_add_notifier(C, NC_SCENE | ND_TRANSFORM_DONE, CTX_data_scene(C)); } - + #if 0 // TRANSFORM_FIX_ME if (t->spacetype == SPACE_VIEW3D) { allqueue(REDRAWBUTSOBJECT, 0); @@ -845,14 +845,14 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) {TFM_MODAL_INSERTOFS_TOGGLE_DIR, "INSERTOFS_TOGGLE_DIR", 0, "Toggle Direction for Node Auto-offset", ""}, {0, NULL, 0, NULL, NULL} }; - + wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Transform Modal Map"); - + /* this function is called for each spacetype, only needs to add map once */ if (keymap && keymap->modal_items) return NULL; - + keymap = WM_modalkeymap_add(keyconf, "Transform Modal Map", modal_items); - + /* items for modal map */ WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_CANCEL); WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM); @@ -862,7 +862,7 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) WM_modalkeymap_add_item(keymap, GKEY, KM_PRESS, 0, 0, TFM_MODAL_TRANSLATE); WM_modalkeymap_add_item(keymap, RKEY, KM_PRESS, 0, 0, TFM_MODAL_ROTATE); WM_modalkeymap_add_item(keymap, SKEY, KM_PRESS, 0, 0, TFM_MODAL_RESIZE); - + WM_modalkeymap_add_item(keymap, TABKEY, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_SNAP_TOGGLE); WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_SNAP_INV_ON); @@ -870,7 +870,7 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) WM_modalkeymap_add_item(keymap, RIGHTCTRLKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_SNAP_INV_ON); WM_modalkeymap_add_item(keymap, RIGHTCTRLKEY, KM_RELEASE, KM_ANY, 0, TFM_MODAL_SNAP_INV_OFF); - + WM_modalkeymap_add_item(keymap, AKEY, KM_PRESS, 0, 0, TFM_MODAL_ADD_SNAP); WM_modalkeymap_add_item(keymap, AKEY, KM_PRESS, KM_ALT, 0, TFM_MODAL_REMOVE_SNAP); @@ -886,7 +886,7 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) WM_modalkeymap_add_item(keymap, WHEELDOWNMOUSE, KM_PRESS, KM_ALT, 0, TFM_MODAL_EDGESLIDE_UP); WM_modalkeymap_add_item(keymap, WHEELUPMOUSE, KM_PRESS, KM_ALT, 0, TFM_MODAL_EDGESLIDE_DOWN); - + WM_modalkeymap_add_item(keymap, PAGEUPKEY, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_AUTOIK_LEN_INC); WM_modalkeymap_add_item(keymap, PAGEDOWNKEY, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_AUTOIK_LEN_DEC); WM_modalkeymap_add_item(keymap, WHEELDOWNMOUSE, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_AUTOIK_LEN_INC); @@ -905,7 +905,7 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm const bool edit_2d = (t->flag & T_2D_EDIT) != 0; const char *msg1 = "", *msg2 = "", *msg3 = ""; char axis; - + /* Initialize */ switch (key_type) { case XKEY: @@ -1078,7 +1078,7 @@ int transformEvent(TransInfo *t, const wmEvent *event) restoreTransObjects(t); resetTransModal(t); resetTransRestrictions(t); - + if (t->mode == TFM_ROTATION) { initTrackball(t); } @@ -1123,7 +1123,7 @@ int transformEvent(TransInfo *t, const wmEvent *event) } } break; - + case TFM_MODAL_SNAP_INV_ON: t->modifiers |= MOD_SNAP_INVERT; t->redraw |= TREDRAW_HARD; @@ -1705,7 +1705,7 @@ static void drawArc(float size, float angle_start, float angle_end, int segments static int helpline_poll(bContext *C) { ARegion *ar = CTX_wm_region(C); - + if (ar && ar->regiontype == RGN_TYPE_WINDOW) return 1; return 0; @@ -1867,7 +1867,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) static void drawTransformView(const struct bContext *C, ARegion *UNUSED(ar), void *arg) { TransInfo *t = arg; - + glLineWidth(1.0f); drawConstraint(t); @@ -1891,10 +1891,10 @@ static void drawAutoKeyWarning(TransInfo *UNUSED(t), ARegion *ar) const int font_id = BLF_default(); BLF_width_and_height(font_id, printable, BLF_DRAW_STR_DUMMY_MAX, &printable_size[0], &printable_size[1]); - + xco = (rect.xmax - U.widget_unit) - (int)printable_size[0]; yco = (rect.ymax - U.widget_unit); - + /* warning text (to clarify meaning of overlays) * - original color was red to match the icon, but that clashes badly with a less nasty border */ @@ -1906,28 +1906,28 @@ static void drawAutoKeyWarning(TransInfo *UNUSED(t), ARegion *ar) #else BLF_draw_default_ascii(xco, yco, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX); #endif - + /* autokey recording icon... */ glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - + xco -= U.widget_unit; yco -= (int)printable_size[1] / 2; UI_icon_draw(xco, yco, ICON_REC); - + glDisable(GL_BLEND); } static void drawTransformPixel(const struct bContext *UNUSED(C), ARegion *ar, void *arg) -{ +{ TransInfo *t = arg; Scene *scene = t->scene; ViewLayer *view_layer = t->view_layer; Object *ob = OBACT(view_layer); - - /* draw autokeyframing hint in the corner - * - only draw if enabled (advanced users may be distracted/annoyed), + + /* draw autokeyframing hint in the corner + * - only draw if enabled (advanced users may be distracted/annoyed), * for objects that will be autokeyframed (no point ohterwise), * AND only for the active region (as showing all is too overwhelming) */ @@ -2018,7 +2018,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) ts->prop_mode = t->prop_mode; } } - + /* do we check for parameter? */ if (t->modifiers & MOD_SNAP) { ts->snap_flag |= SCE_SNAP; @@ -2038,7 +2038,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) } } } - + if ((prop = RNA_struct_find_property(op->ptr, "proportional"))) { RNA_property_enum_set(op->ptr, prop, proportional); RNA_enum_set(op->ptr, "proportional_edit_falloff", t->prop_mode); @@ -2121,7 +2121,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve options |= CTX_TEXTURE; } } - + if ((prop = RNA_struct_find_property(op->ptr, "gpencil_strokes")) && RNA_property_is_set(op->ptr, prop)) { if (RNA_property_boolean_get(op->ptr, prop)) { options |= CTX_GPENCIL_STROKES; @@ -2490,7 +2490,7 @@ int transformEnd(bContext *C, TransInfo *t) else if (t->mode == TFM_VERT_SLIDE) { doVertSlide(t, 0.0f); } - + exit_code = OPERATOR_CANCELLED; restoreTransObjects(t); // calls recalcData() } @@ -2555,7 +2555,7 @@ static void protectedAxisAngleBits(short protectflag, float axis[3], float *angl /* check that protection flags are set */ if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0) return; - + if (protectflag & OB_LOCK_ROT4D) { /* axis-angle getting limited as 4D entities that they are... */ if (protectflag & OB_LOCK_ROTW) @@ -2570,19 +2570,19 @@ static void protectedAxisAngleBits(short protectflag, float axis[3], float *angl else { /* axis-angle get limited with euler... */ float eul[3], oldeul[3]; - + axis_angle_to_eulO(eul, EULER_ORDER_DEFAULT, axis, *angle); axis_angle_to_eulO(oldeul, EULER_ORDER_DEFAULT, oldAxis, oldAngle); - + if (protectflag & OB_LOCK_ROTX) eul[0] = oldeul[0]; if (protectflag & OB_LOCK_ROTY) eul[1] = oldeul[1]; if (protectflag & OB_LOCK_ROTZ) eul[2] = oldeul[2]; - + eulO_to_axis_angle(axis, angle, eul, EULER_ORDER_DEFAULT); - + /* when converting to axis-angle, we need a special exception for the case when there is no axis */ if (IS_EQF(axis[0], axis[1]) && IS_EQF(axis[1], axis[2])) { /* for now, rotate around y-axis then (so that it simply becomes the roll) */ @@ -2597,7 +2597,7 @@ static void protectedQuaternionBits(short protectflag, float quat[4], const floa /* check that protection flags are set */ if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0) return; - + if (protectflag & OB_LOCK_ROT4D) { /* quaternions getting limited as 4D entities that they are... */ if (protectflag & OB_LOCK_ROTW) @@ -2631,7 +2631,7 @@ static void protectedQuaternionBits(short protectflag, float quat[4], const floa /* restore original quat size */ mul_qt_fl(quat, qlen); - + /* quaternions flip w sign to accumulate rotations correctly */ if ((nquat[0] < 0.0f && quat[0] > 0.0f) || (nquat[0] > 0.0f && quat[0] < 0.0f)) @@ -2648,43 +2648,43 @@ static void constraintTransLim(TransInfo *t, TransData *td) if (td->con) { const bConstraintTypeInfo *ctiLoc = BKE_constraint_typeinfo_from_type(CONSTRAINT_TYPE_LOCLIMIT); const bConstraintTypeInfo *ctiDist = BKE_constraint_typeinfo_from_type(CONSTRAINT_TYPE_DISTLIMIT); - + bConstraintOb cob = {NULL}; bConstraint *con; float ctime = (float)(t->scene->r.cfra); - + /* Make a temporary bConstraintOb for using these limit constraints * - they only care that cob->matrix is correctly set ;-) * - current space should be local */ unit_m4(cob.matrix); copy_v3_v3(cob.matrix[3], td->loc); - + /* Evaluate valid constraints */ for (con = td->con; con; con = con->next) { const bConstraintTypeInfo *cti = NULL; ListBase targets = {NULL, NULL}; - + /* only consider constraint if enabled */ if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) continue; if (con->enforce == 0.0f) continue; - + /* only use it if it's tagged for this purpose (and the right type) */ if (con->type == CONSTRAINT_TYPE_LOCLIMIT) { bLocLimitConstraint *data = con->data; - + if ((data->flag2 & LIMIT_TRANSFORM) == 0) continue; cti = ctiLoc; } else if (con->type == CONSTRAINT_TYPE_DISTLIMIT) { bDistLimitConstraint *data = con->data; - + if ((data->flag & LIMITDIST_TRANSFORM) == 0) continue; cti = ctiDist; } - + if (cti) { /* do space conversions */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { @@ -2695,24 +2695,24 @@ static void constraintTransLim(TransInfo *t, TransData *td) /* skip... incompatable spacetype */ continue; } - + /* get constraint targets if needed */ BKE_constraint_targets_for_solving_get(t->depsgraph, con, &cob, &targets, ctime); - + /* do constraint */ cti->evaluate_constraint(con, &cob, &targets); - + /* convert spaces again */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { /* just multiply by td->smtx (this should be ok) */ mul_m4_m3m4(cob.matrix, td->smtx, cob.matrix); } - + /* free targets list */ BLI_freelistN(&targets); } } - + /* copy results from cob->matrix */ copy_v3_v3(td->loc, cob.matrix[3]); } @@ -2783,10 +2783,10 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td) /* just multiply by td->mtx (this should be ok) */ mul_m4_m3m4(cob.matrix, td->mtx, cob.matrix); } - + /* do constraint */ cti->evaluate_constraint(con, &cob, NULL); - + /* convert spaces again */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { /* just multiply by td->smtx (this should be ok) */ @@ -2794,7 +2794,7 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td) } } } - + if (do_limit) { /* copy results from cob->matrix */ if (td->ext->rotOrder == ROT_MODE_QUAT) { @@ -2821,7 +2821,7 @@ static void constraintSizeLim(TransInfo *t, TransData *td) bConstraint *con; float size_sign[3], size_abs[3]; int i; - + /* Make a temporary bConstraintOb for using these limit constraints * - they only care that cob->matrix is correctly set ;-) * - current space should be local @@ -2840,24 +2840,24 @@ static void constraintSizeLim(TransInfo *t, TransData *td) size_sign[i] = signf(td->ext->size[i]); size_abs[i] = fabsf(td->ext->size[i]); } - + size_to_mat4(cob.matrix, size_abs); } - + /* Evaluate valid constraints */ for (con = td->con; con; con = con->next) { /* only consider constraint if enabled */ if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) continue; if (con->enforce == 0.0f) continue; - + /* we're only interested in Limit-Scale constraints */ if (con->type == CONSTRAINT_TYPE_SIZELIMIT) { bSizeLimitConstraint *data = con->data; - + /* only use it if it's tagged for this purpose */ if ((data->flag2 & LIMIT_TRANSFORM) == 0) continue; - + /* do space conversions */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { /* just multiply by td->mtx (this should be ok) */ @@ -2867,10 +2867,10 @@ static void constraintSizeLim(TransInfo *t, TransData *td) /* skip... incompatible spacetype */ continue; } - + /* do constraint */ cti->evaluate_constraint(con, &cob, NULL); - + /* convert spaces again */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { /* just multiply by td->smtx (this should be ok) */ @@ -2921,14 +2921,14 @@ static void initBend(TransInfo *t) const float *curs; float tvec[3]; struct BendCustomData *data; - + t->mode = TFM_BEND; t->transform = Bend; t->handleEvent = handleEventBend; - + setInputPostFct(&t->mouse, postInputRotation); initMouseInputMode(t, &t->mouse, INPUT_ANGLE_SPRING); - + t->idx_max = 1; t->num.idx_max = 1; t->snap[0] = 0.0f; @@ -2974,11 +2974,11 @@ static void initBend(TransInfo *t) static eRedrawFlag handleEventBend(TransInfo *UNUSED(t), const wmEvent *event) { eRedrawFlag status = TREDRAW_NOTHING; - + if (event->type == MIDDLEMOUSE && event->val == KM_PRESS) { status = TREDRAW_HARD; } - + return status; } @@ -3025,7 +3025,7 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2])) char c[NUM_STR_REP_LEN * 2]; outputNumInput(&(t->num), c, &t->scene->unit); - + BLI_snprintf(str, sizeof(str), IFACE_("Bend Angle: %s Radius: %s Alt, Clamp %s"), &c[0], &c[NUM_STR_REP_LEN], WM_bool_as_string(is_clamp)); @@ -3036,10 +3036,10 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2])) RAD2DEGF(values.angle), values.scale * data->warp_init_dist, WM_bool_as_string(is_clamp)); } - + values.angle *= -1.0f; values.scale *= data->warp_init_dist; - + /* calc 'data->warp_end' from 'data->warp_end_init' */ copy_v3_v3(warp_end_radius_global, data->warp_end); dist_ensure_v3_v3fl(warp_end_radius_global, data->warp_sta, values.scale); @@ -3125,7 +3125,7 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2])) } recalcData(t); - + ED_area_headerprint(t->sa, str); } /** \} */ @@ -3144,7 +3144,7 @@ static void initShear(TransInfo *t) t->handleEvent = handleEventShear; initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO); - + t->idx_max = 0; t->num.idx_max = 0; t->snap[0] = 0.0f; @@ -3161,7 +3161,7 @@ static void initShear(TransInfo *t) static eRedrawFlag handleEventShear(TransInfo *t, const wmEvent *event) { eRedrawFlag status = TREDRAW_NOTHING; - + if (event->type == MIDDLEMOUSE && event->val == KM_PRESS) { /* Use custom.mode.data pointer to signal Shear direction */ if (t->custom.mode.data == NULL) { @@ -3178,16 +3178,16 @@ static eRedrawFlag handleEventShear(TransInfo *t, const wmEvent *event) else if (event->type == XKEY && event->val == KM_PRESS) { initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO); t->custom.mode.data = NULL; - + status = TREDRAW_HARD; } else if (event->type == YKEY && event->val == KM_PRESS) { initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_RATIO); t->custom.mode.data = (void *)1; - + status = TREDRAW_HARD; } - + return status; } @@ -3200,39 +3200,39 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2])) int i; char str[UI_MAX_DRAW_STR]; const bool is_local_center = transdata_check_local_center(t, t->around); - + copy_m3_m4(persmat, t->viewmat); invert_m3_m3(persinv, persmat); - + value = t->values[0]; - + snapGridIncrement(t, &value); - + applyNumInput(&t->num, &value); - + t->values[0] = value; /* header print for NumInput */ if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; - + outputNumInput(&(t->num), c, &t->scene->unit); - + BLI_snprintf(str, sizeof(str), IFACE_("Shear: %s %s"), c, t->proptext); } else { /* default header print */ BLI_snprintf(str, sizeof(str), IFACE_("Shear: %.3f %s (Press X or Y to set shear axis)"), value, t->proptext); } - + unit_m3(smat); - + // Custom data signals shear direction if (t->custom.mode.data == NULL) smat[1][0] = value; else smat[0][1] = value; - + mul_m3_m3m3(tmat, smat, persmat); mul_m3_m3m3(totmat, persinv, tmat); @@ -3279,7 +3279,7 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2])) } recalcData(t); - + ED_area_headerprint(t->sa, str); } /** \} */ @@ -3295,9 +3295,9 @@ static void initResize(TransInfo *t) { t->mode = TFM_RESIZE; t->transform = applyResize; - + initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP); - + t->flag |= T_NULL_ONE; t->num.val_flag[0] |= NUM_NULL_ONE; t->num.val_flag[1] |= NUM_NULL_ONE; @@ -3311,7 +3311,7 @@ static void initResize(TransInfo *t) t->num.val_flag[2] |= NUM_NO_ZERO; #endif } - + t->idx_max = 2; t->num.idx_max = 2; t->snap[0] = 0.0f; @@ -3391,7 +3391,7 @@ static void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, f { float tmat[3][3], smat[3][3], center[3]; float vec[3]; - + if (t->flag & T_EDIT) { mul_m3_m3m3(smat, mat, td->mtx); mul_m3_m3m3(tmat, td->smtx, smat); @@ -3399,11 +3399,11 @@ static void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, f else { copy_m3_m3(tmat, mat); } - + if (t->con.applySize) { t->con.applySize(t, tc, td, tmat); } - + /* local constraint shouldn't alter center */ if (transdata_check_local_center(t, t->around)) { copy_v3_v3(center, td->center); @@ -3422,7 +3422,7 @@ static void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, f if (td->ext) { float fsize[3]; - + if (t->flag & (T_OBJECT | T_TEXTURE | T_POSE)) { float obsizemat[3][3]; /* Reorient the size mat to fit the oriented object. */ @@ -3434,14 +3434,14 @@ static void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, f else { mat3_to_size(fsize, tmat); } - + protectedSizeBits(td->protectflag, fsize); - + if ((t->flag & T_V3D_ALIGN) == 0) { /* align mode doesn't resize objects itself */ if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) { /* scale val and reset size */ *td->val = td->ival * (1 + (fsize[0] - 1) * td->factor); - + td->ext->size[0] = td->ext->isize[0]; td->ext->size[1] = td->ext->isize[1]; td->ext->size[2] = td->ext->isize[2]; @@ -3450,13 +3450,13 @@ static void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, f /* Reset val if SINGLESIZE but using a constraint */ if (td->flag & TD_SINGLESIZE) *td->val = td->ival; - + td->ext->size[0] = td->ext->isize[0] * (1 + (fsize[0] - 1) * td->factor); td->ext->size[1] = td->ext->isize[1] * (1 + (fsize[1] - 1) * td->factor); td->ext->size[2] = td->ext->isize[2] * (1 + (fsize[2] - 1) * td->factor); } } - + constraintSizeLim(t, td); } @@ -3465,26 +3465,26 @@ static void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, f sub_v3_v3v3(vec, td->iloc, center); else sub_v3_v3v3(vec, td->center, center); - + mul_m3_v3(tmat, vec); - + add_v3_v3(vec, center); if (t->flag & T_POINTS) sub_v3_v3(vec, td->iloc); else sub_v3_v3(vec, td->center); - + mul_v3_fl(vec, td->factor); - + if (t->flag & (T_OBJECT | T_POSE)) { mul_m3_v3(td->smtx, vec); } - + protectedTransBits(td->protectflag, vec); if (td->loc) { add_v3_v3v3(td->loc, td->iloc, vec); } - + constraintTransLim(t, td); } @@ -3510,15 +3510,15 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2])) applySnapping(t, t->values); } - + size_to_mat3(mat, t->values); - + if (t->con.applySize) { t->con.applySize(t, NULL, NULL, mat); } - + copy_m3_m3(t->mat, mat); // used in manipulator - + headerResize(t, t->values, str); FOREACH_TRANS_DATA_CONTAINER (t, tc) { @@ -3556,9 +3556,9 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2])) } } } - + recalcData(t); - + ED_area_headerprint(t->sa, str); } /** \} */ @@ -3574,9 +3574,9 @@ static void initSkinResize(TransInfo *t) { t->mode = TFM_SKIN_RESIZE; t->transform = applySkinResize; - + initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP); - + t->flag |= T_NULL_ONE; t->num.val_flag[0] |= NUM_NULL_ONE; t->num.val_flag[1] |= NUM_NULL_ONE; @@ -3590,7 +3590,7 @@ static void initSkinResize(TransInfo *t) t->num.val_flag[2] |= NUM_NO_ZERO; #endif } - + t->idx_max = 2; t->num.idx_max = 2; t->snap[0] = 0.0f; @@ -3609,25 +3609,25 @@ static void applySkinResize(TransInfo *t, const int UNUSED(mval[2])) float size[3], mat[3][3]; int i; char str[UI_MAX_DRAW_STR]; - + copy_v3_fl(size, t->values[0]); - + snapGridIncrement(t, size); - + if (applyNumInput(&t->num, size)) { constraintNumInput(t, size); } - + applySnapping(t, size); - + if (t->flag & T_AUTOVALUES) { copy_v3_v3(size, t->auto_values); } - + copy_v3_v3(t->values, size); - + size_to_mat3(mat, size); - + headerResize(t, size, str); FOREACH_TRANS_DATA_CONTAINER (t, tc) { @@ -3661,7 +3661,7 @@ static void applySkinResize(TransInfo *t, const int UNUSED(mval[2])) } recalcData(t); - + ED_area_headerprint(t->sa, str); } /** \} */ @@ -3676,18 +3676,18 @@ static void applySkinResize(TransInfo *t, const int UNUSED(mval[2])) static void initToSphere(TransInfo *t) { int i; - + t->mode = TFM_TOSPHERE; t->transform = applyToSphere; - + initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO); - + t->idx_max = 0; t->num.idx_max = 0; t->snap[0] = 0.0f; t->snap[1] = 0.1f; t->snap[2] = t->snap[1] * 0.1f; - + copy_v3_fl(t->num.val_inc, t->snap[1]); t->num.unit_sys = t->scene->unit.system; t->num.unit_type[0] = B_UNIT_NONE; @@ -3714,21 +3714,21 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2])) char str[UI_MAX_DRAW_STR]; ratio = t->values[0]; - + snapGridIncrement(t, &ratio); - + applyNumInput(&t->num, &ratio); - + CLAMP(ratio, 0.0f, 1.0f); - + t->values[0] = ratio; /* header print for NumInput */ if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; - + outputNumInput(&(t->num), c, &t->scene->unit); - + BLI_snprintf(str, sizeof(str), IFACE_("To Sphere: %s %s"), c, t->proptext); } else { @@ -3759,7 +3759,7 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2])) } recalcData(t); - + ED_area_headerprint(t->sa, str); } /** \} */ @@ -3782,16 +3782,16 @@ static void initRotation(TransInfo *t) { t->mode = TFM_ROTATION; t->transform = applyRotation; - + setInputPostFct(&t->mouse, postInputRotation); initMouseInputMode(t, &t->mouse, INPUT_ANGLE); - + t->idx_max = 0; t->num.idx_max = 0; t->snap[0] = 0.0f; t->snap[1] = DEG2RAD(5.0); t->snap[2] = DEG2RAD(1.0); - + copy_v3_fl(t->num.val_inc, t->snap[2]); t->num.unit_sys = t->scene->unit.system; t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS); @@ -3827,24 +3827,24 @@ static void ElementRotation_ex(TransInfo *t, TransDataContainer *tc, TransData * if (t->flag & T_POINTS) { mul_m3_m3m3(totmat, mat, td->mtx); mul_m3_m3m3(smat, td->smtx, totmat); - + sub_v3_v3v3(vec, td->iloc, center); mul_m3_v3(smat, vec); - + add_v3_v3v3(td->loc, vec, center); - + sub_v3_v3v3(vec, td->loc, td->iloc); protectedTransBits(td->protectflag, vec); add_v3_v3v3(td->loc, td->iloc, vec); - - + + if (td->flag & TD_USEQUAT) { mul_m3_series(fmat, td->smtx, mat, td->mtx); mat3_to_quat(quat, fmat); // Actual transform - + if (td->ext->quat) { mul_qt_qtqt(td->ext->quat, quat, td->ext->iquat); - + /* is there a reason not to have this here? -jahka */ protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat); } @@ -3867,16 +3867,16 @@ static void ElementRotation_ex(TransInfo *t, TransDataContainer *tc, TransData * if ((td->flag & TD_NO_LOC) == 0) { sub_v3_v3v3(vec, td->center, center); - + mul_m3_v3(tc->mat3, vec); // To Global space mul_m3_v3(mat, vec); // Applying rotation mul_m3_v3(tc->imat3, vec); // To Local space - + add_v3_v3(vec, center); /* vec now is the location where the object has to be */ - + sub_v3_v3v3(vec, vec, td->center); // Translation needed from the initial location - + /* special exception, see TD_PBONE_LOCAL_MTX definition comments */ if (td->flag & TD_PBONE_LOCAL_MTX_P) { /* do nothing */ @@ -3891,12 +3891,12 @@ static void ElementRotation_ex(TransInfo *t, TransDataContainer *tc, TransData * } protectedTransBits(td->protectflag, vec); - + add_v3_v3v3(td->loc, td->iloc, vec); - + constraintTransLim(t, td); } - + /* rotation */ /* MORE HACK: as in some cases the matrix to apply location and rot/scale is not the same, * and ElementRotation() might be called in Translation context (with align snapping), @@ -3906,50 +3906,50 @@ static void ElementRotation_ex(TransInfo *t, TransDataContainer *tc, TransData * /* euler or quaternion/axis-angle? */ if (td->ext->rotOrder == ROT_MODE_QUAT) { mul_m3_series(fmat, td->ext->r_smtx, mat, td->ext->r_mtx); - + mat3_to_quat(quat, fmat); /* Actual transform */ - + mul_qt_qtqt(td->ext->quat, quat, td->ext->iquat); /* this function works on end result */ protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat); - + } else if (td->ext->rotOrder == ROT_MODE_AXISANGLE) { /* calculate effect based on quats */ float iquat[4], tquat[4]; - + axis_angle_to_quat(iquat, td->ext->irotAxis, td->ext->irotAngle); - + mul_m3_series(fmat, td->ext->r_smtx, mat, td->ext->r_mtx); mat3_to_quat(quat, fmat); /* Actual transform */ mul_qt_qtqt(tquat, quat, iquat); - + quat_to_axis_angle(td->ext->rotAxis, td->ext->rotAngle, tquat); - + /* this function works on end result */ protectedAxisAngleBits(td->protectflag, td->ext->rotAxis, td->ext->rotAngle, td->ext->irotAxis, td->ext->irotAngle); } else { float eulmat[3][3]; - + mul_m3_m3m3(totmat, mat, td->ext->r_mtx); mul_m3_m3m3(smat, td->ext->r_smtx, totmat); - + /* calculate the total rotatation in eulers */ copy_v3_v3(eul, td->ext->irot); eulO_to_mat3(eulmat, eul, td->ext->rotOrder); - + /* mat = transform, obmat = bone rotation */ mul_m3_m3m3(fmat, smat, eulmat); - + mat3_to_compatible_eulO(eul, td->ext->rot, td->ext->rotOrder, fmat); - + /* and apply (to end result only) */ protectedRotateBits(td->protectflag, eul, td->ext->irot); copy_v3_v3(td->ext->rot, eul); } - + constraintRotLim(t, td); } } @@ -3962,15 +3962,15 @@ static void ElementRotation_ex(TransInfo *t, TransDataContainer *tc, TransData * /* vec now is the location where the object has to be */ sub_v3_v3(vec, td->center); mul_m3_v3(td->smtx, vec); - + protectedTransBits(td->protectflag, vec); - + add_v3_v3v3(td->loc, td->iloc, vec); } - - + + constraintTransLim(t, td); - + /* rotation */ if ((t->flag & T_V3D_ALIGN) == 0) { // align mode doesn't rotate objects itself /* euler or quaternion? */ @@ -3979,7 +3979,7 @@ static void ElementRotation_ex(TransInfo *t, TransDataContainer *tc, TransData * if (td->ext->quat) { mul_m3_series(fmat, td->smtx, mat, td->mtx); mat3_to_quat(quat, fmat); // Actual transform - + mul_qt_qtqt(td->ext->quat, quat, td->ext->iquat); /* this function works on end result */ protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat); @@ -3988,41 +3988,41 @@ static void ElementRotation_ex(TransInfo *t, TransDataContainer *tc, TransData * else if (td->ext->rotOrder == ROT_MODE_AXISANGLE) { /* calculate effect based on quats */ float iquat[4], tquat[4]; - + axis_angle_to_quat(iquat, td->ext->irotAxis, td->ext->irotAngle); - + mul_m3_series(fmat, td->smtx, mat, td->mtx); mat3_to_quat(quat, fmat); // Actual transform mul_qt_qtqt(tquat, quat, iquat); - + quat_to_axis_angle(td->ext->rotAxis, td->ext->rotAngle, tquat); - + /* this function works on end result */ protectedAxisAngleBits(td->protectflag, td->ext->rotAxis, td->ext->rotAngle, td->ext->irotAxis, td->ext->irotAngle); } else { float obmat[3][3]; - + mul_m3_m3m3(totmat, mat, td->mtx); mul_m3_m3m3(smat, td->smtx, totmat); - + /* calculate the total rotatation in eulers */ add_v3_v3v3(eul, td->ext->irot, td->ext->drot); /* we have to correct for delta rot */ eulO_to_mat3(obmat, eul, td->ext->rotOrder); /* mat = transform, obmat = object rotation */ mul_m3_m3m3(fmat, smat, obmat); - + mat3_to_compatible_eulO(eul, td->ext->rot, td->ext->rotOrder, fmat); - + /* correct back for delta rot */ sub_v3_v3v3(eul, eul, td->ext->drot); - + /* and apply */ protectedRotateBits(td->protectflag, eul, td->ext->irot); copy_v3_v3(td->ext->rot, eul); } - + constraintRotLim(t, td); } } @@ -4047,7 +4047,7 @@ static void applyRotationValue(TransInfo *t, float angle, float axis[3]) { float mat[3][3]; int i; - + axis_angle_normalized_to_mat3(mat, axis, angle); FOREACH_TRANS_DATA_CONTAINER (t, tc) { @@ -4101,24 +4101,24 @@ static void applyRotation(TransInfo *t, const int UNUSED(mval[2])) if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; - + outputNumInput(&(t->num), c, &t->scene->unit); - + ofs += BLI_snprintf(str + ofs, sizeof(str) - ofs, IFACE_("Rot: %s %s %s"), &c[0], t->con.text, t->proptext); } else { ofs += BLI_snprintf(str + ofs, sizeof(str) - ofs, IFACE_("Rot: %.2f%s %s"), RAD2DEGF(final), t->con.text, t->proptext); } - + if (t->flag & T_PROP_EDIT_ALL) { ofs += BLI_snprintf(str + ofs, sizeof(str) - ofs, IFACE_(" Proportional size: %.2f"), t->prop_size); } applyRotationValue(t, final, t->axis); - + recalcData(t); - + ED_area_headerprint(t->sa, str); } /** \} */ @@ -4288,7 +4288,7 @@ static void initTranslation(TransInfo *t) { if (t->spacetype == SPACE_ACTION) { /* this space uses time translate */ - BKE_report(t->reports, RPT_ERROR, + BKE_report(t->reports, RPT_ERROR, "Use 'Time_Translate' transform mode instead of 'Translation' mode " "for translating keyframes in Dope Sheet Editor"); t->state = TRANS_CANCEL; @@ -5365,23 +5365,23 @@ static void applyBoneSize(TransInfo *t, const int UNUSED(mval[2])) char str[UI_MAX_DRAW_STR]; copy_v3_fl(size, ratio); - + snapGridIncrement(t, size); - + if (applyNumInput(&t->num, size)) { constraintNumInput(t, size); } - + copy_v3_v3(t->values, size); size_to_mat3(mat, size); - + if (t->con.applySize) { t->con.applySize(t, NULL, NULL, mat); } - + copy_m3_m3(t->mat, mat); // used in manipulator - + headerBoneSize(t, size, str); FOREACH_TRANS_DATA_CONTAINER (t, tc) { @@ -5398,7 +5398,7 @@ static void applyBoneSize(TransInfo *t, const int UNUSED(mval[2])) } recalcData(t); - + ED_area_headerprint(t->sa, str); } /** \} */ @@ -5414,15 +5414,15 @@ static void initBoneEnvelope(TransInfo *t) { t->mode = TFM_BONE_ENVELOPE; t->transform = applyBoneEnvelope; - + initMouseInputMode(t, &t->mouse, INPUT_SPRING); - + t->idx_max = 0; t->num.idx_max = 0; t->snap[0] = 0.0f; t->snap[1] = 0.1f; t->snap[2] = t->snap[1] * 0.1f; - + copy_v3_fl(t->num.val_inc, t->snap[1]); t->num.unit_sys = t->scene->unit.system; t->num.unit_type[0] = B_UNIT_NONE; @@ -5435,19 +5435,19 @@ static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2])) float ratio; int i; char str[UI_MAX_DRAW_STR]; - + ratio = t->values[0]; - + snapGridIncrement(t, &ratio); - + applyNumInput(&t->num, &ratio); - + t->values[0] = ratio; /* header print for NumInput */ if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; - + outputNumInput(&(t->num), c, &t->scene->unit); BLI_snprintf(str, sizeof(str), IFACE_("Envelope: %s"), c); } @@ -5475,7 +5475,7 @@ static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2])) } recalcData(t); - + ED_area_headerprint(t->sa, str); } /** \} */ @@ -5957,7 +5957,7 @@ static BMLoop *get_next_loop(BMVert *v, BMLoop *l, l_first = l; do { l = BM_loop_other_edge_loop(l, v); - + if (l->e == e_next) { if (i) { normalize_v3_length(vec_accum, vec_accum_len / (float)i); @@ -6029,9 +6029,9 @@ static BMLoop *get_next_loop(BMVert *v, BMLoop *l, if (i) { normalize_v3_length(vec_accum, vec_accum_len / (float)i); } - + copy_v3_v3(r_slide_vec, vec_accum); - + return NULL; } @@ -6362,7 +6362,7 @@ static bool createEdgeSlideVerts_double_side(TransInfo *t, TransDataContainer *t if (!v->e) continue; - + v_first = v; /*walk along the edge loop*/ @@ -6821,17 +6821,17 @@ void freeEdgeSlideTempFaces(EdgeSlideData *sld) void freeEdgeSlideVerts(TransInfo *UNUSED(t), TransDataContainer *UNUSED(tc), TransCustomData *custom_data) { EdgeSlideData *sld = custom_data->data; - + if (!sld) return; freeEdgeSlideTempFaces(sld); bmesh_edit_end(sld->em->bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES); - + MEM_freeN(sld->sv); MEM_freeN(sld); - + custom_data->data = NULL; } @@ -6889,7 +6889,7 @@ static void initEdgeSlide_ex(TransInfo *t, bool use_double_side, bool use_even, /* set custom point first if you want value to be initialized by init */ calcEdgeSlideCustomPoints(t); initMouseInputMode(t, &t->mouse, INPUT_CUSTOM_RATIO_FLIP); - + t->idx_max = 0; t->num.idx_max = 0; t->snap[0] = 0.0f; @@ -8234,30 +8234,30 @@ static void applySeqSlide(TransInfo *t, const int mval[2]) static short getAnimEdit_SnapMode(TransInfo *t) { short autosnap = SACTSNAP_OFF; - + if (t->spacetype == SPACE_ACTION) { SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first; - + if (saction) autosnap = saction->autosnap; } else if (t->spacetype == SPACE_IPO) { SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first; - + if (sipo) autosnap = sipo->autosnap; } else if (t->spacetype == SPACE_NLA) { SpaceNla *snla = (SpaceNla *)t->sa->spacedata.first; - + if (snla) autosnap = snla->autosnap; } else { autosnap = SACTSNAP_OFF; } - - /* toggle autosnap on/off + + /* toggle autosnap on/off * - when toggling on, prefer nearest frame over 1.0 frame increments */ if (t->modifiers & MOD_SNAP_INVERT) { @@ -8280,13 +8280,13 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d, const Scene *scene = t->scene; const double secf = FPS; double val; - + /* convert frame to nla-action time (if needed) */ if (adt) val = BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP); else val = *(td->val); - + /* do the snapping to nearest frame/second */ if (autosnap == SACTSNAP_FRAME) { val = floorf(val + 0.5); @@ -8294,7 +8294,7 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d, else if (autosnap == SACTSNAP_SECOND) { val = (float)(floor((val / secf) + 0.5) * secf); } - + /* convert frame out of nla-action time */ if (adt) *(td->val) = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP); @@ -8304,26 +8304,26 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d, /* snap key to nearest marker? */ else if (autosnap == SACTSNAP_MARKER) { float val; - + /* convert frame to nla-action time (if needed) */ if (adt) val = BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP); else val = *(td->val); - + /* snap to nearest marker */ // TODO: need some more careful checks for where data comes from val = (float)ED_markers_find_nearest_marker_time(&t->scene->markers, val); - + /* convert frame out of nla-action time */ if (adt) *(td->val) = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP); else *(td->val) = val; } - - /* if the handles are to be moved too (as side-effect of keyframes moving, to keep the general effect) - * offset them by the same amount so that the general angles are maintained (i.e. won't change while + + /* if the handles are to be moved too (as side-effect of keyframes moving, to keep the general effect) + * offset them by the same amount so that the general angles are maintained (i.e. won't change while * handles are free-to-roam and keyframes are snap-locked) */ if ((td->flag & TD_MOVEHANDLE1) && td2d->h1) { @@ -8383,7 +8383,7 @@ static void headerTimeTranslate(TransInfo *t, char str[UI_MAX_DRAW_STR]) const short autosnap = getAnimEdit_SnapMode(t); const double secf = FPS; float val = t->values[0]; - + /* apply snapping + frame->seconds conversions */ if (autosnap == SACTSNAP_STEP) { /* frame step */ @@ -8397,7 +8397,7 @@ static void headerTimeTranslate(TransInfo *t, char str[UI_MAX_DRAW_STR]) /* nearest second */ val = (float)((double)val / secf); } - + if (autosnap == SACTSNAP_FRAME) BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%d.00 (%.4f)", (int)val, val); else if (autosnap == SACTSNAP_SECOND) @@ -8797,7 +8797,7 @@ static void applyTimeScaleValue(TransInfo *t) static void applyTimeScale(TransInfo *t, const int UNUSED(mval[2])) { char str[UI_MAX_DRAW_STR]; - + /* handle numeric-input stuff */ t->vec[0] = t->values[0]; applyNumInput(&t->num, &t->vec[0]); |