Fix View Roll failure to align the quaternion to the view-axis
View roll checked if the resulting roll was close to a view axis but didn't write the aligned quaternion back to the final result. Add ED_view3d_quat_to_axis_view_and_reset_quat since most callers to ED_view3d_quat_to_axis_view will reset the quaternion when a view aligned axis is found.
This commit is contained in:
parent
214e61fc2c
commit
76b6741981
|
@ -1064,6 +1064,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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue