diff options
Diffstat (limited to 'source/blender/editors/transform/transform.c')
-rw-r--r-- | source/blender/editors/transform/transform.c | 118 |
1 files changed, 65 insertions, 53 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index a3fb4e851e2..ee5d50c7aba 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -126,11 +126,11 @@ static void convertViewVec2D(View2D *v2d, float r_vec[3], int dx, int dy) { float divx, divy; - divx = BLI_RCT_SIZE_X(&v2d->mask); - divy = BLI_RCT_SIZE_Y(&v2d->mask); + divx = BLI_rcti_size_x(&v2d->mask); + divy = BLI_rcti_size_y(&v2d->mask); - r_vec[0] = BLI_RCT_SIZE_X(&v2d->cur) * dx / divx; - r_vec[1] = BLI_RCT_SIZE_Y(&v2d->cur) * dy / divy; + r_vec[0] = BLI_rctf_size_x(&v2d->cur) * dx / divx; + r_vec[1] = BLI_rctf_size_y(&v2d->cur) * dy / divy; r_vec[2] = 0.0f; } @@ -139,11 +139,11 @@ static void convertViewVec2D_mask(View2D *v2d, float r_vec[3], int dx, int dy) float divx, divy; float mulx, muly; - divx = BLI_RCT_SIZE_X(&v2d->mask); - divy = BLI_RCT_SIZE_Y(&v2d->mask); + divx = BLI_rcti_size_x(&v2d->mask); + divy = BLI_rcti_size_y(&v2d->mask); - mulx = BLI_RCT_SIZE_X(&v2d->cur); - muly = BLI_RCT_SIZE_Y(&v2d->cur); + mulx = BLI_rctf_size_x(&v2d->cur); + muly = BLI_rctf_size_y(&v2d->cur); /* difference with convertViewVec2D */ /* clamp w/h, mask only */ @@ -226,7 +226,7 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2]) { if (t->spacetype == SPACE_VIEW3D) { if (t->ar->regiontype == RGN_TYPE_WINDOW) - project_int_noclip(t->ar, vec, adr); + ED_view3d_project_int_noclip(t->ar, vec, adr); } else if (t->spacetype == SPACE_IMAGE) { SpaceImage *sima = t->sa->spacedata.first; @@ -344,7 +344,7 @@ void projectFloatView(TransInfo *t, const float vec[3], float adr[2]) case SPACE_VIEW3D: { if (t->ar->regiontype == RGN_TYPE_WINDOW) { - project_float_noclip(t->ar, vec, adr); + ED_view3d_project_float_noclip(t->ar, vec, adr); return; } break; @@ -820,9 +820,6 @@ int transformEvent(TransInfo *t, wmEvent *event) t->redraw |= handleMouseInput(t, &t->mouse, event); if (event->type == MOUSEMOVE) { - if (t->modifiers & MOD_CONSTRAINT_SELECT) - t->con.mode |= CON_SELECT; - copy_v2_v2_int(t->mval, event->mval); // t->redraw |= TREDRAW_SOFT; /* Use this for soft redraw. Might cause flicker in object mode */ @@ -1963,6 +1960,9 @@ void transformApply(bContext *C, TransInfo *t) t->context = C; if ((t->redraw & TREDRAW_HARD) || (t->draw_handle_apply == NULL && (t->redraw & TREDRAW_SOFT))) { + if (t->modifiers & MOD_CONSTRAINT_SELECT) + t->con.mode |= CON_SELECT; + selectConstraint(t); if (t->transform) { t->transform(t, t->mval); // calls recalcData() @@ -2195,7 +2195,6 @@ static void constraintTransLim(TransInfo *t, TransData *td) for (con = td->con; con; con = con->next) { bConstraintTypeInfo *cti = NULL; ListBase targets = {NULL, NULL}; - float tmat[4][4]; /* only consider constraint if enabled */ if (con->flag & CONSTRAINT_DISABLE) continue; @@ -2221,8 +2220,7 @@ static void constraintTransLim(TransInfo *t, TransData *td) /* do space conversions */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { /* just multiply by td->mtx (this should be ok) */ - copy_m4_m4(tmat, cob.matrix); - mul_m4_m3m4(cob.matrix, td->mtx, tmat); + mul_m4_m3m4(cob.matrix, td->mtx, cob.matrix); } else if (con->ownspace != CONSTRAINT_SPACE_LOCAL) { /* skip... incompatable spacetype */ @@ -2237,9 +2235,8 @@ static void constraintTransLim(TransInfo *t, TransData *td) /* convert spaces again */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { - /* just multiply by td->mtx (this should be ok) */ - copy_m4_m4(tmat, cob.matrix); - mul_m4_m3m4(cob.matrix, td->smtx, tmat); + /* just multiply by td->smtx (this should be ok) */ + mul_m4_m3m4(cob.matrix, td->smtx, cob.matrix); } /* free targets list */ @@ -2287,18 +2284,17 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td) bConstraintOb cob; bConstraint *con; int do_limit = FALSE; - + /* Evaluate valid constraints */ for (con = td->con; con; con = con->next) { /* only consider constraint if enabled */ if (con->flag & CONSTRAINT_DISABLE) continue; if (con->enforce == 0.0f) continue; - + /* we're only interested in Limit-Rotation constraints */ if (con->type == CONSTRAINT_TYPE_ROTLIMIT) { bRotLimitConstraint *data = con->data; - float tmat[4][4]; - + /* only use it if it's tagged for this purpose */ if ((data->flag2 & LIMIT_TRANSFORM) == 0) continue; @@ -2312,12 +2308,11 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td) constraintob_from_transdata(&cob, td); do_limit = TRUE; } - + /* do space conversions */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { /* just multiply by td->mtx (this should be ok) */ - copy_m4_m4(tmat, cob.matrix); - mul_m4_m3m4(cob.matrix, td->mtx, tmat); + mul_m4_m3m4(cob.matrix, td->mtx, cob.matrix); } /* do constraint */ @@ -2325,9 +2320,8 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td) /* convert spaces again */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { - /* just multiply by td->mtx (this should be ok) */ - copy_m4_m4(tmat, cob.matrix); - mul_m4_m3m4(cob.matrix, td->smtx, tmat); + /* just multiply by td->smtx (this should be ok) */ + mul_m4_m3m4(cob.matrix, td->smtx, cob.matrix); } } } @@ -2382,7 +2376,6 @@ static void constraintSizeLim(TransInfo *t, TransData *td) /* we're only interested in Limit-Scale constraints */ if (con->type == CONSTRAINT_TYPE_SIZELIMIT) { bSizeLimitConstraint *data = con->data; - float tmat[4][4]; /* only use it if it's tagged for this purpose */ if ((data->flag2 & LIMIT_TRANSFORM) == 0) @@ -2391,11 +2384,10 @@ static void constraintSizeLim(TransInfo *t, TransData *td) /* do space conversions */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { /* just multiply by td->mtx (this should be ok) */ - copy_m4_m4(tmat, cob.matrix); - mul_m4_m3m4(cob.matrix, td->mtx, tmat); + mul_m4_m3m4(cob.matrix, td->mtx, cob.matrix); } else if (con->ownspace != CONSTRAINT_SPACE_LOCAL) { - /* skip... incompatable spacetype */ + /* skip... incompatible spacetype */ continue; } @@ -2404,13 +2396,12 @@ static void constraintSizeLim(TransInfo *t, TransData *td) /* convert spaces again */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { - /* just multiply by td->mtx (this should be ok) */ - copy_m4_m4(tmat, cob.matrix); - mul_m4_m3m4(cob.matrix, td->smtx, tmat); + /* just multiply by td->smtx (this should be ok) */ + mul_m4_m3m4(cob.matrix, td->smtx, cob.matrix); } } } - + /* copy results from cob->matrix */ if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) { /* scale val and reset size */ @@ -2420,7 +2411,7 @@ static void constraintSizeLim(TransInfo *t, TransData *td) /* Reset val if SINGLESIZE but using a constraint */ if (td->flag & TD_SINGLESIZE) return; - + mat4_to_size(td->ext->size, cob.matrix); } } @@ -2852,11 +2843,11 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) if (t->flag & (T_OBJECT | T_TEXTURE | T_POSE)) { float obsizemat[3][3]; - // Reorient the size mat to fit the oriented object. + /* Reorient the size mat to fit the oriented object. */ mul_m3_m3m3(obsizemat, tmat, td->axismtx); - //print_m3("obsizemat", obsizemat); + /* print_m3("obsizemat", obsizemat); */ TransMat3ToSize(obsizemat, td->axismtx, fsize); - //print_v3("fsize", fsize); + /* print_v3("fsize", fsize); */ } else { mat3_to_size(fsize, tmat); @@ -2864,7 +2855,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) protectedSizeBits(td->protectflag, fsize); - if ((t->flag & T_V3D_ALIGN) == 0) { // align mode doesn't resize objects itself + 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); @@ -4100,9 +4091,9 @@ void initMaskShrinkFatten(TransInfo *t) int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) { - TransData *td = t->data; + TransData *td; float ratio; - int i; + int i, initial_feather = FALSE; char str[50]; ratio = t->values[0]; @@ -4116,13 +4107,30 @@ int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) char c[NUM_STR_REP_LEN]; outputNumInput(&(t->num), c); - sprintf(str, "Shrink/Fatten: %s", c); + sprintf(str, "Feather Shrink/Fatten: %s", c); } else { - sprintf(str, "Shrink/Fatten: %3f", ratio); + sprintf(str, "Feather Shrink/Fatten: %3f", ratio); } - for (i = 0; i < t->total; i++, td++) { + /* detect if no points have feather yet */ + if (ratio > 1.0f) { + initial_feather = TRUE; + + for (td = t->data, i = 0; i < t->total; i++, td++) { + if (td->flag & TD_NOACTION) + break; + + if (td->flag & TD_SKIP) + continue; + + if (td->ival >= 0.001f) + initial_feather = FALSE; + } + } + + /* apply shrink/fatten */ + for (td = t->data, i = 0; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; @@ -4130,7 +4138,11 @@ int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) continue; if (td->val) { - *td->val = td->ival * ratio; + if (initial_feather) + *td->val = td->ival + (ratio - 1.0f) * 0.01f; + else + *td->val = td->ival * ratio; + /* apply PET */ *td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival); if (*td->val <= 0.0f) *td->val = 0.001f; @@ -4774,7 +4786,7 @@ static void calcNonProportionalEdgeSlide(TransInfo *t, SlideData *sld, const flo sv->edge_len = len_v3v3(dw_p, up_p); mul_v3_m4v3(v_proj, t->obedit->obmat, sv->v->co); - project_float_noclip(t->ar, v_proj, v_proj); + ED_view3d_project_float_noclip(t->ar, v_proj, v_proj); dist = len_squared_v2v2(mval, v_proj); if (dist < min_dist) { @@ -5040,19 +5052,19 @@ static int createSlideVerts(TransInfo *t) j = GET_INT_FROM_POINTER(BLI_smallhash_lookup(&table, (uintptr_t)v)); if (sv_array[j].down) { - ED_view3d_project_float_v3(ar, sv_array[j].down->co, vec1, projectMat); + ED_view3d_project_float_v3_m4(ar, sv_array[j].down->co, vec1, projectMat); } else { add_v3_v3v3(vec1, v->co, sv_array[j].downvec); - ED_view3d_project_float_v3(ar, vec1, vec1, projectMat); + ED_view3d_project_float_v3_m4(ar, vec1, vec1, projectMat); } if (sv_array[j].up) { - ED_view3d_project_float_v3(ar, sv_array[j].up->co, vec2, projectMat); + ED_view3d_project_float_v3_m4(ar, sv_array[j].up->co, vec2, projectMat); } else { add_v3_v3v3(vec2, v->co, sv_array[j].upvec); - ED_view3d_project_float_v3(ar, vec2, vec2, projectMat); + ED_view3d_project_float_v3_m4(ar, vec2, vec2, projectMat); } /* global direction */ |