[gimp/gimp-2-10] app: in gimp_transform_matrix_generic(), apply matrix even if invalid



commit d6bb1efd77c2e18a0cacdf5b8f51b4ccf901fd09
Author: Ell <ell_se yahoo com>
Date:   Mon Feb 4 04:58:34 2019 -0500

    app: in gimp_transform_matrix_generic(), apply matrix even if invalid
    
    In gimp_transform_matrix_generic(), apply the resulting matrix even
    if the transformation is invalid, since GimpGenericTransformTool
    relies on the matrix to properly update the transform-grid widget.
    
    (cherry picked from commit 59ef222c7fc549fe0f34ae74413bc2548ee11356)

 app/core/gimp-transform-utils.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/app/core/gimp-transform-utils.c b/app/core/gimp-transform-utils.c
index 00bcb86ac7..e183807339 100644
--- a/app/core/gimp-transform-utils.c
+++ b/app/core/gimp-transform-utils.c
@@ -441,8 +441,9 @@ gimp_transform_matrix_generic (GimpMatrix3       *matrix,
 {
   GimpMatrix3 trafo;
   gdouble     coeff[8 * 9];
-  gboolean    negative;
+  gboolean    negative = -1;
   gint        i;
+  gboolean    result   = TRUE;
 
   g_return_val_if_fail (matrix != NULL, FALSE);
   g_return_val_if_fail (input_points != NULL, FALSE);
@@ -494,21 +495,26 @@ gimp_transform_matrix_generic (GimpMatrix3       *matrix,
           trafo.coeff[2][2];
 
       if (fabs (w) <= EPSILON)
-        return FALSE;
+        result = FALSE;
 
       neg = (w < 0.0);
 
-      if (i == 0)
-        negative = neg;
+      if (negative < 0)
+        {
+          negative = neg;
+        }
       else if (neg != negative)
-        return FALSE;
+        {
+          result = FALSE;
+          break;
+        }
     }
 
   /* if the output points are all behind the camera, negate the matrix, which
    * would map the input points to the corresponding points in front of the
    * camera.
    */
-  if (negative)
+  if (negative > 0)
     {
       gint r;
       gint c;
@@ -525,7 +531,7 @@ gimp_transform_matrix_generic (GimpMatrix3       *matrix,
   /* append the transformation to 'matrix' */
   gimp_matrix3_mult (&trafo, matrix);
 
-  return TRUE;
+  return result;
 }
 
 gboolean


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]