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-02-07 14:00:57 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2020-02-07 14:01:50 +0300
commit28cd16ec448f57b863f8be0a8f5d303d94bc1f1f (patch)
tree9a1f5ea9db62095ab281fa29accafa13ca5ca2c1 /source/blender/blenkernel/intern/tracking_detect.c
parent0f7a90d4ad2c144b82679c24020e1338a3fc7cef (diff)
Cleanup: Tracking, reduce scope of variables
Mainly affects for() loops. The reason why loop parameter was declared outside of the loop roots back to the times when not all compilers supported C99.
Diffstat (limited to 'source/blender/blenkernel/intern/tracking_detect.c')
-rw-r--r--source/blender/blenkernel/intern/tracking_detect.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/tracking_detect.c b/source/blender/blenkernel/intern/tracking_detect.c
index ec044f14fa8..08719161e1a 100644
--- a/source/blender/blenkernel/intern/tracking_detect.c
+++ b/source/blender/blenkernel/intern/tracking_detect.c
@@ -38,7 +38,6 @@
/* Check whether point is inside grease pencil stroke. */
static bool check_point_in_stroke(bGPDstroke *stroke, float x, float y)
{
- int i, prev;
int count = 0;
bGPDspoint *points = stroke->points;
@@ -50,9 +49,7 @@ static bool check_point_in_stroke(bGPDstroke *stroke, float x, float y)
* work, but such situation is crappy anyway.
*/
- prev = stroke->totpoints - 1;
-
- for (i = 0; i < stroke->totpoints; i++) {
+ for (int i = 0, prev = stroke->totpoints - 1; i < stroke->totpoints; prev = i, i++) {
if ((points[i].y < y && points[prev].y >= y) || (points[prev].y < y && points[i].y >= y)) {
float fac = (y - points[i].y) / (points[prev].y - points[i].y);
@@ -60,8 +57,6 @@ static bool check_point_in_stroke(bGPDstroke *stroke, float x, float y)
count++;
}
}
-
- prev = i;
}
return (count % 2) ? true : false;