Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_generics.c
| Show First 20 Lines • Show All 684 Lines • ▼ Show 20 Lines | |||||
| #endif | #endif | ||||
| /* Disable cursor wrap when edge panning is enabled. */ | /* Disable cursor wrap when edge panning is enabled. */ | ||||
| if (t->options & CTX_VIEW2D_EDGE_PAN) { | if (t->options & CTX_VIEW2D_EDGE_PAN) { | ||||
| t->flag |= T_NO_CURSOR_WRAP; | t->flag |= T_NO_CURSOR_WRAP; | ||||
| } | } | ||||
| setTransformViewMatrices(t); | setTransformViewMatrices(t); | ||||
| calculateCenter2D(t); | |||||
| calculateCenterLocal(t, t->center_global); | |||||
| initNumInput(&t->num); | initNumInput(&t->num); | ||||
| } | } | ||||
| static void freeTransCustomData(TransInfo *t, TransDataContainer *tc, TransCustomData *custom_data) | static void freeTransCustomData(TransInfo *t, TransDataContainer *tc, TransCustomData *custom_data) | ||||
| { | { | ||||
| if (custom_data->free_cb) { | if (custom_data->free_cb) { | ||||
| /* Can take over freeing t->data and data_2d etc... */ | /* Can take over freeing t->data and data_2d etc... */ | ||||
| custom_data->free_cb(t, tc, custom_data); | custom_data->free_cb(t, tc, custom_data); | ||||
| ▲ Show 20 Lines • Show All 445 Lines • ▼ Show 20 Lines | case V3D_AROUND_ACTIVE: { | ||||
| /* fallback */ | /* fallback */ | ||||
| calculateCenterMedian(t, r_center); | calculateCenterMedian(t, r_center); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void calculateZfac(TransInfo *t) | |||||
| { | |||||
| /* ED_view3d_calc_zfac() defines a factor for perspective depth correction, | |||||
| * used in ED_view3d_win_to_delta() */ | |||||
| /* zfac is only used convertViewVec only in cases operator was invoked in RGN_TYPE_WINDOW | |||||
| * and never used in other cases. | |||||
| * | |||||
| * We need special case here as well, since ED_view3d_calc_zfac will crash when called | |||||
| * for a region different from RGN_TYPE_WINDOW. | |||||
| */ | |||||
| if (t->spacetype == SPACE_VIEW3D) { | |||||
| t->zfac = ED_view3d_calc_zfac(t->region->regiondata, t->center_global, NULL); | |||||
| } | |||||
| else if (t->spacetype == SPACE_IMAGE) { | |||||
| SpaceImage *sima = t->area->spacedata.first; | |||||
| t->zfac = 1.0f / sima->zoom; | |||||
| } | |||||
| else { | |||||
| View2D *v2d = &t->region->v2d; | |||||
| /* Get zoom fac the same way as in | |||||
| * `ui_view2d_curRect_validate_resize` - better keep in sync! */ | |||||
| const float zoomx = (float)(BLI_rcti_size_x(&v2d->mask) + 1) / BLI_rctf_size_x(&v2d->cur); | |||||
| t->zfac = 1.0f / zoomx; | |||||
| } | |||||
| } | |||||
| void calculateCenter(TransInfo *t) | void calculateCenter(TransInfo *t) | ||||
| { | { | ||||
| if ((t->flag & T_OVERRIDE_CENTER) == 0) { | if ((t->flag & T_OVERRIDE_CENTER) == 0) { | ||||
| calculateCenter_FromAround(t, t->around, t->center_global); | calculateCenter_FromAround(t, t->around, t->center_global); | ||||
| } | } | ||||
| calculateCenterLocal(t, t->center_global); | calculateCenterLocal(t, t->center_global); | ||||
| calculateCenter2D(t); | calculateCenter2D(t); | ||||
| Show All 18 Lines | if (t->spacetype == SPACE_VIEW3D && t->region && t->region->regiontype == RGN_TYPE_WINDOW) { | ||||
| /* rotate only needs correct 2d center, grab needs ED_view3d_calc_zfac() value */ | /* rotate only needs correct 2d center, grab needs ED_view3d_calc_zfac() value */ | ||||
| if (t->mode == TFM_TRANSLATION) { | if (t->mode == TFM_TRANSLATION) { | ||||
| copy_v3_v3(t->center_global, axis); | copy_v3_v3(t->center_global, axis); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| calculateZfac(t); | |||||
| } | |||||
| /* Called every time the view changes due to navigation. | |||||
| * Adjusts the mouse position relative to the object. */ | |||||
| void tranformViewUpdate(TransInfo *t) | |||||
| { | |||||
| if (t->spacetype == SPACE_VIEW3D) { | if (t->spacetype == SPACE_VIEW3D) { | ||||
| /* ED_view3d_calc_zfac() defines a factor for perspective depth correction, | setTransformViewMatrices(t); | ||||
| * used in ED_view3d_win_to_delta() */ | |||||
| /* zfac is only used convertViewVec only in cases operator was invoked in RGN_TYPE_WINDOW | for (int i = 0; i < ARRAY_SIZE(t->orient); i++) { | ||||
| * and never used in other cases. | if (t->orient[i].type == V3D_ORIENT_VIEW) { | ||||
| * | copy_m3_m4(t->orient[i].matrix, t->viewinv); | ||||
| * We need special case here as well, since ED_view3d_calc_zfac will crash when called | normalize_m3(t->orient[i].matrix); | ||||
| * for a region different from RGN_TYPE_WINDOW. | if (t->orient_curr == i) { | ||||
| */ | copy_m3_m3(t->spacemtx, t->orient[i].matrix); | ||||
| if (t->region->regiontype == RGN_TYPE_WINDOW) { | invert_m3_m3_safe_ortho(t->spacemtx_inv, t->spacemtx); | ||||
| t->zfac = ED_view3d_calc_zfac(t->region->regiondata, t->center_global, NULL); | |||||
| } | } | ||||
| else { | |||||
| t->zfac = 0.0f; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| float fac = 1.0f; | |||||
| if (ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE)) { | |||||
| float zfac_prev = t->zfac; | |||||
| calculateZfac(t); | |||||
| fac = zfac_prev / t->zfac; | |||||
| } | |||||
| calculateCenter2D(t); | |||||
| transform_input_update(t, fac); | |||||
| t->flag &= ~T_VIEW_DIRTY; | |||||
| } | |||||
| void calculatePropRatio(TransInfo *t) | void calculatePropRatio(TransInfo *t) | ||||
| { | { | ||||
| int i; | int i; | ||||
| float dist; | float dist; | ||||
| const bool connected = (t->flag & T_PROP_CONNECTED) != 0; | const bool connected = (t->flag & T_PROP_CONNECTED) != 0; | ||||
| t->proptext[0] = '\0'; | t->proptext[0] = '\0'; | ||||
| ▲ Show 20 Lines • Show All 236 Lines • Show Last 20 Lines | |||||