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-05-19 07:32:54 +0300
committerCampbell Barton <campbell@blender.org>2022-05-19 07:32:54 +0300
commita111aae415d0cc3415bb9bc0c56fa9e53e9d00d8 (patch)
treea24f9ff1be9e09463ef64c04184b6f6adb988e87
parentae11233b65778c653c2214a605e60f9d3302e318 (diff)
parent76b674198123eb0c5d77270ae037ad9c6c32c321 (diff)
Merge branch 'blender-v3.2-release'
-rw-r--r--source/blender/editors/include/ED_view3d.h10
-rw-r--r--source/blender/editors/space_view3d/view3d_navigate_roll.c6
-rw-r--r--source/blender/editors/space_view3d/view3d_navigate_rotate.c6
-rw-r--r--source/blender/editors/space_view3d/view3d_utils.c14
4 files changed, 27 insertions, 9 deletions
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 744f74bf25f..8695e03a57f 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -1083,6 +1083,16 @@ bool ED_view3d_quat_to_axis_view(const float viewquat[4],
float epsilon,
char *r_view,
char *r_view_axis_rotation);
+/**
+ * A version of #ED_view3d_quat_to_axis_view that updates `viewquat`
+ * if it's within `epsilon` to an axis-view.
+ *
+ * \note Include the special case function since most callers need to perform these operations.
+ */
+bool ED_view3d_quat_to_axis_view_and_reset_quat(float viewquat[4],
+ float epsilon,
+ char *r_view,
+ char *r_view_axis_rotation);
char ED_view3d_lock_view_from_index(int index);
char ED_view3d_axis_view_opposite(char view);
diff --git a/source/blender/editors/space_view3d/view3d_navigate_roll.c b/source/blender/editors/space_view3d/view3d_navigate_roll.c
index ea21eed6445..087ca72211e 100644
--- a/source/blender/editors/space_view3d/view3d_navigate_roll.c
+++ b/source/blender/editors/space_view3d/view3d_navigate_roll.c
@@ -48,11 +48,7 @@ static void view_roll_angle(ARegion *region,
normalize_qt(quat);
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);
- }
- }
+ ED_view3d_quat_to_axis_view_and_reset_quat(quat, 0.01f, &rv3d->view, &rv3d->view_axis_roll);
}
else {
rv3d->view = RV3D_VIEW_USER;
diff --git a/source/blender/editors/space_view3d/view3d_navigate_rotate.c b/source/blender/editors/space_view3d/view3d_navigate_rotate.c
index c9ef6422982..989fa152acc 100644
--- a/source/blender/editors/space_view3d/view3d_navigate_rotate.c
+++ b/source/blender/editors/space_view3d/view3d_navigate_rotate.c
@@ -162,10 +162,8 @@ static void viewrotate_apply_snap(ViewOpsData *vod)
if (found) {
/* lock 'quat_best' to an axis view if we can */
- ED_view3d_quat_to_axis_view(quat_best, 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_best);
- }
+ ED_view3d_quat_to_axis_view_and_reset_quat(
+ quat_best, 0.01f, &rv3d->view, &rv3d->view_axis_roll);
}
else {
copy_qt_qt(quat_best, viewquat_align);
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c
index 0306bfe70bd..e75567f3201 100644
--- a/source/blender/editors/space_view3d/view3d_utils.c
+++ b/source/blender/editors/space_view3d/view3d_utils.c
@@ -1333,6 +1333,20 @@ bool ED_view3d_quat_to_axis_view(const float quat[4],
return false;
}
+bool ED_view3d_quat_to_axis_view_and_reset_quat(float quat[4],
+ const float epsilon,
+ char *r_view,
+ char *r_view_axis_roll)
+{
+ const bool is_axis_view = ED_view3d_quat_to_axis_view(quat, epsilon, r_view, r_view_axis_roll);
+ if (is_axis_view) {
+ /* Reset `quat` to it's view axis, so axis-aligned views are always *exactly* aligned. */
+ BLI_assert(*r_view != RV3D_VIEW_USER);
+ ED_view3d_quat_from_axis_view(*r_view, *r_view_axis_roll, quat);
+ }
+ return is_axis_view;
+}
+
char ED_view3d_lock_view_from_index(int index)
{
switch (index) {