Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_mode_push_pull.c
| Show All 31 Lines | |||||
| #include "ED_screen.h" | #include "ED_screen.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_constraints.h" | #include "transform_constraints.h" | ||||
| #include "transform_data.h" | |||||
| #include "transform_mode.h" | #include "transform_mode.h" | ||||
| #include "transform_snap.h" | #include "transform_snap.h" | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /* Transform (Push/Pull) */ | /* Transform (Push/Pull) */ | ||||
| /** \name Transform Push/Pull | /** \name Transform Push/Pull | ||||
| * \{ */ | * \{ */ | ||||
| static void applyPushPull(TransInfo *t, const int UNUSED(mval[2])) | static void applyPushPull(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| float vec[3], axis_global[3]; | float vec[3], axis_global[3]; | ||||
| float distance; | float distance; | ||||
| int i; | |||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| distance = t->values[0]; | distance = t->values[0]; | ||||
| snapGridIncrement(t, &distance); | snapGridIncrement(t, &distance); | ||||
| applyNumInput(&t->num, &distance); | applyNumInput(&t->num, &distance); | ||||
| Show All 9 Lines | static void applyPushPull(TransInfo *t, const int UNUSED(mval[2])) | ||||
| } | } | ||||
| else { | else { | ||||
| /* default header print */ | /* default header print */ | ||||
| BLI_snprintf( | BLI_snprintf( | ||||
| str, sizeof(str), TIP_("Push/Pull: %.4f%s %s"), distance, t->con.text, t->proptext); | str, sizeof(str), TIP_("Push/Pull: %.4f%s %s"), distance, t->con.text, t->proptext); | ||||
| } | } | ||||
| if (t->con.applyRot && t->con.mode & CON_APPLY) { | if (t->con.applyRot && t->con.mode & CON_APPLY) { | ||||
| t->con.applyRot(t, NULL, NULL, axis_global, NULL); | t->con.applyRot(t, NULL, 0, axis_global, NULL); | ||||
| } | } | ||||
| 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++) { | ||||
| if (td->flag & TD_SKIP) { | if (td->basic[tdi].flag & TD_SKIP) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| sub_v3_v3v3(vec, tc->center_local, td->center); | sub_v3_v3v3(vec, tc->center_local, td->center[tdi]); | ||||
| if (t->con.applyRot && t->con.mode & CON_APPLY) { | if (t->con.applyRot && t->con.mode & CON_APPLY) { | ||||
| float axis[3]; | float axis[3]; | ||||
| copy_v3_v3(axis, axis_global); | copy_v3_v3(axis, axis_global); | ||||
| t->con.applyRot(t, tc, td, axis, NULL); | t->con.applyRot(t, tc, tdi, axis, NULL); | ||||
| mul_m3_v3(td->smtx, axis); | mul_m3_v3(td->space[tdi].smtx, axis); | ||||
| if (isLockConstraint(t)) { | if (isLockConstraint(t)) { | ||||
| float dvec[3]; | float dvec[3]; | ||||
| project_v3_v3v3(dvec, vec, axis); | project_v3_v3v3(dvec, vec, axis); | ||||
| sub_v3_v3(vec, dvec); | sub_v3_v3(vec, dvec); | ||||
| } | } | ||||
| else { | else { | ||||
| project_v3_v3v3(vec, vec, axis); | project_v3_v3v3(vec, vec, axis); | ||||
| } | } | ||||
| } | } | ||||
| normalize_v3_length(vec, distance * td->factor); | normalize_v3_length(vec, distance * 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 18 Lines | |||||