Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2020-05-01 17:00:59 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2020-05-01 17:13:10 +0300
commit9c2c69701191776ada66917a95a10c62ba4b903a (patch)
tree04a260ac81fe1b705027e6e29a1c83b3e5700543 /source/blender/editors/space_clip/clip_draw.c
parentb22abd112d1f4268d7e3974fa90ba2505a1e276c (diff)
Tracking: Cleanup, localize variable
Also avoid possible accumulation of floating point error.
Diffstat (limited to 'source/blender/editors/space_clip/clip_draw.c')
-rw-r--r--source/blender/editors/space_clip/clip_draw.c22
1 files changed, 6 insertions, 16 deletions
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;