Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_edit.c
| Show First 20 Lines • Show All 667 Lines • ▼ Show 20 Lines | static void viewrotate_apply_snap(ViewOpsData *vod) | ||||
| RegionView3D *rv3d = vod->rv3d; | RegionView3D *rv3d = vod->rv3d; | ||||
| float viewquat_inv[4]; | float viewquat_inv[4]; | ||||
| float zaxis[3] = {0, 0, 1}; | float zaxis[3] = {0, 0, 1}; | ||||
| float zaxis_best[3]; | float zaxis_best[3]; | ||||
| int x, y, z; | int x, y, z; | ||||
| bool found = false; | bool found = false; | ||||
| bool is_axis_aligned = false; | |||||
| invert_qt_qt_normalized(viewquat_inv, vod->curr.viewquat); | invert_qt_qt_normalized(viewquat_inv, vod->curr.viewquat); | ||||
| mul_qt_v3(viewquat_inv, zaxis); | mul_qt_v3(viewquat_inv, zaxis); | ||||
| normalize_v3(zaxis); | normalize_v3(zaxis); | ||||
| for (x = -1; x < 2; x++) { | for (x = -1; x < 2; x++) { | ||||
| for (y = -1; y < 2; y++) { | for (y = -1; y < 2; y++) { | ||||
| for (z = -1; z < 2; z++) { | for (z = -1; z < 2; z++) { | ||||
| if (x || y || z) { | if (x || y || z) { | ||||
| float zaxis_test[3] = {x, y, z}; | float zaxis_test[3] = {x, y, z}; | ||||
| normalize_v3(zaxis_test); | normalize_v3(zaxis_test); | ||||
| if (angle_normalized_v3v3(zaxis_test, zaxis) < axis_limit) { | if (angle_normalized_v3v3(zaxis_test, zaxis) < axis_limit) { | ||||
| copy_v3_v3(zaxis_best, zaxis_test); | copy_v3_v3(zaxis_best, zaxis_test); | ||||
| found = true; | found = true; | ||||
| if (abs(x) + abs(y) + abs(z) == 1) { | |||||
| is_axis_aligned = true; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (found) { | if (found) { | ||||
| ▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | else { | ||||
| copy_qt_qt(quat_best, viewquat_align); | copy_qt_qt(quat_best, viewquat_align); | ||||
| } | } | ||||
| copy_qt_qt(rv3d->viewquat, quat_best); | copy_qt_qt(rv3d->viewquat, quat_best); | ||||
| viewrotate_apply_dyn_ofs(vod, rv3d->viewquat); | viewrotate_apply_dyn_ofs(vod, rv3d->viewquat); | ||||
| if (U.uiflag & USER_AUTOPERSP) { | if (U.uiflag & USER_AUTOPERSP) { | ||||
| if (is_axis_aligned) { | if (RV3D_VIEW_IS_AXIS(rv3d->view)) { | ||||
| if (rv3d->persp == RV3D_PERSP) { | if (rv3d->persp == RV3D_PERSP) { | ||||
| rv3d->persp = RV3D_ORTHO; | rv3d->persp = RV3D_ORTHO; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else if (U.uiflag & USER_AUTOPERSP) { | else if (U.uiflag & USER_AUTOPERSP) { | ||||
| rv3d->persp = vod->init.persp; | rv3d->persp = vod->init.persp; | ||||
| ▲ Show 20 Lines • Show All 4,653 Lines • Show Last 20 Lines | |||||