Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_mode_shear.c
| Show All 34 Lines | |||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "transform.h" | #include "transform.h" | ||||
| #include "transform_data.h" | |||||
| #include "transform_mode.h" | #include "transform_mode.h" | ||||
| #include "transform_snap.h" | #include "transform_snap.h" | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /* Transform (Shear) */ | /* Transform (Shear) */ | ||||
| /** \name Transform Shear | /** \name Transform Shear | ||||
| * \{ */ | * \{ */ | ||||
| ▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | static eRedrawFlag handleEventShear(TransInfo *t, const wmEvent *event) | ||||
| return status; | return status; | ||||
| } | } | ||||
| static void applyShear(TransInfo *t, const int UNUSED(mval[2])) | static void applyShear(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| float vec[3]; | float vec[3]; | ||||
| float smat[3][3], tmat[3][3], totmat[3][3], axismat[3][3], axismat_inv[3][3]; | float smat[3][3], tmat[3][3], totmat[3][3], axismat[3][3], axismat_inv[3][3]; | ||||
| float value; | float value; | ||||
| int i; | |||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| const bool is_local_center = transdata_check_local_center(t, t->around); | const bool is_local_center = transdata_check_local_center(t, t->around); | ||||
| value = t->values[0]; | value = t->values[0]; | ||||
| snapGridIncrement(t, &value); | snapGridIncrement(t, &value); | ||||
| applyNumInput(&t->num, &value); | applyNumInput(&t->num, &value); | ||||
| Show All 24 Lines | static void applyShear(TransInfo *t, const int UNUSED(mval[2])) | ||||
| copy_v3_v3(axismat_inv[2], t->spacemtx[t->orient_axis]); | copy_v3_v3(axismat_inv[2], t->spacemtx[t->orient_axis]); | ||||
| cross_v3_v3v3(axismat_inv[1], axismat_inv[0], axismat_inv[2]); | cross_v3_v3v3(axismat_inv[1], axismat_inv[0], axismat_inv[2]); | ||||
| invert_m3_m3(axismat, axismat_inv); | invert_m3_m3(axismat, axismat_inv); | ||||
| mul_m3_series(totmat, axismat_inv, smat, axismat); | mul_m3_series(totmat, axismat_inv, smat, axismat); | ||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | TransData *td = tc->data; | ||||
| for (i = 0; i < tc->data_len; i++, td++) { | for (int tdi = 0; tdi < tc->data_len; tdi++) { | ||||
| const float *center, *co; | const float *center, *co; | ||||
| if (td->flag & TD_SKIP) { | if (td->basic[tdi].flag & TD_SKIP) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (t->flag & T_EDIT) { | if (t->flag & T_EDIT) { | ||||
| mul_m3_series(tmat, td->smtx, totmat, td->mtx); | mul_m3_series(tmat, td->space[tdi].smtx, totmat, td->space[tdi].mtx); | ||||
| } | } | ||||
| else { | else { | ||||
| copy_m3_m3(tmat, totmat); | copy_m3_m3(tmat, totmat); | ||||
| } | } | ||||
| if (is_local_center) { | if (is_local_center) { | ||||
| center = td->center; | center = td->center[tdi]; | ||||
| co = td->loc; | co = td->basic[tdi].loc; | ||||
| } | } | ||||
| else { | else { | ||||
| center = tc->center_local; | center = tc->center_local; | ||||
| co = td->center; | co = td->center[tdi]; | ||||
| } | } | ||||
| sub_v3_v3v3(vec, co, center); | sub_v3_v3v3(vec, co, center); | ||||
| mul_m3_v3(tmat, vec); | mul_m3_v3(tmat, vec); | ||||
| add_v3_v3(vec, center); | add_v3_v3(vec, center); | ||||
| sub_v3_v3(vec, co); | sub_v3_v3(vec, co); | ||||
| if (t->options & CTX_GPENCIL_STROKES) { | if (t->options & CTX_GPENCIL_STROKES) { | ||||
| /* grease pencil multiframe falloff */ | /* grease pencil multiframe falloff */ | ||||
| bGPDstroke *gps = (bGPDstroke *)td->extra; | bGPDstroke *gps = (bGPDstroke *)td->basic[tdi].extra; | ||||
| if (gps != NULL) { | if (gps != NULL) { | ||||
| mul_v3_fl(vec, td->factor * gps->runtime.multi_frame_falloff); | mul_v3_fl(vec, td->prop[tdi].factor * gps->runtime.multi_frame_falloff); | ||||
| } | } | ||||
| else { | else { | ||||
| mul_v3_fl(vec, td->factor); | mul_v3_fl(vec, td->prop[tdi].factor); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| mul_v3_fl(vec, td->factor); | mul_v3_fl(vec, td->prop[tdi].factor); | ||||
| } | } | ||||
| add_v3_v3v3(td->loc, td->iloc, vec); | add_v3_v3v3(td->basic[tdi].loc, td->basic[tdi].iloc, vec); | ||||
| } | } | ||||
| } | } | ||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_status_text(t->area, str); | ED_area_status_text(t->area, str); | ||||
| } | } | ||||
| Show All 26 Lines | |||||