Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_edit.c
| Show First 20 Lines • Show All 4,346 Lines • ▼ Show 20 Lines | static void view_roll_angle( | ||||
| mul_qt_qtqt(quat, orig_quat, quat_mul); | mul_qt_qtqt(quat, orig_quat, quat_mul); | ||||
| /* avoid precision loss over time */ | /* avoid precision loss over time */ | ||||
| normalize_qt(quat); | normalize_qt(quat); | ||||
| rv3d->view = RV3D_VIEW_USER; | rv3d->view = RV3D_VIEW_USER; | ||||
| } | } | ||||
| static void viewroll_apply(ViewOpsData *vod, int x, int UNUSED(y)) | static void viewroll_apply(ViewOpsData *vod, int x, int y) | ||||
| { | { | ||||
| float angle = 0.0; | float angle = 0.0; | ||||
| { | { | ||||
| float len1, len2, tot; | float dir_prev[2], dir_curr[2], mi_center[2]; | ||||
| mi_center[0] = (vod->region->winrct.xmax - vod->region->winrct.xmin) / 2; | |||||
| mi_center[1] = (vod->region->winrct.ymax - vod->region->winrct.ymin) / 2; | |||||
| tot = vod->region->winrct.xmax - vod->region->winrct.xmin; | sub_v2_v2v2(dir_prev, (const float[2]){UNPACK2(vod->init.event_xy)}, mi_center); | ||||
| len1 = (vod->region->winrct.xmax - x) / tot; | sub_v2_v2v2(dir_curr, (const float[2]){x, y}, mi_center); | ||||
| len2 = (vod->region->winrct.xmax - vod->init.event_xy[0]) / tot; | |||||
| angle = (len1 - len2) * (float)M_PI * 4.0f; | if (normalize_v2(dir_prev) && normalize_v2(dir_curr)) { | ||||
| float dphi = angle_normalized_v2v2(dir_prev, dir_curr); | |||||
| if (cross_v2v2(dir_prev, dir_curr) > 0.0f) { | |||||
| dphi = -dphi; | |||||
| } | |||||
| angle = ((double)dphi); | |||||
| } | |||||
| } | } | ||||
| if (angle != 0.0f) { | if (angle != 0.0f) { | ||||
| view_roll_angle(vod->region, vod->rv3d->viewquat, vod->init.quat, vod->init.mousevec, angle); | view_roll_angle(vod->region, vod->rv3d->viewquat, vod->init.quat, vod->init.mousevec, angle); | ||||
| } | } | ||||
| if (vod->use_dyn_ofs) { | if (vod->use_dyn_ofs) { | ||||
| view3d_orbit_apply_dyn_ofs( | view3d_orbit_apply_dyn_ofs( | ||||
| Show All 30 Lines | switch (event->val) { | ||||
| event_code = VIEW_CONFIRM; | event_code = VIEW_CONFIRM; | ||||
| break; | break; | ||||
| case VIEWROT_MODAL_SWITCH_ROTATE: | case VIEWROT_MODAL_SWITCH_ROTATE: | ||||
| WM_operator_name_call(C, "VIEW3D_OT_rotate", WM_OP_INVOKE_DEFAULT, NULL); | WM_operator_name_call(C, "VIEW3D_OT_rotate", WM_OP_INVOKE_DEFAULT, NULL); | ||||
| event_code = VIEW_CONFIRM; | event_code = VIEW_CONFIRM; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| else if (ELEM(event->type, EVT_ESCKEY, RIGHTMOUSE)) { | |||||
| /* Note this does not remove autokeys on locked cameras. */ | |||||
| copy_qt_qt(vod->rv3d->viewquat, vod->init.quat); | |||||
| ED_view3d_camera_lock_sync(vod->depsgraph, vod->v3d, vod->rv3d); | |||||
| viewops_data_free(C, op); | |||||
| return OPERATOR_CANCELLED; | |||||
| } | |||||
campbellbarton: This can be committed separately. | |||||
| else if (event->type == vod->init.event_type && event->val == KM_RELEASE) { | else if (event->type == vod->init.event_type && event->val == KM_RELEASE) { | ||||
| event_code = VIEW_CONFIRM; | event_code = VIEW_CONFIRM; | ||||
| } | } | ||||
| if (event_code == VIEW_APPLY) { | if (event_code == VIEW_APPLY) { | ||||
| viewroll_apply(vod, event->x, event->y); | viewroll_apply(vod, event->x, event->y); | ||||
| if (ED_screen_animation_playing(CTX_wm_manager(C))) { | if (ED_screen_animation_playing(CTX_wm_manager(C))) { | ||||
| use_autokey = true; | use_autokey = true; | ||||
| ▲ Show 20 Lines • Show All 949 Lines • Show Last 20 Lines | |||||
This can be committed separately.