From b99d064e9142b2e9d790731f4c4c6c107ca43696 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 13 May 2018 06:44:03 +0200 Subject: Cleanup: trailing space --- source/blender/editors/transform/transform.c | 584 ++++++++++---------- source/blender/editors/transform/transform.h | 16 +- .../editors/transform/transform_constraints.c | 10 +- .../editors/transform/transform_conversions.c | 596 ++++++++++----------- .../blender/editors/transform/transform_generics.c | 314 +++++------ source/blender/editors/transform/transform_input.c | 6 +- .../editors/transform/transform_manipulator.c | 4 +- source/blender/editors/transform/transform_ops.c | 58 +- .../editors/transform/transform_orientations.c | 54 +- source/blender/editors/transform/transform_snap.c | 218 ++++---- 10 files changed, 931 insertions(+), 929 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 4a8bd5287df..69e8ebf5ca4 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -638,7 +638,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)) @@ -650,12 +650,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); @@ -831,14 +831,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); @@ -848,7 +848,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); @@ -856,7 +856,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); @@ -872,7 +872,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); @@ -891,7 +891,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: @@ -1062,7 +1062,7 @@ int transformEvent(TransInfo *t, const wmEvent *event) restoreTransObjects(t); resetTransModal(t); resetTransRestrictions(t); - + if (t->mode == TFM_ROTATION) { initTrackball(t); } @@ -1107,7 +1107,7 @@ int transformEvent(TransInfo *t, const wmEvent *event) } } break; - + case TFM_MODAL_SNAP_INV_ON: t->modifiers |= MOD_SNAP_INVERT; t->redraw |= TREDRAW_HARD; @@ -1683,7 +1683,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; @@ -1810,7 +1810,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.0); drawConstraint(t); @@ -1831,12 +1831,12 @@ static void drawAutoKeyWarning(TransInfo *UNUSED(t), ARegion *ar) int xco, yco; ED_region_visible_rect(ar, &rect); - + BLF_width_and_height_default(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 */ @@ -1846,27 +1846,27 @@ 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... */ glBlendFunc(GL_SRC_ALPHA, 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; Object *ob = OBACT; - - /* 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) */ @@ -1957,7 +1957,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; @@ -1976,7 +1976,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); @@ -2055,7 +2055,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; @@ -2414,7 +2414,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() } @@ -2479,7 +2479,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) @@ -2494,19 +2494,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) */ @@ -2521,7 +2521,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) @@ -2555,7 +2555,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)) @@ -2572,43 +2572,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) { @@ -2619,24 +2619,24 @@ static void constraintTransLim(TransInfo *t, TransData *td) /* skip... incompatable spacetype */ continue; } - + /* get constraint targets if needed */ BKE_constraint_targets_for_solving_get(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]); } @@ -2707,10 +2707,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) */ @@ -2718,7 +2718,7 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td) } } } - + if (do_limit) { /* copy results from cob->matrix */ if (td->ext->rotOrder == ROT_MODE_QUAT) { @@ -2745,7 +2745,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 @@ -2764,24 +2764,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) */ @@ -2791,10 +2791,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) */ @@ -2844,14 +2844,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; @@ -2901,11 +2901,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; } @@ -2953,7 +2953,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)); @@ -2964,10 +2964,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, data->warp_end); dist_ensure_v3_v3fl(warp_end_radius, data->warp_sta, values.scale); @@ -2989,7 +2989,7 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2])) if (td->flag & TD_NOACTION) break; - + if (td->flag & TD_SKIP) continue; @@ -3028,9 +3028,9 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2])) /* location */ copy_v3_v3(td->loc, vec); } - + recalcData(t); - + ED_area_headerprint(t->sa, str); } /** \} */ @@ -3049,7 +3049,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; @@ -3066,7 +3066,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) { @@ -3083,16 +3083,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; } @@ -3106,39 +3106,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); @@ -3147,10 +3147,10 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2])) if (td->flag & TD_NOACTION) break; - + if (td->flag & TD_SKIP) continue; - + if (t->obedit) { float mat3[3][3]; mul_m3_m3m3(mat3, totmat, td->mtx); @@ -3170,19 +3170,19 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2])) } sub_v3_v3v3(vec, co, center); - + mul_m3_v3(tmat, vec); - + add_v3_v3(vec, center); sub_v3_v3(vec, co); - + mul_v3_fl(vec, td->factor); - + add_v3_v3v3(td->loc, td->iloc, vec); } - + recalcData(t); - + ED_area_headerprint(t->sa, str); } /** \} */ @@ -3198,9 +3198,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; @@ -3214,7 +3214,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; @@ -3294,7 +3294,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) { 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); @@ -3302,11 +3302,11 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) else { copy_m3_m3(tmat, mat); } - + if (t->con.applySize) { t->con.applySize(t, td, tmat); } - + /* local constraint shouldn't alter center */ if (transdata_check_local_center(t, t->around)) { copy_v3_v3(center, td->center); @@ -3325,7 +3325,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) 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. */ @@ -3337,14 +3337,14 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) 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]; @@ -3353,13 +3353,13 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) /* 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); } @@ -3368,26 +3368,26 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) 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); } @@ -3422,34 +3422,34 @@ static void applyResize(TransInfo *t, const int mval[2]) applySnapping(t, t->values); } - + size_to_mat3(mat, t->values); - + if (t->con.applySize) { t->con.applySize(t, NULL, mat); } - + copy_m3_m3(t->mat, mat); // used in manipulator - + headerResize(t, t->values, str); - + for (i = 0, td = t->data; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; - + if (td->flag & TD_SKIP) continue; - + ElementResize(t, td, mat); } - + /* evil hack - redo resize if cliping needed */ if (t->flag & T_CLIP_UV && clipUVTransform(t, t->values, 1)) { size_to_mat3(mat, t->values); - + if (t->con.applySize) t->con.applySize(t, NULL, mat); - + for (i = 0, td = t->data; i < t->total; i++, td++) ElementResize(t, td, mat); @@ -3461,9 +3461,9 @@ static void applyResize(TransInfo *t, const int mval[2]) clipUVData(t); } } - + recalcData(t); - + ED_area_headerprint(t->sa, str); } /** \} */ @@ -3479,9 +3479,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; @@ -3495,7 +3495,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; @@ -3515,34 +3515,34 @@ 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); - + for (i = 0, td = t->data; i < t->total; i++, td++) { float tmat[3][3], smat[3][3]; float fsize[3]; - + if (td->flag & TD_NOACTION) break; - + if (td->flag & TD_SKIP) continue; @@ -3553,7 +3553,7 @@ static void applySkinResize(TransInfo *t, const int UNUSED(mval[2])) else { copy_m3_m3(tmat, mat); } - + if (t->con.applySize) { t->con.applySize(t, NULL, tmat); } @@ -3562,9 +3562,9 @@ static void applySkinResize(TransInfo *t, const int UNUSED(mval[2])) td->val[0] = td->ext->isize[0] * (1 + (fsize[0] - 1) * td->factor); td->val[1] = td->ext->isize[1] * (1 + (fsize[1] - 1) * td->factor); } - + recalcData(t); - + ED_area_headerprint(t->sa, str); } /** \} */ @@ -3580,30 +3580,30 @@ static void initToSphere(TransInfo *t) { TransData *td = t->data; 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; t->num.val_flag[0] |= NUM_NULL_ONE | NUM_NO_NEGATIVE; t->flag |= T_NO_CONSTRAINT; - + // Calculate average radius for (i = 0; i < t->total; i++, td++) { t->val += len_v3v3(t->center, td->iloc); } - + t->val /= (float)t->total; } @@ -3614,53 +3614,53 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2])) int i; char str[UI_MAX_DRAW_STR]; TransData *td = t->data; - + 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 { /* default header print */ BLI_snprintf(str, sizeof(str), IFACE_("To Sphere: %.4f %s"), ratio, t->proptext); } - - + + for (i = 0; i < t->total; i++, td++) { float tratio; if (td->flag & TD_NOACTION) break; - + if (td->flag & TD_SKIP) continue; - + sub_v3_v3v3(vec, td->iloc, t->center); - + radius = normalize_v3(vec); - + tratio = ratio * td->factor; - + mul_v3_fl(vec, radius * (1.0f - tratio) + t->val * tratio); - + add_v3_v3v3(td->loc, t->center, vec); } - - + + recalcData(t); - + ED_area_headerprint(t->sa, str); } /** \} */ @@ -3683,16 +3683,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); @@ -3728,24 +3728,24 @@ static void ElementRotation_ex(TransInfo *t, TransData *td, float mat[3][3], con 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); } @@ -3765,23 +3765,23 @@ static void ElementRotation_ex(TransInfo *t, TransData *td, float mat[3][3], con */ else if (t->flag & T_POSE) { float pmtx[3][3], imtx[3][3]; - + // Extract and invert armature object matrix copy_m3_m4(pmtx, t->poseobj->obmat); invert_m3_m3(imtx, pmtx); - + if ((td->flag & TD_NO_LOC) == 0) { sub_v3_v3v3(vec, td->center, center); - + mul_m3_v3(pmtx, vec); // To Global space mul_m3_v3(mat, vec); // Applying rotation mul_m3_v3(imtx, 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 */ @@ -3796,12 +3796,12 @@ static void ElementRotation_ex(TransInfo *t, TransData *td, float mat[3][3], con } 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), @@ -3811,50 +3811,50 @@ static void ElementRotation_ex(TransInfo *t, TransData *td, float mat[3][3], con /* 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); } } @@ -3867,15 +3867,15 @@ static void ElementRotation_ex(TransInfo *t, TransData *td, float mat[3][3], con /* 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? */ @@ -3884,7 +3884,7 @@ static void ElementRotation_ex(TransInfo *t, TransData *td, float mat[3][3], con 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); @@ -3893,41 +3893,41 @@ static void ElementRotation_ex(TransInfo *t, TransData *td, float mat[3][3], con 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); } } @@ -3953,17 +3953,17 @@ static void applyRotationValue(TransInfo *t, float angle, float axis[3]) TransData *td = t->data; float mat[3][3]; int i; - + axis_angle_normalized_to_mat3(mat, axis, angle); - + for (i = 0; i < t->total; i++, td++) { - + if (td->flag & TD_NOACTION) break; - + if (td->flag & TD_SKIP) continue; - + if (t->con.applyRot) { t->con.applyRot(t, td, axis, NULL); axis_angle_normalized_to_mat3(mat, axis, angle * td->factor); @@ -3971,7 +3971,7 @@ static void applyRotationValue(TransInfo *t, float angle, float axis[3]) else if (t->flag & T_PROP_EDIT) { axis_angle_normalized_to_mat3(mat, axis, angle * td->factor); } - + ElementRotation(t, td, mat, t->around); } } @@ -4004,24 +4004,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); } /** \} */ @@ -4189,7 +4189,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; @@ -4354,7 +4354,7 @@ static void applyTranslationValue(TransInfo *t, const float vec[3]) for (int i = 0; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; - + if (td->flag & TD_SKIP) continue; @@ -4399,12 +4399,12 @@ static void applyTranslationValue(TransInfo *t, const float vec[3]) if (use_rotate_offset) { add_v3_v3(tvec, rotate_offset); } - + mul_m3_v3(td->smtx, tvec); mul_v3_fl(tvec, td->factor); - + protectedTransBits(td->protectflag, tvec); - + if (td->loc) add_v3_v3v3(td->loc, td->iloc, tvec); @@ -5244,7 +5244,7 @@ static void applyBoneSize(TransInfo *t, const int mval[2]) float ratio; int i; char str[UI_MAX_DRAW_STR]; - + // TRANSFORM_FIX_ME MOVE TO MOUSE INPUT /* for manipulator, center handle, the scaling can't be done relative to center */ if ((t->flag & T_USES_MANIPULATOR) && t->con.mode == 0) { @@ -5253,39 +5253,39 @@ static void applyBoneSize(TransInfo *t, const int mval[2]) else { ratio = t->values[0]; } - + 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, mat); } - + copy_m3_m3(t->mat, mat); // used in manipulator - + headerBoneSize(t, size, str); - + for (i = 0; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; - + if (td->flag & TD_SKIP) continue; - + ElementBoneSize(t, td, mat); } - + recalcData(t); - + ED_area_headerprint(t->sa, str); } /** \} */ @@ -5301,15 +5301,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; @@ -5323,33 +5323,33 @@ 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); } else { BLI_snprintf(str, sizeof(str), IFACE_("Envelope: %3f"), ratio); } - + for (i = 0; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; - + if (td->flag & TD_SKIP) continue; - + if (td->val) { /* if the old/original value was 0.0f, then just use ratio */ if (td->ival) @@ -5358,9 +5358,9 @@ static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2])) *td->val = ratio; } } - + recalcData(t); - + ED_area_headerprint(t->sa, str); } /** \} */ @@ -5840,7 +5840,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); @@ -5912,9 +5912,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; } @@ -6247,7 +6247,7 @@ static bool createEdgeSlideVerts_double_side(TransInfo *t, bool use_even, bool f if (!v->e) continue; - + v_first = v; /*walk along the edge loop*/ @@ -6481,11 +6481,11 @@ static bool createEdgeSlideVerts_double_side(TransInfo *t, bool use_even, bool f } sld->em = em; - + sld->perc = 0.0f; - + t->custom.mode.data = sld; - + MEM_freeN(sv_table); return true; @@ -6714,17 +6714,17 @@ void freeEdgeSlideTempFaces(EdgeSlideData *sld) void freeEdgeSlideVerts(TransInfo *UNUSED(t), 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; } @@ -6748,7 +6748,7 @@ static void initEdgeSlide_ex(TransInfo *t, bool use_double_side, bool use_even, t->state = TRANS_CANCEL; return; } - + sld = t->custom.mode.data; if (!sld) @@ -6759,7 +6759,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; @@ -8049,30 +8049,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) { @@ -8095,13 +8095,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); @@ -8109,7 +8109,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); @@ -8119,26 +8119,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) { @@ -8198,7 +8198,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 */ @@ -8212,7 +8212,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) @@ -8236,7 +8236,7 @@ static void applyTimeTranslateValue(TransInfo *t) TransData2D *td2d = t->data2d; Scene *scene = t->scene; int i; - + const short autosnap = getAnimEdit_SnapMode(t); const double secf = FPS; @@ -8353,11 +8353,11 @@ static void initTimeSlide(TransInfo *t) for (i = 0; i < t->total; i++, td++) { AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL; float val = *(td->val); - + /* strip/action time to global (mapped) time */ if (adt) val = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_MAP); - + if (min > val) min = val; if (max < val) max = val; } @@ -8434,13 +8434,13 @@ static void applyTimeSlideValue(TransInfo *t, float sval) */ AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL; float cval = t->values[0]; - + /* only apply to data if in range */ if ((sval > minx) && (sval < maxx)) { float cvalc = CLAMPIS(cval, minx, maxx); float ival = td->ival; float timefac; - + /* NLA mapping magic here works as follows: * - "ival" goes from strip time to global time * - calculation is performed into td->val in global time @@ -8451,7 +8451,7 @@ static void applyTimeSlideValue(TransInfo *t, float sval) /* strip to global */ ival = BKE_nla_tweakedit_remap(adt, ival, NLATIME_CONVERT_MAP); } - + /* left half? */ if (ival < sval) { timefac = (sval - ival) / (sval - minx); @@ -8461,7 +8461,7 @@ static void applyTimeSlideValue(TransInfo *t, float sval) timefac = (ival - sval) / (maxx - sval); *(td->val) = cvalc + timefac * (maxx - cvalc); } - + if (adt) { /* global to strip */ *(td->val) = BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_UNMAP); @@ -8606,7 +8606,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]); diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 06a60456cdb..6afdc7b208d 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -188,16 +188,16 @@ typedef struct TransSeq { /* for NLA transform (stored in td->extra pointer) */ typedef struct TransDataNla { ID *id; /* ID-block NLA-data is attached to */ - + struct NlaTrack *oldTrack; /* Original NLA-Track that the strip belongs to */ struct NlaTrack *nlt; /* Current NLA-Track that the strip belongs to */ - + struct NlaStrip *strip; /* NLA-strip this data represents */ - + /* dummy values for transform to write in - must have 3 elements... */ float h1[3]; /* start handle */ float h2[3]; /* end handle */ - + int trackIndex; /* index of track that strip is currently in */ int handle; /* handle-index: 0 for dummy entry, -1 for start, 1 for end, 2 for both ends */ } TransDataNla; @@ -449,7 +449,7 @@ typedef struct TransInfo { short twtype; /* backup from view3d, to restore on end */ short prop_mode; - + short mirror; float values[4]; @@ -652,8 +652,10 @@ bool transdata_check_local_islands(TransInfo *t, short around); int count_set_pose_transflags(int *out_mode, short around, struct Object *ob); /* auto-keying stuff used by special_aftertrans_update */ -void autokeyframe_ob_cb_func(struct bContext *C, struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode); -void autokeyframe_pose_cb_func(struct bContext *C, struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode, short targetless_ik); +void autokeyframe_ob_cb_func( + struct bContext *C, struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode); +void autokeyframe_pose_cb_func( + struct bContext *C, struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode, short targetless_ik); /*********************** Constraints *****************************/ diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 08bd36fe95c..18d47eb9c3d 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -206,7 +206,7 @@ static void axisProjection(TransInfo *t, const float axis[3], const float in[3], /* checks for center being too close to the view center */ viewAxisCorrectCenter(t, t_con_center); - + angle = fabsf(angle_v3v3(axis, t->viewinv[2])); if (angle > (float)M_PI_2) { angle = (float)M_PI - angle; @@ -237,7 +237,7 @@ static void axisProjection(TransInfo *t, const float axis[3], const float in[3], project_v3_v3v3(vec, in, plane); sub_v3_v3v3(vec, in, vec); - + add_v3_v3v3(v, vec, t_con_center); getViewVector(t, v, norm); @@ -255,11 +255,11 @@ static void axisProjection(TransInfo *t, const float axis[3], const float in[3], else { add_v3_v3v3(v2, t_con_center, axis); add_v3_v3v3(v4, v, norm); - + isect_line_line_v3(t_con_center, v2, v, v4, i1, i2); - + sub_v3_v3v3(v, i2, v); - + sub_v3_v3v3(out, i1, t_con_center); /* possible some values become nan when diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 60092a28e36..a9b12a34593 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -174,7 +174,7 @@ void sort_trans_data_dist(TransInfo *t) for (i = 0; i < t->total && start->flag & TD_SELECTED; i++) start++; - + if (i < t->total) { if (t->flag & T_PROP_CONNECTED) qsort(start, t->total - i, sizeof(TransData), trans_data_compare_dist); @@ -475,9 +475,9 @@ static short apply_targetless_ik(Object *ob) /* apply and decompose, doesn't work for constraints or non-uniform scale well */ { float rmat3[3][3], qrmat[3][3], imat3[3][3], smat[3][3]; - + copy_m3_m4(rmat3, rmat); - + /* rotation */ /* [#22409] is partially caused by this, as slight numeric error introduced during * the solving process leads to locked-axis values changing. However, we cannot modify @@ -490,7 +490,7 @@ static short apply_targetless_ik(Object *ob) mat3_to_axis_angle(parchan->rotAxis, &parchan->rotAngle, rmat3); else mat3_to_quat(parchan->quat, rmat3); - + /* for size, remove rotation */ /* causes problems with some constraints (so apply only if needed) */ if (data->flag & CONSTRAINT_IK_STRETCH) { @@ -500,12 +500,12 @@ static short apply_targetless_ik(Object *ob) axis_angle_to_mat3(qrmat, parchan->rotAxis, parchan->rotAngle); else quat_to_mat3(qrmat, parchan->quat); - + invert_m3_m3(imat3, qrmat); mul_m3_m3m3(smat, rmat3, imat3); mat3_to_size(parchan->size, smat); } - + /* causes problems with some constraints (e.g. childof), so disable this */ /* as it is IK shouldn't affect location directly */ /* copy_v3_v3(parchan->loc, rmat[3]); */ @@ -555,7 +555,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr td->ext->rotAxis = NULL; td->ext->rotAngle = NULL; td->ext->quat = NULL; - + copy_v3_v3(td->ext->irot, pchan->eul); } else if (pchan->rotmode == ROT_MODE_AXISANGLE) { @@ -563,7 +563,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr td->ext->rotAxis = pchan->rotAxis; td->ext->rotAngle = &pchan->rotAngle; td->ext->quat = NULL; - + td->ext->irotAngle = pchan->rotAngle; copy_v3_v3(td->ext->irotAxis, pchan->rotAxis); } @@ -572,7 +572,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr td->ext->rotAxis = NULL; td->ext->rotAngle = NULL; td->ext->quat = pchan->quat; - + copy_qt_qt(td->ext->iquat, pchan->quat); } td->ext->rotOrder = pchan->rotmode; @@ -625,7 +625,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr td->flag |= TD_PBONE_LOCAL_MTX_P; } } - + /* for axismat we use bone's own transform */ copy_m3_m4(pmat, pchan->pose_mat); mul_m3_m3m3(td->axismtx, omat, pmat); @@ -710,7 +710,7 @@ int count_set_pose_transflags(int *out_mode, short around, Object *ob) bone->flag |= BONE_TRANSFORM; else bone->flag &= ~BONE_TRANSFORM; - + bone->flag &= ~BONE_HINGE_CHILD_TRANSFORM; bone->flag &= ~BONE_TRANSFORM_CHILD; } @@ -734,7 +734,7 @@ int count_set_pose_transflags(int *out_mode, short around, Object *ob) bone = pchan->bone; if (bone->flag & BONE_TRANSFORM) { total++; - + if (mode == TFM_TRANSLATION) { if (has_targetless_ik(pchan) == NULL) { if (pchan->parent && (pchan->bone->flag & BONE_CONNECTED)) { @@ -860,9 +860,9 @@ static void pose_grab_with_ik_clear(Object *ob) for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { /* clear all temporary lock flags */ pchan->ikflag &= ~(BONE_IK_NO_XDOF_TEMP | BONE_IK_NO_YDOF_TEMP | BONE_IK_NO_ZDOF_TEMP); - + pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_TARGET); - + /* remove all temporary IK-constraints added */ for (con = pchan->constraints.first; con; con = next) { next = con->next; @@ -911,15 +911,15 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan) for (con = pchan->constraints.first; con; con = con->next) { if (con->type == CONSTRAINT_TYPE_KINEMATIC) { data = con->data; - + if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == '\0')) { /* make reference to constraint to base things off later (if it's the last targetless constraint encountered) */ targetless = (bKinematicConstraint *)con->data; - + /* but, if this is a targetless IK, we make it auto anyway (for the children loop) */ if (con->enforce != 0.0f) { data->flag |= CONSTRAINT_IK_AUTO; - + /* if no chain length has been specified, just make things obey standard rotation locks too */ if (data->rootbone == 0) { for (; pchan; pchan = pchan->parent) { @@ -930,11 +930,11 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan) if (pchan->protectflag & OB_LOCK_ROTZ) pchan->ikflag |= BONE_IK_NO_ZDOF_TEMP; } } - - return 0; + + return 0; } } - + if ((con->flag & CONSTRAINT_DISABLE) == 0 && (con->enforce != 0.0f)) return 0; } @@ -952,7 +952,7 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan) data->flag |= CONSTRAINT_IK_TEMP | CONSTRAINT_IK_AUTO | CONSTRAINT_IK_POS; copy_v3_v3(data->grabtarget, pchan->pose_tail); data->rootbone = 0; /* watch-it! has to be 0 here, since we're still on the same bone for the first time through the loop [#25885] */ - + /* we only include bones that are part of a continual connected chain */ do { /* here, we set ik-settings for bone from pchan->protectflag */ @@ -960,10 +960,10 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan) if (pchan->protectflag & OB_LOCK_ROTX) pchan->ikflag |= BONE_IK_NO_XDOF_TEMP; if (pchan->protectflag & OB_LOCK_ROTY) pchan->ikflag |= BONE_IK_NO_YDOF_TEMP; if (pchan->protectflag & OB_LOCK_ROTZ) pchan->ikflag |= BONE_IK_NO_ZDOF_TEMP; - + /* now we count this pchan as being included */ data->rootbone++; - + /* continue to parent, but only if we're connected to it */ if (pchan->bone->flag & BONE_CONNECTED) pchan = pchan->parent; @@ -1132,7 +1132,7 @@ void restoreBones(TransInfo *t) while (bid->bone) { ebo = bid->bone; - + ebo->dist = bid->dist; ebo->rad_tail = bid->rad_tail; ebo->roll = bid->roll; @@ -1140,7 +1140,7 @@ void restoreBones(TransInfo *t) ebo->zwidth = bid->zwidth; copy_v3_v3(ebo->head, bid->head); copy_v3_v3(ebo->tail, bid->tail); - + if (arm->flag & ARM_MIRROR_EDIT) { EditBone *ebo_child; @@ -1159,7 +1159,7 @@ void restoreBones(TransInfo *t) parent->rad_tail = ebo->rad_head; } } - + bid++; } } @@ -1177,7 +1177,7 @@ static void createTransArmatureVerts(TransInfo *t) int total_mirrored = 0, i; int oldtot; BoneInitData *bid; - + t->total = 0; for (ebo = edbo->first; ebo; ebo = ebo->next) { oldtot = t->total; @@ -2681,7 +2681,7 @@ static void createTransEditVerts(TransInfo *t) } } } - + if (island_info) { MEM_freeN(island_info); MEM_freeN(island_vert_map); @@ -2719,9 +2719,9 @@ void flushTransNodes(TransInfo *t) int a; TransData *td; TransData2D *td2d; - + applyGridAbsolute(t); - + /* flush to 2d vector from internally used 3d vector */ for (a = 0, td = t->data, td2d = t->data2d; a < t->total; a++, td++, td2d++) { bNode *node = td->extra; @@ -2735,7 +2735,7 @@ void flushTransNodes(TransInfo *t) locx = td2d->loc[0] / dpi_fac; locy = td2d->loc[1] / dpi_fac; #endif - + /* account for parents (nested nodes) */ if (node->parent) { nodeFromView(node->parent, locx, locy, &node->locx, &node->locy); @@ -2745,7 +2745,7 @@ void flushTransNodes(TransInfo *t) node->locy = locy; } } - + /* handle intersection with noodles */ if (t->total == 1) { ED_node_link_intersect_test(t->sa, 1); @@ -3072,7 +3072,7 @@ static void createTransUVs(bContext *C, TransInfo *t) center = island_center[element->island].co; } } - + BM_elem_flag_enable(l, BM_ELEM_TAG); luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); UVsToTransData(t->aspect, td++, td2d++, luv->uv, center, selected); @@ -3220,28 +3220,28 @@ static void createTransNlaData(bContext *C, TransInfo *t) SpaceNla *snla = NULL; TransData *td = NULL; TransDataNla *tdn = NULL; - + bAnimContext ac; ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + int count = 0; - + /* determine what type of data we are operating on */ if (ANIM_animdata_get_context(C, &ac) == 0) return; snla = (SpaceNla *)ac.sl; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* which side of the current frame should be allowed */ if (t->mode == TFM_TIME_EXTEND) { /* only side on which mouse is gets transformed */ float xmouse, ymouse; - + UI_view2d_region_to_view(&ac.ar->v2d, t->mouse.imval[0], t->mouse.imval[1], &xmouse, &ymouse); t->frame_side = (xmouse > CFRA) ? 'R' : 'L'; } @@ -3249,15 +3249,15 @@ static void createTransNlaData(bContext *C, TransInfo *t) /* normal transform - both sides of current frame are considered */ t->frame_side = 'B'; } - + /* loop 1: count how many strips are selected (consider each strip as 2 points) */ for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - + /* make some meta-strips for chains of selected strips */ BKE_nlastrips_make_metas(&nlt->strips, 1); - + /* only consider selected strips */ for (strip = nlt->strips.first; strip; strip = strip->next) { // TODO: we can make strips have handles later on... @@ -3270,30 +3270,30 @@ static void createTransNlaData(bContext *C, TransInfo *t) } } } - + /* stop if trying to build list if nothing selected */ if (count == 0) { - /* clear temp metas that may have been created but aren't needed now + /* clear temp metas that may have been created but aren't needed now * because they fell on the wrong side of CFRA */ for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; BKE_nlastrips_clear_metas(&nlt->strips, 0, 1); } - + /* cleanup temp list */ ANIM_animdata_freelist(&anim_data); return; } - + /* allocate memory for data */ t->total = count; - + t->data = MEM_callocN(t->total * sizeof(TransData), "TransData(NLA Editor)"); td = t->data; t->custom.type.data = tdn = MEM_callocN(t->total * sizeof(TransDataNla), "TransDataNla (NLA Editor)"); t->custom.type.use_free = true; - + /* loop 2: build transdata array */ for (ale = anim_data.first; ale; ale = ale->next) { /* only if a real NLA-track */ @@ -3301,7 +3301,7 @@ static void createTransNlaData(bContext *C, TransInfo *t) AnimData *adt = ale->adt; NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - + /* only consider selected strips */ for (strip = nlt->strips.first; strip; strip = strip->next) { // TODO: we can make strips have handles later on... @@ -3318,44 +3318,44 @@ static void createTransNlaData(bContext *C, TransInfo *t) * cases, there will need to be 1 of these tdn elements in the array skipped... */ float center[3], yval; - + /* firstly, init tdn settings */ tdn->id = ale->id; tdn->oldTrack = tdn->nlt = nlt; tdn->strip = strip; tdn->trackIndex = BLI_findindex(&adt->nla_tracks, nlt); - + yval = (float)(tdn->trackIndex * NLACHANNEL_STEP(snla)); - + tdn->h1[0] = strip->start; tdn->h1[1] = yval; tdn->h2[0] = strip->end; tdn->h2[1] = yval; - + center[0] = (float)CFRA; center[1] = yval; center[2] = 0.0f; - + /* set td's based on which handles are applicable */ if (FrameOnMouseSide(t->frame_side, strip->start, (float)CFRA)) { /* just set tdn to assume that it only has one handle for now */ tdn->handle = -1; - + /* now, link the transform data up to this data */ if (ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_EXTEND)) { td->loc = tdn->h1; copy_v3_v3(td->iloc, tdn->h1); - + /* store all the other gunk that is required by transform */ copy_v3_v3(td->center, center); memset(td->axismtx, 0, sizeof(td->axismtx)); td->axismtx[2][2] = 1.0f; - + td->ext = NULL; td->val = NULL; - + td->flag |= TD_SELECTED; td->dist = 0.0f; - + unit_m3(td->mtx); unit_m3(td->smtx); } @@ -3364,29 +3364,29 @@ static void createTransNlaData(bContext *C, TransInfo *t) td->val = &tdn->h1[0]; td->ival = tdn->h1[0]; } - + td->extra = tdn; td++; } if (FrameOnMouseSide(t->frame_side, strip->end, (float)CFRA)) { /* if tdn is already holding the start handle, then we're doing both, otherwise, only end */ tdn->handle = (tdn->handle) ? 2 : 1; - + /* now, link the transform data up to this data */ if (ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_EXTEND)) { td->loc = tdn->h2; copy_v3_v3(td->iloc, tdn->h2); - + /* store all the other gunk that is required by transform */ copy_v3_v3(td->center, center); memset(td->axismtx, 0, sizeof(td->axismtx)); td->axismtx[2][2] = 1.0f; - + td->ext = NULL; td->val = NULL; - + td->flag |= TD_SELECTED; td->dist = 0.0f; - + unit_m3(td->mtx); unit_m3(td->smtx); } @@ -3395,11 +3395,11 @@ static void createTransNlaData(bContext *C, TransInfo *t) td->val = &tdn->h2[0]; td->ival = tdn->h2[0]; } - + td->extra = tdn; td++; } - + /* if both handles were used, skip the next tdn (i.e. leave it blank) since the counting code is dumb... * otherwise, just advance to the next one... */ @@ -3412,7 +3412,7 @@ static void createTransNlaData(bContext *C, TransInfo *t) } } } - + /* cleanup temp list */ ANIM_animdata_freelist(&anim_data); } @@ -3461,7 +3461,7 @@ static int masklay_shape_cmp_frame(void *thunk, const void *a, const void *b) static void posttrans_gpd_clean(bGPdata *gpd) { bGPDlayer *gpl; - + for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { bGPDframe *gpf, *gpfn; bool is_double = false; @@ -3517,7 +3517,7 @@ typedef struct tRetainedKeyframe { struct tRetainedKeyframe *next, *prev; float frame; /* frame to cluster around */ float val; /* average value */ - + size_t tot_count; /* number of keyframes that have been averaged */ size_t del_count; /* number of keyframes of this sort that have been deleted so far */ } tRetainedKeyframe; @@ -3530,27 +3530,27 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle) /* NOTE: We assume that all keys are sorted */ ListBase retained_keys = {NULL, NULL}; const bool can_average_points = ((fcu->flag & (FCURVE_INT_VALUES | FCURVE_DISCRETE_VALUES)) == 0); - + /* sanity checks */ if ((fcu->totvert == 0) || (fcu->bezt == NULL)) return; - + /* 1) Identify selected keyframes, and average the values on those * in case there are collisions due to multiple keys getting scaled * to all end up on the same frame */ for (int i = 0; i < fcu->totvert; i++) { BezTriple *bezt = &fcu->bezt[i]; - + if (BEZT_ISSEL_ANY(bezt)) { bool found = false; - + /* If there's another selected frame here, merge it */ for (tRetainedKeyframe *rk = retained_keys.last; rk; rk = rk->prev) { if (IS_EQT(rk->frame, bezt->vec[1][0], BEZT_BINARYSEARCH_THRESH)) { rk->val += bezt->vec[1][1]; rk->tot_count++; - + found = true; break; } @@ -3559,20 +3559,20 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle) break; } } - + /* If nothing found yet, create a new one */ if (found == false) { tRetainedKeyframe *rk = MEM_callocN(sizeof(tRetainedKeyframe), "tRetainedKeyframe"); - + rk->frame = bezt->vec[1][0]; rk->val = bezt->vec[1][1]; rk->tot_count = 1; - + BLI_addtail(&retained_keys, rk); } } } - + if (BLI_listbase_is_empty(&retained_keys)) { /* This may happen if none of the points were selected... */ if (G.debug & G_DEBUG) { @@ -3586,15 +3586,15 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle) rk->val = rk->val / (float)rk->tot_count; } } - + /* 2) Delete all keyframes duplicating the "retained keys" found above * - Most of these will be unselected keyframes * - Some will be selected keyframes though. For those, we only keep the last one - * (or else everything is gone), and replace its value with the averaged value. + * (or else everything is gone), and replace its value with the averaged value. */ for (int i = fcu->totvert - 1; i >= 0; i--) { BezTriple *bezt = &fcu->bezt[i]; - + /* Is this keyframe a candidate for deletion? */ /* TODO: Replace loop with an O(1) lookup instead */ for (tRetainedKeyframe *rk = retained_keys.last; rk; rk = rk->prev) { @@ -3617,7 +3617,7 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle) /* Delete Keyframe */ delete_fcurve_key(fcu, i, 0); } - + /* Update count of how many we've deleted * - It should only matter that we're doing this for all but the last one */ @@ -3627,16 +3627,16 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle) /* Always delete - Unselected keys don't matter */ delete_fcurve_key(fcu, i, 0); } - + /* Stop the RK search... we've found our match now */ break; } } } - + /* 3) Recalculate handles */ testhandles_fcurve(fcu, use_handle); - + /* cleanup */ BLI_freelistN(&retained_keys); } @@ -3661,7 +3661,7 @@ static void posttrans_action_clean(bAnimContext *ac, bAction *act) */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); posttrans_fcurve_clean(ale->key_data, false); /* only use handles in graph editor */ @@ -3708,10 +3708,10 @@ static int count_gplayer_frames(bGPDlayer *gpl, char side, float cfra, bool is_p { bGPDframe *gpf; int count = 0, count_all = 0; - + if (gpl == NULL) return count; - + /* only include points that occur on the right side of cfra */ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { if (FrameOnMouseSide(side, (float)gpf->framenum, cfra)) { @@ -3720,7 +3720,7 @@ static int count_gplayer_frames(bGPDlayer *gpl, char side, float cfra, bool is_p count_all++; } } - + if (is_prop_edit && count > 0) return count_all; else @@ -3790,7 +3790,7 @@ static TransData *ActionFCurveToTransData(TransData *td, TransData2D **td2dv, FC /* only add if on the right 'side' of the current frame */ if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) { TimeToTransData(td, bezt->vec[1], adt, ypos); - + if (bezt->f2 & SELECT) td->flag |= TD_SELECTED; @@ -3798,18 +3798,18 @@ static TransData *ActionFCurveToTransData(TransData *td, TransData2D **td2dv, FC td->flag |= TD_MOVEHANDLE1 | TD_MOVEHANDLE2; td2d->h1 = bezt->vec[0]; td2d->h2 = bezt->vec[2]; - + copy_v2_v2(td2d->ih1, td2d->h1); copy_v2_v2(td2d->ih2, td2d->h2); - + td++; td2d++; } } } - + *td2dv = td2d; - + return td; } @@ -3842,7 +3842,7 @@ static int GPLayerToTransData(TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl, { bGPDframe *gpf; int count = 0; - + /* check for select frames on right side of current frame */ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { if (is_prop_edit || (gpf->flag & GP_FRAME_SELECT)) { @@ -3850,13 +3850,13 @@ static int GPLayerToTransData(TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl, /* memory is calloc'ed, so that should zero everything nicely for us */ td->val = &tfd->val; td->ival = (float)gpf->framenum; - + td->center[0] = td->ival; td->center[1] = ypos; tfd->val = (float)gpf->framenum; tfd->sdata = &gpf->framenum; - + /* advance td now */ td++; tfd++; @@ -3864,7 +3864,7 @@ static int GPLayerToTransData(TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl, } } } - + return count; } @@ -3928,19 +3928,19 @@ static void createTransActionData(bContext *C, TransInfo *t) /* determine what type of data we are operating on */ if (ANIM_animdata_get_context(C, &ac) == 0) return; - + /* filter data */ if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT); else filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* which side of the current frame should be allowed */ if (t->mode == TFM_TIME_EXTEND) { /* only side on which mouse is gets transformed */ float xmouse, ymouse; - + UI_view2d_region_to_view(&ac.ar->v2d, t->mouse.imval[0], t->mouse.imval[1], &xmouse, &ymouse); t->frame_side = (xmouse > CFRA) ? 'R' : 'L'; // XXX use t->frame_side } @@ -3948,7 +3948,7 @@ static void createTransActionData(bContext *C, TransInfo *t) /* normal transform - both sides of current frame are considered */ t->frame_side = 'B'; } - + /* loop 1: fully select ipo-keys and count how many BezTriples are selected */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(&ac, ale); @@ -3960,7 +3960,7 @@ static void createTransActionData(bContext *C, TransInfo *t) cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); else cfra = (float)CFRA; - + if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) adt_count = count_fcurve_keys(ale->key_data, t->frame_side, cfra, is_prop_edit); else if (ale->type == ANIMTYPE_GPLAYER) @@ -3975,27 +3975,27 @@ static void createTransActionData(bContext *C, TransInfo *t) ale->tag = true; } } - + /* stop if trying to build list if nothing selected */ if (count == 0) { /* cleanup temp list */ ANIM_animdata_freelist(&anim_data); return; } - + /* allocate memory for data */ t->total = count; - + t->data = MEM_callocN(t->total * sizeof(TransData), "TransData(Action Editor)"); t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "transdata2d"); td = t->data; td2d = t->data2d; - + if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) { t->custom.type.data = tfd = MEM_callocN(sizeof(tGPFtransdata) * count, "tGPFtransdata"); t->custom.type.use_free = true; } - + /* loop 2: build transdata array */ for (ale = anim_data.first; ale; ale = ale->next) { @@ -4015,7 +4015,7 @@ static void createTransActionData(bContext *C, TransInfo *t) if (ale->type == ANIMTYPE_GPLAYER) { bGPDlayer *gpl = (bGPDlayer *)ale->data; int i; - + i = GPLayerToTransData(td, tfd, gpl, t->frame_side, cfra, is_prop_edit, ypos); td += i; tfd += i; @@ -4031,7 +4031,7 @@ static void createTransActionData(bContext *C, TransInfo *t) else { AnimData *adt = ANIM_nla_mapping_get(&ac, ale); FCurve *fcu = (FCurve *)ale->key_data; - + td = ActionFCurveToTransData(td, &td2d, fcu, adt, t->frame_side, cfra, is_prop_edit, ypos); } } @@ -4167,18 +4167,18 @@ static void bezt_to_transdata(TransData *td, TransData2D *td2d, TransDataGraph * * Due to NLA mapping, we apply NLA mapping to some of the verts here, * and then that mapping will be undone after transform is done. */ - + if (adt) { td2d->loc[0] = BKE_nla_tweakedit_remap(adt, loc[0], NLATIME_CONVERT_MAP); td2d->loc[1] = (loc[1] + offset) * unit_scale; td2d->loc[2] = 0.0f; td2d->loc2d = loc; - + td->loc = td2d->loc; td->center[0] = BKE_nla_tweakedit_remap(adt, cent[0], NLATIME_CONVERT_MAP); td->center[1] = (cent[1] + offset) * unit_scale; td->center[2] = 0.0f; - + copy_v3_v3(td->iloc, td->loc); } else { @@ -4186,7 +4186,7 @@ static void bezt_to_transdata(TransData *td, TransData2D *td2d, TransDataGraph * td2d->loc[1] = (loc[1] + offset) * unit_scale; td2d->loc[2] = 0.0f; td2d->loc2d = loc; - + td->loc = td2d->loc; copy_v3_v3(td->center, cent); td->center[1] = (td->center[1] + offset) * unit_scale; @@ -4206,19 +4206,19 @@ static void bezt_to_transdata(TransData *td, TransData2D *td2d, TransDataGraph * memset(td->axismtx, 0, sizeof(td->axismtx)); td->axismtx[2][2] = 1.0f; - + td->ext = NULL; td->val = NULL; - + /* store AnimData info in td->extra, for applying mapping when flushing */ td->extra = adt; - + if (selected) { td->flag |= TD_SELECTED; td->dist = 0.0f; } else td->dist = FLT_MAX; - + if (ishandle) td->flag |= TD_NOTIMESNAP; if (intvals) @@ -4272,16 +4272,16 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) Scene *scene = t->scene; ARegion *ar = t->ar; View2D *v2d = &ar->v2d; - + TransData *td = NULL; TransData2D *td2d = NULL; TransDataGraph *tdg = NULL; - + bAnimContext ac; ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + BezTriple *bezt; int count = 0, i; float mtx[3][3], smtx[3][3]; @@ -4290,7 +4290,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) const bool use_local_center = graph_edit_use_local_center(t); const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0; short anim_map_flag = ANIM_UNITCONV_ONLYSEL | ANIM_UNITCONV_SELVERTS; - + /* determine what type of data we are operating on */ if (ANIM_animdata_get_context(C, &ac) == 0) return; @@ -4300,13 +4300,13 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* which side of the current frame should be allowed */ // XXX we still want this mode, but how to get this using standard transform too? if (t->mode == TFM_TIME_EXTEND) { /* only side on which mouse is gets transformed */ float xmouse, ymouse; - + UI_view2d_region_to_view(v2d, t->mouse.imval[0], t->mouse.imval[1], &xmouse, &ymouse); t->frame_side = (xmouse > CFRA) ? 'R' : 'L'; // XXX use t->frame_side } @@ -4314,7 +4314,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) /* normal transform - both sides of current frame are considered */ t->frame_side = 'B'; } - + /* loop 1: count how many BezTriples (specifically their verts) are selected (or should be edited) */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(&ac, ale); @@ -4373,46 +4373,46 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) } } } - + /* stop if trying to build list if nothing selected */ if (count == 0) { /* cleanup temp list */ ANIM_animdata_freelist(&anim_data); return; } - + /* allocate memory for data */ t->total = count; - + t->data = MEM_callocN(t->total * sizeof(TransData), "TransData (Graph Editor)"); /* for each 2d vert a 3d vector is allocated, so that they can be treated just as if they were 3d verts */ t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransData2D (Graph Editor)"); t->custom.type.data = MEM_callocN(t->total * sizeof(TransDataGraph), "TransDataGraph"); t->custom.type.use_free = true; - + td = t->data; td2d = t->data2d; tdg = t->custom.type.data; - + /* precompute space-conversion matrices for dealing with non-uniform scaling of Graph Editor */ unit_m3(mtx); unit_m3(smtx); - + if (ELEM(t->mode, TFM_ROTATION, TFM_RESIZE)) { float xscale, yscale; - + /* apply scale factors to x and y axes of space-conversion matrices */ UI_view2d_scale_get(v2d, &xscale, &yscale); - + /* mtx is data to global (i.e. view) conversion */ mul_v3_fl(mtx[0], xscale); mul_v3_fl(mtx[1], yscale); - + /* smtx is global (i.e. view) to data conversion */ if (IS_EQF(xscale, 0.0f) == 0) mul_v3_fl(smtx[0], 1.0f / xscale); if (IS_EQF(yscale, 0.0f) == 0) mul_v3_fl(smtx[1], 1.0f / yscale); } - + /* loop 2: build transdata arrays */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(&ac, ale); @@ -4444,7 +4444,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) TransDataCurveHandleFlags *hdata = NULL; /* short h1=1, h2=1; */ /* UNUSED */ - + if (is_prop_edit) { bool is_sel = (sel2 || sel1 || sel3); /* we always select all handles for proportional editing if central handle is selected */ @@ -4512,7 +4512,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) } } } - + /* Sets handles based on the selection */ testhandles_fcurve(fcu, use_handle); } @@ -4600,19 +4600,19 @@ static BeztMap *bezt_to_beztmaps(BezTriple *bezts, int totvert, const short UNUS BezTriple *prevbezt = NULL; BeztMap *bezm, *bezms; int i; - + /* allocate memory for this array */ if (totvert == 0 || bezts == NULL) return NULL; bezm = bezms = MEM_callocN(sizeof(BeztMap) * totvert, "BeztMaps"); - + /* assign beztriples to beztmaps */ for (i = 0; i < totvert; i++, bezm++, prevbezt = bezt, bezt++) { bezm->bezt = bezt; - + bezm->oldIndex = i; bezm->newIndex = i; - + bezm->pipo = (prevbezt) ? prevbezt->ipo : bezt->ipo; bezm->cipo = bezt->ipo; } @@ -4625,11 +4625,11 @@ static void sort_time_beztmaps(BeztMap *bezms, int totvert, const short UNUSED(u { BeztMap *bezm; int i, ok = 1; - + /* keep repeating the process until nothing is out of place anymore */ while (ok) { ok = 0; - + bezm = bezms; i = totvert; while (i--) { @@ -4638,13 +4638,13 @@ static void sort_time_beztmaps(BeztMap *bezms, int totvert, const short UNUSED(u if (bezm->bezt->vec[1][0] > (bezm + 1)->bezt->vec[1][0]) { bezm->newIndex++; (bezm + 1)->newIndex--; - + SWAP(BeztMap, *bezm, *(bezm + 1)); - + ok = 1; } } - + /* do we need to check if the handles need to be swapped? * optimization: this only needs to be performed in the first loop */ @@ -4660,7 +4660,7 @@ static void sort_time_beztmaps(BeztMap *bezms, int totvert, const short UNUSED(u bezm->swapHs = -1; } } - + bezm++; } } @@ -4675,13 +4675,13 @@ static void beztmap_to_data(TransInfo *t, FCurve *fcu, BeztMap *bezms, int totve TransData *td; int i, j; char *adjusted; - + /* dynamically allocate an array of chars to mark whether an TransData's * pointers have been fixed already, so that we don't override ones that are * already done */ adjusted = MEM_callocN(t->total, "beztmap_adjusted_map"); - + /* for each beztmap item, find if it is used anywhere */ bezm = bezms; for (i = 0; i < totvert; i++, bezm++) { @@ -4693,7 +4693,7 @@ static void beztmap_to_data(TransInfo *t, FCurve *fcu, BeztMap *bezms, int totve for (j = 0; j < t->total; j++, td2d++, td++) { /* skip item if already marked */ if (adjusted[j] != 0) continue; - + /* update all transdata pointers, no need to check for selections etc, * since only points that are really needed were created as transdata */ @@ -4713,13 +4713,13 @@ static void beztmap_to_data(TransInfo *t, FCurve *fcu, BeztMap *bezms, int totve } else if (td2d->loc2d == bezm->bezt->vec[1]) { td2d->loc2d = (bezts + bezm->newIndex)->vec[1]; - + /* if only control point is selected, the handle pointers need to be updated as well */ if (td2d->h1) td2d->h1 = (bezts + bezm->newIndex)->vec[0]; if (td2d->h2) td2d->h2 = (bezts + bezm->newIndex)->vec[2]; - + adjusted[j] = 1; } @@ -4735,9 +4735,9 @@ static void beztmap_to_data(TransInfo *t, FCurve *fcu, BeztMap *bezms, int totve } } } - + } - + /* free temp memory used for 'adjusted' array */ MEM_freeN(adjusted); } @@ -4754,26 +4754,26 @@ void remake_graph_transdata(TransInfo *t, ListBase *anim_data) SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first; bAnimListElem *ale; const bool use_handle = (sipo->flag & SIPO_NOHANDLES) == 0; - + /* sort and reassign verts */ for (ale = anim_data->first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; - + if (fcu->bezt) { BeztMap *bezm; - + /* adjust transform-data pointers */ /* note, none of these functions use 'use_handle', it could be removed */ bezm = bezt_to_beztmaps(fcu->bezt, fcu->totvert, use_handle); sort_time_beztmaps(bezm, fcu->totvert, use_handle); beztmap_to_data(t, fcu, bezm, fcu->totvert, use_handle); - + /* free mapping stuff */ MEM_freeN(bezm); - + /* re-sort actual beztriples (perhaps this could be done using the beztmaps to save time?) */ sort_time_fcurve(fcu); - + /* make sure handles are all set correctly */ testhandles_fcurve(fcu, use_handle); } @@ -4811,11 +4811,11 @@ void flushTransGraphData(TransInfo *t) case SACTSNAP_FRAME: /* snap to nearest frame */ td2d->loc[0] = floor((double)td2d->loc[0] + 0.5); break; - + case SACTSNAP_SECOND: /* snap to nearest second */ td2d->loc[0] = floor(((double)td2d->loc[0] / secf) + 0.5) * secf; break; - + case SACTSNAP_MARKER: /* snap to nearest marker */ td2d->loc[0] = (float)ED_markers_find_nearest_marker_time(&t->scene->markers, td2d->loc[0]); break; @@ -4827,7 +4827,7 @@ void flushTransGraphData(TransInfo *t) td2d->loc2d[0] = BKE_nla_tweakedit_remap(adt, td2d->loc[0], NLATIME_CONVERT_UNMAP); else td2d->loc2d[0] = td2d->loc[0]; - + /* Time-stepping auto-snapping modes don't get applied for Graph Editor transforms, * as these use the generic transform modes which don't account for this sort of thing. * These ones aren't affected by NLA mapping, so we do this after the conversion... @@ -4836,15 +4836,15 @@ void flushTransGraphData(TransInfo *t) * to, otherwise we get "swimming handles" * NOTE: We don't do this when canceling transforms, or else these changes don't go away */ - if ((t->state != TRANS_CANCEL) && (td->flag & TD_NOTIMESNAP) == 0 && - ELEM(sipo->autosnap, SACTSNAP_STEP, SACTSNAP_TSTEP)) + if ((t->state != TRANS_CANCEL) && (td->flag & TD_NOTIMESNAP) == 0 && + ELEM(sipo->autosnap, SACTSNAP_STEP, SACTSNAP_TSTEP)) { switch (sipo->autosnap) { case SACTSNAP_STEP: /* frame step */ td2d->loc2d[0] = floor((double)td2d->loc[0] + 0.5); td->loc[0] = floor((double)td->loc[0] + 0.5); break; - + case SACTSNAP_TSTEP: /* second step */ /* XXX: the handle behaviour in this case is still not quite right... */ td2d->loc[0] = floor(((double)td2d->loc[0] / secf) + 0.5) * secf; @@ -4852,18 +4852,18 @@ void flushTransGraphData(TransInfo *t) break; } } - + /* if int-values only, truncate to integers */ if (td->flag & TD_INTVALUES) td2d->loc2d[1] = floorf(td2d->loc[1] * inv_unit_scale - tdg->offset + 0.5f); else td2d->loc2d[1] = td2d->loc[1] * inv_unit_scale - tdg->offset; - + if ((td->flag & TD_MOVEHANDLE1) && td2d->h1) { td2d->h1[0] = td2d->ih1[0] + td->loc[0] - td->iloc[0]; td2d->h1[1] = td2d->ih1[1] + (td->loc[1] - td->iloc[1]) * inv_unit_scale; } - + if ((td->flag & TD_MOVEHANDLE2) && td2d->h2) { td2d->h2[0] = td2d->ih2[0] + td->loc[0] - td->iloc[0]; td2d->h2[1] = td2d->ih2[1] + (td->loc[1] - td->iloc[1]) * inv_unit_scale; @@ -5408,7 +5408,7 @@ static void createTransSeqData(bContext *C, TransInfo *t) /* loop 2: build transdata array */ SeqToTransData_Recursive(t, ed->seqbasep, td, td2d, tdsq); SeqTransDataBounds(t, ed->seqbasep, ts); - + /* set the snap mode based on how close the mouse is at the end/start points */ if (abs(xmouse - ts->max) > abs(xmouse - ts->min)) ts->snap_left = true; @@ -5446,19 +5446,19 @@ static bool constraints_list_needinv(TransInfo *t, ListBase *list) { return true; } - + /* constraints that require this only under special conditions */ if (con->type == CONSTRAINT_TYPE_CHILDOF) { /* ChildOf constraint only works when using all location components, see T42256. */ bChildOfConstraint *data = (bChildOfConstraint *)con->data; - + if ((data->flag & CHILDOF_LOCX) && (data->flag & CHILDOF_LOCY) && (data->flag & CHILDOF_LOCZ)) return true; } else if (con->type == CONSTRAINT_TYPE_ROTLIKE) { /* CopyRot constraint only does this when rotating, and offset is on */ bRotateLikeConstraint *data = (bRotateLikeConstraint *)con->data; - + if ((data->flag & ROTLIKE_OFFSET) && (t->mode == TFM_ROTATION)) return true; } @@ -5466,7 +5466,7 @@ static bool constraints_list_needinv(TransInfo *t, ListBase *list) /* Transform constraint needs it for rotation at least (r.57309), * but doing so when translating may also mess things up [#36203] */ - + if (t->mode == TFM_ROTATION) return true; /* ??? (t->mode == TFM_SCALE) ? */ @@ -5542,13 +5542,13 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) td->loc = ob->loc; copy_v3_v3(td->iloc, td->loc); - + if (ob->rotmode > 0) { td->ext->rot = ob->rot; td->ext->rotAxis = NULL; td->ext->rotAngle = NULL; td->ext->quat = NULL; - + copy_v3_v3(td->ext->irot, ob->rot); copy_v3_v3(td->ext->drot, ob->drot); } @@ -5557,7 +5557,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) td->ext->rotAxis = ob->rotAxis; td->ext->rotAngle = &ob->rotAngle; td->ext->quat = NULL; - + td->ext->irotAngle = ob->rotAngle; copy_v3_v3(td->ext->irotAxis, ob->rotAxis); // td->ext->drotAngle = ob->drotAngle; // XXX, not implemented @@ -5568,7 +5568,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) td->ext->rotAxis = NULL; td->ext->rotAngle = NULL; td->ext->quat = ob->quat; - + copy_qt_qt(td->ext->iquat, ob->quat); copy_qt_qt(td->ext->dquat, ob->dquat); } @@ -5694,7 +5694,7 @@ static bool mark_children(Object *ob) return true; } } - + return false; } @@ -5713,7 +5713,7 @@ static int count_proportional_objects(TransInfo *t) for (base = scene->base.first; base; base = base->next) { if (TESTBASELIB_BGMODE(v3d, scene, base)) { Object *parent = base->object->parent; - + /* flag all parents */ while (parent) { parent->flag |= BA_TRANSFORM_PARENT; @@ -5732,7 +5732,7 @@ static int count_proportional_objects(TransInfo *t) } } } - + for (base = scene->base.first; base; base = base->next) { Object *ob = base->object; @@ -5746,7 +5746,7 @@ static int count_proportional_objects(TransInfo *t) total += 1; } } - + /* all recalc flags get flushed to all layers, so a layer flip later on works fine */ DAG_scene_relations_update(G.main, t->scene); @@ -5784,7 +5784,7 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob, { ID *id = &ob->id; FCurve *fcu; - + // TODO: this should probably be done per channel instead... if (autokeyframe_cfra_can_key(scene, id)) { ReportList *reports = CTX_wm_reports(C); @@ -5793,36 +5793,36 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob, ListBase dsources = {NULL, NULL}; float cfra = (float)CFRA; // xxx this will do for now short flag = 0; - + /* get flags used for inserting keyframes */ flag = ANIM_get_keyframing_flags(scene, 1); - + /* add datasource override for the object */ - ANIM_relative_keyingset_add_source(&dsources, id, NULL, NULL); - + ANIM_relative_keyingset_add_source(&dsources, id, NULL, NULL); + if (IS_AUTOKEY_FLAG(scene, ONLYKEYINGSET) && (active_ks)) { - /* only insert into active keyingset + /* only insert into active keyingset * NOTE: we assume here that the active Keying Set does not need to have its iterator overridden */ ANIM_apply_keyingset(C, &dsources, NULL, active_ks, MODIFYKEY_MODE_INSERT, cfra); } else if (IS_AUTOKEY_FLAG(scene, INSERTAVAIL)) { AnimData *adt = ob->adt; - + /* only key on available channels */ if (adt && adt->action) { for (fcu = adt->action->curves.first; fcu; fcu = fcu->next) { fcu->flag &= ~FCURVE_SELECTED; insert_keyframe(reports, id, adt->action, (fcu->grp ? fcu->grp->name : NULL), - fcu->rna_path, fcu->array_index, cfra, + fcu->rna_path, fcu->array_index, cfra, ts->keyframe_type, flag); } } } else if (IS_AUTOKEY_FLAG(scene, INSERTNEEDED)) { bool do_loc = false, do_rot = false, do_scale = false; - + /* filter the conditions when this happens (assume that curarea->spacetype==SPACE_VIE3D) */ if (tmode == TFM_TRANSLATION) { do_loc = true; @@ -5834,7 +5834,7 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob, } else if (v3d->around == V3D_AROUND_CURSOR) do_loc = true; - + if ((v3d->flag & V3D_ALIGN) == 0) do_rot = true; } @@ -5845,11 +5845,11 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob, } else if (v3d->around == V3D_AROUND_CURSOR) do_loc = true; - + if ((v3d->flag & V3D_ALIGN) == 0) do_scale = true; } - + /* insert keyframes for the affected sets of channels using the builtin KeyingSets found */ if (do_loc) { KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOCATION_ID); @@ -5869,23 +5869,23 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob, KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOC_ROT_SCALE_ID); ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); } - + /* only calculate paths if there are paths to be recalculated, * assuming that since we've autokeyed the transforms this is * now safe to apply... - * + * * NOTE: only do this when there's context info */ if (C && (ob->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS)) { //ED_objects_clear_paths(C); // XXX for now, don't need to clear ED_objects_recalculate_paths(C, scene); - - /* XXX: there's potential here for problems with unkeyed rotations/scale, + + /* XXX: there's potential here for problems with unkeyed rotations/scale, * but for now (until proper data-locality for baking operations), * this should be a better fix for T24451 and T37755 */ } - + /* free temp info */ BLI_freelistN(&dsources); } @@ -5904,7 +5904,7 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o bPose *pose = ob->pose; bPoseChannel *pchan; FCurve *fcu; - + // TODO: this should probably be done per channel instead... if (autokeyframe_cfra_can_key(scene, id)) { ReportList *reports = CTX_wm_reports(C); @@ -5912,27 +5912,27 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o KeyingSet *active_ks = ANIM_scene_get_active_keyingset(scene); float cfra = (float)CFRA; short flag = 0; - + /* flag is initialized from UserPref keyframing settings * - special exception for targetless IK - INSERTKEY_MATRIX keyframes should get * visual keyframes even if flag not set, as it's not that useful otherwise * (for quick animation recording) */ flag = ANIM_get_keyframing_flags(scene, 1); - - if (targetless_ik) + + if (targetless_ik) flag |= INSERTKEY_MATRIX; - + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->bone->flag & BONE_TRANSFORM) { ListBase dsources = {NULL, NULL}; - + /* clear any 'unkeyed' flag it may have */ pchan->bone->flag &= ~BONE_UNKEYED; - + /* add datasource override for the camera object */ - ANIM_relative_keyingset_add_source(&dsources, id, &RNA_PoseBone, pchan); - + ANIM_relative_keyingset_add_source(&dsources, id, &RNA_PoseBone, pchan); + /* only insert into active keyingset? */ if (IS_AUTOKEY_FLAG(scene, ONLYKEYINGSET) && (active_ks)) { /* run the active Keying Set on the current datasource */ @@ -5945,17 +5945,17 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o /* only insert keyframes for this F-Curve if it affects the current bone */ if (strstr(fcu->rna_path, "bones")) { char *pchanName = BLI_str_quoted_substrN(fcu->rna_path, "bones["); - - /* only if bone name matches too... + + /* only if bone name matches too... * NOTE: this will do constraints too, but those are ok to do here too? */ if (pchanName && STREQ(pchanName, pchan->name)) { - insert_keyframe(reports, id, act, + insert_keyframe(reports, id, act, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, ts->keyframe_type, flag); } - + if (pchanName) MEM_freeN(pchanName); } } @@ -5964,7 +5964,7 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o /* only insert keyframe if needed? */ else if (IS_AUTOKEY_FLAG(scene, INSERTNEEDED)) { bool do_loc = false, do_rot = false, do_scale = false; - + /* filter the conditions when this happens (assume that curarea->spacetype==SPACE_VIE3D) */ if (tmode == TFM_TRANSLATION) { if (targetless_ik) @@ -5975,18 +5975,18 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o else if (ELEM(tmode, TFM_ROTATION, TFM_TRACKBALL)) { if (ELEM(v3d->around, V3D_AROUND_CURSOR, V3D_AROUND_ACTIVE)) do_loc = true; - + if ((v3d->flag & V3D_ALIGN) == 0) do_rot = true; } else if (tmode == TFM_RESIZE) { if (ELEM(v3d->around, V3D_AROUND_CURSOR, V3D_AROUND_ACTIVE)) do_loc = true; - + if ((v3d->flag & V3D_ALIGN) == 0) do_scale = true; } - + if (do_loc) { KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOCATION_ID); ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); @@ -6005,13 +6005,13 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOC_ROT_SCALE_ID); ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); } - + /* free temp info */ BLI_freelistN(&dsources); } } - - /* do the bone paths + + /* do the bone paths * - only do this when there is context info, since we need that to resolve * how to do the updates and so on... * - do not calculate unless there are paths already to update... @@ -6109,7 +6109,7 @@ static void special_aftertrans_update__mask(bContext *C, TransInfo *t) static void special_aftertrans_update__node(bContext *UNUSED(C), TransInfo *t) { const bool canceled = (t->state == TRANS_CANCEL); - + if (canceled && t->remove_on_cancel) { /* remove selected nodes on cancel */ SpaceNode *snode = (SpaceNode *)t->sa->spacedata.first; @@ -6167,7 +6167,7 @@ static void special_aftertrans_update__mesh(bContext *UNUSED(C), TransInfo *t) } /* inserting keys, pointcache, redraw events... */ -/* +/* * note: sequencer freeing has its own function now because of a conflict with transform's order of freeing (campbell) * Order changed, the sequencer stuff should go back in here * */ @@ -6177,11 +6177,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t) // short redrawipo=0, resetslowpar=1; const bool canceled = (t->state == TRANS_CANCEL); const bool duplicate = (t->mode == TFM_TIME_DUPLICATE); - + /* early out when nothing happened */ if (t->total == 0 || t->mode == TFM_DUMMY) return; - + if (t->spacetype == SPACE_VIEW3D) { if (t->obedit) { /* Special Exception: @@ -6264,10 +6264,10 @@ void special_aftertrans_update(bContext *C, TransInfo *t) special_aftertrans_update__node(C, t); if (canceled == 0) { ED_node_post_apply_transform(C, snode->edittree); - + ED_node_link_insert(t->sa); } - + /* clear link line */ ED_node_link_intersect_test(t->sa, 0); } @@ -6282,26 +6282,26 @@ void special_aftertrans_update(bContext *C, TransInfo *t) else if (t->spacetype == SPACE_ACTION) { SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first; bAnimContext ac; - + /* initialize relevant anim-context 'context' data */ if (ANIM_animdata_get_context(C, &ac) == 0) return; - + ob = ac.obact; - + if (ELEM(ac.datatype, ANIMCONT_DOPESHEET, ANIMCONT_SHAPEKEY)) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; short filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/); - + /* get channels to work on */ ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* these should all be F-Curves */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(&ac, ale); FCurve *fcu = (FCurve *)ale->key_data; - + /* 3 cases here for curve cleanups: * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done * 2) canceled == 0 -> user confirmed the transform, so duplicates should be removed @@ -6319,7 +6319,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) posttrans_fcurve_clean(fcu, false); /* only use handles in graph editor */ } } - + /* free temp memory */ ANIM_animdata_freelist(&anim_data); } @@ -6332,7 +6332,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) else DAG_id_tag_update(&ob->id, OB_RECALC_OB); } - + /* 3 cases here for curve cleanups: * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done * 2) canceled == 0 -> user confirmed the transform, so duplicates should be removed @@ -6355,7 +6355,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) ((canceled == 0) || (duplicate))) { bGPdata *gpd; - + // XXX: BAD! this get gpencil datablocks directly from main db... // but that's how this currently works :/ for (gpd = G.main->gpencil.first; gpd; gpd = gpd->id.next) { @@ -6384,9 +6384,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t) } } } - + /* marker transform, not especially nice but we may want to move markers - * at the same time as keyframes in the dope sheet. + * at the same time as keyframes in the dope sheet. */ if ((saction->flag & SACTION_MARKERS_MOVE) && (canceled == 0)) { if (t->mode == TFM_TIME_TRANSLATE) { @@ -6405,11 +6405,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t) ED_markers_post_apply_transform(ED_context_get_markers(C), t->scene, t->mode, t->values[0], t->frame_side); } } - + /* make sure all F-Curves are set correctly */ if (!ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) ANIM_editkeyframes_refresh(&ac); - + /* clear flag that was set for time-slide drawing */ saction->flag &= ~SACTION_MOVING; } @@ -6417,23 +6417,23 @@ void special_aftertrans_update(bContext *C, TransInfo *t) SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first; bAnimContext ac; const bool use_handle = (sipo->flag & SIPO_NOHANDLES) == 0; - + /* initialize relevant anim-context 'context' data */ if (ANIM_animdata_get_context(C, &ac) == 0) return; - + if (ac.datatype) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; short filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE); - + /* get channels to work on */ ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(&ac, ale); FCurve *fcu = (FCurve *)ale->key_data; - + /* 3 cases here for curve cleanups: * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done * 2) canceled == 0 -> user confirmed the transform, so duplicates should be removed @@ -6451,11 +6451,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t) posttrans_fcurve_clean(fcu, use_handle); } } - + /* free temp memory */ ANIM_animdata_freelist(&anim_data); } - + /* Make sure all F-Curves are set correctly, but not if transform was * canceled, since then curves were already restored to initial state. * Note: if the refresh is really needed after cancel then some way @@ -6466,32 +6466,32 @@ void special_aftertrans_update(bContext *C, TransInfo *t) } else if (t->spacetype == SPACE_NLA) { bAnimContext ac; - + /* initialize relevant anim-context 'context' data */ if (ANIM_animdata_get_context(C, &ac) == 0) return; - + if (ac.datatype) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; short filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT); - + /* get channels to work on */ ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; - + /* make sure strips are in order again */ BKE_nlatrack_sort_strips(nlt); - + /* remove the temp metas */ BKE_nlastrips_clear_metas(&nlt->strips, 0, 1); } - + /* free temp memory */ ANIM_animdata_freelist(&anim_data); - + /* perform after-transfrom validation */ ED_nla_postop_refresh(&ac); } @@ -6574,7 +6574,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) if (td->flag & TD_NOACTION) break; - + if (td->flag & TD_SKIP) continue; @@ -6600,7 +6600,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) if (!canceled) { autokeyframe_ob_cb_func(C, t->scene, (View3D *)t->view, ob, t->mode); } - + /* restore rigid body transform */ if (ob->rigidbody_object && canceled) { float ctime = BKE_scene_frame_get(t->scene); @@ -6643,13 +6643,13 @@ static void createTransObject(bContext *C, TransInfo *t) /* count */ t->total = CTX_DATA_COUNT(C, selected_objects); - + if (!t->total) { /* clear here, main transform function escapes too */ clear_trans_object_base_flags(t); return; } - + if (is_prop_edit) { t->total += count_proportional_objects(t); } @@ -6660,29 +6660,29 @@ static void createTransObject(bContext *C, TransInfo *t) CTX_DATA_BEGIN(C, Base *, base, selected_bases) { Object *ob = base->object; - + td->flag = TD_SELECTED; td->protectflag = ob->protectflag; td->ext = tx; td->ext->rotOrder = ob->rotmode; - + if (base->flag & BA_TRANSFORM_CHILD) { td->flag |= TD_NOCENTER; td->flag |= TD_NO_LOC; } - + /* select linked objects, but skip them later */ if (ID_IS_LINKED(ob)) { td->flag |= TD_SKIP; } - + ObjectToTransData(t, td, ob); td->val = NULL; td++; tx++; } CTX_DATA_END; - + if (is_prop_edit) { View3D *v3d = t->view; Base *base; @@ -6697,7 +6697,7 @@ static void createTransObject(bContext *C, TransInfo *t) td->protectflag = ob->protectflag; td->ext = tx; td->ext->rotOrder = ob->rotmode; - + ObjectToTransData(t, td, ob); td->val = NULL; td++; @@ -6711,7 +6711,7 @@ static void createTransObject(bContext *C, TransInfo *t) static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node, const float dpi_fac) { float locx, locy; - + /* account for parents (nested nodes) */ if (node->parent) { nodeToView(node->parent, node->locx, node->locy, &locx, &locy); @@ -6720,7 +6720,7 @@ static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node, const locx = node->locx; locy = node->locy; } - + /* use top-left corner as the transform origin for nodes */ /* weirdo - but the node system is a mix of free 2d elements and dpi sensitive UI */ #ifdef USE_NODE_CENTER @@ -7893,14 +7893,14 @@ static void createTransGPencil(bContext *C, TransInfo *t) bGPDlayer *gpl; TransData *td = NULL; float mtx[3][3], smtx[3][3]; - + const Scene *scene = CTX_data_scene(C); const int cfra_scene = CFRA; - + const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0; const bool is_prop_edit_connected = (t->flag & T_PROP_CONNECTED) != 0; - - + + /* == Grease Pencil Strokes to Transform Data == * Grease Pencil stroke points can be a mixture of 2D (screen-space), * or 3D coordinates. However, they're always saved as 3D points. @@ -7908,11 +7908,11 @@ static void createTransGPencil(bContext *C, TransInfo *t) * strokes. This may cause issues in future though. */ t->total = 0; - + if (gpd == NULL) return; - - /* First Pass: Count the number of datapoints required for the strokes, + + /* First Pass: Count the number of datapoints required for the strokes, * (and additional info about the configuration - e.g. 2D/3D?) */ for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { @@ -7948,30 +7948,30 @@ static void createTransGPencil(bContext *C, TransInfo *t) if (gps->flag & GP_STROKE_SELECT) { bGPDspoint *pt; int i; - + // TODO: 2D vs 3D? for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { if (pt->flag & GP_SPOINT_SELECT) t->total++; } } - } + } } } } - + /* Stop trying if nothing selected */ if (t->total == 0) { return; } - + /* Allocate memory for data */ t->data = MEM_callocN(t->total * sizeof(TransData), "TransData(GPencil)"); td = t->data; - + unit_m3(smtx); unit_m3(mtx); - + /* Second Pass: Build transdata array */ for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { /* only editable and visible layers are considered */ @@ -7988,7 +7988,7 @@ static void createTransGPencil(bContext *C, TransInfo *t) /* undo matrix */ invert_m4_m4(inverse_diff_mat, diff_mat); } - + /* Make a new frame to work on if the layer's frame and the current scene frame don't match up * - This is useful when animating as it saves that "uh-oh" moment when you realize you've * spent too much time editing the wrong frame... @@ -8000,13 +8000,13 @@ static void createTransGPencil(bContext *C, TransInfo *t) continue; } } - + /* Loop over strokes, adding TransData for points as needed... */ for (gps = gpf->strokes.first; gps; gps = gps->next) { TransData *head = td; TransData *tail = td; bool stroke_ok; - + /* skip strokes that are invalid for current view */ if (ED_gpencil_stroke_can_use(C, gps) == false) { continue; @@ -8030,26 +8030,26 @@ static void createTransGPencil(bContext *C, TransInfo *t) /* C) Only selected points in selected strokes */ stroke_ok = (gps->flag & GP_STROKE_SELECT) != 0; } - + /* Do stroke... */ if (stroke_ok && gps->totpoints) { bGPDspoint *pt; int i; - + #if 0 /* XXX: this isn't needed anymore; cannot calculate center this way or is_prop_edit breaks */ const float ninv = 1.0f / gps->totpoints; float center[3] = {0.0f}; - + /* compute midpoint of stroke */ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { madd_v3_v3v3fl(center, center, &pt->x, ninv); } #endif - + /* add all necessary points... */ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { bool point_ok; - + /* include point? */ if (is_prop_edit) { /* Always all points in strokes that get included */ @@ -8059,30 +8059,30 @@ static void createTransGPencil(bContext *C, TransInfo *t) /* Only selected points in selected strokes */ point_ok = (pt->flag & GP_SPOINT_SELECT) != 0; } - + /* do point... */ if (point_ok) { copy_v3_v3(td->iloc, &pt->x); copy_v3_v3(td->center, &pt->x); // XXX: what about t->around == local? - + td->loc = &pt->x; - + td->flag = 0; - + if (pt->flag & GP_SPOINT_SELECT) td->flag |= TD_SELECTED; - + /* for other transform modes (e.g. shrink-fatten), need to additional data */ if (t->mode == TFM_GPENCIL_SHRINKFATTEN) { td->val = &pt->pressure; td->ival = pt->pressure; } - + /* screenspace needs special matrices... */ if ((gps->flag & (GP_STROKE_3DSPACE | GP_STROKE_2DSPACE | GP_STROKE_2DIMAGE)) == 0) { /* screenspace */ td->protectflag = OB_LOCK_LOCZ | OB_LOCK_ROTZ | OB_LOCK_SCALEZ; - + /* apply parent transformations */ if (gpl->parent == NULL) { copy_m3_m4(td->smtx, t->persmat); @@ -8102,7 +8102,7 @@ static void createTransGPencil(bContext *C, TransInfo *t) td->protectflag = OB_LOCK_LOCZ | OB_LOCK_ROTZ | OB_LOCK_SCALEZ; // XXX: matrices may need to be different? } - + /* apply parent transformations */ if (gpl->parent == NULL) { copy_m3_m3(td->smtx, smtx); @@ -8123,7 +8123,7 @@ static void createTransGPencil(bContext *C, TransInfo *t) tail++; } } - + /* March over these points, and calculate the proportional editing distances */ if (is_prop_edit && (head != tail)) { /* XXX: for now, we are similar enough that this works... */ @@ -8160,7 +8160,7 @@ void createTransData(bContext *C, TransInfo *t) t->options |= CTX_GPENCIL_STROKES; t->flag |= T_POINTS; createTransGPencil(C, t); - + if (t->data && (t->flag & T_PROP_EDIT)) { sort_trans_data(t); // makes selected become first in array set_prop_dist(t, 1); @@ -8311,7 +8311,7 @@ void createTransData(bContext *C, TransInfo *t) createTransPose(t, ob_armature); } } - + } } else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT) && PE_start_edit(PE_get_current(scene, ob))) { diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 1ff602e075e..be6067f9c2d 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -128,11 +128,11 @@ static void clipMirrorModifier(TransInfo *t, Object *ob) ModifierData *md = ob->modifiers.first; float tolerance[3] = {0.0f, 0.0f, 0.0f}; int axis = 0; - + for (; md; md = md->next) { if ((md->type == eModifierType_Mirror) && (md->mode & eModifierMode_Realtime)) { MirrorModifierData *mmd = (MirrorModifierData *) md; - + if (mmd->flag & MOD_MIR_CLIPPING) { axis = 0; if (mmd->flag & MOD_MIR_AXIS_X) { @@ -151,35 +151,35 @@ static void clipMirrorModifier(TransInfo *t, Object *ob) float mtx[4][4], imtx[4][4]; int i; TransData *td = t->data; - + if (mmd->mirror_ob) { float obinv[4][4]; - + invert_m4_m4(obinv, mmd->mirror_ob->obmat); mul_m4_m4m4(mtx, obinv, ob->obmat); invert_m4_m4(imtx, mtx); } - + for (i = 0; i < t->total; i++, td++) { int clip; float loc[3], iloc[3]; - + if (td->flag & TD_NOACTION) break; if (td->loc == NULL) break; - + if (td->flag & TD_SKIP) continue; - + copy_v3_v3(loc, td->loc); copy_v3_v3(iloc, td->iloc); - + if (mmd->mirror_ob) { mul_m4_v3(mtx, loc); mul_m4_v3(mtx, iloc); } - + clip = 0; if (axis & 1) { if (fabsf(iloc[0]) <= tolerance[0] || @@ -189,7 +189,7 @@ static void clipMirrorModifier(TransInfo *t, Object *ob) clip = 1; } } - + if (axis & 2) { if (fabsf(iloc[1]) <= tolerance[1] || loc[1] * iloc[1] < 0.0f) @@ -214,7 +214,7 @@ static void clipMirrorModifier(TransInfo *t, Object *ob) } } } - + } } } @@ -226,7 +226,7 @@ static void editbmesh_apply_to_mirror(TransInfo *t) TransData *td = t->data; BMVert *eve; int i; - + for (i = 0; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; @@ -234,14 +234,14 @@ static void editbmesh_apply_to_mirror(TransInfo *t) break; if (td->flag & TD_SKIP) continue; - + eve = td->extra; if (eve) { eve->co[0] = -td->loc[0]; eve->co[1] = td->loc[1]; eve->co[2] = td->loc[2]; } - + if (td->flag & TD_MIRROR_EDGE) { td->loc[0] = 0; } @@ -252,11 +252,11 @@ static void editbmesh_apply_to_mirror(TransInfo *t) static void animrecord_check_state(Scene *scene, ID *id, wmTimer *animtimer) { ScreenAnimData *sad = (animtimer) ? animtimer->customdata : NULL; - + /* sanity checks */ if (ELEM(NULL, scene, id, sad)) return; - + /* check if we need a new strip if: * - if animtimer is running * - we're not only keying for available channels @@ -267,26 +267,26 @@ static void animrecord_check_state(Scene *scene, ID *id, wmTimer *animtimer) if ((sad) && (sad->flag & ANIMPLAY_FLAG_JUMPED)) { AnimData *adt = BKE_animdata_from_id(id); const bool is_first = (adt) && (adt->nla_tracks.first == NULL); - - /* perform push-down manually with some differences + + /* perform push-down manually with some differences * NOTE: BKE_nla_action_pushdown() sync warning... */ if ((adt->action) && !(adt->flag & ADT_NLA_EDIT_ON)) { float astart, aend; - + /* only push down if action is more than 1-2 frames long */ calc_action_range(adt->action, &astart, &aend, 1); if (aend > astart + 2.0f) { NlaStrip *strip = BKE_nlastack_add_strip(adt, adt->action); - + /* clear reference to action now that we've pushed it onto the stack */ id_us_min(&adt->action->id); adt->action = NULL; - + /* adjust blending + extend so that they will behave correctly */ strip->extendmode = NLASTRIP_EXTEND_NOTHING; strip->flag &= ~(NLASTRIP_FLAG_AUTO_BLENDS | NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_ACTIVE); - + /* copy current "action blending" settings from adt to the strip, * as it was keyframed with these settings, so omitting them will * change the effect [T54766] @@ -294,7 +294,7 @@ static void animrecord_check_state(Scene *scene, ID *id, wmTimer *animtimer) if (is_first == false) { strip->blendmode = adt->act_blendmode; strip->influence = adt->act_influence; - + if (adt->act_influence < 1.0f) { /* enable "user-controlled" influence (which will insert a default keyframe) * so that the influence doesn't get lost on the new update @@ -309,9 +309,9 @@ static void animrecord_check_state(Scene *scene, ID *id, wmTimer *animtimer) BKE_nlastrip_validate_fcurves(strip); } } - - /* also, adjust the AnimData's action extend mode to be on - * 'nothing' so that previous result still play + + /* also, adjust the AnimData's action extend mode to be on + * 'nothing' so that previous result still play */ adt->act_extendmode = NLASTRIP_EXTEND_NOTHING; } @@ -340,12 +340,12 @@ static void recalcData_actedit(TransInfo *t) { Scene *scene = t->scene; SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first; - + bAnimContext ac = {NULL}; ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* initialize relevant anim-context 'context' data from TransInfo data */ /* NOTE: sync this with the code in ANIM_animdata_get_context() */ ac.scene = t->scene; @@ -355,9 +355,9 @@ static void recalcData_actedit(TransInfo *t) ac.sl = (t->sa) ? t->sa->spacedata.first : NULL; ac.spacetype = (t->sa) ? t->sa->spacetype : 0; ac.regiontype = (t->ar) ? t->ar->regiontype : 0; - + ANIM_animdata_context_getdata(&ac); - + /* perform flush */ if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) { /* flush transform values back to actual coordinates */ @@ -367,8 +367,8 @@ static void recalcData_actedit(TransInfo *t) /* get animdata blocks visible in editor, assuming that these will be the ones where things changed */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - - /* just tag these animdata-blocks to recalc, assuming that some data there changed + + /* just tag these animdata-blocks to recalc, assuming that some data there changed * BUT only do this if realtime updates are enabled */ if ((saction->flag & SACTION_NOREALTIMEUPDATES) == 0) { @@ -377,7 +377,7 @@ static void recalcData_actedit(TransInfo *t) ANIM_list_elem_update(t->scene, ale); } } - + /* now free temp channels */ ANIM_animdata_freelist(&anim_data); } @@ -387,11 +387,11 @@ static void recalcData_graphedit(TransInfo *t) { SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first; Scene *scene; - + ListBase anim_data = {NULL, NULL}; bAnimContext ac = {NULL}; int filter; - + bAnimListElem *ale; int dosort = 0; @@ -404,20 +404,20 @@ static void recalcData_graphedit(TransInfo *t) ac.sl = (t->sa) ? t->sa->spacedata.first : NULL; ac.spacetype = (t->sa) ? t->sa->spacetype : 0; ac.regiontype = (t->ar) ? t->ar->regiontype : 0; - + ANIM_animdata_context_getdata(&ac); - + /* do the flush first */ flushTransGraphData(t); - + /* get curves to check if a re-sort is needed */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* now test if there is a need to re-sort */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; - + /* ignore FC-Curves without any selected verts */ if (!fcu_test_selected(fcu)) continue; @@ -427,17 +427,17 @@ static void recalcData_graphedit(TransInfo *t) dosort++; else calchandles_fcurve(fcu); - + /* set refresh tags for objects using this animation, - * BUT only if realtime updates are enabled + * BUT only if realtime updates are enabled */ if ((sipo->flag & SIPO_NOREALTIMEUPDATES) == 0) ANIM_list_elem_update(t->scene, ale); } - + /* do resort and other updates? */ if (dosort) remake_graph_transdata(t, &anim_data); - + /* now free temp channels */ ANIM_animdata_freelist(&anim_data); } @@ -450,7 +450,7 @@ static void recalcData_nla(TransInfo *t) Scene *scene = t->scene; double secf = FPS; int i; - + /* for each strip we've got, perform some additional validation of the values that got set before * using RNA to set the value (which does some special operations when setting these values to make * sure that everything works ok) @@ -460,48 +460,48 @@ static void recalcData_nla(TransInfo *t) PointerRNA strip_ptr; short pExceeded, nExceeded, iter; int delta_y1, delta_y2; - + /* if this tdn has no handles, that means it is just a dummy that should be skipped */ if (tdn->handle == 0) continue; - + /* set refresh tags for objects using this animation, - * BUT only if realtime updates are enabled + * BUT only if realtime updates are enabled */ if ((snla->flag & SNLA_NOREALTIMEUPDATES) == 0) ANIM_id_update(t->scene, tdn->id); - + /* if canceling transform, just write the values without validating, then move on */ if (t->state == TRANS_CANCEL) { /* clear the values by directly overwriting the originals, but also need to restore * endpoints of neighboring transition-strips */ - + /* start */ strip->start = tdn->h1[0]; - + if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION)) strip->prev->end = tdn->h1[0]; - + /* end */ strip->end = tdn->h2[0]; - + if ((strip->next) && (strip->next->type == NLASTRIP_TYPE_TRANSITION)) strip->next->start = tdn->h2[0]; - + /* flush transforms to child strips (since this should be a meta) */ BKE_nlameta_flush_transforms(strip); - + /* restore to original track (if needed) */ if (tdn->oldTrack != tdn->nlt) { /* just append to end of list for now, since strips get sorted in special_aftertrans_update() */ BLI_remlink(&tdn->nlt->strips, strip); BLI_addtail(&tdn->oldTrack->strips, strip); } - + continue; } - + /* firstly, check if the proposed transform locations would overlap with any neighboring strips * (barring transitions) which are absolute barriers since they are not being moved * @@ -510,7 +510,7 @@ static void recalcData_nla(TransInfo *t) for (iter = 0; iter < 5; iter++) { pExceeded = ((strip->prev) && (strip->prev->type != NLASTRIP_TYPE_TRANSITION) && (tdn->h1[0] < strip->prev->end)); nExceeded = ((strip->next) && (strip->next->type != NLASTRIP_TYPE_TRANSITION) && (tdn->h2[0] > strip->next->start)); - + if ((pExceeded && nExceeded) || (iter == 4)) { /* both endpoints exceeded (or iteration ping-pong'd meaning that we need a compromise) * - simply crop strip to fit within the bounds of the strips bounding it @@ -528,21 +528,21 @@ static void recalcData_nla(TransInfo *t) else if (nExceeded) { /* move backwards */ float offset = tdn->h2[0] - strip->next->start; - + tdn->h1[0] -= offset; tdn->h2[0] -= offset; } else if (pExceeded) { /* more forwards */ float offset = strip->prev->end - tdn->h1[0]; - + tdn->h1[0] += offset; tdn->h2[0] += offset; } else /* all is fine and well */ break; } - + /* handle auto-snapping * NOTE: only do this when transform is still running, or we can't restore */ @@ -555,7 +555,7 @@ static void recalcData_nla(TransInfo *t) tdn->h2[0] = floorf(tdn->h2[0] + 0.5f); break; } - + case SACTSNAP_SECOND: /* snap to nearest second */ case SACTSNAP_TSTEP: /* second step - this is basically the same, since we don't have any remapping going on */ { @@ -570,12 +570,12 @@ static void recalcData_nla(TransInfo *t) */ float h1_new = (float)(floor(((double)tdn->h1[0] / secf) + 0.5) * secf); float delta = h1_new - tdn->h1[0]; - + tdn->h1[0] = h1_new; tdn->h2[0] += delta; break; } - + case SACTSNAP_MARKER: /* snap to nearest marker */ { tdn->h1[0] = (float)ED_markers_find_nearest_marker_time(&t->scene->markers, tdn->h1[0]); @@ -584,36 +584,36 @@ static void recalcData_nla(TransInfo *t) } } } - + /* Use RNA to write the values to ensure that constraints on these are obeyed * (e.g. for transition strips, the values are taken from the neighbors) - * + * * NOTE: we write these twice to avoid truncation errors which can arise when - * moving the strips a large distance using numeric input [#33852] + * moving the strips a large distance using numeric input [#33852] */ RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &strip_ptr); - + RNA_float_set(&strip_ptr, "frame_start", tdn->h1[0]); RNA_float_set(&strip_ptr, "frame_end", tdn->h2[0]); - + RNA_float_set(&strip_ptr, "frame_start", tdn->h1[0]); RNA_float_set(&strip_ptr, "frame_end", tdn->h2[0]); - + /* flush transforms to child strips (since this should be a meta) */ BKE_nlameta_flush_transforms(strip); - - + + /* now, check if we need to try and move track * - we need to calculate both, as only one may have been altered by transform if only 1 handle moved */ delta_y1 = ((int)tdn->h1[1] / NLACHANNEL_STEP(snla) - tdn->trackIndex); delta_y2 = ((int)tdn->h2[1] / NLACHANNEL_STEP(snla) - tdn->trackIndex); - + if (delta_y1 || delta_y2) { NlaTrack *track; int delta = (delta_y2) ? delta_y2 : delta_y1; int n; - + /* move in the requested direction, checking at each layer if there's space for strip to pass through, * stopping on the last track available or that we're able to fit in */ @@ -624,7 +624,7 @@ static void recalcData_nla(TransInfo *t) /* move strip to this track */ BLI_remlink(&tdn->nlt->strips, strip); BKE_nlatrack_add_strip(track, strip); - + tdn->nlt = track; tdn->trackIndex++; } @@ -635,14 +635,14 @@ static void recalcData_nla(TransInfo *t) else { /* make delta 'positive' before using it, since we now know to go backwards */ delta = -delta; - + for (track = tdn->nlt->prev, n = 0; (track) && (n < delta); track = track->prev, n++) { /* check if space in this track for the strip */ if (BKE_nlatrack_has_space(track, strip->start, strip->end)) { /* move strip to this track */ BLI_remlink(&tdn->nlt->strips, strip); BKE_nlatrack_add_strip(track, strip); - + tdn->nlt = track; tdn->trackIndex--; } @@ -674,11 +674,11 @@ static void recalcData_image(TransInfo *t) } else if (t->obedit && t->obedit->type == OB_MESH) { SpaceImage *sima = t->sa->spacedata.first; - + flushTransUVs(t); if (sima->flag & SI_LIVE_UNWRAP) ED_uvedit_live_unwrap_re_solve(); - + DAG_id_tag_update(t->obedit->data, 0); } } @@ -739,14 +739,14 @@ static void recalcData_objects(TransInfo *t) Curve *cu = t->obedit->data; ListBase *nurbs = BKE_curve_editNurbs_get(cu); Nurb *nu = nurbs->first; - + if (t->state != TRANS_CANCEL) { clipMirrorModifier(t, t->obedit); applyProject(t); } - + DAG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */ - + if (t->state == TRANS_CANCEL) { while (nu) { BKE_nurb_handles_calc(nu); /* Cant do testhandlesNurb here, it messes up the h1 and h2 flags */ @@ -764,13 +764,13 @@ static void recalcData_objects(TransInfo *t) } else if (t->obedit->type == OB_LATTICE) { Lattice *la = t->obedit->data; - + if (t->state != TRANS_CANCEL) { applyProject(t); } - + DAG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */ - + if (la->editlatt->latt->flag & LT_OUTSIDE) outside_lattice(la->editlatt->latt); } else if (t->obedit->type == OB_MESH) { @@ -792,7 +792,7 @@ static void recalcData_objects(TransInfo *t) } DAG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */ - + EDBM_mesh_normals_update(em); BKE_editmesh_tessface_calc(em); } @@ -802,15 +802,15 @@ static void recalcData_objects(TransInfo *t) EditBone *ebo, *ebo_parent; TransData *td = t->data; int i; - + if (t->state != TRANS_CANCEL) { applyProject(t); } - + /* Ensure all bones are correctly adjusted */ for (ebo = edbo->first; ebo; ebo = ebo->next) { ebo_parent = (ebo->flag & BONE_CONNECTED) ? ebo->parent : NULL; - + if (ebo_parent) { /* If this bone has a parent tip that has been moved */ if (ebo_parent->flag & BONE_TIPSEL) { @@ -823,7 +823,7 @@ static void recalcData_objects(TransInfo *t) if (t->mode == TFM_BONE_ENVELOPE) ebo_parent->rad_tail = ebo->rad_head; } } - + /* on extrude bones, oldlength==0.0f, so we scale radius of points */ ebo->length = len_v3v3(ebo->head, ebo->tail); if (ebo->oldlength == 0.0f) { @@ -847,7 +847,7 @@ static void recalcData_objects(TransInfo *t) } } } - + if (!ELEM(t->mode, TFM_BONE_ROLL, TFM_BONE_ENVELOPE, TFM_BONE_ENVELOPE_DIST, TFM_BONESIZE)) { /* fix roll */ for (i = 0; i < t->total; i++, td++) { @@ -855,7 +855,7 @@ static void recalcData_objects(TransInfo *t) float vec[3], up_axis[3]; float qrot[4]; float roll; - + ebo = td->extra; if (t->state == TRANS_CANCEL) { @@ -877,7 +877,7 @@ static void recalcData_objects(TransInfo *t) } } } - + if (arm->flag & ARM_MIRROR_EDIT) { if (t->state != TRANS_CANCEL) ED_armature_edit_transform_mirror_update(t->obedit); @@ -895,7 +895,7 @@ static void recalcData_objects(TransInfo *t) else if ((t->flag & T_POSE) && t->poseobj) { Object *ob = t->poseobj; bArmature *arm = ob->data; - + /* if animtimer is running, and the object already has animation data, * check if the auto-record feature means that we should record 'samples' * (i.e. uneditable animation values) @@ -905,11 +905,11 @@ static void recalcData_objects(TransInfo *t) // TODO: autokeyframe calls need some setting to specify to add samples (FPoints) instead of keyframes? if ((t->animtimer) && (t->context) && IS_AUTOKEY_ON(t->scene)) { int targetless_ik = (t->flag & T_AUTOIK); // XXX this currently doesn't work, since flags aren't set yet! - + animrecord_check_state(t->scene, &ob->id, t->animtimer); autokeyframe_pose_cb_func(t->context, t->scene, (View3D *)t->view, ob, t->mode, targetless_ik); } - + /* old optimize trick... this enforces to bypass the depgraph */ if (!(arm->flag & ARM_DELAYDEFORM)) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */ @@ -927,21 +927,21 @@ static void recalcData_objects(TransInfo *t) } else { int i; - + if (t->state != TRANS_CANCEL) { applyProject(t); } - + for (i = 0; i < t->total; i++) { TransData *td = t->data + i; Object *ob = td->ob; - + if (td->flag & TD_NOACTION) break; - + if (td->flag & TD_SKIP) continue; - + /* if animtimer is running, and the object already has animation data, * check if the auto-record feature means that we should record 'samples' * (i.e. uneditable animation values) @@ -951,8 +951,8 @@ static void recalcData_objects(TransInfo *t) animrecord_check_state(t->scene, &ob->id, t->animtimer); autokeyframe_ob_cb_func(t->context, t->scene, (View3D *)t->view, ob, t->mode); } - - /* sets recalc flags fully, instead of flushing existing ones + + /* sets recalc flags fully, instead of flushing existing ones * otherwise proxies don't function correctly */ DAG_id_tag_update(&ob->id, OB_RECALC_OB); @@ -1054,18 +1054,18 @@ void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis if (t->spacetype == SPACE_VIEW3D) { View3D *v3d = t->view; - + glPushMatrix(); - + //if (t->obedit) glLoadMatrixf(t->obedit->obmat); // sets opengl viewing - - + + copy_v3_v3(v3, dir); mul_v3_fl(v3, v3d->far); - + sub_v3_v3v3(v2, center, v3); add_v3_v3v3(v1, center, v3); - + if (options & DRAWLIGHT) { col[0] = col[1] = col[2] = 220; } @@ -1074,13 +1074,13 @@ void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis } UI_make_axis_color(col, col2, axis); glColor3ubv(col2); - + setlinestyle(0); glBegin(GL_LINES); glVertex3fv(v1); glVertex3fv(v2); glEnd(); - + glPopMatrix(); } } @@ -1134,7 +1134,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve Object *ob = CTX_data_active_object(C); bGPdata *gpd = CTX_data_gpencil_data(C); PropertyRNA *prop; - + t->scene = sce; t->sa = sa; t->ar = ar; @@ -1149,13 +1149,13 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->data = NULL; t->ext = NULL; - + t->helpline = HLP_NONE; - + t->flag = 0; - + t->redraw = TREDRAW_HARD; /* redraw first time */ - + if (event) { t->mouse.imval[0] = event->mval[0]; t->mouse.imval[1] = event->mval[1]; @@ -1164,18 +1164,18 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->mouse.imval[0] = 0; t->mouse.imval[1] = 0; } - + t->con.imval[0] = t->mouse.imval[0]; t->con.imval[1] = t->mouse.imval[1]; - + t->mval[0] = t->mouse.imval[0]; t->mval[1] = t->mouse.imval[1]; - + t->transform = NULL; t->handleEvent = NULL; - + t->total = 0; - + t->val = 0.0f; zero_v3(t->vec); @@ -1183,7 +1183,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve zero_v3(t->center_global); unit_m3(t->mat); - + /* if there's an event, we're modal */ if (event) { t->flag |= T_MODAL; @@ -1201,7 +1201,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->remove_on_cancel = true; } } - + /* GPencil editing context */ if ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE)) { t->options |= CTX_GPENCIL_STROKES; @@ -1238,10 +1238,10 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve if (t->spacetype == SPACE_VIEW3D) { View3D *v3d = sa->spacedata.first; bScreen *animscreen = ED_screen_animation_playing(CTX_wm_manager(C)); - + t->view = v3d; t->animtimer = (animscreen) ? animscreen->animtimer : NULL; - + /* turn manipulator off during transform */ // FIXME: but don't do this when USING the manipulator... if (t->flag & T_MODAL) { @@ -1251,7 +1251,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve if (v3d->flag & V3D_ALIGN) t->flag |= T_V3D_ALIGN; t->around = v3d->around; - + /* bend always uses the cursor */ if (t->mode == TFM_BEND) { t->around = V3D_AROUND_CURSOR; @@ -1383,7 +1383,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->mirror = 1; } } - + /* setting PET flag only if property exist in operator. Otherwise, assume it's not supported */ if (op && (prop = RNA_struct_find_property(op->ptr, "proportional"))) { if (RNA_property_is_set(op->ptr, prop)) { @@ -1420,7 +1420,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } } } - + if (op && ((prop = RNA_struct_find_property(op->ptr, "proportional_size")) && RNA_property_is_set(op->ptr, prop))) { @@ -1429,14 +1429,14 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve else { t->prop_size = ts->proportional_size; } - - + + /* TRANSFORM_FIX_ME rna restrictions */ if (t->prop_size <= 0.00001f) { printf("Proportional size (%f) under 0.00001, resetting to 1!\n", t->prop_size); t->prop_size = 1.0f; } - + if (op && ((prop = RNA_struct_find_property(op->ptr, "proportional_edit_falloff")) && RNA_property_is_set(op->ptr, prop))) { @@ -1449,7 +1449,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve else { /* add not pet option to context when not available */ t->options |= CTX_NO_PET; } - + // Mirror is not supported with PET, turn it off. #if 0 if (t->flag & T_PROP_EDIT) { @@ -1473,7 +1473,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve void postTrans(bContext *C, TransInfo *t) { TransData *td; - + if (t->draw_handle_view) ED_region_draw_cb_exit(t->ar->type, t->draw_handle_view); if (t->draw_handle_apply) @@ -1501,7 +1501,7 @@ void postTrans(bContext *C, TransInfo *t) /* postTrans can be called when nothing is selected, so data is NULL already */ if (t->data) { - + /* free data malloced per trans-data */ if ((t->obedit && ELEM(t->obedit->type, OB_CURVE, OB_SURF)) || (t->spacetype == SPACE_IPO)) @@ -1515,7 +1515,7 @@ void postTrans(bContext *C, TransInfo *t) } MEM_freeN(t->data); } - + BLI_freelistN(&t->tsnap.points); if (t->ext) MEM_freeN(t->ext); @@ -1523,7 +1523,7 @@ void postTrans(bContext *C, TransInfo *t) MEM_freeN(t->data2d); t->data2d = NULL; } - + if (t->spacetype == SPACE_IMAGE) { if (t->options & (CTX_MASK | CTX_PAINT_CURVE)) { /* pass */ @@ -1541,7 +1541,7 @@ void postTrans(bContext *C, TransInfo *t) v3d->twtype = t->twtype; } } - + if (t->mouse.data) { MEM_freeN(t->mouse.data); } @@ -1552,7 +1552,7 @@ void postTrans(bContext *C, TransInfo *t) void applyTransObjects(TransInfo *t) { TransData *td; - + for (td = t->data; td < t->data + t->total; td++) { copy_v3_v3(td->iloc, td->loc); if (td->ext->rot) { @@ -1593,7 +1593,7 @@ static void restoreElement(TransData *td) copy_qt_qt(td->ext->quat, td->ext->iquat); } } - + if (td->flag & TD_BEZTRIPLE) { *(td->hdata->h1) = td->hdata->ih1; *(td->hdata->h2) = td->hdata->ih2; @@ -1608,7 +1608,7 @@ void restoreTransObjects(TransInfo *t) for (td = t->data; td < t->data + t->total; td++) { restoreElement(td); } - + for (td2d = t->data2d; t->data2d && td2d < t->data2d + t->total; td2d++) { if (td2d->h1) { td2d->h1[0] = td2d->ih1[0]; @@ -1621,7 +1621,7 @@ void restoreTransObjects(TransInfo *t) } unit_m3(t->mat); - + recalcData(t); } @@ -1632,7 +1632,7 @@ void calculateCenter2D(TransInfo *t) if (t->flag & (T_EDIT | T_POSE)) { Object *ob = t->obedit ? t->obedit : t->poseobj; float vec[3]; - + copy_v3_v3(vec, t->center); mul_m4_v3(ob->obmat, vec); projectFloatView(t, vec, t->center2d); @@ -1660,15 +1660,15 @@ void calculateCenterGlobal( void calculateCenterCursor(TransInfo *t, float r_center[3]) { const float *cursor; - + cursor = ED_view3d_cursor3d_get(t->scene, t->view); copy_v3_v3(r_center, cursor); - + /* If edit or pose mode, move cursor in local space */ if (t->flag & (T_EDIT | T_POSE)) { Object *ob = t->obedit ? t->obedit : t->poseobj; float mat[3][3], imat[3][3]; - + sub_v3_v3v3(r_center, r_center, ob->obmat[3]); copy_m3_m4(mat, ob->obmat); invert_m3_m3(imat, mat); @@ -1686,7 +1686,7 @@ void calculateCenterCursor(TransInfo *t, float r_center[3]) void calculateCenterCursor2D(TransInfo *t, float r_center[2]) { const float *cursor = NULL; - + if (t->spacetype == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first; cursor = sima->cursor; @@ -1732,7 +1732,7 @@ void calculateCenterCursorGraph2D(TransInfo *t, float r_center[2]) { SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first; Scene *scene = t->scene; - + /* cursor is combination of current frame, and graph-editor cursor value */ if (sipo->mode == SIPO_MODE_DRIVERS) { r_center[0] = sipo->cursorTime; @@ -1749,7 +1749,7 @@ void calculateCenterMedian(TransInfo *t, float r_center[3]) float partial[3] = {0.0f, 0.0f, 0.0f}; int total = 0; int i; - + for (i = 0; i < t->total; i++) { if (t->data[i].flag & TD_SELECTED) { if (!(t->data[i].flag & TD_NOCENTER)) { @@ -1883,20 +1883,20 @@ void calculateCenter(TransInfo *t) /* for panning from cameraview */ if ((t->flag & T_OBJECT) && (t->flag & T_OVERRIDE_CENTER) == 0) { if (t->spacetype == SPACE_VIEW3D && t->ar && t->ar->regiontype == RGN_TYPE_WINDOW) { - + if (t->flag & T_CAMERA) { float axis[3]; /* persinv is nasty, use viewinv instead, always right */ copy_v3_v3(axis, t->viewinv[2]); normalize_v3(axis); - + /* 6.0 = 6 grid units */ axis[0] = t->center[0] - 6.0f * axis[0]; axis[1] = t->center[1] - 6.0f * axis[1]; axis[2] = t->center[2] - 6.0f * axis[2]; - + projectFloatView(t, axis, t->center2d); - + /* rotate only needs correct 2d center, grab needs ED_view3d_calc_zfac() value */ if (t->mode == TFM_TRANSLATION) { copy_v3_v3(t->center, axis); @@ -1905,7 +1905,7 @@ void calculateCenter(TransInfo *t) } } } - + if (t->spacetype == SPACE_VIEW3D) { /* ED_view3d_calc_zfac() defines a factor for perspective depth correction, used in ED_view3d_win_to_delta() */ @@ -1969,14 +1969,14 @@ void calculatePropRatio(TransInfo *t) * that means we can stop when it finds one element outside of the propsize. * do not set 'td->flag |= TD_NOACTION', the prop circle is being changed. */ - + td->factor = 0.0f; restoreElement(td); } else { /* Use rdist for falloff calculations, it is the real distance */ td->flag &= ~TD_NOACTION; - + if (connected) dist = (t->prop_size - td->dist) / t->prop_size; else @@ -1989,7 +1989,7 @@ void calculatePropRatio(TransInfo *t) */ if (dist < 0.0f) dist = 0.0f; - + switch (t->prop_mode) { case PROP_SHARP: td->factor = dist * dist; diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index 5f2e5a99090..b60c8bf47f6 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -37,7 +37,7 @@ #include "transform.h" -#include "MEM_guardedalloc.h" +#include "MEM_guardedalloc.h" /* ************************** INPUT FROM MOUSE *************************** */ @@ -125,7 +125,7 @@ void setCustomPoints(TransInfo *UNUSED(t), MouseInput *mi, const int mval_start[ int *data; mi->data = MEM_reallocN(mi->data, sizeof(int) * 4); - + data = mi->data; data[0] = mval_start[0]; @@ -140,7 +140,7 @@ static void InputCustomRatioFlip(TransInfo *UNUSED(t), MouseInput *mi, const dou double distance; double dx, dy; const int *data = mi->data; - + if (data) { int mdx, mdy; dx = data[2] - data[0]; diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 193a29928ef..5997777f635 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -611,7 +611,7 @@ static int calc_manipulator_stats(const bContext *C, struct TransformBounds *tbo if (ob && totsel && !is_gp_edit) { switch (v3d->twmode) { - + case V3D_MANIP_GLOBAL: { break; /* nothing to do */ @@ -1035,7 +1035,7 @@ static void draw_manipulator_rotate( ortho = is_orthogonal_m4(rv3d->twmat); - + /* apply the transform delta */ if (is_moving) { copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3] diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 46bd83b5d35..4157b69fded 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -163,7 +163,7 @@ static int select_orientation_exec(bContext *C, wmOperator *op) int orientation = RNA_enum_get(op->ptr, "orientation"); BIF_selectTransformOrientationValue(C, orientation); - + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C)); return OPERATOR_FINISHED; @@ -209,7 +209,7 @@ static int delete_orientation_exec(bContext *C, wmOperator *UNUSED(op)) int selected_index = (v3d->twmode - V3D_MANIP_CUSTOM); BIF_removeTransformOrientationIndex(C, selected_index); - + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); WM_event_add_notifier(C, NC_SCENE | NA_EDITED, CTX_data_scene(C)); @@ -225,15 +225,15 @@ static int delete_orientation_poll(bContext *C) { int selected_index = -1; View3D *v3d = CTX_wm_view3d(C); - + if (ED_operator_areaactive(C) == 0) return 0; - - + + if (v3d) { selected_index = (v3d->twmode - V3D_MANIP_CUSTOM); } - + return selected_index >= 0; } @@ -270,7 +270,7 @@ static int create_orientation_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); WM_event_add_notifier(C, NC_SCENE | NA_EDITED, CTX_data_scene(C)); - + return OPERATOR_FINISHED; } @@ -470,7 +470,7 @@ static int transform_exec(bContext *C, wmOperator *op) transformEnd(C, t); transformops_exit(C, op); - + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; @@ -541,7 +541,7 @@ void Transform_Properties(struct wmOperatorType *ot, int flags) RNA_def_property_flag(prop, PROP_HIDDEN); prop = RNA_def_float_vector(ot->srna, "snap_point", 3, NULL, -FLT_MAX, FLT_MAX, "Point", "", -FLT_MAX, FLT_MAX); RNA_def_property_flag(prop, PROP_HIDDEN); - + if (flags & P_ALIGN_SNAP) { prop = RNA_def_boolean(ot->srna, "snap_align", 0, "Align with Point Normal", ""); RNA_def_property_flag(prop, PROP_HIDDEN); @@ -550,11 +550,11 @@ void Transform_Properties(struct wmOperatorType *ot, int flags) } } } - + if (flags & P_GPENCIL_EDIT) { RNA_def_boolean(ot->srna, "gpencil_strokes", 0, "Edit Grease Pencil", "Edit selected Grease Pencil strokes"); } - + if ((flags & P_OPTIONS) && !(flags & P_NO_TEXSPACE)) { RNA_def_boolean(ot->srna, "texture_space", 0, "Edit Texture Space", "Edit Object data texture space"); prop = RNA_def_boolean(ot->srna, "remove_on_cancel", 0, "Remove on Cancel", "Remove elements on cancel"); @@ -606,7 +606,7 @@ static void TRANSFORM_OT_resize(struct wmOperatorType *ot) { /* identifiers */ ot->name = "Resize"; - ot->description = "Scale (resize) selected items"; + ot->description = "Scale (resize) selected items"; ot->idname = OP_RESIZE; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; @@ -637,7 +637,7 @@ static void TRANSFORM_OT_skin_resize(struct wmOperatorType *ot) { /* identifiers */ ot->name = "Skin Resize"; - ot->description = "Scale selected vertices' skin radii"; + ot->description = "Scale selected vertices' skin radii"; ot->idname = OP_SKIN_RESIZE; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; @@ -702,7 +702,7 @@ static void TRANSFORM_OT_tilt(struct wmOperatorType *ot) /* optional - * "Tilt selected vertices" * "Specify an extra axis rotation for selected vertices of 3D curve" */ - ot->description = "Tilt selected control vertices of 3D curve"; + ot->description = "Tilt selected control vertices of 3D curve"; ot->idname = OP_TILT; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; @@ -805,7 +805,7 @@ static void TRANSFORM_OT_tosphere(struct wmOperatorType *ot) { /* identifiers */ ot->name = "To Sphere"; - //added "around mesh center" to differentiate between "MESH_OT_vertices_to_sphere()" + //added "around mesh center" to differentiate between "MESH_OT_vertices_to_sphere()" ot->description = "Move selected vertices outward in a spherical shape around mesh center"; ot->idname = OP_TOSPHERE; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; @@ -846,7 +846,7 @@ static void TRANSFORM_OT_edge_slide(struct wmOperatorType *ot) /* identifiers */ ot->name = "Edge Slide"; - ot->description = "Slide an edge loop along a mesh"; + ot->description = "Slide an edge loop along a mesh"; ot->idname = OP_EDGE_SLIDE; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; @@ -1023,7 +1023,7 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac { wmKeyMapItem *kmi; wmKeyMap *modalmap; - + /* transform.c, only adds modal map once, checks if it's there */ modalmap = transform_modal_keymap(keyconf); @@ -1036,7 +1036,7 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac } WM_modalkeymap_assign(modalmap, "TRANSFORM_OT_transform"); } - + switch (spaceid) { case SPACE_VIEW3D: WM_keymap_add_item(keymap, OP_TRANSLATION, GKEY, KM_PRESS, 0, 0); @@ -1079,41 +1079,41 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac case SPACE_ACTION: kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", GKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "mode", TFM_TIME_TRANSLATE); - + kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EVT_TWEAK_S, KM_ANY, 0, 0); RNA_enum_set(kmi->ptr, "mode", TFM_TIME_TRANSLATE); - + kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "mode", TFM_TIME_EXTEND); - + kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "mode", TFM_TIME_SCALE); - + kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", TKEY, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "mode", TFM_TIME_SLIDE); break; case SPACE_IPO: WM_keymap_add_item(keymap, OP_TRANSLATION, GKEY, KM_PRESS, 0, 0); - + WM_keymap_add_item(keymap, OP_TRANSLATION, EVT_TWEAK_S, KM_ANY, 0, 0); - + kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "mode", TFM_TIME_EXTEND); - + WM_keymap_add_item(keymap, OP_ROTATION, RKEY, KM_PRESS, 0, 0); - + WM_keymap_add_item(keymap, OP_RESIZE, SKEY, KM_PRESS, 0, 0); break; case SPACE_NLA: kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", GKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "mode", TFM_TRANSLATION); - + kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EVT_TWEAK_S, KM_ANY, 0, 0); RNA_enum_set(kmi->ptr, "mode", TFM_TRANSLATION); - + kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "mode", TFM_TIME_EXTEND); - + kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "mode", TFM_TIME_SCALE); break; diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 18b5e952a3d..c38fb15fc89 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -67,7 +67,7 @@ void BIF_clearTransformOrientation(bContext *C) ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces; BLI_freelistN(transform_spaces); - + // Need to loop over all view3d if (v3d && v3d->twmode >= V3D_MANIP_CUSTOM) { v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */ @@ -188,14 +188,14 @@ static TransformOrientation *createMeshSpace(bContext *C, ReportList *reports, int type; type = getTransformOrientation(C, normal, plane); - + switch (type) { case ORIENTATION_VERT: if (createSpaceNormal(mat, normal) == 0) { BKE_reports_prepend(reports, "Cannot use vertex with zero-length normal"); return NULL; } - + if (name[0] == 0) { name = "Vertex"; } @@ -205,7 +205,7 @@ static TransformOrientation *createMeshSpace(bContext *C, ReportList *reports, BKE_reports_prepend(reports, "Cannot use zero-length edge"); return NULL; } - + if (name[0] == 0) { name = "Edge"; } @@ -215,7 +215,7 @@ static TransformOrientation *createMeshSpace(bContext *C, ReportList *reports, BKE_reports_prepend(reports, "Cannot use zero-area face"); return NULL; } - + if (name[0] == 0) { name = "Face"; } @@ -230,7 +230,7 @@ static TransformOrientation *createMeshSpace(bContext *C, ReportList *reports, bool createSpaceNormal(float mat[3][3], const float normal[3]) { float tangent[3] = {0.0f, 0.0f, 1.0f}; - + copy_v3_v3(mat[2], normal); if (normalize_v3(mat[2]) == 0.0f) { return false; /* error return */ @@ -246,7 +246,7 @@ bool createSpaceNormal(float mat[3][3], const float normal[3]) cross_v3_v3v3(mat[1], mat[2], mat[0]); normalize_m3(mat); - + return true; } @@ -272,13 +272,13 @@ bool createSpaceNormalTangent(float mat[3][3], const float normal[3], const floa if (normalize_v3(mat[0]) == 0.0f) { return false; /* error return */ } - + cross_v3_v3v3(mat[1], mat[2], mat[0]); normalize_v3(mat[1]); /* final matrix must be normalized, do inline */ // normalize_m3(mat); - + return true; } @@ -417,7 +417,7 @@ static int count_bone_select(bArmature *arm, ListBase *lb, const bool do_it) Bone *bone; bool do_next; int total = 0; - + for (bone = lb->first; bone; bone = bone->next) { bone->flag &= ~BONE_TRANSFORM; do_next = do_it; @@ -434,7 +434,7 @@ static int count_bone_select(bArmature *arm, ListBase *lb, const bool do_it) } total += count_bone_select(arm, &bone->childbase, do_next); } - + return total; } @@ -465,7 +465,7 @@ void initTransformOrientation(bContext *C, TransInfo *t) ATTR_FALLTHROUGH; /* we define 'normal' as 'local' in Object mode */ case V3D_MANIP_LOCAL: BLI_strncpy(t->spacename, IFACE_("local"), sizeof(t->spacename)); - + if (ob) { copy_m3_m4(t->spacemtx, ob->obmat); normalize_m3(t->spacemtx); @@ -473,9 +473,9 @@ void initTransformOrientation(bContext *C, TransInfo *t) else { unit_m3(t->spacemtx); } - + break; - + case V3D_MANIP_VIEW: if ((t->spacetype == SPACE_VIEW3D) && (t->ar->regiontype == RGN_TYPE_WINDOW)) @@ -598,10 +598,10 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3 if (obedit) { float imat[3][3], mat[3][3]; - + /* we need the transpose of the inverse for a normal... */ copy_m3_m4(imat, ob->obmat); - + invert_m3_m3(mat, imat); transpose_m3(mat); @@ -611,12 +611,12 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3 BMEditMesh *em = BKE_editmesh_from_object(ob); BMEditSelection ese; float vec[3] = {0, 0, 0}; - + /* USE LAST SELECTED WITH ACTIVE */ if (activeOnly && BM_select_history_active_get(em->bm, &ese)) { BM_editselection_normal(&ese, normal); BM_editselection_plane(&ese, plane); - + switch (ese.htype) { case BM_VERT: result = ORIENTATION_VERT; @@ -641,7 +641,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3 add_v3_v3(plane, vec); } } - + result = ORIENTATION_FACE; } else if (em->bm->totvertsel == 3) { @@ -702,7 +702,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3 else if (em->bm->totedgesel == 1 || em->bm->totvertsel == 2) { BMVert *v_pair[2] = {NULL, NULL}; BMEdge *eed = NULL; - + if (em->bm->totedgesel == 1) { if (bm_mesh_edges_select_get_n(em->bm, &eed, 1) == 1) { v_pair[0] = eed->v1; @@ -932,7 +932,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3 } } } - + if (!is_zero_v3(normal)) { result = ORIENTATION_FACE; } @@ -942,7 +942,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3 MetaElem *ml; bool ok = false; float tmat[3][3]; - + if (activeOnly && (ml = mb->lastelem)) { quat_to_mat3(tmat, ml->quat); add_v3_v3(normal, tmat[2]); @@ -990,7 +990,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3 } } } - + if (ok) { if (!is_zero_v3(plane)) { result = ORIENTATION_EDGE; @@ -1047,12 +1047,12 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3 if (ok) { /* we need the transpose of the inverse for a normal... */ copy_m3_m4(imat, ob->obmat); - + invert_m3_m3(mat, imat); transpose_m3(mat); mul_m3_v3(mat, normal); mul_m3_v3(mat, plane); - + result = ORIENTATION_EDGE; } } @@ -1076,14 +1076,14 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3 } } } - + if (ob) { copy_v3_v3(normal, ob->obmat[2]); copy_v3_v3(plane, ob->obmat[1]); } result = ORIENTATION_NORMAL; } - + return result; } diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 660a3748191..295f27d830f 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -112,12 +112,12 @@ static NodeBorder snapNodeBorder(int snap_node_mode); int BIF_snappingSupported(Object *obedit) { int status = 0; - + /* only support object mesh, armature, curves */ if (obedit == NULL || ELEM(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE, OB_MBALL)) { status = 1; } - + return status; } #endif @@ -137,19 +137,19 @@ bool activeSnap(TransInfo *t) void drawSnapping(const struct bContext *C, TransInfo *t) { unsigned char col[4], selectedCol[4], activeCol[4]; - + if (!activeSnap(t)) return; - + UI_GetThemeColor3ubv(TH_TRANSFORM, col); col[3] = 128; - + UI_GetThemeColor3ubv(TH_SELECT, selectedCol); selectedCol[3] = 128; - + UI_GetThemeColor3ubv(TH_ACTIVE, activeCol); activeCol[3] = 192; - + if (t->spacetype == SPACE_VIEW3D) { if (validSnap(t)) { TransSnapPoint *p; @@ -157,13 +157,13 @@ void drawSnapping(const struct bContext *C, TransInfo *t) RegionView3D *rv3d = CTX_wm_region_view3d(C); float imat[4][4]; float size; - + glDisable(GL_DEPTH_TEST); - + size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE); - + invert_m4_m4(imat, rv3d->viewmat); - + for (p = t->tsnap.points.first; p; p = p->next) { if (p == t->tsnap.selectedPoint) { glColor4ubv(selectedCol); @@ -171,20 +171,20 @@ void drawSnapping(const struct bContext *C, TransInfo *t) else { glColor4ubv(col); } - + drawcircball(GL_LINE_LOOP, p->co, ED_view3d_pixel_size(rv3d, p->co) * size * 0.75f, imat); } - + if (t->tsnap.status & POINT_INIT) { glColor4ubv(activeCol); - + drawcircball(GL_LINE_LOOP, t->tsnap.snapPoint, ED_view3d_pixel_size(rv3d, t->tsnap.snapPoint) * size, imat); } - + /* draw normal if needed */ if (usingSnappingNormal(t) && validSnappingNormal(t)) { glColor4ubv(activeCol); - + glBegin(GL_LINES); glVertex3f(t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], t->tsnap.snapPoint[2]); glVertex3f(t->tsnap.snapPoint[0] + t->tsnap.snapNormal[0], @@ -192,7 +192,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) t->tsnap.snapPoint[2] + t->tsnap.snapNormal[2]); glEnd(); } - + if (v3d->zbuf) glEnable(GL_DEPTH_TEST); } @@ -204,28 +204,28 @@ void drawSnapping(const struct bContext *C, TransInfo *t) float xuser_asp, yuser_asp; int wi, hi; float w, h; - + calc_image_view(G.sima, 'f'); // float myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax); glLoadIdentity(); - + ED_space_image_get_aspect(t->sa->spacedata.first, &xuser_aspx, &yuser_asp); ED_space_image_width(t->sa->spacedata.first, &wi, &hi); w = (((float)wi) / IMG_SIZE_FALLBACK) * G.sima->zoom * xuser_asp; h = (((float)hi) / IMG_SIZE_FALLBACK) * G.sima->zoom * yuser_asp; - + cpack(0xFFFFFF); glTranslate2fv(t->tsnap.snapPoint); - + //glRectf(0, 0, 1, 1); - + setlinestyle(0); cpack(0x0); fdrawline(-0.020 / w, 0, -0.1 / w, 0); fdrawline(0.1 / w, 0, 0.020 / w, 0); fdrawline(0, -0.020 / h, 0, -0.1 / h); fdrawline(0, 0.1 / h, 0, 0.020 / h); - + glTranslatef(-t->tsnap.snapPoint[0], -t->tsnap.snapPoint[1], 0.0f); setlinestyle(0); #endif @@ -236,11 +236,11 @@ void drawSnapping(const struct bContext *C, TransInfo *t) ARegion *ar = CTX_wm_region(C); TransSnapPoint *p; float size; - + size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE); - + glEnable(GL_BLEND); - + for (p = t->tsnap.points.first; p; p = p->next) { if (p == t->tsnap.selectedPoint) { glColor4ubv(selectedCol); @@ -248,16 +248,16 @@ void drawSnapping(const struct bContext *C, TransInfo *t) else { glColor4ubv(col); } - + ED_node_draw_snap(&ar->v2d, p->co, size, 0); } - + if (t->tsnap.status & POINT_INIT) { glColor4ubv(activeCol); - + ED_node_draw_snap(&ar->v2d, t->tsnap.snapPoint, size, t->tsnap.snapNodeBorder); } - + glDisable(GL_BLEND); } } @@ -278,7 +278,7 @@ eRedrawFlag handleSnapping(TransInfo *t, const wmEvent *event) if (event->type == MOUSEMOVE) { status |= updateSelectedSnapPoint(t); } - + return status; } @@ -290,7 +290,7 @@ void applyProject(TransInfo *t) float tvec[3]; float imat[4][4]; int i; - + if (t->flag & (T_EDIT | T_POSE)) { Object *ob = t->obedit ? t->obedit : t->poseobj; invert_m4_m4(imat, ob->obmat); @@ -300,16 +300,16 @@ void applyProject(TransInfo *t) float iloc[3], loc[3], no[3]; float mval_fl[2]; float dist_px = TRANSFORM_DIST_MAX_PX; - + if (td->flag & TD_NOACTION) break; - + if (td->flag & TD_SKIP) continue; if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f)) continue; - + copy_v3_v3(iloc, td->loc); if (t->flag & (T_EDIT | T_POSE)) { Object *ob = t->obedit ? t->obedit : t->poseobj; @@ -319,7 +319,7 @@ void applyProject(TransInfo *t) BKE_object_eval_transform_all(G.main->eval_ctx, t->scene, td->ob); copy_v3_v3(iloc, td->ob->obmat[3]); } - + if (ED_view3d_project_float_global(t->ar, iloc, mval_fl, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { if (snapObjectsTransform( t, mval_fl, &dist_px, @@ -351,7 +351,7 @@ void applyProject(TransInfo *t) } } } - + //XXX constraintTransLim(t, td); } } @@ -365,14 +365,14 @@ void applyGridAbsolute(TransInfo *t) float (*obmat)[4] = NULL; bool use_obmat = false; int i; - + if (!(activeSnap(t) && (ELEM(t->tsnap.mode, SCE_SNAP_MODE_INCREMENT, SCE_SNAP_MODE_GRID)))) return; - + grid_action = BIG_GEARS; if (t->modifiers & MOD_PRECISION) grid_action = SMALL_GEARS; - + switch (grid_action) { case NO_GEARS: grid_size = t->snap_spatial[0]; break; case BIG_GEARS: grid_size = t->snap_spatial[1]; break; @@ -381,25 +381,25 @@ void applyGridAbsolute(TransInfo *t) /* early exit on unusable grid size */ if (grid_size == 0.0f) return; - + if (t->flag & (T_EDIT | T_POSE)) { Object *ob = t->obedit ? t->obedit : t->poseobj; obmat = ob->obmat; use_obmat = true; } - + for (i = 0, td = t->data; i < t->total; i++, td++) { float iloc[3], loc[3], tvec[3]; - + if (td->flag & TD_NOACTION) break; - + if (td->flag & TD_SKIP) continue; - + if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f)) continue; - + copy_v3_v3(iloc, td->loc); if (use_obmat) { mul_m4_v3(obmat, iloc); @@ -408,7 +408,7 @@ void applyGridAbsolute(TransInfo *t) BKE_object_eval_transform_all(G.main->eval_ctx, t->scene, td->ob); copy_v3_v3(iloc, td->ob->obmat[3]); } - + mul_v3_v3fl(loc, iloc, 1.0f / grid_size); loc[0] = roundf(loc[0]); loc[1] = roundf(loc[1]); @@ -426,21 +426,21 @@ void applySnapping(TransInfo *t, float *vec) /* project is not applied this way */ if (t->tsnap.project) return; - + if (t->tsnap.status & SNAP_FORCED) { t->tsnap.targetSnap(t); - + t->tsnap.applySnap(t, vec); } else if (!ELEM(t->tsnap.mode, SCE_SNAP_MODE_INCREMENT, SCE_SNAP_MODE_GRID) && activeSnap(t)) { double current = PIL_check_seconds_timer(); - + // Time base quirky code to go around findnearest slowness /* !TODO! add exception for object mode, no need to slow it down then */ if (current - t->tsnap.last >= 0.01) { t->tsnap.calcSnap(t, vec); t->tsnap.targetSnap(t); - + t->tsnap.last = current; } if (validSnap(t)) { @@ -463,7 +463,7 @@ void resetSnapping(TransInfo *t) t->tsnap.snapNormal[0] = 0; t->tsnap.snapNormal[1] = 0; t->tsnap.snapNormal[2] = 0; - + t->tsnap.snapNodeBorder = 0; } @@ -479,7 +479,7 @@ bool validSnappingNormal(TransInfo *t) return true; } } - + return false; } @@ -522,20 +522,20 @@ static void initSnappingMode(TransInfo *t) if (t->spacetype == SPACE_NODE) { /* force project off when not supported */ t->tsnap.project = 0; - + t->tsnap.mode = ts->snap_node_mode; } else if (t->spacetype == SPACE_IMAGE) { /* force project off when not supported */ t->tsnap.project = 0; - + t->tsnap.mode = ts->snap_uv_mode; } else { /* force project off when not supported */ if (ts->snap_mode != SCE_SNAP_MODE_FACE) t->tsnap.project = 0; - + t->tsnap.mode = ts->snap_mode; } @@ -577,7 +577,7 @@ static void initSnappingMode(TransInfo *t) } else if (t->spacetype == SPACE_NODE) { setSnappingCallback(t); - + if (t->tsnap.applySnap != NULL) { t->tsnap.modeSelect = SNAP_NOT_SELECTED; } @@ -615,9 +615,9 @@ void initSnapping(TransInfo *t, wmOperator *op) { ToolSettings *ts = t->settings; short snap_target = t->settings->snap_target; - + resetSnapping(t); - + /* if snap property exists */ if (op && RNA_struct_find_property(op->ptr, "snap") && RNA_struct_property_is_set(op->ptr, "snap")) { if (RNA_boolean_get(op->ptr, "snap")) { @@ -626,12 +626,12 @@ void initSnapping(TransInfo *t, wmOperator *op) if (RNA_struct_property_is_set(op->ptr, "snap_target")) { snap_target = RNA_enum_get(op->ptr, "snap_target"); } - + if (RNA_struct_property_is_set(op->ptr, "snap_point")) { RNA_float_get_array(op->ptr, "snap_point", t->tsnap.snapPoint); t->tsnap.status |= SNAP_FORCED | POINT_INIT; } - + /* snap align only defined in specific cases */ if (RNA_struct_find_property(op->ptr, "snap_align")) { t->tsnap.align = RNA_boolean_get(op->ptr, "snap_align"); @@ -666,7 +666,7 @@ void initSnapping(TransInfo *t, wmOperator *op) t->tsnap.snap_spatial_grid = ((t->settings->snap_flag & SCE_SNAP_ABS_GRID) != 0); } } - + t->tsnap.target = snap_target; initSnappingMode(t); @@ -884,24 +884,24 @@ static float RotationBetween(TransInfo *t, const float p1[3], const float p2[3]) sub_v3_v3v3(start, p1, t->center_global); sub_v3_v3v3(end, p2, t->center_global); - + // Angle around a constraint axis (error prone, will need debug) if (t->con.applyRot != NULL && (t->con.mode & CON_APPLY)) { float axis[3], tmp[3]; - + t->con.applyRot(t, NULL, axis, NULL); project_v3_v3v3(tmp, end, axis); sub_v3_v3v3(end, end, tmp); - + project_v3_v3v3(tmp, start, axis); sub_v3_v3v3(start, start, tmp); - + normalize_v3(end); normalize_v3(start); - + cross_v3_v3v3(tmp, start, end); - + if (dot_v3v3(tmp, axis) < 0.0f) angle = -acosf(dot_v3v3(start, end)); else @@ -909,22 +909,22 @@ static float RotationBetween(TransInfo *t, const float p1[3], const float p2[3]) } else { float mtx[3][3]; - + copy_m3_m4(mtx, t->viewmat); mul_m3_v3(mtx, end); mul_m3_v3(mtx, start); - + angle = atan2f(start[1], start[0]) - atan2f(end[1], end[0]); } - + if (angle > (float)M_PI) { angle = angle - 2 * (float)M_PI; } else if (angle < -((float)M_PI)) { angle = 2.0f * (float)M_PI + angle; } - + return angle; } @@ -941,7 +941,7 @@ static float ResizeBetween(TransInfo *t, const float p1[3], const float p2[3]) } project_v3_v3v3(d1, d1, d2); - + len_d1 = len_v3(d1); /* Use 'invalid' dist when `center == p1` (after projecting), @@ -965,10 +965,10 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec)) float mval[2]; bool found = false; float dist_px = SNAP_MIN_DISTANCE; // Use a user defined value here - + mval[0] = t->mval[0]; mval[1] = t->mval[1]; - + if (t->tsnap.mode == SCE_SNAP_MODE_VOLUME) { found = peelObjectsTransform( t, mval, @@ -981,7 +981,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec)) t, mval, &dist_px, loc, no); } - + if (found == true) { copy_v3_v3(t->tsnap.snapPoint, loc); copy_v3_v3(t->tsnap.snapNormal, no); @@ -996,7 +996,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec)) /* same as above but for UV's */ Image *ima = ED_space_image(t->sa->spacedata.first); float co[2]; - + UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], &co[0], &co[1]); if (ED_uvedit_nearest_uv(t->scene, t->obedit, ima, co, t->tsnap.snapPoint)) { @@ -1013,11 +1013,11 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec)) float loc[2]; float dist_px = SNAP_MIN_DISTANCE; // Use a user defined value here char node_border; - + if (snapNodesTransform(t, t->mval, loc, &dist_px, &node_border)) { copy_v2_v2(t->tsnap.snapPoint, loc); t->tsnap.snapNodeBorder = node_border; - + t->tsnap.status |= POINT_INIT; } else { @@ -1035,7 +1035,7 @@ static void TargetSnapOffset(TransInfo *t, TransData *td) char border = t->tsnap.snapNodeBorder; float width = BLI_rctf_size_x(&node->totr); float height = BLI_rctf_size_y(&node->totr); - + #ifdef USE_NODE_CENTER if (border & NODE_LEFT) t->tsnap.snapTarget[0] -= 0.5f * width; @@ -1064,7 +1064,7 @@ static void TargetSnapCenter(TransInfo *t) if ((t->tsnap.status & TARGET_INIT) == 0) { copy_v3_v3(t->tsnap.snapTarget, t->center_global); TargetSnapOffset(t, NULL); - + t->tsnap.status |= TARGET_INIT; } } @@ -1102,20 +1102,20 @@ static void TargetSnapMedian(TransInfo *t) t->tsnap.snapTarget[0] = 0; t->tsnap.snapTarget[1] = 0; t->tsnap.snapTarget[2] = 0; - + for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) { add_v3_v3(t->tsnap.snapTarget, td->center); } - + mul_v3_fl(t->tsnap.snapTarget, 1.0 / i); - + if (t->flag & (T_EDIT | T_POSE)) { Object *ob = t->obedit ? t->obedit : t->poseobj; mul_m4_v3(ob->obmat, t->tsnap.snapTarget); } - + TargetSnapOffset(t, NULL); - + t->tsnap.status |= TARGET_INIT; } } @@ -1126,24 +1126,24 @@ static void TargetSnapClosest(TransInfo *t) if (t->tsnap.status & POINT_INIT) { float dist_closest = 0.0f; TransData *closest = NULL, *td = NULL; - + /* Object mode */ if (t->flag & T_OBJECT) { int i; for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) { struct BoundBox *bb = BKE_object_boundbox_get(td->ob); - + /* use boundbox if possible */ if (bb) { int j; - + for (j = 0; j < 8; j++) { float loc[3]; float dist; - + copy_v3_v3(loc, bb->vec[j]); mul_m4_v3(td->ext->obmat, loc); - + dist = t->tsnap.distance(t, loc, t->tsnap.snapPoint); if ((dist != TRANSFORM_DIST_INVALID) && @@ -1159,9 +1159,9 @@ static void TargetSnapClosest(TransInfo *t) else { float loc[3]; float dist; - + copy_v3_v3(loc, td->center); - + dist = t->tsnap.distance(t, loc, t->tsnap.snapPoint); if ((dist != TRANSFORM_DIST_INVALID) && @@ -1178,16 +1178,16 @@ static void TargetSnapClosest(TransInfo *t) for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) { float loc[3]; float dist; - + copy_v3_v3(loc, td->center); - + if (t->flag & (T_EDIT | T_POSE)) { Object *ob = t->obedit ? t->obedit : t->poseobj; mul_m4_v3(ob->obmat, loc); } - + dist = t->tsnap.distance(t, loc, t->tsnap.snapPoint); - + if ((dist != TRANSFORM_DIST_INVALID) && (closest == NULL || fabsf(dist) < fabsf(dist_closest))) { @@ -1197,9 +1197,9 @@ static void TargetSnapClosest(TransInfo *t) } } } - + TargetSnapOffset(t, closest); - + t->tsnap.status |= TARGET_INIT; } } @@ -1344,9 +1344,9 @@ static bool snapNode( bool retval = false; rcti totr; int new_dist; - + UI_view2d_view_to_region_rcti(v2d, &node->totr, &totr); - + if (border & NODE_LEFT) { new_dist = abs(totr.xmin - mval[0]); if (new_dist < *r_dist_px) { @@ -1356,7 +1356,7 @@ static bool snapNode( retval = true; } } - + if (border & NODE_RIGHT) { new_dist = abs(totr.xmax - mval[0]); if (new_dist < *r_dist_px) { @@ -1366,7 +1366,7 @@ static bool snapNode( retval = true; } } - + if (border & NODE_BOTTOM) { new_dist = abs(totr.ymin - mval[1]); if (new_dist < *r_dist_px) { @@ -1376,7 +1376,7 @@ static bool snapNode( retval = true; } } - + if (border & NODE_TOP) { new_dist = abs(totr.ymax - mval[1]); if (new_dist < *r_dist_px) { @@ -1386,7 +1386,7 @@ static bool snapNode( retval = true; } } - + return retval; } @@ -1398,15 +1398,15 @@ static bool snapNodes( bNodeTree *ntree = snode->edittree; bNode *node; bool retval = false; - + *r_node_border = 0; - + for (node = ntree->nodes.first; node; node = node->next) { if (snapNodeTest(&ar->v2d, node, snap_select)) { retval |= snapNode(ts, snode, ar, node, mval, r_loc, r_dist_px, r_node_border); } } - + return retval; } @@ -1431,7 +1431,7 @@ void snapGridIncrementAction(TransInfo *t, float *val, GearsType action) fac[NO_GEARS] = t->snap[0]; fac[BIG_GEARS] = t->snap[1]; fac[SMALL_GEARS] = t->snap[2]; - + applyGridIncrement(t, val, t->idx_max, fac, action); } -- cgit v1.2.3