[Bf-blender-cvs] [9c2c6970119] master: Tracking: Cleanup, localize variable

Sergey Sharybin noreply at git.blender.org
Fri May 1 16:36:40 CEST 2020


Commit: 9c2c69701191776ada66917a95a10c62ba4b903a
Author: Sergey Sharybin
Date:   Fri May 1 16:00:59 2020 +0200
Branches: master
https://developer.blender.org/rB9c2c69701191776ada66917a95a10c62ba4b903a

Tracking: Cleanup, localize variable

Also avoid possible accumulation of floating point error.

===================================================================

M	source/blender/editors/space_clip/clip_draw.c

===================================================================

diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index 33e38894671..fe7ae7096a0 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -1730,7 +1730,7 @@ static void draw_distortion(SpaceClip *sc,
 {
   float x, y;
   const int n = 10;
-  float pos[2], tpos[2], grid[11][11][2];
+  float tpos[2], grid[11][11][2];
   MovieTracking *tracking = &clip->tracking;
   bGPdata *gpd = NULL;
   float aspy = 1.0f / tracking->camera.pixel_aspect;
@@ -1772,10 +1772,10 @@ static void draw_distortion(SpaceClip *sc,
       }
     }
 
-    zero_v2(pos);
     for (int i = 0; i <= n; i++) {
       for (int j = 0; j <= n; j++) {
         if (i == 0 || j == 0 || i == n || j == n) {
+          const float pos[2] = {dx * j, dy * i};
           BKE_tracking_distort_v2(tracking, width, height, pos, tpos);
 
           for (int a = 0; a < 4; a++) {
@@ -1795,41 +1795,31 @@ static void draw_distortion(SpaceClip *sc,
             }
           }
         }
-
-        pos[0] += dx;
       }
-
-      pos[0] = 0.0f;
-      pos[1] += dy;
     }
 
     INIT_MINMAX2(min, max);
 
     for (int a = 0; a < 4; a++) {
-      pos[0] = idx[a][0] * dx;
-      pos[1] = idx[a][1] * dy;
+      const float pos[2] = {idx[a][0] * dx, idx[a][1] * dy};
 
       BKE_tracking_undistort_v2(tracking, width, height, pos, tpos);
 
       minmax_v2v2_v2(min, max, tpos);
     }
 
-    copy_v2_v2(pos, min);
     dx = (max[0] - min[0]) / n;
     dy = (max[1] - min[1]) / n;
 
     for (int i = 0; i <= n; i++) {
       for (int j = 0; j <= n; j++) {
+        const float pos[2] = {min[0] + dx * j, min[1] + dy * i};
+
         BKE_tracking_distort_v2(tracking, width, height, pos, grid[i][j]);
 
         grid[i][j][0] /= width;
         grid[i][j][1] /= height * aspy;
-
-        pos[0] += dx;
       }
-
-      pos[0] = min[0];
-      pos[1] += dy;
     }
 
     immUniformColor3f(1.0f, 0.0f, 0.0f);
@@ -1882,7 +1872,7 @@ static void draw_distortion(SpaceClip *sc,
           if (stroke->flag & GP_STROKE_2DSPACE) {
             if (stroke->totpoints > 1) {
               for (int i = 0; i < stroke->totpoints - 1; i++) {
-                float npos[2], dpos[2], len;
+                float pos[2], npos[2], dpos[2], len;
                 int steps;
 
                 pos[0] = (stroke->points[i].x + offsx) * width;



More information about the Bf-blender-cvs mailing list