Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_mode_translate.c
| Show All 38 Lines | |||||
| #include "WM_api.h" | #include "WM_api.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_convert.h" | #include "transform_convert.h" | ||||
| #include "transform_data.h" | |||||
| #include "transform_mode.h" | #include "transform_mode.h" | ||||
| #include "transform_snap.h" | #include "transform_snap.h" | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /* Transform (Translation) */ | /* Transform (Translation) */ | ||||
| /** \name Transform Translation | /** \name Transform Translation | ||||
| * \{ */ | * \{ */ | ||||
| ▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Lines | if (apply_snap_align_rotation) { | ||||
| copy_v3_v3(pivot, t->tsnap.snapTarget); | copy_v3_v3(pivot, t->tsnap.snapTarget); | ||||
| /* The pivot has to be in local-space (see T49494) */ | /* The pivot has to be in local-space (see T49494) */ | ||||
| if (tc->use_local_mat) { | if (tc->use_local_mat) { | ||||
| mul_m4_v3(tc->imat, pivot); | mul_m4_v3(tc->imat, pivot); | ||||
| } | } | ||||
| } | } | ||||
| TransData *td = tc->data; | TransData *td = tc->data; | ||||
| for (int 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; | ||||
| } | } | ||||
| float rotate_offset[3] = {0}; | float rotate_offset[3] = {0}; | ||||
| bool use_rotate_offset = false; | bool use_rotate_offset = false; | ||||
| /* handle snapping rotation before doing the translation */ | /* handle snapping rotation before doing the translation */ | ||||
| if (apply_snap_align_rotation) { | if (apply_snap_align_rotation) { | ||||
| float mat[3][3]; | float mat[3][3]; | ||||
| if (validSnappingNormal(t)) { | if (validSnappingNormal(t)) { | ||||
| const float *original_normal; | const float *original_normal; | ||||
| /* In pose mode, we want to align normals with Y axis of bones... */ | /* In pose mode, we want to align normals with Y axis of bones... */ | ||||
| if (t->flag & T_POSE) { | if (t->flag & T_POSE) { | ||||
| original_normal = td->axismtx[1]; | original_normal = td->space[tdi].axismtx[1]; | ||||
| } | } | ||||
| else { | else { | ||||
| original_normal = td->axismtx[2]; | original_normal = td->space[tdi].axismtx[2]; | ||||
| } | } | ||||
| rotation_between_vecs_to_mat3(mat, original_normal, t->tsnap.snapNormal); | rotation_between_vecs_to_mat3(mat, original_normal, t->tsnap.snapNormal); | ||||
| } | } | ||||
| else { | else { | ||||
| unit_m3(mat); | unit_m3(mat); | ||||
| } | } | ||||
| ElementRotation_ex(t, tc, td, mat, pivot); | ElementRotation_ex(t, tc, tdi, mat, pivot); | ||||
| if (td->loc) { | if (td->basic[tdi].loc) { | ||||
| use_rotate_offset = true; | use_rotate_offset = true; | ||||
| sub_v3_v3v3(rotate_offset, td->loc, td->iloc); | sub_v3_v3v3(rotate_offset, td->basic[tdi].loc, td->basic[tdi].iloc); | ||||
| } | } | ||||
| } | } | ||||
| if (t->con.applyVec) { | if (t->con.applyVec) { | ||||
| t->con.applyVec(t, tc, td, vec, tvec); | t->con.applyVec(t, tc, tdi, vec, tvec); | ||||
| } | } | ||||
| else { | else { | ||||
| copy_v3_v3(tvec, vec); | copy_v3_v3(tvec, vec); | ||||
| } | } | ||||
| mul_m3_v3(td->smtx, tvec); | mul_m3_v3(td->space[tdi].smtx, tvec); | ||||
| if (use_rotate_offset) { | if (use_rotate_offset) { | ||||
| add_v3_v3(tvec, rotate_offset); | add_v3_v3(tvec, rotate_offset); | ||||
| } | } | ||||
| 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(tvec, td->factor * gps->runtime.multi_frame_falloff); | mul_v3_fl(tvec, td->prop[tdi].factor * gps->runtime.multi_frame_falloff); | ||||
| } | } | ||||
| else { | else { | ||||
| mul_v3_fl(tvec, td->factor); | mul_v3_fl(tvec, td->prop[tdi].factor); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* proportional editing falloff */ | /* proportional editing falloff */ | ||||
| mul_v3_fl(tvec, td->factor); | mul_v3_fl(tvec, td->prop[tdi].factor); | ||||
| } | } | ||||
| protectedTransBits(td->protectflag, tvec); | protectedTransBits(td->object[tdi].protectflag, tvec); | ||||
| if (td->loc) { | if (td->basic[tdi].loc) { | ||||
| add_v3_v3v3(td->loc, td->iloc, tvec); | add_v3_v3v3(td->basic[tdi].loc, td->basic[tdi].iloc, tvec); | ||||
| } | } | ||||
| constraintTransLim(t, td); | constraintTransLim(t, td, tdi); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void applyTranslation(TransInfo *t, const int UNUSED(mval[2])) | static void applyTranslation(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| float global_dir[3]; | float global_dir[3]; | ||||
| Show All 12 Lines | else { | ||||
| } | } | ||||
| applySnapping(t, global_dir); | applySnapping(t, global_dir); | ||||
| } | } | ||||
| if (t->con.mode & CON_APPLY) { | if (t->con.mode & CON_APPLY) { | ||||
| float in[3]; | float in[3]; | ||||
| copy_v3_v3(in, global_dir); | copy_v3_v3(in, global_dir); | ||||
| t->con.applyVec(t, NULL, NULL, in, global_dir); | t->con.applyVec(t, NULL, 0, in, global_dir); | ||||
| headerTranslation(t, global_dir, str); | headerTranslation(t, global_dir, str); | ||||
| } | } | ||||
| else { | else { | ||||
| headerTranslation(t, global_dir, str); | headerTranslation(t, global_dir, str); | ||||
| } | } | ||||
| applyTranslationValue(t, global_dir); | applyTranslationValue(t, global_dir); | ||||
| ▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines | |||||