app: in 3D Transform tool, fix rotation direction when rotating arouns local Z axis

In GimpToolTransform3DGrid, fix the test for determining which side
of the plane is facing the viewer, affecting the direction of
rotation when rotating around the local Z axis.

(cherry picked from commit bcaaa453c4)
This commit is contained in:
Ell
2020-01-10 22:15:56 +02:00
parent 8143564627
commit c4d0c0bd6d

View File

@ -952,7 +952,8 @@ gimp_tool_transform_3d_grid_motion_rotate (GimpToolTransform3DGrid *grid,
} }
else else
{ {
GimpVector2 o, u, v; {
GimpVector3 o, n, c;
gimp_matrix4_identity (&matrix); gimp_matrix4_identity (&matrix);
@ -961,9 +962,34 @@ gimp_tool_transform_3d_grid_motion_rotate (GimpToolTransform3DGrid *grid,
priv->angle_x, priv->angle_x,
priv->angle_y, priv->angle_y,
priv->angle_z, priv->angle_z,
0.0, 0.0, 0.0); priv->pivot_x,
priv->pivot_y,
priv->pivot_z);
z_sign = matrix.coeff[2][2] >= 0.0 ? +1.0 : -1.0; gimp_transform_3d_matrix4_translate (&matrix,
priv->offset_x,
priv->offset_y,
priv->offset_z);
gimp_matrix4_transform_point (&matrix,
0.0, 0.0, 0.0,
&o.x, &o.y, &o.z);
gimp_matrix4_transform_point (&matrix,
0.0, 0.0, 1.0,
&n.x, &n.y, &n.z);
c.x = priv->camera_x;
c.y = priv->camera_y;
c.z = priv->camera_z;
gimp_vector3_sub (&n, &n, &o);
gimp_vector3_sub (&c, &c, &o);
z_sign = gimp_vector3_inner_product (&c, &n) <= 0.0 ? +1.0 : -1.0;
}
{
GimpVector2 o, u, v;
gimp_matrix3_transform_point (&priv->orig_transform, gimp_matrix3_transform_point (&priv->orig_transform,
priv->pivot_x, priv->pivot_y, priv->pivot_x, priv->pivot_y,
@ -988,6 +1014,7 @@ gimp_tool_transform_3d_grid_motion_rotate (GimpToolTransform3DGrid *grid,
gimp_matrix2_invert (&basis_inv); gimp_matrix2_invert (&basis_inv);
} }
}
if (! priv->z_axis) if (! priv->z_axis)
{ {