[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59376] trunk/blender/source/blender/ blenlib: minor internal change: isect_point_poly_v2 was assigning a value past the array bounds,
Campbell Barton
ideasman42 at gmail.com
Thu Aug 22 01:33:50 CEST 2013
Revision: 59376
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59376
Author: campbellbarton
Date: 2013-08-21 23:33:50 +0000 (Wed, 21 Aug 2013)
Log Message:
-----------
minor internal change: isect_point_poly_v2 was assigning a value past the array bounds,
not that bad since it wasn't read but this isnt good practice and its simple to avoid.
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/BLI_math_geom.h
trunk/blender/source/blender/blenlib/intern/math_geom.c
Modified: trunk/blender/source/blender/blenlib/BLI_math_geom.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_geom.h 2013-08-21 23:19:01 UTC (rev 59375)
+++ trunk/blender/source/blender/blenlib/BLI_math_geom.h 2013-08-21 23:33:50 UTC (rev 59376)
@@ -138,8 +138,8 @@
const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2], const float epsilon);
/* point in polygon */
-bool isect_point_poly_v2(const float pt[2], const float verts[][2], const int nr);
-bool isect_point_poly_v2_int(const int pt[2], const int verts[][2], const int nr);
+bool isect_point_poly_v2(const float pt[2], const float verts[][2], const unsigned int nr);
+bool isect_point_poly_v2_int(const int pt[2], const int verts[][2], const unsigned int nr);
int isect_point_quad_v2(const float p[2], const float a[2], const float b[2], const float c[2], const float d[2]);
Modified: trunk/blender/source/blender/blenlib/intern/math_geom.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_geom.c 2013-08-21 23:19:01 UTC (rev 59375)
+++ trunk/blender/source/blender/blenlib/intern/math_geom.c 2013-08-21 23:33:50 UTC (rev 59376)
@@ -696,16 +696,15 @@
}
/* point in polygon (keep float and int versions in sync) */
-bool isect_point_poly_v2(const float pt[2], const float verts[][2], const int nr)
+bool isect_point_poly_v2(const float pt[2], const float verts[][2], const unsigned int nr)
{
/* we do the angle rule, define that all added angles should be about zero or (2 * PI) */
float angletot = 0.0;
float fp1[2], fp2[2];
- int i;
+ unsigned int i;
const float *p1, *p2;
p1 = verts[nr - 1];
- p2 = verts[0];
/* first vector */
fp1[0] = (float)(p1[0] - pt[0]);
@@ -714,6 +713,8 @@
for (i = 0; i < nr; i++) {
float dot, ang, cross;
+ p2 = verts[i];
+
/* second vector */
fp2[0] = (float)(p2[0] - pt[0]);
fp2[1] = (float)(p2[1] - pt[1]);
@@ -730,21 +731,19 @@
/* circulate */
copy_v2_v2(fp1, fp2);
p1 = p2;
- p2 = verts[i + 1];
}
return (fabsf(angletot) > 4.0f);
}
-bool isect_point_poly_v2_int(const int pt[2], const int verts[][2], const int nr)
+bool isect_point_poly_v2_int(const int pt[2], const int verts[][2], const unsigned int nr)
{
/* we do the angle rule, define that all added angles should be about zero or (2 * PI) */
float angletot = 0.0;
float fp1[2], fp2[2];
- int i;
+ unsigned int i;
const int *p1, *p2;
p1 = verts[nr - 1];
- p2 = verts[0];
/* first vector */
fp1[0] = (float)(p1[0] - pt[0]);
@@ -753,6 +752,8 @@
for (i = 0; i < nr; i++) {
float dot, ang, cross;
+ p2 = verts[i];
+
/* second vector */
fp2[0] = (float)(p2[0] - pt[0]);
fp2[1] = (float)(p2[1] - pt[1]);
@@ -769,7 +770,6 @@
/* circulate */
copy_v2_v2(fp1, fp2);
p1 = p2;
- p2 = verts[i + 1];
}
return (fabsf(angletot) > 4.0f);
More information about the Bf-blender-cvs
mailing list