[gimp] app: pass near-plane z-coordinate to gegl:transform



commit 5f58a7a260f4ef6601512492639b32c5e3d0aaa2
Author: Ell <ell_se yahoo com>
Date:   Sun Jan 28 15:53:01 2018 -0500

    app: pass near-plane z-coordinate to gegl:transform
    
    ... so that GEGL performs the same clipping we do.

 app/core/gimp-transform-utils.c          |   11 +++++------
 app/core/gimp-transform-utils.h          |    3 +++
 app/display/gimpcanvastransformpreview.c |    1 +
 app/gegl/gimp-gegl-apply-operation.c     |    2 ++
 4 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/app/core/gimp-transform-utils.c b/app/core/gimp-transform-utils.c
index a58ce94..2afe91f 100644
--- a/app/core/gimp-transform-utils.c
+++ b/app/core/gimp-transform-utils.c
@@ -27,7 +27,6 @@
 
 
 #define EPSILON 1e-6
-#define NEAR_Z  0.02
 
 
 void
@@ -541,7 +540,7 @@ gimp_transform_polygon (const GimpMatrix3 *matrix,
            matrix->coeff[2][1] * vertices[0].y +
            matrix->coeff[2][2];
 
-  curr_visible = (curr.z >= NEAR_Z);
+  curr_visible = (curr.z >= GIMP_TRANSFORM_NEAR_Z);
 
   for (i = 0; i < n_vertices; i++)
     {
@@ -567,15 +566,15 @@ gimp_transform_polygon (const GimpMatrix3 *matrix,
                    matrix->coeff[2][1] * vertices[j].y +
                    matrix->coeff[2][2];
 
-          next_visible = (next.z >= NEAR_Z);
+          next_visible = (next.z >= GIMP_TRANSFORM_NEAR_Z);
 
           if (next_visible != curr_visible)
             {
-              gdouble ratio = (curr.z - NEAR_Z) / (curr.z - next.z);
+              gdouble ratio = (curr.z - GIMP_TRANSFORM_NEAR_Z) / (curr.z - next.z);
 
               t_vertices[(*n_t_vertices)++] =
-                (GimpVector2) { (curr.x + (next.x - curr.x) * ratio) / NEAR_Z,
-                                (curr.y + (next.y - curr.y) * ratio) / NEAR_Z };
+                (GimpVector2) { (curr.x + (next.x - curr.x) * ratio) / GIMP_TRANSFORM_NEAR_Z,
+                                (curr.y + (next.y - curr.y) * ratio) / GIMP_TRANSFORM_NEAR_Z };
             }
 
           curr         = next;
diff --git a/app/core/gimp-transform-utils.h b/app/core/gimp-transform-utils.h
index 2c4c08f..d1910f5 100644
--- a/app/core/gimp-transform-utils.h
+++ b/app/core/gimp-transform-utils.h
@@ -19,6 +19,9 @@
 #define __GIMP_TRANSFORM_UTILS_H__
 
 
+#define GIMP_TRANSFORM_NEAR_Z 0.02
+
+
 void       gimp_transform_get_rotate_center    (gint                 x,
                                                 gint                 y,
                                                 gint                 width,
diff --git a/app/display/gimpcanvastransformpreview.c b/app/display/gimpcanvastransformpreview.c
index 31b8099..65d008e 100644
--- a/app/display/gimpcanvastransformpreview.c
+++ b/app/display/gimpcanvastransformpreview.c
@@ -464,6 +464,7 @@ gimp_canvas_transform_preview_sync_node (GimpCanvasItem *item)
       private->transform_node =
         gegl_node_new_child (private->node,
                              "operation", "gegl:transform",
+                             "near-z",    GIMP_TRANSFORM_NEAR_Z,
                              "sampler",   GIMP_INTERPOLATION_NONE,
                              NULL);
 
diff --git a/app/gegl/gimp-gegl-apply-operation.c b/app/gegl/gimp-gegl-apply-operation.c
index ba85e78..c22e5e0 100644
--- a/app/gegl/gimp-gegl-apply-operation.c
+++ b/app/gegl/gimp-gegl-apply-operation.c
@@ -28,6 +28,7 @@
 
 #include "gimp-gegl-types.h"
 
+#include "core/gimp-transform-utils.h"
 #include "core/gimp-utils.h"
 #include "core/gimpprogress.h"
 
@@ -707,6 +708,7 @@ gimp_gegl_apply_transform (GeglBuffer            *src_buffer,
 
   node = gegl_node_new_child (NULL,
                               "operation", "gegl:transform",
+                              "near-z",    GIMP_TRANSFORM_NEAR_Z,
                               "sampler",   interpolation_type,
                               NULL);
 


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