3D View: check view quaternion alignment which orbiting
This makes auto-perspective work as expected when orbiting out of a snapped view.
This commit is contained in:
@@ -624,6 +624,8 @@ void ED_view3d_update_viewmat(struct Depsgraph *depsgraph,
|
|||||||
bool offscreen);
|
bool offscreen);
|
||||||
bool ED_view3d_quat_from_axis_view(const char view, float quat[4]);
|
bool ED_view3d_quat_from_axis_view(const char view, float quat[4]);
|
||||||
char ED_view3d_quat_to_axis_view(const float quat[4], const float epsilon);
|
char ED_view3d_quat_to_axis_view(const float quat[4], const float epsilon);
|
||||||
|
bool ED_view3d_quat_is_axis_aligned(const float viewquat[4]);
|
||||||
|
|
||||||
char ED_view3d_lock_view_from_index(int index);
|
char ED_view3d_lock_view_from_index(int index);
|
||||||
char ED_view3d_axis_view_opposite(char view);
|
char ED_view3d_axis_view_opposite(char view);
|
||||||
bool ED_view3d_lock(struct RegionView3D *rv3d);
|
bool ED_view3d_lock(struct RegionView3D *rv3d);
|
||||||
|
|||||||
@@ -470,7 +470,7 @@ bool ED_view3d_persp_ensure(const Depsgraph *depsgraph, View3D *v3d, ARegion *ar
|
|||||||
char persp = (autopersp && RV3D_VIEW_IS_AXIS(rv3d->lview)) ? RV3D_PERSP : rv3d->lpersp;
|
char persp = (autopersp && RV3D_VIEW_IS_AXIS(rv3d->lview)) ? RV3D_PERSP : rv3d->lpersp;
|
||||||
ED_view3d_persp_switch_from_camera(depsgraph, v3d, rv3d, persp);
|
ED_view3d_persp_switch_from_camera(depsgraph, v3d, rv3d, persp);
|
||||||
}
|
}
|
||||||
else if (autopersp && RV3D_VIEW_IS_AXIS(rv3d->view)) {
|
else if (autopersp && ED_view3d_quat_is_axis_aligned(rv3d->viewquat)) {
|
||||||
rv3d->persp = RV3D_PERSP;
|
rv3d->persp = RV3D_PERSP;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -1339,6 +1339,22 @@ char ED_view3d_quat_to_axis_view(const float quat[4], const float epsilon)
|
|||||||
return RV3D_VIEW_USER;
|
return RV3D_VIEW_USER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if input view quaternion is aligned view axis in direction & angle.
|
||||||
|
*/
|
||||||
|
bool ED_view3d_quat_is_axis_aligned(const float viewquat[4])
|
||||||
|
{
|
||||||
|
float mat[3][3];
|
||||||
|
quat_to_mat3(mat, viewquat);
|
||||||
|
for (int row = 0; row < 3; row++) {
|
||||||
|
int axis = axis_dominant_v3_single(mat[row]);
|
||||||
|
if (fabsf(fabsf(mat[row][axis]) - 1.0f) > 1e-4f) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
char ED_view3d_lock_view_from_index(int index)
|
char ED_view3d_lock_view_from_index(int index)
|
||||||
{
|
{
|
||||||
switch (index) {
|
switch (index) {
|
||||||
|
|||||||
Reference in New Issue
Block a user