Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_edit.c
| Show All 32 Lines | |||||
| #include "DNA_curve_types.h" | #include "DNA_curve_types.h" | ||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_dial_2d.h" | |||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BKE_action.h" | #include "BKE_action.h" | ||||
| #include "BKE_armature.h" | #include "BKE_armature.h" | ||||
| #include "BKE_camera.h" | #include "BKE_camera.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_font.h" | #include "BKE_font.h" | ||||
| ▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | struct { | ||||
| /** Dolly only. */ | /** Dolly only. */ | ||||
| float mousevec[3]; | float mousevec[3]; | ||||
| /** | /** | ||||
| * #RegionView3D.persp set after auto-perspective is applied. | * #RegionView3D.persp set after auto-perspective is applied. | ||||
| * If we want the value before running the operator, add a separate member. | * If we want the value before running the operator, add a separate member. | ||||
| */ | */ | ||||
| char persp; | char persp; | ||||
| /** Used for roll */ | |||||
| Dial *dial; | |||||
| } init; | } init; | ||||
| /** Previous state (previous modal event handled). */ | /** Previous state (previous modal event handled). */ | ||||
| struct { | struct { | ||||
| int event_xy[2]; | int event_xy[2]; | ||||
| /** For operators that use time-steps (continuous zoom). */ | /** For operators that use time-steps (continuous zoom). */ | ||||
| double time; | double time; | ||||
| } prev; | } prev; | ||||
| ▲ Show 20 Lines • Show All 4,126 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 len1, len2, tot; | float angle = BLI_dial_angle(vod->init.dial, (const float[2]){x, y}); | ||||
| tot = vod->region->winrct.xmax - vod->region->winrct.xmin; | |||||
| len1 = (vod->region->winrct.xmax - x) / tot; | |||||
| len2 = (vod->region->winrct.xmax - vod->init.event_xy[0]) / tot; | |||||
| angle = (len1 - len2) * (float)M_PI * 4.0f; | |||||
| } | |||||
| 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( | ||||
| vod->rv3d->ofs, vod->init.ofs, vod->init.quat, vod->rv3d->viewquat, vod->dyn_ofs); | vod->rv3d->ofs, vod->init.ofs, vod->init.quat, vod->rv3d->viewquat, vod->dyn_ofs); | ||||
| Show All 29 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 92 Lines • ▼ Show 20 Lines | static int viewroll_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| if (use_angle || RNA_struct_property_is_set(op->ptr, "angle")) { | if (use_angle || RNA_struct_property_is_set(op->ptr, "angle")) { | ||||
| viewroll_exec(C, op); | viewroll_exec(C, op); | ||||
| } | } | ||||
| else { | else { | ||||
| /* makes op->customdata */ | /* makes op->customdata */ | ||||
| viewops_data_alloc(C, op); | viewops_data_alloc(C, op); | ||||
| viewops_data_create(C, op, event, viewops_flag_from_prefs()); | viewops_data_create(C, op, event, viewops_flag_from_prefs()); | ||||
| vod = op->customdata; | vod = op->customdata; | ||||
| vod->init.dial = BLI_dial_init( | |||||
| (const float[2]){(vod->region->winrct.xmax - vod->region->winrct.xmin) / 2, | |||||
| (vod->region->winrct.ymax - vod->region->winrct.ymin) / 2}, | |||||
| FLT_EPSILON); | |||||
| ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->region); | ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->region); | ||||
| /* overwrite the mouse vector with the view direction */ | /* overwrite the mouse vector with the view direction */ | ||||
| normalize_v3_v3(vod->init.mousevec, vod->rv3d->viewinv[2]); | normalize_v3_v3(vod->init.mousevec, vod->rv3d->viewinv[2]); | ||||
| negate_v3(vod->init.mousevec); | negate_v3(vod->init.mousevec); | ||||
| if (event->type == MOUSEROTATE) { | if (event->type == MOUSEROTATE) { | ||||
| ▲ Show 20 Lines • Show All 841 Lines • Show Last 20 Lines | |||||
This can be committed separately.