Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_convert_node.c
| Show First 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Node Transform Creation | /** \name Node Transform Creation | ||||
| * \{ */ | * \{ */ | ||||
| void flushTransNodes(TransInfo *t) | void flushTransNodes(TransInfo *t) | ||||
| { | { | ||||
| const float dpi_fac = UI_DPI_FAC; | const float dpi_fac = UI_DPI_FAC; | ||||
| float offset[2] = {0.0f, 0.0f}; | |||||
| View2DEdgePanData *customdata = (View2DEdgePanData *)t->custom.type.data; | View2DEdgePanData *customdata = (View2DEdgePanData *)t->custom.type.data; | ||||
| if (t->options & CTX_VIEW2D_EDGE_PAN) { | if (t->options & CTX_VIEW2D_EDGE_PAN) { | ||||
| if (t->state == TRANS_CANCEL) { | if (t->state == TRANS_CANCEL) { | ||||
| UI_view2d_edge_pan_cancel(t->context, customdata); | UI_view2d_edge_pan_cancel(t->context, customdata); | ||||
| } | } | ||||
| else { | else { | ||||
| /* Edge panning functions expect window coordinates, mval is relative to region */ | /* Edge panning functions expect window coordinates, mval is relative to region */ | ||||
| const int xy[2] = { | const int xy[2] = { | ||||
| t->region->winrct.xmin + t->mval[0], | t->region->winrct.xmin + t->mval[0], | ||||
| t->region->winrct.ymin + t->mval[1], | t->region->winrct.ymin + t->mval[1], | ||||
| }; | }; | ||||
| const rctf rect = t->region->v2d.cur; | |||||
| UI_view2d_edge_pan_apply(t->context, customdata, xy); | UI_view2d_edge_pan_apply(t->context, customdata, xy); | ||||
| if (!BLI_rctf_compare(&rect, &t->region->v2d.cur, FLT_EPSILON)) { | |||||
| /* Additional offset due to change in view2D rect. */ | |||||
| BLI_rctf_transform_pt_v(&t->region->v2d.cur, &rect, offset, offset); | |||||
| t->flag |= T_VIEW_DIRTY; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| /* Initial and current view2D rects for additional transform due to view panning and zooming */ | |||||
| const rctf *rect_src = &customdata->initial_rect; | |||||
| const rctf *rect_dst = &t->region->v2d.cur; | |||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| applyGridAbsolute(t); | applyGridAbsolute(t); | ||||
| /* flush to 2d vector from internally used 3d vector */ | /* flush to 2d vector from internally used 3d vector */ | ||||
| for (int i = 0; i < tc->data_len; i++) { | for (int i = 0; i < tc->data_len; i++) { | ||||
| TransData *td = &tc->data[i]; | TransData *td = &tc->data[i]; | ||||
| TransData2D *td2d = &tc->data_2d[i]; | TransData2D *td2d = &tc->data_2d[i]; | ||||
| bNode *node = td->extra; | bNode *node = td->extra; | ||||
| float loc[2]; | float loc[2]; | ||||
| copy_v2_v2(loc, td2d->loc); | add_v2_v2v2(loc, td2d->loc, offset); | ||||
| /* additional offset due to change in view2D rect */ | |||||
| BLI_rctf_transform_pt_v(rect_dst, rect_src, loc, loc); | |||||
| #ifdef USE_NODE_CENTER | #ifdef USE_NODE_CENTER | ||||
| loc[0] -= 0.5f * BLI_rctf_size_x(&node->totr); | loc[0] -= 0.5f * BLI_rctf_size_x(&node->totr); | ||||
| loc[1] += 0.5f * BLI_rctf_size_y(&node->totr); | loc[1] += 0.5f * BLI_rctf_size_y(&node->totr); | ||||
| #endif | #endif | ||||
| /* weirdo - but the node system is a mix of free 2d elements and dpi sensitive UI */ | /* weirdo - but the node system is a mix of free 2d elements and dpi sensitive UI */ | ||||
| loc[0] /= dpi_fac; | loc[0] /= dpi_fac; | ||||
| ▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines | |||||