Commit: bc1eb0bf0a0c5a6ebf3ff19dae0bfe6a65529b8e
Author: Campbell Barton
Date:   Thu Dec 26 20:05:03 2013 +1100
https://developer.blender.org/rBbc1eb0bf0a0c5a6ebf3ff19dae0bfe6a65529b8e

Simplify isect_point_poly_v2 functions using angle_signed_v2v2

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

M       source/blender/blenlib/intern/math_geom.c

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

diff --git a/source/blender/blenlib/intern/math_geom.c 
b/source/blender/blenlib/intern/math_geom.c
index 1187572..1d03bf4 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -721,24 +721,16 @@ bool isect_point_poly_v2(const float pt[2], const float 
verts[][2], const unsign
        /* first vector */
        fp1[0] = (float)(p1[0] - pt[0]);
        fp1[1] = (float)(p1[1] - pt[1]);
-       normalize_v2(fp1);
 
        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]);
-               normalize_v2(fp2);
 
                /* dot and angle and cross */
-               dot = dot_v2v2(fp1, fp2);
-               ang = fabsf(saacos(dot));
-               cross = (float)((p1[1] - p2[1]) * (p1[0] - pt[0]) + (p2[0] - 
p1[0]) * (p1[1] - pt[1]));
-
-               if (cross < 0.0f) angletot -= ang;
-               else              angletot += ang;
+               angletot += angle_signed_v2v2(fp1, fp2);
 
                /* circulate */
                copy_v2_v2(fp1, fp2);
@@ -769,24 +761,16 @@ bool isect_point_poly_v2_int(const int pt[2], const int 
verts[][2], const unsign
        /* first vector */
        fp1[0] = (float)(p1[0] - pt[0]);
        fp1[1] = (float)(p1[1] - pt[1]);
-       normalize_v2(fp1);
 
        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]);
-               normalize_v2(fp2);
 
                /* dot and angle and cross */
-               dot = dot_v2v2(fp1, fp2);
-               ang = fabsf(saacos(dot));
-               cross = (float)((p1[1] - p2[1]) * (p1[0] - pt[0]) + (p2[0] - 
p1[0]) * (p1[1] - pt[1]));
-
-               if (cross < 0.0f) angletot -= ang;
-               else              angletot += ang;
+               angletot += angle_signed_v2v2(fp1, fp2);
 
                /* circulate */
                copy_v2_v2(fp1, fp2);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to