Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform.c
| Show All 38 Lines | |||||
| #include "DNA_anim_types.h" | #include "DNA_anim_types.h" | ||||
| #include "DNA_armature_types.h" | #include "DNA_armature_types.h" | ||||
| #include "DNA_constraint_types.h" | #include "DNA_constraint_types.h" | ||||
| #include "DNA_mask_types.h" | #include "DNA_mask_types.h" | ||||
| #include "DNA_movieclip_types.h" | #include "DNA_movieclip_types.h" | ||||
| #include "DNA_scene_types.h" /* PET modes */ | #include "DNA_scene_types.h" /* PET modes */ | ||||
| #include "DNA_workspace_types.h" | #include "DNA_workspace_types.h" | ||||
| #include "DNA_gpencil_types.h" | |||||
| #include "BLI_alloca.h" | #include "BLI_alloca.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_rect.h" | #include "BLI_rect.h" | ||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| #include "BLI_ghash.h" | #include "BLI_ghash.h" | ||||
| Show All 24 Lines | |||||
| #include "ED_keyframing.h" | #include "ED_keyframing.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "ED_space_api.h" | #include "ED_space_api.h" | ||||
| #include "ED_markers.h" | #include "ED_markers.h" | ||||
| #include "ED_view3d.h" | #include "ED_view3d.h" | ||||
| #include "ED_mesh.h" | #include "ED_mesh.h" | ||||
| #include "ED_clip.h" | #include "ED_clip.h" | ||||
| #include "ED_node.h" | #include "ED_node.h" | ||||
| #include "ED_gpencil.h" | |||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "UI_view2d.h" | #include "UI_view2d.h" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_interface_icons.h" | #include "UI_interface_icons.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "BLF_api.h" | #include "BLF_api.h" | ||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "transform.h" | #include "transform.h" | ||||
| #include "DEG_depsgraph.h" | |||||
| /* Disabling, since when you type you know what you are doing, and being able to set it to zero is handy. */ | /* Disabling, since when you type you know what you are doing, and being able to set it to zero is handy. */ | ||||
| // #define USE_NUM_NO_ZERO | // #define USE_NUM_NO_ZERO | ||||
| static void drawTransformApply(const struct bContext *C, ARegion *ar, void *arg); | static void drawTransformApply(const struct bContext *C, ARegion *ar, void *arg); | ||||
| static void doEdgeSlide(TransInfo *t, float perc); | static void doEdgeSlide(TransInfo *t, float perc); | ||||
| static void doVertSlide(TransInfo *t, float perc); | static void doVertSlide(TransInfo *t, float perc); | ||||
| static void drawEdgeSlide(TransInfo *t); | static void drawEdgeSlide(TransInfo *t); | ||||
| ▲ Show 20 Lines • Show All 454 Lines • ▼ Show 20 Lines | if (t->options & (CTX_MOVIECLIP | CTX_MASK)) { | ||||
| vec[1] *= t->aspect[1]; | vec[1] *= t->aspect[1]; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void viewRedrawForce(const bContext *C, TransInfo *t) | static void viewRedrawForce(const bContext *C, TransInfo *t) | ||||
| { | { | ||||
| if (t->options & CTX_GPENCIL_STROKES) { | if (t->options & CTX_GPENCIL_STROKES) { | ||||
| bGPdata *gpd = ED_gpencil_data_get_active(C); | |||||
| if (gpd) { | |||||
| DEG_id_tag_update(&gpd->id, OB_RECALC_DATA); | |||||
| } | |||||
| WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); | ||||
| } | } | ||||
| else if (t->spacetype == SPACE_VIEW3D) { | else if (t->spacetype == SPACE_VIEW3D) { | ||||
| if (t->options & CTX_PAINT_CURVE) { | if (t->options & CTX_PAINT_CURVE) { | ||||
| wmWindow *window = CTX_wm_window(C); | wmWindow *window = CTX_wm_window(C); | ||||
| WM_paint_cursor_tag_redraw(window, t->ar); | WM_paint_cursor_tag_redraw(window, t->ar); | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 1,143 Lines • ▼ Show 20 Lines | float mval[3] = { | ||||
| y, | y, | ||||
| 0.0f, | 0.0f, | ||||
| }; | }; | ||||
| float tmval[2] = { | float tmval[2] = { | ||||
| (float)t->mval[0], | (float)t->mval[0], | ||||
| (float)t->mval[1], | (float)t->mval[1], | ||||
| }; | }; | ||||
| #if 0 /* XXX: Fix from 1c9690e7607bc990cc4a3e6ba839949bb83a78af cannot be used anymore */ | |||||
| if ((t->flag & T_POINTS) && (t->options & CTX_GPENCIL_STROKES)) { | |||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | |||||
| Object *ob = tc->obedit; | |||||
| float vecrot[3]; | |||||
| copy_v3_v3(vecrot, t->center); | |||||
| mul_m4_v3(ob->obmat, vecrot); | |||||
| projectFloatViewEx(t, vecrot, cent, V3D_PROJ_TEST_CLIP_ZERO); | |||||
| } | |||||
| } | |||||
| else { | |||||
| projectFloatViewEx(t, t->center_global, cent, V3D_PROJ_TEST_CLIP_ZERO); | projectFloatViewEx(t, t->center_global, cent, V3D_PROJ_TEST_CLIP_ZERO); | ||||
| } | |||||
| #else | |||||
| projectFloatViewEx(t, t->center_global, cent, V3D_PROJ_TEST_CLIP_ZERO); | |||||
| #endif | |||||
| /* Offset the values for the area region. */ | /* Offset the values for the area region. */ | ||||
| const float offset[2] = { | const float offset[2] = { | ||||
| t->ar->winrct.xmin, | t->ar->winrct.xmin, | ||||
| t->ar->winrct.ymin, | t->ar->winrct.ymin, | ||||
| }; | }; | ||||
| for (int i = 0; i < 2; i++) { | for (int i = 0; i < 2; i++) { | ||||
| ▲ Show 20 Lines • Show All 1,736 Lines • ▼ Show 20 Lines | static void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, float mat[3][3]) | ||||
| mul_m3_v3(tmat, vec); | mul_m3_v3(tmat, vec); | ||||
| add_v3_v3(vec, center); | add_v3_v3(vec, center); | ||||
| if (t->flag & T_POINTS) | if (t->flag & T_POINTS) | ||||
| sub_v3_v3(vec, td->iloc); | sub_v3_v3(vec, td->iloc); | ||||
| else | else | ||||
| sub_v3_v3(vec, td->center); | sub_v3_v3(vec, td->center); | ||||
| /* grease pencil falloff */ | |||||
| if (t->options & CTX_GPENCIL_STROKES) { | |||||
| bGPDstroke *gps = (bGPDstroke *)td->extra; | |||||
| mul_v3_fl(vec, td->factor * gps->runtime.multi_frame_falloff); | |||||
| /* scale stroke thickness */ | |||||
| if (td->val) { | |||||
| snapGridIncrement(t, t->values); | |||||
| applyNumInput(&t->num, t->values); | |||||
| float ratio = t->values[0]; | |||||
| *td->val = td->ival * ratio * gps->runtime.multi_frame_falloff; | |||||
| CLAMP_MIN(*td->val, 0.001f); | |||||
| } | |||||
| } | |||||
| else { | |||||
| mul_v3_fl(vec, td->factor); | mul_v3_fl(vec, td->factor); | ||||
| } | |||||
| if (t->flag & (T_OBJECT | T_POSE)) { | if (t->flag & (T_OBJECT | T_POSE)) { | ||||
| mul_m3_v3(td->smtx, vec); | mul_m3_v3(td->smtx, vec); | ||||
| } | } | ||||
| protectedTransBits(td->protectflag, vec); | protectedTransBits(td->protectflag, vec); | ||||
| if (td->loc) { | if (td->loc) { | ||||
| add_v3_v3v3(td->loc, td->iloc, vec); | add_v3_v3v3(td->loc, td->iloc, vec); | ||||
| ▲ Show 20 Lines • Show All 337 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| float vec[3], totmat[3][3], smat[3][3]; | float vec[3], totmat[3][3], smat[3][3]; | ||||
| float eul[3], fmat[3][3], quat[4]; | float eul[3], fmat[3][3], quat[4]; | ||||
| if (t->flag & T_POINTS) { | if (t->flag & T_POINTS) { | ||||
| mul_m3_m3m3(totmat, mat, td->mtx); | mul_m3_m3m3(totmat, mat, td->mtx); | ||||
| mul_m3_m3m3(smat, td->smtx, totmat); | mul_m3_m3m3(smat, td->smtx, totmat); | ||||
| /* apply gpencil falloff */ | |||||
| if (t->options & CTX_GPENCIL_STROKES) { | |||||
| bGPDstroke *gps = (bGPDstroke *)td->extra; | |||||
| float sx = smat[0][0]; | |||||
| float sy = smat[1][1]; | |||||
| float sz = smat[2][2]; | |||||
| mul_m3_fl(smat, gps->runtime.multi_frame_falloff); | |||||
| /* fix scale */ | |||||
| smat[0][0] = sx; | |||||
| smat[1][1] = sy; | |||||
| smat[2][2] = sz; | |||||
| } | |||||
| sub_v3_v3v3(vec, td->iloc, center); | sub_v3_v3v3(vec, td->iloc, center); | ||||
| mul_m3_v3(smat, vec); | mul_m3_v3(smat, vec); | ||||
| add_v3_v3v3(td->loc, vec, center); | add_v3_v3v3(td->loc, vec, center); | ||||
| sub_v3_v3v3(vec, td->loc, td->iloc); | sub_v3_v3v3(vec, td->loc, td->iloc); | ||||
| protectedTransBits(td->protectflag, vec); | protectedTransBits(td->protectflag, vec); | ||||
| add_v3_v3v3(td->loc, td->iloc, vec); | add_v3_v3v3(td->loc, td->iloc, vec); | ||||
| ▲ Show 20 Lines • Show All 657 Lines • ▼ Show 20 Lines | for (int i = 0; i < tc->data_len; i++, td++) { | ||||
| copy_v3_v3(tvec, vec); | copy_v3_v3(tvec, vec); | ||||
| } | } | ||||
| if (use_rotate_offset) { | if (use_rotate_offset) { | ||||
| add_v3_v3(tvec, rotate_offset); | add_v3_v3(tvec, rotate_offset); | ||||
| } | } | ||||
| mul_m3_v3(td->smtx, tvec); | mul_m3_v3(td->smtx, tvec); | ||||
| if (t->options & CTX_GPENCIL_STROKES) { | |||||
| /* grease pencil multiframe falloff */ | |||||
| bGPDstroke *gps = (bGPDstroke *)td->extra; | |||||
| mul_v3_fl(tvec, td->factor * gps->runtime.multi_frame_falloff); | |||||
| } | |||||
| else { | |||||
| /* proportional editing falloff */ | |||||
| mul_v3_fl(tvec, td->factor); | mul_v3_fl(tvec, td->factor); | ||||
| } | |||||
| protectedTransBits(td->protectflag, tvec); | protectedTransBits(td->protectflag, tvec); | ||||
| if (td->loc) | if (td->loc) | ||||
| add_v3_v3v3(td->loc, td->iloc, tvec); | add_v3_v3v3(td->loc, td->iloc, tvec); | ||||
| constraintTransLim(t, td); | constraintTransLim(t, td); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 4,318 Lines • Show Last 20 Lines | |||||