Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-02-24 09:56:01 +0300
committerCampbell Barton <campbell@blender.org>2022-02-24 10:00:17 +0300
commit13efaa8a09ab805c81164bc04a7ac4cc2c40bd1c (patch)
tree7f2782263203261d7c66d842ac6418a6666c99db /source/blender/editors/space_view3d
parent87c2b1988d7c040a76f741a2e7eb6bda5dcea973 (diff)
3D View: keep the orthographic view when rolling 90 degrees
Support for maintaining orthographic view for view3d.view_roll for an angle of 90/-90 degrees.
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r--source/blender/editors/space_view3d/view3d_navigate_roll.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/source/blender/editors/space_view3d/view3d_navigate_roll.c b/source/blender/editors/space_view3d/view3d_navigate_roll.c
index 56bd9c93216..8d01f6b591b 100644
--- a/source/blender/editors/space_view3d/view3d_navigate_roll.c
+++ b/source/blender/editors/space_view3d/view3d_navigate_roll.c
@@ -24,8 +24,12 @@
/** \name View Roll Operator
* \{ */
-static void view_roll_angle(
- ARegion *region, float quat[4], const float orig_quat[4], const float dvec[3], float angle)
+static void view_roll_angle(ARegion *region,
+ float quat[4],
+ const float orig_quat[4],
+ const float dvec[3],
+ float angle,
+ bool use_axis_view)
{
RegionView3D *rv3d = region->regiondata;
float quat_mul[4];
@@ -38,7 +42,16 @@ static void view_roll_angle(
/* avoid precision loss over time */
normalize_qt(quat);
- rv3d->view = RV3D_VIEW_USER;
+ if (use_axis_view && RV3D_VIEW_IS_AXIS(rv3d->view) && (fabsf(angle) == (float)M_PI_2)) {
+ if (ED_view3d_quat_to_axis_view(quat, 0.01f, &rv3d->view, &rv3d->view_axis_roll)) {
+ if (rv3d->view != RV3D_VIEW_USER) {
+ ED_view3d_quat_from_axis_view(rv3d->view, rv3d->view_axis_roll, quat_mul);
+ }
+ }
+ }
+ else {
+ rv3d->view = RV3D_VIEW_USER;
+ }
}
static void viewroll_apply(ViewOpsData *vod, int x, int y)
@@ -46,7 +59,8 @@ static void viewroll_apply(ViewOpsData *vod, int x, int y)
float angle = BLI_dial_angle(vod->init.dial, (const float[2]){x, y});
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, false);
}
if (vod->use_dyn_ofs) {
@@ -169,7 +183,7 @@ static int viewroll_exec(bContext *C, wmOperator *op)
normalize_v3_v3(mousevec, rv3d->viewinv[2]);
negate_v3(mousevec);
- view_roll_angle(region, quat_new, rv3d->viewquat, mousevec, angle);
+ view_roll_angle(region, quat_new, rv3d->viewquat, mousevec, angle, true);
const float *dyn_ofs_pt = NULL;
float dyn_ofs[3];